Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#17090 closed defect (bug) (invalid)

Multisite 3.1.1 Upgrade Redirect Loop Network Admin & Plugins

Reported by: theshadowfan's profile theshadowfan Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description (last modified by nacin)

I have Wordpress MultiSite and was upgrading from 3.1 to 3.1.1. Both my Network Admin and my website displayed redirecting loop errors. The website was initally caused by the Plugins, so I disabled those and the redirect loop error was removed. However the Network Admin error remained. My server provider found code in the admin.php that was causing the issue:

We had modifed the following code from the file "admin.php" in the path "/wp-admin/network".

===========
Previous Code

if ( ( $current_blog->domain != $current_site->domain ) || ( $current_blog->path != $current_site->path ) ) {
wp_redirect( network_admin_url() );
exit;

===========
Corrected Code

if ( ! is_main_site() ) {
wp_redirect( network_admin_url() );
exit;

Attachments (3)

admin.php (513 bytes) - added by theshadowfan 14 years ago.
This is my old admin.php file before the fix
ticket-17090.php (610 bytes) - added by nacin 14 years ago.
ticket-17090.2.php (1.0 KB) - added by nacin 14 years ago.

Download all attachments as: .zip

Change History (24)

@theshadowfan
14 years ago

This is my old admin.php file before the fix

#1 @nacin
14 years ago

We need some details about your setup. What's the domain (you can use example.com) and path of the main site, as well as other sites?

#2 @theshadowfan
14 years ago

The blog was initially set up at example.com/example. When we switched to multi-site with Wordpress 3.0 or 3.1 and that main blog was moved to example.com. The sub blogs are examplesubblog.example.com

#3 @nacin
14 years ago

So, for the network, the domain should be example.com, and the path should be /.

The domain is also example.com with a path of / for the main site.

Thus, this code should be equivalent.

Can you do a var_dump() on $current_blog and $current_site for both the main blog and another blog?

#4 @theshadowfan
14 years ago

Could you send me the exact code that you want me to try out in wp-admin/network/admin.php on example.com and example1.example.com? What file should I edit for example1.example.com?

#5 @nacin
14 years ago

Activate the attached plugin. Go to various different URLs (including the network admin), but append ?debug to them. Capture the output. There should be enough there to diagnose. Also let us know which attempted URLs work and don't work without the plugin.

Kill the plugin when done.

@nacin
14 years ago

#6 @theshadowfan
14 years ago

I've activated the plugin on the network level. The Network Admin, example.com, and sub blogs all load correctly without the redirect loop notice. How do I "append ? debug" to them?

Do I install a plugin on Firefox to debug pages? If so which plugin should I download that allows me to save the debug files?

#8 @theshadowfan
14 years ago

Here's the message that occurs when I went to that URL:

Attempted URL: www.example.com/wp-admin/network/
Network admin: true
Main site: true
stdClass Object
(
    [id] => 1
    [domain] => www.example.com
    [path] => /
    [blog_id] => 1
    [cookie_domain] => example.com
    [site_name] => Example.com Sites
)
stdClass Object
(
    [blog_id] => 1
    [site_id] => 1
    [domain] => www.example.com
    [path] => /example
    [registered] => 2010-10-15 23:12:39
    [last_updated] => 2011-04-08 18:34:19
    [public] => 1
    [archived] => 0
    [mature] => 0
    [spam] => 0
    [deleted] => 0
    [lang_id] => 0
)
Last edited 14 years ago by nacin (previous) (diff)

#9 @nacin
14 years ago

  • Description modified (diff)

#10 @nacin
14 years ago

Can you also add a line in there for var_dump( network_admin_url() ); and please run this on a sub blog as well.

So you seem to have a discrepancy in your data here. I don't think you could have gotten the data you have via the UI, either, unless you edited internal options.

If the main blog is 1, then the second [path] here should also match the first [path]. But it doesn't.

I'm wondering if there's something odd going on in ms-settings.php, but if I had to guess, your network was moved incorrectly.

I have some more debugging we can try next.

#11 @nacin
14 years ago

Add this to that function:

global $wpdb;
var_dump( $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = 1" ) );
var_dump( $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE site_id = 1" ) );
foreach ( array( 'DOMAIN_CURRENT_SITE', 'PATH_CURRENT_SITE', 'SITE_ID_CURRENT_SITE', 'BLOG_ID_CURRENT_SITE', 'BLOGID_CURRENT_SITE' ) as $constant ) {
	if ( defined( $constant ) )
		echo "$constant is " . constant( $constant ) . "\n";
}
Last edited 14 years ago by nacin (previous) (diff)

#12 @theshadowfan
14 years ago

When we moved the blog I did encounter redirection issues. When someone tried to access the old blog post URL it did not automatically redirect them to the new blog post URL. My host figured out whatever the issue was. I just checked right now and if I go a new blog post via the old blog directory URL, it was redirect me to the new blog directory URL.

When I added the above code to my wp-admin/network/admin.php file and tried to access the Network Admin file, I received this error:

Parse error: syntax error, unexpected T_ECHO in /home/stuffwel/public_html/wp-admin/network/admin.php on line 28

This is where I inserted the code, is this correct?:
<?php
/

  • WordPress Network Administration Bootstrap *
  • @package WordPress
  • @subpackage Multisite
  • @since 3.1.0 */

define( 'WP_NETWORK_ADMIN', TRUE );

/ Load WordPress Administration Bootstrap */
require_once( dirname( dirname( FILE ) ) . '/admin.php' );

if ( ! is_multisite() )

wp_die( ( 'Multisite support is not enabled.' ) );

if ( ! is_main_site() ) {

wp_redirect( network_admin_url() );
exit;

}

global $wpdb;
var_dump( $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = 1" ) );
var_dump( $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE site_id = 1" ) );
foreach ( array( 'DOMAIN_CURRENT_SITE', 'PATH_CURRENT_SITE', 'SITE_ID_CURRENT_SITE', 'BLOG_ID_CURRENT_SITE', 'BLOGID_CURRENT_SITE' ) as $constant ) {

if ( defined( $constant )

echo "$constant is " . constant( $constant ) . "\n";

}

?>

Last edited 14 years ago by theshadowfan (previous) (diff)

#13 @nacin
14 years ago

No. Remove that, try this new version of the plugin.

@nacin
14 years ago

#14 @theshadowfan
14 years ago

Removed the code from admin.php. Activated the plugin.

Here's what it said when I went to wp-admin/network:

Attempted URL:
www.example.com/wp-admin/network/
Network admin: true
Main site: true
stdClass Object
(

[id] => 1
[domain] => www.example.com
[path] => /
[blog_id] => 1
[cookie_domain] => example.com
[site_name] => example.com Sites

)
stdClass Object
(

[blog_id] => 1
[site_id] => 1
[domain] => www.example.com
[path] => /example
[registered] => 2010-10-15 23:12:39
[last_updated] => 2011-04-08 18:34:19
[public] => 1
[archived] => 0
[mature] => 0
[spam] => 0
[deleted] => 0
[lang_id] => 0

)

Here's what happened on a sub-blog:
Attempted URL: www.example1.example.com/wp-admin/network/
Network admin: true
Main site: false
stdClass Object
(

[id] => 1
[domain] => www.example.com
[path] => /
[blog_id] => 1
[cookie_domain] => example.com
[site_name] => example.com Sites

)
stdClass Object
(

[blog_id] => 4
[site_id] => 1
[domain] => example1.example.com
[path] => /
[registered] => 2010-12-25 19:51:07
[last_updated] => 2011-03-31 00:18:53
[public] => 1
[archived] => 0
[mature] => 0
[spam] => 0
[deleted] => 0
[lang_id] => 0

)

#16 @theshadowfan
14 years ago

I downloaded and activated that plugin but the code is the same as what I previously sent. I tried both a network activation and individual blog activation and the debug information was unchanged.

#17 @theshadowfan
14 years ago

Sorry, I put the file in the wrong folder. Trying it out now.

#18 @theshadowfan
14 years ago

Example.com/wp-admin/network?debug:
Attempted URL: www.example.com/wp-admin/network/
Network admin: true
Main site: true
Network admin URL: http://www.example.com/wp-admin/network/
stdClass Object
(
    [id] => 1
    [domain] => www.example.com
    [path] => /
    [blog_id] => 1
    [cookie_domain] => example.com
    [site_name] => example.com Sites
)
stdClass Object
(
    [blog_id] => 1
    [site_id] => 1
    [domain] => www.example.com
    [path] => /example
    [registered] => 2010-10-15 23:12:39
    [last_updated] => 2011-04-08 18:34:19
    [public] => 1
    [archived] => 0
    [mature] => 0
    [spam] => 0
    [deleted] => 0
    [lang_id] => 0
)
stdClass Object
(
    [blog_id] => 1
    [site_id] => 1
    [domain] => www.example.com
    [path] => /example
    [registered] => 2010-10-15 23:12:39
    [last_updated] => 2011-04-08 18:34:19
    [public] => 1
    [archived] => 0
    [mature] => 0
    [spam] => 0
    [deleted] => 0
    [lang_id] => 0
)
DOMAIN_CURRENT_SITE is www.example.com
PATH_CURRENT_SITE is /
SITE_ID_CURRENT_SITE is 1
BLOG_ID_CURRENT_SITE is 1




example1.example.com/wp-admin/network/?debug:
Attempted URL: www.example1.example.com/wp-admin/network/
Network admin: true
Main site: false
Network admin URL: http://www.example.com/wp-admin/network/
stdClass Object
(
    [id] => 1
    [domain] => www.example.com
    [path] => /
    [blog_id] => 1
    [cookie_domain] => example.com
    [site_name] => example.com Sites
)
stdClass Object
(
    [blog_id] => 4
    [site_id] => 1
    [domain] => example1.example.com
    [path] => /
    [registered] => 2010-12-25 19:51:07
    [last_updated] => 2011-03-31 00:18:53
    [public] => 1
    [archived] => 0
    [mature] => 0
    [spam] => 0
    [deleted] => 0
    [lang_id] => 0
)
stdClass Object
(
    [blog_id] => 1
    [site_id] => 1
    [domain] => www.example.com
    [path] => /example
    [registered] => 2010-10-15 23:12:39
    [last_updated] => 2011-04-08 18:34:19
    [public] => 1
    [archived] => 0
    [mature] => 0
    [spam] => 0
    [deleted] => 0
    [lang_id] => 0
)
DOMAIN_CURRENT_SITE is www.example.com
PATH_CURRENT_SITE is /
SITE_ID_CURRENT_SITE is 1
BLOG_ID_CURRENT_SITE is 1
Last edited 14 years ago by nacin (previous) (diff)

#19 @nacin
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Go into the $wpdb->blogs table and edit the path for blog ID 1, to /, from /example.

#20 @theshadowfan
14 years ago

Where are the blogs table located?

#21 @nacin
14 years ago

At this point, this is not a bug in WordPress. Please try the support forums: http://wordpress.org/support/forum/multisite.

Note: See TracTickets for help on using tickets.