Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecated call to wp.components.ServerSideRender; Remove some missed wp.components.ServerSideRender usages. #16133

Merged

Conversation

jorgefilipecosta
Copy link
Member

Description

Follow up from #15635.

In #15635 we kept the back-compatibility for usages of wp.components.ServerSideRender but we did not implement a deprecated call.

This PR adds the missing deprecated call.

How has this been tested?

I changed the archives block to use ServerSideRender from wp.components.
I verified the block works as expected, but a deprecated warning is thrown in the browser console.

@jorgefilipecosta jorgefilipecosta added the Backwards Compatibility Issues or PRs that impact backwards compatability label Jun 12, 2019
lib/client-assets.php Outdated Show resolved Hide resolved
@jorgefilipecosta jorgefilipecosta force-pushed the add/deprecated-call-in-wp.components.ServerSideRender branch 2 times, most recently from 79e0058 to e3b6997 Compare June 28, 2019 15:08
@jorgefilipecosta jorgefilipecosta changed the title Add deprecated call to wp.components.ServerSideRender Add deprecated call to wp.components.ServerSideRender; Remove some missed wp.components.ServerSideRender usages. Jun 28, 2019
aduth
aduth previously requested changes Jul 29, 2019
lib/client-assets.php Outdated Show resolved Hide resolved
@jorgefilipecosta jorgefilipecosta force-pushed the add/deprecated-call-in-wp.components.ServerSideRender branch from e3b6997 to 2b74300 Compare August 6, 2019 13:56
@jorgefilipecosta
Copy link
Member Author

This PR was updated to avoid arrow function usage, it should be ready.

@jorgefilipecosta jorgefilipecosta force-pushed the add/deprecated-call-in-wp.components.ServerSideRender branch from 2b74300 to 988f83a Compare August 9, 2019 19:30
' if ( wp && wp.components && wp.serverSideRender && ! wp.components.ServerSideRender ) {',
' wp.components.ServerSideRender = wp.serverSideRender;',
' };',
' if ( wp && wp.components && wp.serverSideRender ) {',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried that this might not work in all cases. What if someone has a block which imports ServerSideRender from wp.components but never references wp-server-side-render as a dependency. It's a tough problem. I see that we expose ServerSideRender from wp.editor, so maybe we should attach this polyfill there without any guard clauses? Or even we could include it inside @wordpress/editor which is less likely to be used outside of WordPress.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you still need to rebase this PR after I merged your other PR which updates import for ServerSideRender.

@jorgefilipecosta jorgefilipecosta force-pushed the add/deprecated-call-in-wp.components.ServerSideRender branch from 988f83a to 1926ec7 Compare August 12, 2019 11:58
@jorgefilipecosta
Copy link
Member Author

Hi @gziolo the PR was rebased.

@gziolo gziolo added Needs Dev Note Requires a developer note for a major WordPress release cycle [Package] Server Side Render /packages/server-side-render [Package] Components /packages/components and removed [Package] Server Side Render /packages/server-side-render labels Aug 12, 2019
@gziolo gziolo added this to the Gutenberg 6.3 milestone Aug 12, 2019

if( window && window.wp && window.wp.components ) {
window.wp.components.ServerSideRender = forwardRef( ( props, ref ) => {
wp.deprecated( 'wp.components.ServerSideRender', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you import deprecated to ensure it's listed as a dependency of the module when generating deps file for WordPress?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR updated 👍

if( window && window.wp && window.wp.components ) {
window.wp.components.ServerSideRender = forwardRef( ( props, ref ) => {
wp.deprecated( 'wp.components.ServerSideRender', {
alternative: 'wp.serverSideRender',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unfortunate that this global variable starts with lowercase.

@jorgefilipecosta jorgefilipecosta force-pushed the add/deprecated-call-in-wp.components.ServerSideRender branch 2 times, most recently from 8af3a96 to 4515584 Compare August 12, 2019 14:22
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with the following change:

@@ -17,10 +17,10 @@ import {
        BlockControls,
        InspectorControls,
 } from '@wordpress/block-editor';
-import ServerSideRender from '@wordpress/server-side-render';
 
 const DEFAULT_MIN_ITEMS = 1;
 const DEFAULT_MAX_ITEMS = 10;
+const { ServerSideRender } = wp.components;
 
 class RSSEdit extends Component {
        constructor() {

which is the closest you can get when developing as plugin. It works perfectly fine and I can see deprecation message:
Screen Shot 2019-08-12 at 16 35 23

I can also see wp.components.ServerSideRender when using Web Console.

@gziolo
Copy link
Member

gziolo commented Aug 12, 2019

I noticed that PHP and JS linters are still unhappy. You will have to convince them this PR is ready to go :)

@jorgefilipecosta jorgefilipecosta force-pushed the add/deprecated-call-in-wp.components.ServerSideRender branch from 4515584 to aa092c9 Compare August 12, 2019 14:45
@jorgefilipecosta jorgefilipecosta merged commit d38a123 into master Aug 12, 2019
@jorgefilipecosta jorgefilipecosta deleted the add/deprecated-call-in-wp.components.ServerSideRender branch August 12, 2019 15:04
@youknowriad youknowriad removed the Needs Dev Note Requires a developer note for a major WordPress release cycle label Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Package] Components /packages/components [Package] Server Side Render /packages/server-side-render
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants