#50717 closed defect (bug) (invalid)
rest_no_routes with PHP 7.3
Reported by: | yozana | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.5 |
Component: | REST API | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
When calling an endroute with PHP 7.3.x i get the following no_route error.
route example (job is a custom post type)
http://localhost/libi-smart-backoffice/wp-json/api/v2/job/334
results with:
{ "code": "rest_no_route", "message": "No route was found matching the URL and request method", "data": { "status": 404 } }
The same call works well with PHP 7.1.9.
PHP error log shows:
PHP Warning: preg_match(): Compilation failed: subpattern name expected at offset 24 in C:\wamp64\www\libi-smart-backoffice\wp-includes\rest-api\class-wp-rest-server.php on line 897
Change History (4)
#2
follow-up:
↓ 4
@
4 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
The group structure in your regex for the route is invalid.
Try (?P<id>[0-9]+)
instead of (?P<>[0-9]+)
. Or even simpler: (?P<id>[\d]+)
Check how WP_REST_Posts_Controller
registers the routes, and verify your regex using something like https://regex101.com/
#4
in reply to:
↑ 2
@
4 years ago
Replying to swissspidy:
The group structure in your regex for the route is invalid.
Try
(?P<id>[0-9]+)
instead of(?P<>[0-9]+)
. Or even simpler:(?P<id>[\d]+)
Check how
WP_REST_Posts_Controller
registers the routes, and verify your regex using something like https://regex101.com/
Thank you!
this has indeed solved the problem.
Sorry: missed the register route: