Make WordPress Core


Ignore:
Timestamp:
12/22/2025 11:12:59 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Replace some isset() ternary checks with null coalescing.

Since PHP 7.0 introduced the null coalescing operator, and WordPress now requires at least PHP 7.2.24, isset( $var ) ? $var : null ternary checks can be safely replaced with the more concise $var ?? null syntax.

As some new code using the null coalescing operator has already been introduced into core in recent releases, this commit continues with the code modernization by implementing incremental changes for easier review.

Props seanwei, getsyash, krupalpanchal, wildworks, jorbin, SergeyBiryukov.
Fixes #63430. See #58874.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-site-query.php

    r60697 r61403  
    675675        $clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) );
    676676
    677         $fields  = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
    678         $join    = isset( $clauses['join'] ) ? $clauses['join'] : '';
    679         $where   = isset( $clauses['where'] ) ? $clauses['where'] : '';
    680         $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
    681         $limits  = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
    682         $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
     677        $fields  = $clauses['fields'] ?? '';
     678        $join    = $clauses['join'] ?? '';
     679        $where   = $clauses['where'] ?? '';
     680        $orderby = $clauses['orderby'] ?? '';
     681        $limits  = $clauses['limits'] ?? '';
     682        $groupby = $clauses['groupby'] ?? '';
    683683
    684684        if ( $where ) {
Note: See TracChangeset for help on using the changeset viewer.