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

    r56555 r57750  
    11241124        );
    11251125    }
     1126
     1127    /**
     1128     * @ticket 56841
     1129     */
     1130    public function test_query_does_not_have_leading_whitespace() {
     1131        $q = new WP_Term_Query(
     1132            array(
     1133                'taxonomy'   => 'wptests_tax',
     1134                'hide_empty' => true,
     1135                'fields'     => 'ids',
     1136            )
     1137        );
     1138
     1139        $this->assertSame( ltrim( $q->request ), $q->request, 'The query has leading whitespace' );
     1140    }
    11261141}
Note: See TracChangeset for help on using the changeset viewer.