WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 5 months ago

#16455 closed defect (bug) (invalid)

if MULTISITE constant not defined error message "One or more database tables are unavailable" or "Error establishing a database connection" appears

Reported by: Axel_germany Owned by:
Priority: normal Milestone:
Component: General Version: 3.0.4
Severity: normal Keywords: needs-testing dev-feedback
Cc:

Description

I updated a wordpress installation (no multisite) from 3.0.1 to 3.0.4. After the update the back-end displayed the error message "One or more database tables are unavailable" and the front-end "Error establishing a database connection".

I figured out that this only happened if the constant MULTISITE in wp-config.php was not defined at all.

If you set it to false
define( 'MULTISITE', false );

or true

define( 'MULTISITE', true );

everything seams to be fine.

I tested it with the default 'Twenty Ten 1.1 by the WordPress team' theme and no plugins activated.

This might have to do with this:

if (MULTISITE) {echo "is true";}
else {echo "is false";}

is evaluated to 'true' if you didn't defined the constant while it is evaluated to 'false'

define("MULTISITE", false );
if (MULTISITE) {echo "is true";}
else {echo "is false";}

if you define it to be false.

Attachments (2)

16455.diff (961 bytes) - added by MattyRob 2 years ago.
16455v2.diff (540 bytes) - added by MattyRob 2 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 markjaquith2 years ago

WordPress should never be treating MULTISITE as a boolean without testing first to see if it is defined.

Additionally, in the case of a non-multisite install, we define it to be false.

// Initialize multisite if enabled.
if ( is_multisite() ) {
	require( ABSPATH . WPINC . '/ms-blogs.php' );
	require( ABSPATH . WPINC . '/ms-settings.php' );
} elseif ( ! defined( 'MULTISITE' ) ) {
	define( 'MULTISITE', false );
}

Going to need more information here. Literally millions of people are running 3.0.4 with no MULTISITE constant defined at all. Something else must be going on.

comment:2 nacin2 years ago

If is_multisite() returns true, we assume that, if MULTISITE is defined, it is defined to true. This occurs in a few locations, notably wp-db.php, which allows us to identify whether we're on a 3.0 network, or a network updated from MU.

comment:3 nacin2 years ago

  • Keywords reporter-feedback added

Other note: If you are running a MU network -- such that you have VHOST or SUNRISE defined -- and you define('MULTISITE', false);, the sky will fall on your head.

I don't even have a theory for what's going on here. Something very odd and I think it's your setup.

comment:4 Axel_germany2 years ago

Thanks for your quick reply. I tracked the problem down. It's not critical for normal users but if you have

define( 'SUBDOMAIN_INSTALL', false );  

in your wp-config.php and don't have

define( 'MULTISITE', false );

in your wp-config.php then

/**
 * Whether Multisite support is enabled
 *
 * @since 3.0.0
 *
 * @return bool True if multisite is enabled, false otherwise.
 */
function is_multisite() {
        if ( defined( 'MULTISITE' ) )
                return MULTISITE;

        if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
                return true;

        return false;
}

( line 499 in wp-includes/load.php ) returns true.

comment:5 MattyRob2 years ago

  • Keywords has-patch needs-testing added

The is-subdomain_install() function does part of this query so why not make use of that?

Patch attached, needs testing

MattyRob2 years ago

comment:6 MattyRob2 years ago

Scratch that - it won't call that function is no MS. The attached should be better by on my testing is multisite is not defined but subdomain_install is then WordPress bails. I therefore cannot reproduce.

MattyRob2 years ago

comment:7 SergeyBiryukov22 months ago

  • Keywords reporter-feedback removed

comment:8 bpetty5 months ago

  • Keywords close dev-feedback added; has-patch removed

This looks like it was simply just a single installation mis-configuration, and if not, there's not enough information here to figure out how this happened, but this situation doesn't happen currently, assuming instructions for multisite installation are followed correctly.

Proposing close.

comment:9 SergeyBiryukov5 months ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.