Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#34654 closed defect (bug) (fixed)

Global comment object no longer exists on Admin Comments page

Reported by: stephencronin's profile StephenCronin Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: Comments Keywords:
Focuses: Cc:

Description

In testing one of my plugins with 4.4-beta3, I found it broke because the global comment object no longer exists on the Admin Comments page. Presumably this was removed in 4.4?

The plugin filters the comment text using the get_comment_text filter and uses global $comment; in the resulting function. However $comment is now null rather than an object.

I can fix my plugin easily enough, as get_comment_text passes the comment object as the second parameter (thanks @dd32!), but there may be other plugins out there doing something similar, so I thought I'd report it so you're aware of this.

More details:
The plugin in question is https://wordpress.org/plugins/show-parent-comment/
The affected code is here: https://plugins.trac.wordpress.org/browser/show-parent-comment/tags/0.2/show-parent-comment.php
The global $comment in question is on line 41. When $comment is used on line 44, it throws a "Notice: Trying to get property of non-object" message.

Change History (4)

#1 @samuelsidler
8 years ago

@wonderboymusic, @rachelbaker, @boonebgorges: This something to worry about?

#2 @wonderboymusic
8 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to wonderboymusic
  • Status changed from new to assigned

#3 @rachelbaker
8 years ago

@wonderboymusic want me to search the plugin directory for possible issues where folks are calling the $comment global where it will no longer be available?

#4 @wonderboymusic
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 35674:

List Tables: because we can never eradicate the existence of globals, ensure that $comment is hoisted into the global space inside WP_Comments_List_Table::single_row().

Fixes #34654.

Note: See TracTickets for help on using tickets.