pantheon-systems / WordPress

WordPress upstream for the Pantheon website platform. Includes a platform integration plugins and a pre-configured wp-config.php.
Other
178 stars 226 forks source link

Fatal error in loader.php on a Wordpress site running in PHP 8 or PHP 8.1 #350

Closed danreb closed 1 year ago

danreb commented 1 year ago

Undefined variable $hm_mu_plugins in /code/wp-content/mu-plugins/loader.php on line 70 Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /code/wp-content/mu-plugins/loader.php:70 Stack trace: #0 /code/wp-content/mu-plugins/loader.php(70): in_array('pantheon-mu-plu...', NULL, true) #1 /code/wp-includes/class-wp-hook.php(308): {closure}(Array, 'pantheon-mu-plu...', Array, 'mustuse') #2 /code/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #3 /code/wp-admin/includes/class-wp-plugins-list-table.php(910): apply_filters('network_admin_p...', Array, 'pantheon-mu-plu...', Array, 'mustuse') #4 /code/wp-admin/includes/class-wp-plugins-list-table.php(695): WP_Plugins_List_Table->single_row(Array) #5 /code/wp-admin/includes/class-wp-list-table.php(1444): WP_Plugins_List_Table->display_rows() #6 /code/wp-admin/includes/class-wp-list-table.php(1371): WP_List_Table->display_rows_or_placeholder() #7 /code/wp-admin/plugins.php(773): WP_List_Table->display() #8 /code/wp-admin/network/plugins.php(13): require('/code/wp-admin/...') #9 {main} thrown in /code/wp-content/mu-plugins/loader.php on line 70

This errors popup when you visit the wordpress admin path wp-admin/network/plugins.php?plugin_status=mustuse

danreb commented 1 year ago

The above error can be fixed by checking if the variable is being set and if not declare is as an array

add_filter( 'network_admin_plugin_action_links', function ( $actions, $plugin_file, $plugin_data, $context ) use ( $pantheon_mu_plugins ) { // fixes if (!isset($hm_mu_plugins)) $hm_mu_plugins = array();

if ( $context !== 'mustuse' || ! in_array( $plugin_file, $hm_mu_plugins, true ) ) { return $actions; }

rwagner00 commented 1 year ago

I've created an internal issue to track so we can get this resolved, thank you for the report!

danreb commented 1 year ago

We have tested this on a fresh install of Wordpress (not Multisite) and able to encounter the same fatal error issues, thus updated the title to reflect, this is not just happening to a multisite network wordpress install

jazzsequence commented 1 year ago

This has been fixed via #352 and https://github.com/pantheon-systems/WordPress/commit/100405997fa8dc3dc4380807bfc68bf994bd6efb It will be pushed to Pantheon dashboards alongside the next WordPress release. If you want, you can apply the fix manually, but it's possible you may need to address merge conflicts when the update is deployed.