Make WordPress Core

Changeset 55857


Ignore:
Timestamp:
05/25/2023 12:53:24 PM (17 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Improve formatting of some SQL queries for better readability.

This corrects the placement of double quotes around the query and makes sure the alignment is consistent.

Props umeshmcakadi, mukesh27, krupalpanchal, dhrumilk, SergeyBiryukov.
Fixes #58372.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/export.php

    r55412 r55857  
    142142    $months = $wpdb->get_results(
    143143        $wpdb->prepare(
    144             "
    145         SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    146         FROM $wpdb->posts
    147         WHERE post_type = %s AND post_status != 'auto-draft'
    148         ORDER BY post_date DESC
    149             ",
     144            "SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
     145            FROM $wpdb->posts
     146            WHERE post_type = %s AND post_status != 'auto-draft'
     147            ORDER BY post_date DESC",
    150148            $post_type
    151149        )
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r55293 r55857  
    699699            $months = $wpdb->get_results(
    700700                $wpdb->prepare(
    701                     "
    702                 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    703                 FROM $wpdb->posts
    704                 WHERE post_type = %s
    705                 $extra_checks
    706                 ORDER BY post_date DESC
    707             ",
     701                    "SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
     702                    FROM $wpdb->posts
     703                    WHERE post_type = %s
     704                    $extra_checks
     705                    ORDER BY post_date DESC",
    708706                    $post_type
    709707                )
  • trunk/src/wp-admin/includes/post.php

    r55758 r55857  
    10111011
    10121012    $keys = $wpdb->get_col(
    1013         "
    1014             SELECT meta_key
    1015             FROM $wpdb->postmeta
    1016             GROUP BY meta_key
    1017             ORDER BY meta_key"
     1013        "SELECT meta_key
     1014        FROM $wpdb->postmeta
     1015        GROUP BY meta_key
     1016        ORDER BY meta_key"
    10181017    );
    10191018
  • trunk/src/wp-includes/class-wp-tax-query.php

    r55732 r55857  
    467467            $where = $wpdb->prepare(
    468468                "$operator (
    469                 SELECT 1
    470                 FROM $wpdb->term_relationships
    471                 INNER JOIN $wpdb->term_taxonomy
    472                 ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
    473                 WHERE $wpdb->term_taxonomy.taxonomy = %s
    474                 AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column
    475             )",
     469                    SELECT 1
     470                    FROM $wpdb->term_relationships
     471                    INNER JOIN $wpdb->term_taxonomy
     472                    ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
     473                    WHERE $wpdb->term_taxonomy.taxonomy = %s
     474                    AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column
     475                )",
    476476                $clause['taxonomy']
    477477            );
  • trunk/src/wp-includes/class-wp-user-query.php

    r55732 r55857  
    10101010                $where
    10111011                GROUP BY post_author
    1012             ) p ON ({$wpdb->users}.ID = p.post_author)
    1013             ";
     1012            ) p ON ({$wpdb->users}.ID = p.post_author)";
    10141013            $_orderby          = 'post_count';
    10151014        } elseif ( 'ID' === $orderby || 'id' === $orderby ) {
  • trunk/src/wp-includes/deprecated.php

    r55856 r55857  
    45634563        $post_type_in_string = "'" . implode( "','", $post_type ) . "'";
    45644564        $sql                 = $wpdb->prepare(
    4565             "
    4566             SELECT ID
     4565            "SELECT ID
    45674566            FROM $wpdb->posts
    45684567            WHERE post_title = %s
    4569             AND post_type IN ($post_type_in_string)
    4570         ",
     4568            AND post_type IN ($post_type_in_string)",
    45714569            $page_title
    45724570        );
    45734571    } else {
    45744572        $sql = $wpdb->prepare(
    4575             "
    4576             SELECT ID
     4573            "SELECT ID
    45774574            FROM $wpdb->posts
    45784575            WHERE post_title = %s
    4579             AND post_type = %s
    4580         ",
     4576            AND post_type = %s",
    45814577            $page_title,
    45824578            $post_type
  • trunk/src/wp-includes/general-template.php

    r55703 r55857  
    22992299        WHERE post_date < '$thisyear-$thismonth-01'
    23002300        AND post_type = 'post' AND post_status = 'publish'
    2301             ORDER BY post_date DESC
    2302             LIMIT 1"
     2301        ORDER BY post_date DESC
     2302        LIMIT 1"
    23032303    );
    23042304    $next     = $wpdb->get_row(
     
    23072307        WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
    23082308        AND post_type = 'post' AND post_status = 'publish'
    2309             ORDER BY post_date ASC
    2310             LIMIT 1"
     2309        ORDER BY post_date ASC
     2310        LIMIT 1"
    23112311    );
    23122312
  • trunk/src/wp-includes/media.php

    r55847 r55857  
    44854485    if ( null === $show_audio_playlist ) {
    44864486        $show_audio_playlist = $wpdb->get_var(
    4487             "
    4488             SELECT ID
     4487            "SELECT ID
    44894488            FROM $wpdb->posts
    44904489            WHERE post_type = 'attachment'
    44914490            AND post_mime_type LIKE 'audio%'
    4492             LIMIT 1
    4493         "
     4491            LIMIT 1"
    44944492        );
    44954493    }
     
    45154513    if ( null === $show_video_playlist ) {
    45164514        $show_video_playlist = $wpdb->get_var(
    4517             "
    4518             SELECT ID
     4515            "SELECT ID
    45194516            FROM $wpdb->posts
    45204517            WHERE post_type = 'attachment'
    45214518            AND post_mime_type LIKE 'video%'
    4522             LIMIT 1
    4523         "
     4519            LIMIT 1"
    45244520        );
    45254521    }
     
    45444540        $months = $wpdb->get_results(
    45454541            $wpdb->prepare(
    4546                 "
    4547             SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    4548             FROM $wpdb->posts
    4549             WHERE post_type = %s
    4550             ORDER BY post_date DESC
    4551         ",
     4542                "SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
     4543                FROM $wpdb->posts
     4544                WHERE post_type = %s
     4545                ORDER BY post_date DESC",
    45524546                'attachment'
    45534547            )
  • trunk/src/wp-includes/user.php

    r55747 r55857  
    35463546    $users = $wpdb->get_col(
    35473547        $wpdb->prepare(
    3548             "
    3549         SELECT user_id
    3550         FROM $wpdb->usermeta
    3551         WHERE meta_key = '{$prefix}capabilities'
    3552         AND meta_value NOT REGEXP %s
    3553     ",
     3548            "SELECT user_id
     3549            FROM $wpdb->usermeta
     3550            WHERE meta_key = '{$prefix}capabilities'
     3551            AND meta_value NOT REGEXP %s",
    35543552            $regex
    35553553        )
Note: See TracChangeset for help on using the changeset viewer.