Make WordPress Core

Changeset 29200


Ignore:
Timestamp:
07/16/2014 10:34:18 PM (10 years ago)
Author:
wonderboymusic
Message:

Properly set $subdomain_error to false when applicable in ms_subdomain_constants(). This was previously untestable because it used static vars: use globals instead.

Adds unit test.
Fixes #28697.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-default-constants.php

    r26120 r29200  
    115115 *
    116116 * @since 3.0.0
     117 *
     118 * @global boolean $subdomain_error
     119 * @global boolean $subdomain_error_warn
    117120 */
    118121function ms_subdomain_constants() {
    119     static $error = null;
    120     static $error_warn = false;
     122    global $subdomain_error, $subdomain_error_warn;
    121123
    122     if ( false === $error )
     124    if ( false === $subdomain_error ) {
    123125        return;
     126    }
    124127
    125     if ( $error ) {
     128    if ( $subdomain_error ) {
    126129        $vhost_deprecated = __( 'The constant <code>VHOST</code> <strong>is deprecated</strong>. Use the boolean constant <code>SUBDOMAIN_INSTALL</code> in wp-config.php to enable a subdomain configuration. Use is_subdomain_install() to check whether a subdomain configuration is enabled.' );
    127         if ( $error_warn ) {
     130        if ( $subdomain_error_warn ) {
    128131            trigger_error( __( '<strong>Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL.</strong> The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.' ) . ' ' . $vhost_deprecated, E_USER_WARNING );
    129132        } else {
     
    134137
    135138    if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
    136         if ( SUBDOMAIN_INSTALL == ( 'yes' == VHOST ) ) {
    137             $error = true;
    138         } else {
    139             $error = $error_warn = true;
     139        $subdomain_error = true;
     140        if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) {
     141            $subdomain_error_warn = true;
    140142        }
    141143    } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
     144        $subdomain_error = false;
    142145        define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
    143146    } elseif ( defined( 'VHOST' ) ) {
    144         $error = true;
     147        $subdomain_error = true;
    145148        define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
    146149    } else {
     150        $subdomain_error = false;
    147151        define( 'SUBDOMAIN_INSTALL', false );
    148152        define( 'VHOST', 'no' );
  • trunk/tests/phpunit/tests/ms.php

    r28943 r29200  
    2424        parent::tearDown();
    2525        $wpdb->suppress_errors( $this->suppress );
     26    }
     27
     28    /**
     29     * @ticket 28697
     30     */
     31    function test_ms_subdomain_constants() {
     32        global $subdomain_error;
     33
     34        $this->assertFalse( $subdomain_error );
     35        ms_subdomain_constants();
     36        $this->assertFalse( $subdomain_error );
    2637    }
    2738
Note: See TracChangeset for help on using the changeset viewer.