WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 9 months ago

Last modified 9 months ago

#15498 closed defect (bug) (fixed)

Notice: Trying to get property of non-object in wp-admin/edit-form-advanced.php on line 281

Reported by: wpdavis Owned by: duck_
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.3.2
Component: Users Keywords: has-patch
Focuses: Cc:

Description

The problem seems to arise from the fact that when users are imported their old IDs aren't mapped to their new IDs, so then $last_user = get_userdata($last_id) is trying to look up a user that doesn't exist.

Attachments (1)

15498.diff (906 bytes) - added by duck_ 23 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 wpdavis3 years ago

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

Killing this off — was using old version of WP importer.

comment:2 duck_3 years ago

  • Milestone Awaiting Review deleted

Note that I was thinking of reintroducing importing _edit_last since it's used by get_the_modified_author. If that happens the ID will indeed have to be mapped to the new local ID to stop this.

comment:3 follow-up: Ludwig C.23 months ago

  • Component changed from Import to Users
  • Keywords needs-patch added
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version set to 3.3.2

This error does still exist when deleting a user and reasigning the posts to an other user. Not only the post_author in wp_posts should be changed, please update wp_postmeta too.

UPDATE wp_postmeta SET meta_value='NEW-USER-ID' WHERE meta_key='_edit_last';

An other solution would be to check the object in edit-form-advanced.php and display 'unknown user' when it is null.

duck_23 months ago

comment:4 in reply to: ↑ 3 duck_23 months ago

  • Keywords has-patch added; needs-patch removed
  • Milestone set to Future Release

Replying to Ludwig C.:

This error does still exist when deleting a user and reasigning the posts to an other user. Not only the post_author in wp_posts should be changed, please update wp_postmeta too.

Good point. Attached a patch to include the get_userdata() call in the conditional.

comment:5 duck_9 months ago

  • Owner set to duck_
  • Resolution set to fixed
  • Status changed from reopened to closed

In 24816:

Fix notice and show generic last update message if _edit_last references a nonexistent user.

Fixes #15498.

comment:6 duck_9 months ago

  • Milestone changed from Future Release to 3.7
Note: See TracTickets for help on using tickets.