r57652 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57651‎ | r57652 | r57653 >
Date:14:23, 12 October 2009
Author:werdna
Status:deferred
Tags:
Comment:
Merge r57651
Modified paths:
  • /branches/wmf-deployment/extensions/LiquidThreads (modified) (history)
  • /branches/wmf-deployment/extensions/LiquidThreads/classes/Thread.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/LiquidThreads/classes/Thread.php
@@ -338,6 +338,21 @@
339339
340340 // Lists total reply count, including replies to replies and such
341341 function replyCount() {
 342+ // Populate reply count
 343+ if ( $this->replyCount == - 1 ) {
 344+ if ( $this->isTopmostThread() ) {
 345+ $dbr = wfGetDB( DB_SLAVE );
 346+
 347+ $count = $dbr->selectField( 'thread', 'count(*)',
 348+ array( 'thread_ancestor' => $this->id() ), __METHOD__ );
 349+ } else {
 350+ $count = self::recursiveGetReplyCount( $this );
 351+ }
 352+
 353+ $this->replyCount = $count;
 354+ $this->save();
 355+ }
 356+
342357 return $this->replyCount;
343358 }
344359
@@ -410,6 +425,13 @@
411426 }
412427 }
413428
 429+ Threads::$cache_by_id[$line->thread_id] = $this;
 430+ if ( $line->thread_parent ) {
 431+ if ( !isset( self::$replyCacheById[$line->thread_parent] ) )
 432+ self::$replyCacheById[$line->thread_parent] = array();
 433+ self::$replyCacheById[$line->thread_parent][$line->thread_id] = $this;
 434+ }
 435+
414436 $this->doLazyUpdates( $line );
415437 }
416438
@@ -459,10 +481,6 @@
460482 $pageIds[] = $row->thread_summary_page;
461483
462484 $all_thread_rows[] = $row;
463 -
464 - if ( !isset( self::$replyCacheById[$row->thread_id] ) ) {
465 - self::$replyCacheById[$row->thread_id] = array();
466 - }
467485 }
468486 }
469487
@@ -510,8 +528,6 @@
511529 if ( isset( $articlesById[$thread->rootId] ) )
512530 $thread->root = $articlesById[$thread->rootId];
513531
514 - Threads::$cache_by_id[$row->thread_id] = $thread;
515 -
516532 // User cache data
517533 $t = Title::makeTitleSafe( NS_USER, $row->thread_author_name );
518534 $linkBatch->addObj( $t );
@@ -520,10 +536,6 @@
521537
522538 User::$idCacheByName[$row->thread_author_name] = $row->thread_author_id;
523539 $userIds[$row->thread_author_id] = true;
524 -
525 - if ( $row->thread_parent ) {
526 - self::$replyCacheById[$row->thread_parent][$row->thread_id] = $thread;
527 - }
528540 }
529541
530542 $userIds = array_keys( $userIds );
@@ -609,6 +621,21 @@
610622 return null;
611623 }
612624
 625+ static function recursiveGetReplyCount( $thread, $level = 1 ) {
 626+ if ($level > 80) {
 627+ return 1;
 628+ }
 629+
 630+ $count = 0;
 631+
 632+ foreach( $thread->replies() as $reply ) {
 633+ $count++;
 634+ $count += self::recursiveGetReplyCount( $reply, $level + 1 );
 635+ }
 636+
 637+ return $count;
 638+ }
 639+
613640 // Lazy updates done whenever a thread is loaded.
614641 // Much easier than running a long-running maintenance script.
615642 function doLazyUpdates( ) {
@@ -701,17 +728,6 @@
702729 $this->article = $ancestor->article();
703730 }
704731
705 - // Populate reply count
706 - if ( $this->replyCount == - 1 ) {
707 - $dbr = wfGetDB( DB_SLAVE );
708 -
709 - $count = $dbr->selectField( 'thread', 'count(*)',
710 - array( 'thread_ancestor' => $this->id() ), __METHOD__ );
711 -
712 - $this->replyCount = $count;
713 - $set['thread_replies'] = $count;
714 - }
715 -
716732 // Check for invalid/missing articleId
717733 $articleTitle = null;
718734 $dbTitle = Title::makeTitleSafe( $this->articleNamespace, $this->articleTitle );
Property changes on: branches/wmf-deployment/extensions/LiquidThreads
___________________________________________________________________
Name: svn:mergeinfo
719735 - /branches/REL1_15/phase3/extensions/LiquidThreads:51646
/trunk/extensions/LiquidThreads:56151-57571
/trunk/phase3/extensions/LiquidThreads:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447
720736 + /branches/REL1_15/phase3/extensions/LiquidThreads:51646
/trunk/extensions/LiquidThreads:56151-57571,57651
/trunk/phase3/extensions/LiquidThreads:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57651LiquidThreads bugfixes:...werdna14:15, 12 October 2009

Status & tagging log