WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 19 months ago

Last modified 19 months ago

#16225 closed defect (bug) (fixed)

Undefined properties in ms-functions.php on line 93

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

Description

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 19 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 nacin3 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.

comment:2 nacin3 years ago

  • Milestone changed from Awaiting Review to Future Release

comment:3 garyc403 years ago

Here's the output:

object(stdClass)[48]
  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 ) {

to

if ( ! $primary_blog ) {
Version 0, edited 3 years ago by garyc40 (next)

comment:4 wonderboymusic19 months 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 19 months ago by wonderboymusic (previous) (diff)

comment:5 nacin19 months ago

  • Milestone changed from Future Release to 3.5

comment:6 ryan19 months 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.