Make WordPress Core

Changeset 29931


Ignore:
Timestamp:
10/16/2014 10:06:46 PM (12 years ago)
Author:
boonebgorges
Message:

Remove invalid continue calls from WP_Tax_Query::get_sql_for_clause().

This was leftover code from the previous implementation, which used a foreach()
loop. See [29901].

Props nofearinc.
See #29738, #29718.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r29915 r29931  
    10421042
    10431043                        if ( empty( $terms ) ) {
    1044                                 continue;
     1044                                return $sql;
    10451045                        }
    10461046
     
    10561056
    10571057                        if ( empty( $terms ) ) {
    1058                                 continue;
     1058                                return $sql;
    10591059                        }
    10601060
  • trunk/tests/phpunit/tests/term/query.php

    r29902 r29931  
    353353        }
    354354
     355        /**
     356         * @ticket 29738
     357         */
     358        public function test_get_sql_operator_not_in_empty_terms() {
     359                register_taxonomy( 'wptests_tax', 'post' );
     360
     361                $tq = new WP_Tax_Query( array(
     362                        'relation' => 'OR',
     363                        array(
     364                                'taxonomy' => 'wptests_tax',
     365                                'field' => 'term_id',
     366                                'operator' => 'NOT IN',
     367                                'terms' => array(),
     368                        ),
     369                ) );
     370
     371                global $wpdb;
     372                $expected = array(
     373                        'join' => '',
     374                        'where' => '',
     375                );
     376
     377                $this->assertSame( $expected, $tq->get_sql( $wpdb->posts, 'ID' ) );
     378
     379                _unregister_taxonomy( 'wptests_tax' );
     380        }
     381
     382        /**
     383         * @ticket 29738
     384         */
     385        public function test_get_sql_operator_and_empty_terms() {
     386                register_taxonomy( 'wptests_tax', 'post' );
     387
     388                $tq = new WP_Tax_Query( array(
     389                        'relation' => 'OR',
     390                        array(
     391                                'taxonomy' => 'wptests_tax',
     392                                'field' => 'term_id',
     393                                'operator' => 'AND',
     394                                'terms' => array(),
     395                        ),
     396                ) );
     397
     398                global $wpdb;
     399                $expected = array(
     400                        'join' => '',
     401                        'where' => '',
     402                );
     403
     404                $this->assertSame( $expected, $tq->get_sql( $wpdb->posts, 'ID' ) );
     405
     406                _unregister_taxonomy( 'wptests_tax' );
     407        }
    355408}
Note: See TracChangeset for help on using the changeset viewer.