Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#61029 new defect (bug)

Multisite state 'Delete' can only have a value of 1or 0. Not 2. So why is 2 mentioned in the code?

Reported by: ignatiusjeroe's profile ignatiusjeroe Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords:
Focuses: multisite Cc:


In function ms_site_check() @ 103 "if ( '2' == $blog->deleted )" the code checks if the site deleted state has a value of 2. But in wp-admin/network/site-info.php from line 74 to 82 the code checks the value of all states and either assigns them with a 1 or 0. I havent found anywhere in the source code were any site state could be assigned a value of 2.

So the snippet "if ( '2' == $blog->deleted )" makes no sense. Sure you can alter the state value using wp_update_site(). But that is not the answers since whenever the site is updated on wp-admin/network/site-info.php the values are validated prior to saving the the dB. And like i said, the only valid values are 1 or 0. ms_site_check() should be edited. The drop-in in the if-statement is rendered unusable cause the if-statement will fail every time.

Change History (2)

#1 @dd32
5 weeks ago

  • Component changed from General to Networks and Sites

The '2' state is a historical vestiage of Multisite.

While it's likely not used by Core today, it was previously used by WordPress MU (WordPress Multisite, pre WordPress 3.0)

Here's the earliest reference I can find to it:

While this code branch could be removed (Combining deleted == 1 and deleted == 2), it would likely be at the disadvantage of breaking existing sites that were expecting that specific error page, or plugins which expected Core to handle it.

#2 @costdev
5 weeks ago

The drop-in in the if-statement is rendered unusable cause the if-statement will fail every time.

Note that the return value of get_site() is filterable using the get_site hook.

For example, the following can be used to set $deleted to '2' to differentiate between '1' a site that is no longer available, and '2' a site that has not been activated yet (i.e. it was never available). That branch will be hit, and either load WP_CONTENT_DIR . '/blog-inactive.php' if available, or output the default message.

  static function ( $_site ) {
    $_site->deleted = '2';
    return $_site;
Note: See TracTickets for help on using tickets.