Skip to content

Commit e54f258

Browse files
committed
Use conditional for ensuring args is array
1 parent 35606cf commit e54f258

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,10 @@ static function ( $format ) {
441441
* @param array $args Array of arguments for WP_Query.
442442
* @param WP_REST_Request $request The REST API request.
443443
*/
444-
$args = apply_filters( "rest_{$this->post_type}_query", $args, $request );
445-
$args = is_array( $args ) ? $args : array();
444+
$args = apply_filters( "rest_{$this->post_type}_query", $args, $request );
445+
if ( ! is_array( $args ) ) {
446+
$args = array();
447+
}
446448
$query_args = $this->prepare_items_query( $args, $request );
447449

448450
$posts_query = new WP_Query();

src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@ public function get_items( $request ) {
298298
}
299299

300300
/** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
301-
$args = apply_filters( 'rest_revision_query', $args, $request );
302-
$args = is_array( $args ) ? $args : array();
301+
$args = apply_filters( 'rest_revision_query', $args, $request );
302+
if ( ! is_array( $args ) ) {
303+
$args = array();
304+
}
303305
$query_args = $this->prepare_items_query( $args, $request );
304306

305307
$revisions_query = new WP_Query();

0 commit comments

Comments
 (0)