r72701 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72700‎ | r72701 | r72702 >
Date:05:42, 10 September 2010
Author:werdna
Status:deferred
Tags:
Comment:
Reply count accuracy improvements:
* Add a warning with bt when saving a post with a negative reply count.
* Refuse to re-delete an already-deleted post.
* When deleting a post, ensure that the reply count is decremented properly
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -289,6 +289,10 @@
290290 if ( ! $this->rootId && ! ($this->type & Threads::TYPE_DELETED) ) {
291291 throw new MWException( "Non-deleted thread saved with empty root ID" );
292292 }
 293+
 294+ if ( $this->replyCount < -1 ) {
 295+ wfWarn( "Saving thread $id with negative reply count {$this->replyCount} " . wfGetAllCallers() );
 296+ }
293297
294298 // Reflect schema changes here.
295299
@@ -324,6 +328,10 @@
325329 }
326330
327331 function delete( $reason, $commit = true ) {
 332+ if ( $this->type == Threads::TYPE_DELETED ) {
 333+ return;
 334+ }
 335+
328336 $this->type = Threads::TYPE_DELETED;
329337
330338 if ( $commit ) {
@@ -342,7 +350,7 @@
343351 $t = $this->superthread();
344352
345353 if ( $t ) {
346 - $t->decrementReplyCount();
 354+ $t->decrementReplyCount( 1 + $this->replyCount() );
347355 $t->save();
348356 }
349357 }

Status & tagging log