PHP Fatal error : callback is_numeric
-
Took me a while to find the source of these messages, but I finally did.
Message showing up in my debug log on every “save_post” call, regardless of whether I used your plugin to set a custom permalink for that post_id or not:
`PHP Fatal error: Uncaught ArgumentCountError: is_numeric() expects exactly 1 argument, 3 given in /path/to/wp-includes/rest-api/class-wp-rest-request.php:910
Stack trace:
#0 /path/to/wp-includes/rest-api/class-wp-rest-request.php(910): is_numeric(‘118’, Object(WP_REST_Request), ‘id’)
#1 /path/to/wp-includes/rest-api/class-wp-rest-server.php(979): WP_REST_Request->has_valid_params()
#2 /path/to/wp-includes/rest-api/class-wp-rest-server.php(414): WP_REST_Server->dispatch(Object(WP_REST_Request))
#3 /path/to/wp-includes/rest-api.php(394): WP_REST_Server->serve_request(‘/custom-permali…’)
#4 /path/to/wp-includes/class-wp-hook.php(307): rest_api_loaded(Object(WP))
#5 /path/to/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(”, Array)
#6 /path/to/wp-includes/plugin.php(524): WP_Hook->do_action(Array)
#7 /path/to/wp-includes/class-wp.php(398): do_action_ref_array(‘parse_request’, Array)
#8 /path/to/wp-includes/class-wp.php(770): WP->parse_request(”)
#9 /path/to/wp-includes/functions.php(1330): WP->main(”)
#10 /path/to/wp-blog-header.php(16): wp()
#11 /path/to/index.php(17): require(‘/path/to/wp-blog-header.php’)
#12 {main}
thrown in /path/to/wp-includes/rest-api/class-wp-rest-request.php on line 910`Here’s the WP Core topic on it:
https://core.trac.www.ads-software.com/ticket/54043Apparently prior to PHP 8, it just kicked out a warning, but as of PHP 8 it’s a fatal error.
WP suggestion as per the link above: contact you and let you know.
The problem is in /path/to/wp-content/plugins/custom-permalink-editor/includes/class-custom-permalink-editor-form.php
Specifically the method “rest_edit_form” on line 857 (plugin version 1.0.3), and even more specifically the line (line # 866) that says:
'validate_callback' => 'is_numeric',
Any “save_post” action that uses more than 1 parameter kicks out this error. For example:
function intercept_post_save( $post_id, $post, $update ) { // code to process input before saving post data to DB } add_action( 'save_post', 'intercept_post_save', 5, 3 );
I wish I had a solution to offer you. One suggestion is to only call the “rest_edit_form” method or only “register_rest_route” if/when there’s actually a custom permalink set. Would get rid of the majority of errors, but not all of them. Not sure about how this issue/solution affects rest routes (broken?).
Wish I had more to offer, but this should help resolve it.
- The topic ‘PHP Fatal error : callback is_numeric’ is closed to new replies.