WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 21 months ago

#37685 new defect (bug)

Creating new multisite blog - wpmu_create_blog tries to execute queries on non-existent tables

Reported by: fliespl Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: reporter-feedback
Focuses: multisite Cc:

Description

I have noticed that while creating new wordpress site in multisite install I get quite a few notices about executed queries while using verbose logging.

query: SELECT option_name, option_value FROM wp_85_options WHERE autoload = 'yes'
status: ERR: Table 'wp1.wp_85_options' doesn't exist

which is triggered by wp_roles()->reinit(); during switch_to_blog function

Another are from get_blogaddress_by_id (inside install_blog function):

query: SELECT option_name, option_value FROM wp_85_options
status: ERR: Table 'wp1.wp_85_options' doesn't exist

query: SELECT option_value FROM wp_85_options WHERE option_name = 'home' LIMIT 1
status: ERR: Table 'wp1.wp_85_options' doesn't exist

query: SELECT option_value FROM wp_85_options WHERE option_name = 'blogname' LIMIT 1
status: ERR: Table 'wp1.wp_85_options' doesn't exist

query: SELECT option_value FROM wp_85_options WHERE option_name = 'siteurl' LIMIT 1
status: ERR: Table 'wp1.wp_85_options' doesn't exist

query: SELECT option_value FROM wp_85_options WHERE option_name = 'post_count' LIMIT 1
status: ERR: Table 'wp1.wp_85_options' doesn't exist

query: SELECT option_name, option_value FROM wp_85_options WHERE autoload = 'yes'
status: ERR: Table 'wp1.wp_85_options' doesn't exist

Wouldn't it make sense to skip execution of those queries unless tables has been created?

  1. get_blogaddress_by_id calls get_blog_details with $get_all as true while it makes no sense since additional fields will either be empty.
  2. Do not call reinit of wp_roles if in blog creation mode

Change History (7)

#1 @johnjamesjacoby
22 months ago

Hey @fliespl. Thanks for the report. Do you have any plugins activated on this installation? If so, are you comfortable listing them here? (I'd like to rule out the chance that a plugin is interfering with the core functionality of the wpmu_create_blog() function.)

#2 @fliespl
22 months ago

@johnjamesjacoby Those are logs from a multisite that was customized at some parts due to size/amount of traffic.

Yet I am pretty confident (99%) that those errors were not triggered by them - I have checked full backtrace that lead to this notices and those were happening (and triggered) solely by core functions (before any plugin / modification hopped in).

Still, I will create later today a clean site without any modifications just to be 100% sure.

#3 @swissspidy
22 months ago

Have you been able to reproduce the problem on a clean site? Are you running WordPress 4.6 or an older version?

#4 @fliespl
22 months ago

I have confirmed it with wordpress 4.6 using such script in mu-plugins

add_filter('shutdown', function() {
    global $EZSQL_ERROR;
    
    file_put_contents(ABSPATH.'/errors.log', print_r($EZSQL_ERROR, true)."\n\n", FILE_APPEND);
});

Errors logged:

    [0] => Array
        (
            [query] => SELECT option_value FROM wp_4_options WHERE option_name = 'wp_4_user_roles' LIMIT 1
            [error_str] => Table 'site.wp_4_options' doesn't exist
        )

    [1] => Array
        (
            [query] => DESCRIBE wp_4_posts
            [error_str] => Table 'site.wp_4_posts' doesn't exist
        )

    [2] => Array
        (
            [query] => SELECT option_value FROM wp_4_options WHERE option_name = 'blogname' LIMIT 1
            [error_str] => Table 'site.wp_4_options' doesn't exist
        )

    [3] => Array
        (
            [query] => SELECT option_value FROM wp_4_options WHERE option_name = 'siteurl' LIMIT 1
            [error_str] => Table 'site.wp_4_options' doesn't exist
        )

    [4] => Array
        (
            [query] => SELECT option_value FROM wp_4_options WHERE option_name = 'post_count' LIMIT 1
            [error_str] => Table 'site.wp_4_options' doesn't exist
        )

    [5] => Array
        (
            [query] => SELECT option_value FROM wp_4_options WHERE option_name = 'home' LIMIT 1
            [error_str] => Table 'site.wp_4_options' doesn't exist
        )

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


21 months ago

#6 @flixos90
21 months ago

  • Keywords reporter-feedback added

@fliespl Was your above test with a clean install without any plugins?

#7 @fliespl
21 months ago

@flixos90 correct. No themes/plugins installed. Just unpacked wordpress and created multisite.

Note: See TracTickets for help on using tickets.