Opened 15 years ago
Closed 10 years ago
#11566 closed defect (bug) (fixed)
clean_comment_cache() does not clean $GLOBALS['comment']
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Comments | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
I am trying to add links to comment list, which will allow to delete comments directly without need to move them to trash first (and with trash enabled). For posts/pages I found working workaround: hook trashed_post
and call wp_delete_post()
again from.
Unfortunately similar approach for comments does work. As I checked, wp_trash_comment()
calls get_comment()
. The latter function implements simple comments cache using $GLOBALS['comment']
. When you change comment status to trash
, wp_set_comment_status()
clears cache by calling clean_comment_cache()
, but it leaves that global set. As a result my workaround does not work.
I think that clean_comment_cache()
should clear that global too.
Attachments (1)
Change History (15)
#2
in reply to:
↑ description
@
15 years ago
Replying to sirzooro:
As I checked,
wp_trash_comment()
callsget_comment()
. The latter function implements simple comments cache using$GLOBALS['comment']
.
Why not fix that function to use the propper cache instead of a global?
#3
@
15 years ago
- Milestone changed from 2.9.1 to 3.0
get_comment()
uses wp_cache_add()
/wp_cache_get()
, and additionally that global.
As I checked, $GLOBALScomment? is set by Walker_Comment::start_el()
, and functions from comment-template.php relies on this variable. Therefore my patch may introduce bug when some plugin will change comment when it is displayed. Looks that other solution may be needed here.
BTW, I clear this variable in my comment, so it works now. Therefore I think we can move this to 3.0.
#7
@
10 years ago
- Milestone changed from Future Release to 4.4
- Owner set to wonderboymusic
- Status changed from new to assigned
there are some weird uses of $comment
global
$GLOBALS['comment'] =/= a comment cache