Proposed Bug Fix: Version 1.2.4 Fatal Server Error
-
I encountered a 500 Internal Server Error on my site after updating this plugin to version 1.2.4.
The exact error was:
Parse error: syntax error, unexpected ')' in /wp-content/plugins/accordion-toggle/blocks/accordion-item.php on line 27
Turns out this file had:
function accordion_toggle_accordion_item_block_init() { // Skip block registration if Gutenberg is not enabled/merged. if (!function_exists('register_block_type')) { return; } $dir = dirname(__FILE__); if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/accordion')) { register_block_type( Accordion_Helper::get_block_register_path("accordion-item"), ); } } add_action('init', 'accordion_toggle_accordion_item_block_init',);
when it should actually be:
function accordion_toggle_accordion_item_block_init() { // Skip block registration if Gutenberg is not enabled/merged. if (!function_exists('register_block_type')) { return; } $dir = dirname(__FILE__); if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/accordion')) { register_block_type( Accordion_Helper::get_block_register_path("accordion-item") ); } } add_action('init', 'accordion_toggle_accordion_item_block_init');
There are actually 2 occurrences of the same problem that can result in a fatal PHP error depending on the PHP version it’s hosted on being sensitive about this (with this plugin then not having a specific PHP version that should be used specified in its plugin details [if this plugin has intentions of only supporting a specific PHP version or newer.])
Either way,
Accordion_Helper::get_block_register_path("accordion-item"),
should ideally be changed toAccordion_Helper::get_block_register_path("accordion-item")
andadd_action('init', 'accordion_toggle_accordion_item_block_init',);
should be changed toadd_action('init', 'accordion_toggle_accordion_item_block_init');
Unlike arrays & things, you cannot have a trailing comma within a function call’s attributes as some PHP versions (ex. 7.2 & possibly others) then require a parameter to follow the comma (otherwise it causes this exact error.)
The extra commas really aren’t serving any purpose/benefit whatsoever while it then just makes the plugin more likely to cause a fatal server error while present so it should hopefully be a quick & straightforward update to be made to address this (also helping make the code just be a bit cleaner since those commas really are unnecessary).
- The topic ‘Proposed Bug Fix: Version 1.2.4 Fatal Server Error’ is closed to new replies.