r25524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25523‎ | r25524 | r25525 >
Date:07:55, 5 September 2007
Author:david
Status:old
Tags:
Comment:
Big savings by not querying for every Threads::withRoot invoked from the protection hook. Possible regression: protecting a talkpage doesn't protect the threads on it. But I reverted and still got this behavior, so maybe I remember wrong that that worked.
Modified paths:
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtModel.php
@@ -888,9 +888,13 @@
889889 } else {
890890 $thread->initWithReplies( array() );
891891 }
 892+
 893+ self::$cache_by_root[$thread->root()->getID()] = $thread;
892894 }
893895 return $top_level_threads;
894896 }
 897+
 898+ static $cache_by_root = array();
895899
896900 private static function databaseError( $msg ) {
897901 // TODO tie into MW's error reporting facilities.
@@ -899,6 +903,15 @@
900904 }
901905
902906 static function withRoot( $post ) {
 907+ if( $post->getTitle()->getNamespace() != NS_LQT_THREAD ) {
 908+ // No articles outside the thread namespace have threads associated with them;
 909+ // avoiding the query saves time during the TitleGetRestrictions hook.
 910+ return null;
 911+ }
 912+ if( array_key_exists( $post->getID(), self::$cache_by_root ) ) {
 913+ return self::$cache_by_root[$post->getID()];
 914+ }
 915+ efVarDump(null, "withRoot( {$post->getID()} ) missed.");
903916 $ts = Threads::where( array('thread.thread_root' => $post->getID()) );
904917 if( count($ts) == 0 ) { return null; }
905918 if ( count($ts) >1 ) {

Status & tagging log