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

Gutenberg is not compatible with WordPress 5.0 #15565

Closed
jeremyfelt opened this issue May 10, 2019 · 9 comments
Closed

Gutenberg is not compatible with WordPress 5.0 #15565

jeremyfelt opened this issue May 10, 2019 · 9 comments
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability

Comments

@jeremyfelt
Copy link
Member

Describe the bug

The combination of the current Gutenberg plugin (5.6.1) and WordPress 5.0.x does not work for a couple reasons.

  1. In WordPress 5.0, version_compare( '5.0', '5.0.0', '<' ); evaluates to true and the plugin immediately deactivates. Yay, non-semantic versioning. :)
  2. gutenberg_render_block_core_latest_comments() exists in both Gutenberg and WordPress 5.0.1. This was the case until it was renamed in the WP 5.1.0 release.

To reproduce
Steps to reproduce the behavior:

  1. Update WordPress to 5.0 or 5.0.1 via wp core update --version=5.0 --force
  2. Attempt to activate Gutenberg 5.6.1.
  3. See error message after automatic deactivation.

Expected behavior

I expect (due to the minimum requirements) that the Gutenberg 5.6.1 plugin is compatible with WordPress 5.0. Maintaining that compatibility seems like a good idea. There are still groups working through the 4.9 -> 5.x upgrades on large installs with lots of content and trying to figure out how to adapt that to Gutenberg. It's much easier to do this when you're able to keep Gutenberg at the latest version.

I'd propose:

  • Change the minimum required WordPress version to 5.0.1
  • Add a function_exists() check around gutenberg_render_block_core_latest_comments()
@youknowriad
Copy link
Contributor

Add a function_exists() check around gutenberg_render_block_core_latest_comments()

I know this is not possible because it means Gutenberg is not overriding the latest comments block server side rendering included in 5.0. I know @aduth and @gziolo worked on this "overriding" behavior and would know more here.

@aduth
Copy link
Member

aduth commented May 10, 2019

It might be possible to guard, but it would require some one-off workaround. In recent changes, the naming of these functions is automated in the Webpack build script:

gutenberg/webpack.config.js

Lines 108 to 142 in 4108e37

new CopyWebpackPlugin( [
{
from: './packages/block-library/src/**/index.php',
test: new RegExp( `([\\w-]+)${ escapeRegExp( sep ) }index\\.php$` ),
to: 'build/block-library/blocks/[1].php',
transform( content ) {
content = content.toString();
// Within content, search for any function definitions. For
// each, replace every other reference to it in the file.
return content
.match( /^function [^\(]+/gm )
.reduce( ( result, functionName ) => {
// Trim leading "function " prefix from match.
functionName = functionName.slice( 9 );
// Prepend the Gutenberg prefix, substituting any
// other core prefix (e.g. "wp_").
return result.replace(
new RegExp( functionName, 'g' ),
( match ) => 'gutenberg_' + match.replace( /^wp_/, '' )
);
}, content )
// The core blocks override procedure takes place in
// the init action default priority to ensure that core
// blocks would have been registered already. Since the
// blocks implementations occur at the default priority
// and due to WordPress hooks behavior not considering
// mutations to the same priority during another's
// callback, the Gutenberg build blocks are modified
// to occur at a later priority.
.replace( /(add_action\(\s*'init',\s*'gutenberg_register_block_[^']+'(?!,))/, '$1, 20' );
},
},
] ),

Previously: #13521

@aduth aduth added the Backwards Compatibility Issues or PRs that impact backwards compatability label May 10, 2019
@youknowriad
Copy link
Contributor

Since Gutenberg is a development plugin now, I'm also ok updating the minimum version to a more recent WP release.

@jeremyfelt
Copy link
Member Author

Yeah, it does seem like it would be more effort than it is worth to keep the 5.0.x compatibility. That this has been the case for several months now is probably an indicator that it's not something many people are running into. :)

@aduth
Copy link
Member

aduth commented May 14, 2019

If it's agreeable, should we create a separate issue for the minimum version requirement bump, or can we adapt this issue to serve that purpose?

@youknowriad
Copy link
Contributor

Would WordPress 5.1 as a minimum version work here? We're releasing tomorrow and we can take care of this at the same time.

@aduth
Copy link
Member

aduth commented May 14, 2019

@youknowriad It should. The function was renamed from gutenberg_render_block_core_latest_comments to render_block_core_latest_comments as of WordPress 5.0.2:

https://github.com/WordPress/WordPress/blob/5.0.2/wp-includes/blocks/latest-comments.php#L43

I assume we should want to update the condition here, though:

gutenberg/gutenberg.php

Lines 113 to 116 in 94d311c

if ( version_compare( $version, '5.0.0', '<' ) ) {
add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
return;
}

It was also mentioned in original comment. Based on commentary there, it's unclear whether the logic needs to be updated to account for versions which omit the patch indicator?

Maybe something like this, to normalize the version:

while ( substr_count( $version, '.' ) < 3 ) {
	$version .= '.0';
}

Giving the timing of the pending release and general non-urgency here, perhaps better to wait for the following release?

@youknowriad
Copy link
Contributor

@aduth yes, that works for me

@nerrad
Copy link
Contributor

nerrad commented Jun 12, 2019

Minimum version has been updated to 5.1.0 with the release of GB 5.9.

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
Projects
None yet
Development

No branches or pull requests

4 participants