Bug: Admin Dashboard 2.2 Data, Call to undefined property breaks backend page
- lukasParticipant2 years ago #31154
I`ve registered a bug for my configured wpsolr pro plugin instance. After first configuration on the data tab, the submit button and some additional options are missing. Here the error in the wordpress debug.log:
[01-Oct-2022 18:14:16 UTC] PHP Fatal error: Uncaught Error: Call to undefined method wpsolr\core\classes\models\taxonomy\WPSOLR_Model_Meta_Type_Taxonomy::has_attachments() in /var/www/html/wp-content/plugins/wpsolr-pro/wpsolr/core/dashboard/dashboard_settings.inc.php:662 Stack trace: #0 /var/www/html/wp-content/plugins/wpsolr-pro/wpsolr/core/dashboard/dashboard.php(469): include() #1 /var/www/html/wp-includes/class-wp-hook.php(307): fun_set_solr_options('') #2 /var/www/html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array) #3 /var/www/html/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #4 /var/www/html/wp-admin/admin.php(259): do_action('toplevel_page_s...') #5 {main} thrown in /var/www/html/wp-content/plugins/wpsolr-pro/wpsolr/core/dashboard/dashboard_settings.inc.php on line 662
As a quick fix for my self, I’ve extended the condition by checking for the property which is not available (wpsolr-pro/wpsolr/core/dashboard/dashboard_settings.inc.php:662).
Has anyone noticed the same behaviour?wpsolrKeymaster2 years ago #31155This is strange, because it looks like a taxonomy has custom fields or taxonomies.
This is the condition that had to be true to get to the error code line:
$is_post_type = ! ( empty( $model_type_fields ) && empty( $model_type_taxonomies ) ); if ($is_post_type) { ... $model_type_object->has_attachments() ... }
wpsolrKeymaster2 years ago #31156I fixed the issue in WPSOLR 22.4. You can keep your workaround in the meantime.
lukasParticipant2 years ago #31162I’m a little bit confused, because almost every entity doesn’t has the property has_attachments (post types) but just one taxonomy (the last one) triggers a fatal error. Here the configuration in my theme:
$args = [ 'hierarchical' => false, 'labels' => [ 'name' => _x( 'Magazin Ausgaben', 'taxonomy general name', 'r' ), 'singular_name' => _x( 'Magazin Ausgabe', 'taxonomy singular name', 'r' ), ], 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => [ 'with_front' => false, 'hierarchical' => false, ], ]; register_taxonomy( 'magazine', [ 'post' ], $args );
While debugging this taxonomy, the following variables has values:
$model_type_object => wpsolr\core\classes\models\taxonomy\WPSOLR_Model_Meta_Type_Taxonomy {#13554 ▼ #label: "Magazin Ausgaben" #table_name: "term_taxonomy" #column_id: "term_id" #column_last_updated: null #indexing_sql: null #type: "magazine" }
$model_type_taxonomies => array:1 [▼ 0 => "location" ]
$model_type_fields => []
Is there anything not as expected?wpsolrKeymaster2 years ago #31168If it is a taxonomies, how can it have taxonomies?
$model_type_taxonomies => array:1 [▼
0 => “location”
]($model_type_taxonomies is calculated with get_object_taxonomies(), whom first argument is a post type)
Just silly, but you would not have a post type with the same slug as a taxonomy?
lukasParticipant2 years ago #31174I found the problem. I’ve registered my taxonomy as a taxonomy for the taxonomy “location”. WordPress doesn’t check the taxonomy post type handlers again, so get_object_taxonomies matched. Thank you for your hint 😉
Its fixed, but the extra check in dashboard.php isn’t bad to keep the backend functional.
You must be logged in to reply to this topic.