WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

#39888 closed defect (bug) (fixed)

Right after delete author - PHP notices on '%s is currently editing'

Reported by: esemlabel Owned by: SergeyBiryukov
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.7.2
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:

Description

After deleting autor, who has just edited some post, the error will occur in the next few minutes in posts list table:

PHP Notice: Trying to get property of non-object in \wp-admin\includes\class-wp-posts-list-table.php on line 910

$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );

Need some fix to immediately remove edit_lock meta with deleted author id from posts.

Attachments (4)

39888.1.diff (532 bytes) - added by arshidkv12 2 years ago.
If user not exist return false
22xx22.patch (704 bytes) - added by 1naveengiri 2 years ago.
Since $lock_holder = get_userdata( $lock_holder ); will return false if user id userid not exit.
22xx22.2.patch (704 bytes) - added by 1naveengiri 2 years ago.
Since $lock_holder = get_userdata( $lock_holder ); will return false if user id userid not exit. and the rest functionality will work as expected.
22222.patch (695 bytes) - added by 1naveengiri 2 years ago.
This will be the right cure to handle this situation.

Download all attachments as: .zip

Change History (19)

#1 @esemlabel
3 years ago

Maybe need both to remove: _edit_lock and _edit_last or just _edit_last, which contains user ID

#2 @SergeyBiryukov
3 years ago

  • Keywords needs-patch added

wp_check_post_lock() could check if the user ID exists and return false otherwise.

#3 @swissspidy
3 years ago

  • Keywords good-first-bug added

@arshidkv12
2 years ago

If user not exist return false

@1naveengiri
2 years ago

Since $lock_holder = get_userdata( $lock_holder ); will return false if user id userid not exit.

@1naveengiri
2 years ago

Since $lock_holder = get_userdata( $lock_holder ); will return false if user id userid not exit. and the rest functionality will work as expected.

@1naveengiri
2 years ago

This will be the right cure to handle this situation.

#4 @1naveengiri
2 years ago

  • Keywords 2nd-opinion reporter-feedback needs-testing added; needs-patch good-first-bug removed

Please have a look on this.

#5 @SergeyBiryukov
2 years ago

  • Keywords has-patch added; 2nd-opinion reporter-feedback needs-testing removed
  • Milestone changed from Awaiting Review to 4.8

#6 @1naveengiri
2 years ago

@SergeyBiryukov could you set props for this bug. If it is fixed.

#7 follow-up: @SergeyBiryukov
2 years ago

Tickets are fixed when a commit is made to WordPress trunk.

#8 in reply to: ↑ 7 @1naveengiri
2 years ago

means this ticket is already fixed, and my patch will not be consider here :(

Replying to SergeyBiryukov:

Tickets are fixed when a commit is made to WordPress trunk.

Version 0, edited 2 years ago by 1naveengiri (next)

#9 @swissspidy
2 years ago

@1naveengiri There was no commit yet, which means the ticket is not fixed yet and your patch will be considered for fixing it. So don't worry.

#10 @1naveengiri
2 years ago

Hi Team,
any update on above Bug Fix.

#11 @swissspidy
2 years ago

  • Keywords commit added

Latest patch looks fine to me.

#12 @SergeyBiryukov
2 years ago

wp_check_post_lock() is used in a few more places, so I still think 39888.1.diff would be the correct fix here.

#13 @SergeyBiryukov
2 years ago

In 40423:

Posts, Post Types: Improve the docs for wp_check_post_lock() and wp_set_post_lock().

See #39888.

#14 @SergeyBiryukov
2 years ago

  • Component changed from Users to Posts, Post Types

#15 @SergeyBiryukov
2 years ago

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

In 40424:

Posts, Post Types: In wp_check_post_lock(), check if the user with lock exists and return false otherwise.

Props arshidkv12, 1naveengiri.
Fixes #39888.

Note: See TracTickets for help on using tickets.