Opened 3 years ago
Closed 16 months ago
#54043 closed defect (bug) (invalid)
PHP Fatal Error on the rest api location
Reported by: | passam | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | php80 close |
Focuses: | Cc: |
Description (last modified by )
Here's is the full stack trace. Note, we do not alter core files in any way and it is updated to the latest version (5.8 at time of writing)... Note we recently upgraded to php8
timberry.bplans.com - PHP Fatal error: Uncaught ArgumentCountError: is_numeric() expects exactly 1 argument, 3 given in .../www/wp/wp-includes/rest-api/class-wp-rest-request.php:910 Stack trace: #0 .../www/wp/wp-includes/rest-api/class-wp-rest-request.php(910): is_numeric('14102', Object(WP_REST_Request), 'id') #1 .../www/wp/wp-includes/rest-api/class-wp-rest-server.php(976): WP_REST_Request->has_valid_params() #2 .../www/wp/wp-includes/rest-api/class-wp-rest-server.php(414): WP_REST_Server->dispatch(Object(WP_REST_Request)) #3 .../www/wp/wp-includes/rest-api.php(370): WP_REST_Server->serve_request('/custom-permali...') #4 .../www/wp/wp-includes/class-wp-hook.php(303): rest_api_loaded(Object(WP)) #5 .../www/wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array) #6 .../www/wp/wp-includes/plugin.php(518): WP_Hook->do_action(Array) #7 .../www/wp/wp-includes/class-wp.php(388): do_action_ref_array('parse_request', Array) #8 .../www/wp/wp-includes/class-wp.php(750): WP->parse_request('') #9 .../www/wp/wp-includes/functions.php(1291): WP->main('') #10 .../www/wp/wp-blog-header.php(16): wp() #11 .../www/index.php(9): require('/home/saur...') #12 {main} thrown in .../www/wp/wp-includes/rest-api/class-wp-rest-request.php on line 910
Change History (6)
#6
@
16 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
As there's been no further activity on this ticket for 2 years, I'll go ahead and close it as it appears to be a plugin issue.
Thank you @passam! I hope the issue has already been resolved for you. However, if it persists today after deactivating all plugins, then please reopen and share additional information such as how to reproduce it.
Note: See
TracTickets for help on using
tickets.
Hello @passam,
Welcome to WordPress Core's Trac!
The error message and first entry in the error stack trace give clues:
validate_callback
asis_numeric
You noted that it happened when upgrading to PHP 8. That's a clue too. This sample shows what happens in < PHP 8 and with PHP 8 when the
validate_callback
is set tois_numeric
:A warning was likely being logged in the site's error logs.
Why is this happening?
A custom endpoint exists in the site (from a plugin, theme, or script) that defines a custom endpoint with the
validate_callback
set tois_integer
.PHP's `is_numeric()` accepts only 1 argument, i.e. the value to be evaluated.
The REST API Handbook warns of using
is_integer
as thevalidation_callback
:What to do?
The key is to figure out where the custom endpoint exists and then work with its author to resolve. How to figure out?
wp-content
folderFor resolution, the REST API Handbook recommends using an anonymous function and then within it invoke
is_integer()
.Notes
I'm marking this ticket as
close
.Why? The problem appears to be external to WordPress core itself.
Why not close it? Thinking it would be good for a REST component maintainer to review:
is_integer()
as the callbackrest_is_integer()
might be another option, and if yes, then maybe updating the handbook to suggest it as an alternativethough likely both of these are outside scope of this ticket.