WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#31199 accepted defect (bug)

Potential reference to unset variable in get_bulk_actions (WP_Posts_List_Table)

Reported by: sgrant Owned by: chriscct7
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

get_post_type_object can return null in some cases, which causes a notice when current_user_can is called later in the function.

Attached a patch to check if delete_posts is set, and to only add actions if it is. Thanks!

Attachments (3)

patch.diff (626 bytes) - added by sgrant 7 years ago.
Add isset check before referencing
31199.patch (663 bytes) - added by Fab1en 7 years ago.
31199-2.patch (1.0 KB) - added by chriscct7 3 years ago.

Download all attachments as: .zip

Change History (8)

@sgrant
7 years ago

Add isset check before referencing

#1 @Fab1en
7 years ago

  • Keywords has-patch added

Hi sgrant

Could you please provide a the way you have triggered this bug, so that I can reproduce it ?

And I think you made a mistake in your patch : $post_type_obj->delete_posts will never exist, its $post_type_obj->cap->delete_posts that has to be checked.

@Fab1en
7 years ago

#2 @DrewAPicture
6 years ago

  • Keywords reporter-feedback added
  • Version trunk deleted

@chriscct7
3 years ago

#3 @chriscct7
3 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Awaiting Review to 5.1
  • Owner set to chriscct7
  • Status changed from new to accepted

Updated patch with additional checks for edit_posts cap as well as empty post_type_obj variable.

#4 @pento
3 years ago

  • Milestone changed from 5.1 to Future Release

It'd be good to have some steps to reproduce this.

#5 @pento
3 years ago

  • Keywords reporter-feedback added
Note: See TracTickets for help on using tickets.