Jack Phoenix has uploaded a new change for review. https://gerrit.wikimedia.org/r/305579
Change subject: [SECURITY] Version 4.2.0: remove memcache caching from CommentsPage::display() ...................................................................... [SECURITY] Version 4.2.0: remove memcache caching from CommentsPage::display() Ever since the January 19, 2015 rewrite (version 4.0) of Comments, there was an issue where comments would be erroneously attributed to someone else (https://github.com/Brickimedia/brickimedia/issues/346). Not only was this annoying and meant that users weren't able to up/downvote others' comments, it also posed a security risk because the commentadmin user right wasn't working correctly (i.e. comment admins didn't see the "delete comment" link even though they were meant to see that). The entire RequestContext was being serialized into memcache, causing global $wgUser and $this->getUser() to return different values, the first one returning the correct one and the latter not. Huge thanks to legoktm for looking into this and figuring out what's going on in here! Closes Brickimedia/brickimedia#346 Change-Id: I7f73e4bc59471743b5db364861ac121505ae2dfe --- M Comments.php M CommentsPage.php M extension.json 3 files changed, 5 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Comments refs/changes/79/305579/1 diff --git a/Comments.php b/Comments.php index c7dbcf8..5d24990 100644 --- a/Comments.php +++ b/Comments.php @@ -24,7 +24,7 @@ $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'Comments', - 'version' => '4.1.1', + 'version' => '4.2.0', 'author' => array( 'David Pean', 'Misza', 'Jack Phoenix', 'Adam Carter/UltrasonicNXT' ), 'descriptionmsg' => 'comments-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:Comments' diff --git a/CommentsPage.php b/CommentsPage.php index c2ead66..617c004 100644 --- a/CommentsPage.php +++ b/CommentsPage.php @@ -449,29 +449,14 @@ return array_chunk( $comments, $this->limit ); } - /** * Display all the comments for the current page. - * CSS and JS is loaded in Comment.php + * CSS and JS is loaded in CommentsHooks.php */ function display() { - global $wgMemc; - $output = ''; - // Try cache - $key = wfMemcKey( 'comment', 'pagethreadlist', $this->id ); - $data = $wgMemc->get( $key ); - - if ( !$data ) { - wfDebug( "Loading comments for page {$this->id} from DB\n" ); - $commentThreads = $this->getComments(); - $wgMemc->set( $key, $commentThreads ); - } else { - wfDebug( "Loading comments for page {$this->id} from cache\n" ); - $commentThreads = $data; - } - + $commentThreads = $this->getComments(); $commentThreads = $this->sort( $commentThreads ); $this->comments = $commentThreads; @@ -594,13 +579,10 @@ } /** - * Purge caches (memcached, parser cache and Squid cache) + * Purge caches (parser cache and Squid cache) */ function clearCommentListCache() { - global $wgMemc; wfDebug( "Clearing comments for page {$this->id} from cache\n" ); - $key = wfMemcKey( 'comment', 'pagethreadlist', $this->id ); - $wgMemc->delete( $key ); if ( is_object( $this->title ) ) { $this->title->invalidateCache(); diff --git a/extension.json b/extension.json index ed4f7b1..a81ba04 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Comments", - "version": "4.1.0", + "version": "4.2.0", "author": [ "David Pean", "Misza", -- To view, visit https://gerrit.wikimedia.org/r/305579 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7f73e4bc59471743b5db364861ac121505ae2dfe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Comments Gerrit-Branch: master Gerrit-Owner: Jack Phoenix <j...@countervandalism.net> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits