Make WordPress Core


Ignore:
Timestamp:
03/02/2024 01:36:02 PM (3 years 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/multisite/wpSiteQuery.php

    r55745 r57750  
    11631163                        return array( get_site( self::$site_ids['wordpress.org/'] ) );
    11641164                }
     1165
     1166                /**
     1167                 * @ticket 56841
     1168                 */
     1169                public function test_wp_site_query_does_not_have_leading_whitespace() {
     1170                        $q = new WP_Site_Query();
     1171
     1172                        $q->query(
     1173                                array(
     1174                                        'fields'                 => 'ids',
     1175                                        'network_id'             => self::$network_ids['wordpress.org/'],
     1176                                        'number'                 => 3,
     1177                                        'order'                  => 'ASC',
     1178                                        'update_site_cache'      => true,
     1179                                        'update_site_meta_cache' => true,
     1180                                )
     1181                        );
     1182
     1183                        $this->assertSame( ltrim( $q->request ), $q->request, 'The query has leading whitespace' );
     1184                }
    11651185        }
    11661186
Note: See TracChangeset for help on using the changeset viewer.