admin管理员组文章数量:1322850
I have a site using a customized version of this plugin: /
After installing Wordpress 5.5, any of the taxonomy display pages generate this fatal error:
PHP Fatal error: Uncaught Error: Call to undefined method stdClass::get_rest_controller() in /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php:2209
Stack trace:
#0 /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php(2245): rest_get_route_for_term(Object(WP_Term))
#1 /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php(943): rest_get_queried_resource_route()
#2 /home/abc/domains/mydomain/public_html/wp-includes/class-wp-hook.php(285): rest_output_link_header()
#3 /home/abc/domains/mydomain/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#4 /home/abc/domains/mydomain/public_html/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#5 /home/abc/domains/mydomain/public_html/wp-includes/template-loader.php(13): do_action('template_redire...')
#6 /home/abc/domains/mydomain/public_html/wp-blog-header.php(19): require_once('/home/abc/domai...')
#7 /home/abc/domains/mydomain in /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php on line 2209
Rolling back WP to 5.4.2 restores functionality.
I tried installing the same plugin on a clean version of 5.5 with an unmodified version of the plugin, and I get the same error.
The plugin appears abandoned, but it's a pretty small codebase. I haven't been able to identify the what's triggering the fatal error, and haven't been able to find any other questions noting similar errors. If anyone has any thoughts, it would be greatly appreciated!
I have a site using a customized version of this plugin: https://wordpress/plugins/user-tags/
After installing Wordpress 5.5, any of the taxonomy display pages generate this fatal error:
PHP Fatal error: Uncaught Error: Call to undefined method stdClass::get_rest_controller() in /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php:2209
Stack trace:
#0 /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php(2245): rest_get_route_for_term(Object(WP_Term))
#1 /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php(943): rest_get_queried_resource_route()
#2 /home/abc/domains/mydomain/public_html/wp-includes/class-wp-hook.php(285): rest_output_link_header()
#3 /home/abc/domains/mydomain/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#4 /home/abc/domains/mydomain/public_html/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#5 /home/abc/domains/mydomain/public_html/wp-includes/template-loader.php(13): do_action('template_redire...')
#6 /home/abc/domains/mydomain/public_html/wp-blog-header.php(19): require_once('/home/abc/domai...')
#7 /home/abc/domains/mydomain in /home/abc/domains/mydomain/public_html/wp-includes/rest-api.php on line 2209
Rolling back WP to 5.4.2 restores functionality.
I tried installing the same plugin on a clean version of 5.5 with an unmodified version of the plugin, and I get the same error.
The plugin appears abandoned, but it's a pretty small codebase. I haven't been able to identify the what's triggering the fatal error, and haven't been able to find any other questions noting similar errors. If anyone has any thoughts, it would be greatly appreciated!
Share Improve this question asked Sep 17, 2020 at 19:37 Hugh MongooseHugh Mongoose 111 bronze badge 01 Answer
Reset to default 3Since 5.5 WP_Taxonomy objects now have a new method, get_rest_controller(), to allow for per-taxonomy controller overrides. The problem is that your plugin overwrites the taxonomy saved in the global $wp_taxonomies cache with a version that isn't a real WP_Taxonomy object, just a stdObject property bag, and so does not have get_rest_controller() to call.
This is the relevant bit: ut_registered_taxonomy() in UserTags.php lines 83-101, which is a registered_taxonomy action handler.
public function ut_registered_taxonomy( $taxonomy, $object, $args ) {
global $wp_taxonomies;
// Only modify user taxonomies, everything else can stay as is
if ( $object != 'user' ) {
return;
}
// Array => Object
$args = (object) $args;
// Register any hooks/filters that rely on knowing the taxonomy now
add_filter( "manage_edit-{$taxonomy}_columns", array( $this, 'set_user_column' ) );
add_filter( "manage_{$taxonomy}_custom_column",
array( $this, 'set_user_column_values' ), 10, 3 );
// Save changes
$wp_taxonomies[ $taxonomy ] = $args; // <--- this line is the problem
self::$taxonomies[ $taxonomy ] = $args;
}
Note the line I've marked just below the "Save changes" comment: this overwrites the existing value of $wp_taxonomies[ $taxonomy ]
with a bad value, and isn't needed anyway because there haven't been any changes made to the taxonomy properties. So I'd suggest just deleting this line as the simplest fix.
(In fairness to this code it was written before the WP_Taxonomy class was added in 4.7. And back then the (object)
cast was the correct way to make a taxonomy object from $args if you had changed the contents of $args and needed to update $wp_taxonomies.)
We could now also now ensure we have a real WP_Taxonomy object in self::$taxonomies too, e.g. rather than $args = (object) $args)
fetch the real object from $wp_taxonomies $args = $wp_taxonomies[ $taxonomy ]
where it was placed shortly before this call. But I don't think that's actually necessary here.
本文标签: WP 55 Fatal Errorgetrestcontroller() in restapiphp
版权声明:本文标题:WP 5.5 Fatal Error - get_rest_controller() in rest-api.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742112674a2421323.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论