Make WordPress Core


Ignore:
Timestamp:
03/02/2024 01:36:02 PM (13 months ago)
Author:
swissspidy
Message:

Query: Remove leading whitespace from certain database queries.

Unintended leading whitespace at the beginning of a raw MySQL query led to unexpected behavior such as broken pagination. Eliminating said whitespace avoids that.

Adds unit tests to prevent regressions.

Props wpfed, swissspidy, ironprogrammer, tadamarketing, afercia.
Fixes #56841.

File:
1 edited

Legend:

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

    r56543 r57750  
    819819
    820820        if ( null === $this->results ) {
    821             $this->request = "
    822                 SELECT {$this->query_fields}
    823                 {$this->query_from}
    824                 {$this->query_where}
    825                 {$this->query_orderby}
    826                 {$this->query_limit}
    827             ";
     821            // Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.
     822            $this->request =
     823                "SELECT {$this->query_fields}
     824                 {$this->query_from}
     825                 {$this->query_where}
     826                 {$this->query_orderby}
     827                 {$this->query_limit}";
    828828            $cache_value   = false;
    829829            $cache_key     = $this->generate_cache_key( $qv, $this->request );
Note: See TracChangeset for help on using the changeset viewer.