Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-date-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,7 @@ protected function get_sql_for_clause( $query, $parent_query ) {
if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) {
// Avoid notices.
foreach ( array( 'hour', 'minute', 'second' ) as $unit ) {
if ( ! isset( $query[ $unit ] ) ) {
$query[ $unit ] = null;
}
$query[ $unit ] ??= null;
}

$time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] );
Expand Down
8 changes: 2 additions & 6 deletions src/wp-includes/class-wp-metadata-lazyloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,11 @@ public function queue_objects( $object_type, $object_ids ) {

$type_settings = $this->settings[ $object_type ];

if ( ! isset( $this->pending_objects[ $object_type ] ) ) {
$this->pending_objects[ $object_type ] = array();
}
$this->pending_objects[ $object_type ] ??= array();

foreach ( $object_ids as $object_id ) {
// Keyed by ID for faster lookup.
if ( ! isset( $this->pending_objects[ $object_type ][ $object_id ] ) ) {
$this->pending_objects[ $object_type ][ $object_id ] = 1;
}
$this->pending_objects[ $object_type ][ $object_id ] ??= 1;
}

add_filter( $type_settings['filter'], $type_settings['callback'], 10, 5 );
Expand Down
54 changes: 14 additions & 40 deletions src/wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,7 @@ public function fill_query_vars( $query_vars ) {
);

foreach ( $keys as $key ) {
if ( ! isset( $query_vars[ $key ] ) ) {
$query_vars[ $key ] = '';
}
$query_vars[ $key ] ??= '';
}

$array_keys = array(
Expand All @@ -643,9 +641,7 @@ public function fill_query_vars( $query_vars ) {
);

foreach ( $array_keys as $key ) {
if ( ! isset( $query_vars[ $key ] ) ) {
$query_vars[ $key ] = array();
}
$query_vars[ $key ] ??= array();
}

return $query_vars;
Expand Down Expand Up @@ -1279,10 +1275,8 @@ public function parse_tax_query( &$query_vars ) {
}

if ( ! empty( $query_vars['category__and'] ) && 1 === count( (array) $query_vars['category__and'] ) ) {
$query_vars['category__and'] = (array) $query_vars['category__and'];
if ( ! isset( $query_vars['category__in'] ) ) {
$query_vars['category__in'] = array();
}
$query_vars['category__and'] = (array) $query_vars['category__and'];
$query_vars['category__in'] ??= array();
$query_vars['category__in'][] = absint( reset( $query_vars['category__and'] ) );
unset( $query_vars['category__and'] );
}
Expand Down Expand Up @@ -1967,40 +1961,26 @@ public function get_posts() {
)
);

if ( ! isset( $query_vars['ignore_sticky_posts'] ) ) {
$query_vars['ignore_sticky_posts'] = $query_vars['caller_get_posts'];
}
$query_vars['ignore_sticky_posts'] ??= $query_vars['caller_get_posts'];
}

if ( ! isset( $query_vars['ignore_sticky_posts'] ) ) {
$query_vars['ignore_sticky_posts'] = false;
}
$query_vars['ignore_sticky_posts'] ??= false;

if ( ! isset( $query_vars['suppress_filters'] ) ) {
$query_vars['suppress_filters'] = false;
}
$query_vars['suppress_filters'] ??= false;

if ( ! isset( $query_vars['cache_results'] ) ) {
$query_vars['cache_results'] = true;
}
$query_vars['cache_results'] ??= true;

if ( ! isset( $query_vars['update_post_term_cache'] ) ) {
$query_vars['update_post_term_cache'] = true;
}
$query_vars['update_post_term_cache'] ??= true;

if ( ! isset( $query_vars['update_menu_item_cache'] ) ) {
$query_vars['update_menu_item_cache'] = false;
}
$query_vars['update_menu_item_cache'] ??= false;

if ( ! isset( $query_vars['lazy_load_term_meta'] ) ) {
$query_vars['lazy_load_term_meta'] = $query_vars['update_post_term_cache'];
} elseif ( $query_vars['lazy_load_term_meta'] ) { // Lazy loading term meta only works if term caches are primed.
$query_vars['update_post_term_cache'] = true;
}

if ( ! isset( $query_vars['update_post_meta_cache'] ) ) {
$query_vars['update_post_meta_cache'] = true;
}
$query_vars['update_post_meta_cache'] ??= true;

if ( ! isset( $query_vars['post_type'] ) ) {
if ( $this->is_search ) {
Expand Down Expand Up @@ -3322,9 +3302,7 @@ public function get_posts() {
}

if ( 'ids' === $query_vars['fields'] ) {
if ( null === $this->posts ) {
$this->posts = $wpdb->get_col( $this->request );
}
$this->posts ??= $wpdb->get_col( $this->request );

/** @var int[] */
$this->posts = array_map( 'intval', $this->posts );
Expand All @@ -3345,9 +3323,7 @@ public function get_posts() {
}

if ( 'id=>parent' === $query_vars['fields'] ) {
if ( null === $this->posts ) {
$this->posts = $wpdb->get_results( $this->request );
}
$this->posts ??= $wpdb->get_results( $this->request );

$this->post_count = count( $this->posts );
$this->set_found_posts( $query_vars, $limits );
Expand Down Expand Up @@ -5081,9 +5057,7 @@ protected function generate_cache_key( array $args, $sql ) {
}

// Add a default orderby value of date to ensure same cache key generation.
if ( ! isset( $args['orderby'] ) ) {
$args['orderby'] = 'date';
}
$args['orderby'] ??= 'date';

$placeholder = $wpdb->placeholder_escape();
array_walk_recursive(
Expand Down
9 changes: 3 additions & 6 deletions src/wp-includes/class-wp-tax-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ public function sanitize_query( $queries ) {
*/
if ( ! empty( $cleaned_clause['taxonomy'] ) && 'NOT IN' !== $cleaned_clause['operator'] ) {
$taxonomy = $cleaned_clause['taxonomy'];
if ( ! isset( $this->queried_terms[ $taxonomy ] ) ) {
$this->queried_terms[ $taxonomy ] = array();
}

$this->queried_terms[ $taxonomy ] ??= array();

/*
* Backward compatibility: Only store the first
Expand All @@ -184,9 +183,7 @@ public function sanitize_query( $queries ) {

if ( ! empty( $cleaned_subquery ) ) {
// All queries with children must have a relation.
if ( ! isset( $cleaned_subquery['relation'] ) ) {
$cleaned_subquery['relation'] = 'AND';
}
$cleaned_subquery['relation'] ??= 'AND';

$cleaned_query[] = $cleaned_subquery;
}
Expand Down
Loading