Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#16225 closed defect (bug) (fixed)

Undefined properties in ms-functions.php on line 93

Reported by: garyc40's profile garyc40 Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.1
Component: Import Keywords: has-patch
Focuses: Cc:


Reproducing this one is a bit tricky:

  1. Import content from an xml file, choose to create users to attach these imported posts to
  2. Go to Users -> Edit an imported user's password so that you can log in under that user
  3. Log in as that imported user

There are 3 notices:

Notice: Undefined property: stdClass::$archived in /Applications/MAMP/htdocs/wptest/wp-includes/ms-functions.php on line 93

Notice: Undefined property: stdClass::$spam in /Applications/MAMP/htdocs/wptest/wp-includes/ms-functions.php on line 93

Notice: Undefined property: stdClass::$deleted in /Applications/MAMP/htdocs/wptest/wp-includes/ms-functions.php on line 93

Attachments (1)

missing-user-blog-data.diff (950 bytes) - added by wonderboymusic 12 years ago.

Download all attachments as: .zip

Change History (8)

#1 @nacin
13 years ago

Can you var_dump $primary?

Sounds like the is_object() check there is designed to prevent this, but it just isn't enough.

#2 @nacin
13 years ago

  • Milestone changed from Awaiting Review to Future Release

#3 @garyc40
13 years ago

Here's the output:

  public 'userblog_id' => int 1
  public 'blogname' => string 'WP Test' (length=7)
  public 'domain' => string 'localhost' (length=9)
  public 'path' => string '/wptest/' (length=8)
  public 'site_id' => string '1' (length=1)
  public 'siteurl' => string 'http://localhost/wptest' (length=23)

The weird thing is that $primary_blog is an empty string. Perhaps the importer I used (WordPress importer) didn't properly update the 'primary_blog' user meta?

I repeated the steps to reproduce above, and try to get_user_meta() of the imported users right after importing. The primary_blog is always empty string.

Or perhaps line 79 in get_active_blog_for_user() is the problem. It seems to work when I change

if ( false !== $primary_blog ) {


if ( $primary_blog ) {
Last edited 13 years ago by garyc40 (previous) (diff)

#4 @wonderboymusic
12 years ago

  • Keywords has-patch added; needs-patch removed

this happens because get_blogs_of_user() builds a map of blogs, checks to make sure ! $blog->archived && ! $blog->spam && ! $blog->deleted but then builds a new stdClass and doesn't pass that data along.

( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) is checked by get_active_blog_for_user(), which is correct, because sometimes $primary = get_blog_details( $primary_blog ); which is an object with those properties.

Patch attached.

Last edited 12 years ago by wonderboymusic (previous) (diff)

#5 @nacin
12 years ago

  • Milestone changed from Future Release to 3.5

#6 @ryan
12 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [21794]:

Set the archived, spam, and deleted properties in the objects returned from get_blogs_of_user(). Props wonderboymusic. fixes #16225

Note: See TracTickets for help on using tickets.