-
AuthorPosts
-
December 18, 2018 at 4:12 pm #1046928
Hi there,
When using WordPress 5+, Enfold and WooCommerce memberships it will throw a fatal error when editing WooCommerce > Memberships
I’m pretty sure this is an Enfold specific incompatibility as other sites running WooCommerce Memberships and WordPress 5+ doesn’t have this Fatal Error.
Here’s the debug output
Fatal error: Uncaught TypeError: Argument 1 passed to Avia_Gutenberg::handler_display_post_states() must be of the type array, string given, called in /var/www/DOMAIN.COM.CLOAKED/public_html/wp-includes/class-wp-hook.php on line 286 and defined in /var/www/DOMAIN.COM.CLOAKED/public_html/wp-content/themes/enfold/config-gutenberg/class-avia-gutenberg.php:366 Stack trace: #0 /var/www/DOMAIN.COM.CLOAKED/public_html/wp-includes/class-wp-hook.php(286): Avia_Gutenberg->handler_display_post_states('', Object(WP_Post)) #1 /var/www/DOMAIN.COM.CLOAKED/public_html/wp-includes/plugin.php(203): WP_Hook->apply_filters('', Array) #2 /var/www/DOMAIN.COM.CLOAKED/public_html/wp-admin/includes/template.php(1933): apply_filters('display_post_st...', Array, Object(WP_Post)) #3 /var/www/DOMAIN.COM.CLOAKED/public_html/wp-admin/includes/class-wp-posts-list-table.php(943): _post_states(Object(WP_Post)) #4 /var/www/DOMAIN.COM.CLOAKED/public_html/wp-admin/includes/class-wp-posts-list-table.php(857): WP_Posts_List_Table->column_title(Object(WP_Post)) #5 /var/www/p in /var/www/DOMAIN.COM.CLOAKED/public_html/wp-content/themes/enfold/config-gutenberg/class-avia-gutenberg.php on line 366
The error happens because /enfold/config-gutenberg/class-avia-gutenberg.php on line 366 this function
public function handler_display_post_states( array $post_states, WP_Post $post )
Assums that $post_states is always an array, which it iisn’t nessecarily, it can also be a string.
It should be changed to
public function handler_display_post_states( $post_states, WP_Post $post )
Then in the same file on line 382 it is assumed again to be an array
$key = array_search( 'Gutenberg', $post_states ); if( false !== $key ) { unset( $post_states[ $key ] ); }
It should be changed to check if it’s actually an array
if( is_array($post_states ) ) { $key = array_search( 'Gutenberg', $post_states ); if( false !== $key ) { unset( $post_states[ $key ] ); } }
Kind Regard
Yan KnudtskovDecember 21, 2018 at 12:13 pm #1048141 -
AuthorPosts
- You must be logged in to reply to this topic.