Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -289,6 +289,10 @@ |
290 | 290 | if ( ! $this->rootId && ! ($this->type & Threads::TYPE_DELETED) ) { |
291 | 291 | throw new MWException( "Non-deleted thread saved with empty root ID" ); |
292 | 292 | } |
| 293 | + |
| 294 | + if ( $this->replyCount < -1 ) { |
| 295 | + wfWarn( "Saving thread $id with negative reply count {$this->replyCount} " . wfGetAllCallers() ); |
| 296 | + } |
293 | 297 | |
294 | 298 | // Reflect schema changes here. |
295 | 299 | |
— | — | @@ -324,6 +328,10 @@ |
325 | 329 | } |
326 | 330 | |
327 | 331 | function delete( $reason, $commit = true ) { |
| 332 | + if ( $this->type == Threads::TYPE_DELETED ) { |
| 333 | + return; |
| 334 | + } |
| 335 | + |
328 | 336 | $this->type = Threads::TYPE_DELETED; |
329 | 337 | |
330 | 338 | if ( $commit ) { |
— | — | @@ -342,7 +350,7 @@ |
343 | 351 | $t = $this->superthread(); |
344 | 352 | |
345 | 353 | if ( $t ) { |
346 | | - $t->decrementReplyCount(); |
| 354 | + $t->decrementReplyCount( 1 + $this->replyCount() ); |
347 | 355 | $t->save(); |
348 | 356 | } |
349 | 357 | } |