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

Fix PHP 7.2.x Syntax Error Causing Site-wide Fatal Server Error (Trailing Comma in the Parameters of a Function) #263

Merged
merged 1 commit into from
May 17, 2024

Conversation

KZeni
Copy link
Contributor

@KZeni KZeni commented May 15, 2024

What?

The plugin claims PHP 7.0+ support, but the trailing comma in the parameters when calling wp_register_style is a syntax error for PHP 7.2.x (and possibly others) which then causes a site-wide fatal server error when the plugin is enabled.

The exact error message is:

PHP Parse error: syntax error, unexpected ) in /wp-content/plugins/interactive-code-block/wordpress-playground-block.php on line 28

Why?

This either needs to not try to and/or claim support of PHP 7.2 & older, or (per this pull request) make this one fix & just be mindful to not have these trailing commas in future updates and/or have the plugin files be checked for this type of thing via CI before releasing a new version (these trailing commas don't do anything anyway & just cause it to potentially break on some hosting environments; unlike the trailing commas in PHP arrays, etc. for whatever reason.)

How?

This simply removes the comma at the end of wp_register_style's parameters which isn't doing anything other than breaking things for those with PHP 7.2.x.

Testing Instructions

  1. Have a site with this plugin on PHP 7.2.x where it causes the entire site to give a fatal server error before the fix.
  2. Implement this quick fix of just removing that one comma
  3. Find the site's back to working as expected.

…ion being called)

The plugin claims PHP 7.0+ support, but the trailing comma in the parameters when calling `wp_register_style` is a syntax error for PHP 7.2 (and possibly others) which then causes a site-wide fatal server error.

Either need to not try to and/or claim support of PHP 7.2 & older, or make this one fix & be mindful to not have these trailing commas (they're not doing anything anyway & just cause it to potentially break on some hosting environments; unlike the trailing commas in PHP arrays, etc. for whatever reason.)
@bgrgicak
Copy link
Collaborator

Thanks for the fix @KZeni!

@bgrgicak
Copy link
Collaborator

Have a site with this plugin on PHP 7.2.x where it causes the entire site to give a fatal server error before the fix.

This can also be tested using the dev server by adding a php flag nx dev wordpress-playground-block -- --php=7.1.

@adamziel adamziel merged commit f470bda into WordPress:trunk May 17, 2024
2 checks passed
@adamziel
Copy link
Collaborator

Thank you so much for contributing @KZeni!

@adamziel
Copy link
Collaborator

@bgrgicak would you please release a new version?

@bgrgicak
Copy link
Collaborator

Version 0.2.5 is released.
I tested the plugin using version 7.2 and it seems to work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants