Make WordPress Core

Opened 11 years ago

Last modified 4 months ago

#31199 accepted defect (bug)

Potential reference to unset variable in get_bulk_actions (WP_Posts_List_Table)

Reported by: sgrant's profile sgrant Owned by: chriscct7's profile chriscct7
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch reporter-feedback close
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 11 years ago.
Add isset check before referencing
31199.patch (663 bytes) - added by Fab1en 11 years ago.
31199-2.patch (1.0 KB) - added by chriscct7 7 years ago.

Download all attachments as: .zip

Change History (9)

@sgrant
11 years ago

Add isset check before referencing

#1 @Fab1en
11 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
11 years ago

#2 @DrewAPicture
11 years ago

  • Keywords reporter-feedback added
  • Version trunk deleted

@chriscct7
7 years ago

#3 @chriscct7
7 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
7 years ago

  • Milestone changed from 5.1 to Future Release

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

#5 @pento
7 years ago

  • Keywords reporter-feedback added

#6 @callumbw95
4 months ago

  • Keywords close added

Hi @sgrant,

As we haven't seen any progress on this regarding steps to recreate the problem, I'm applying the close tag.

Feel free to respond and remove it if you'd prefer to keep the discussion going. For example, you might try installing the Test Reports plugin and submitting a bug report. This will help us pinpoint any external factors contributing to the issue, allowing the community and me to offer more effective assistance. 😃

Note: See TracTickets for help on using tickets.