Make WordPress Core

Changeset 27086


Ignore:
Timestamp:
02/03/2014 10:39:47 PM (11 years ago)
Author:
nacin
Message:

Test suite: Trim queries before deciding whether to create temporary tables.

props jdgrimes.
fixes #24800.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r27041 r27086  
    3636        $this->expectedDeprecated();
    3737        $wpdb->query( 'ROLLBACK' );
    38         remove_filter( 'query', array( $this, '_create_temporary_table' ) );
    39         remove_filter( 'query', array( $this, '_drop_temporary_table' ) );
     38        remove_filter( 'query', array( $this, '_create_temporary_tables' ) );
     39        remove_filter( 'query', array( $this, '_drop_temporary_tables' ) );
    4040        remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
    4141    }
     
    6565        $wpdb->query( 'SET autocommit = 0;' );
    6666        $wpdb->query( 'START TRANSACTION;' );
    67         add_filter( 'query', array( $this, '_create_temporary_table' ) );
    68         add_filter( 'query', array( $this, '_drop_temporary_table' ) );
    69     }
    70 
    71     function _create_temporary_table( $query ) {
    72         if ( 'CREATE TABLE' === substr( $query, 0, 12 ) )
    73             return substr_replace( $query, 'CREATE TEMPORARY TABLE', 0, 12 );
     67        add_filter( 'query', array( $this, '_create_temporary_tables' ) );
     68        add_filter( 'query', array( $this, '_drop_temporary_tables' ) );
     69    }
     70
     71    function _create_temporary_tables( $query ) {
     72        if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) )
     73            return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 );
    7474        return $query;
    7575    }
    7676
    77     function _drop_temporary_table( $query ) {
    78         if ( 'DROP TABLE' === substr( $query, 0, 10 ) )
    79             return substr_replace( $query, 'DROP TEMPORARY TABLE', 0, 10 );
     77    function _drop_temporary_tables( $query ) {
     78        if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) )
     79            return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 );
    8080        return $query;
    8181    }
Note: See TracChangeset for help on using the changeset viewer.