[wp-trac] [WordPress Trac] #62646: PHP Warning in REST API when post_type doesn't support post-formats, but a post-format filter is applied.
WordPress Trac
noreply at wordpress.org
Thu Dec 5 04:27:47 UTC 2024
#62646: PHP Warning in REST API when post_type doesn't support post-formats, but a
post-format filter is applied.
--------------------------+------------------------------
Reporter: dd32 | Owner: peterwilsoncc
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 6.7
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------------
Changes (by dd32):
* owner: (none) => peterwilsoncc
* status: new => reviewing
Comment:
Personally I'm not in love with the idea of returning an error here. It's
not an error, it's an unknown query parameter.
upon reviewing the file, my diff took the wrong approach, the existing
endpoint validation uses the list of registered input variables, updated
change included below. Checking `isset()` is enough as it can't be an
empty value.
{{{#!diff
Index: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
===================================================================
--- wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
(revision 58872)
+++ wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
(working copy)
@@ -346,7 +346,7 @@
$args = $this->prepare_tax_query( $args, $request );
- if ( ! empty( $request['format'] ) ) {
+ if ( isset( $registered['format'], $request['format'] ) )
{
$formats = $request['format'];
/*
* The relation needs to be set to `OR` since the
request can contain
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62646#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list