WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12038 closed defect (bug) (invalid)

external scripts that interact with WPMU fail (redirect to sign-up page)

Reported by: wpmuguru Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:

Description

MU Trac Ticket: http://trac.mu.wordpress.org/ticket/1074

require('/home/httpd/htdocs/wordpress-mu/wp-blog-header.php'); in a script that interacts with WPMU fails as internally there is a redirect to the sign-up page, and therefore the php code below doesn't have a chance to run.

The reason is wpmu-settings.php line 119: $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain) ); does not work as $domain is guessed from $_SERVERHTTP_HOST? but in my system that does not give useful info.

Adding the following line it works (it gets $current_blog from $current_site->domain instead):

if (!$current_blog) $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $current_site->domain) );

A similar problem may happen at line 149 but I could not check it.

Change History (2)

comment:1 wpmuguru4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

The redirect occurs when the requested blog doesn't exist. A better solution would be to create a plugin that the external script can call to determine of the blog exists before requesting it.

comment:2 nacin4 years ago

  • Milestone Unassigned deleted
Note: See TracTickets for help on using tickets.