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-term-query.php

    r57719 r57750  
    753753        $this->sql_clauses['limits']  = $limits;
    754754
    755         $this->request = "
    756             {$this->sql_clauses['select']}
    757             {$this->sql_clauses['from']}
    758             {$where}
    759             {$this->sql_clauses['orderby']}
    760             {$this->sql_clauses['limits']}
    761         ";
     755        // Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.
     756        $this->request =
     757            "{$this->sql_clauses['select']}
     758             {$this->sql_clauses['from']}
     759             {$where}
     760             {$this->sql_clauses['orderby']}
     761             {$this->sql_clauses['limits']}";
    762762
    763763        $this->terms = null;
Note: See TracChangeset for help on using the changeset viewer.