Index: trunk/extensions/LiquidThreads/classes/Dispatch.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | class LqtDispatch { |
5 | 5 | /** static cache of per-page LiquidThreads activation setting */ |
6 | | - static $userLqtOverride; |
| 6 | + static $userLqtOverride = array(); |
7 | 7 | static $primaryView = null; |
8 | 8 | |
9 | 9 | static function talkpageMain( &$output, &$article, &$title, &$user, &$request ) { |
— | — | @@ -50,6 +50,8 @@ |
51 | 51 | $viewname = 'TalkpageView'; |
52 | 52 | } |
53 | 53 | |
| 54 | + Thread::$titleCacheById[$article->getId()] = $title; |
| 55 | + |
54 | 56 | $view = new $viewname( $output, $article, $title, $user, $request ); |
55 | 57 | self::$primaryView = $view; |
56 | 58 | return $view->show(); |
— | — | @@ -94,12 +96,22 @@ |
95 | 97 | } |
96 | 98 | |
97 | 99 | static function isLqtPage( $title ) { |
| 100 | + // Ignore it if it's a thread or a summary, makes no sense to have LiquidThreads there. |
| 101 | + if ( $title->getNamespace() == NS_LQT_THREAD || |
| 102 | + $title->getNamespace() == NS_LQT_SUMMARY ) { |
| 103 | + return false; |
| 104 | + } |
| 105 | + |
98 | 106 | global $wgLqtPages, $wgLqtTalkPages; |
99 | 107 | $isTalkPage = ( $title->isTalkPage() && $wgLqtTalkPages ) || |
100 | 108 | in_array( $title->getPrefixedText(), $wgLqtPages ); |
101 | | - |
102 | | - $override = self::getUserLqtOverride( $title->getArticleId() ); |
103 | 109 | |
| 110 | + if ( $title->exists() ) { |
| 111 | + $override = self::getUserLqtOverride( $title->getArticleId() ); |
| 112 | + } else { |
| 113 | + $override = null; |
| 114 | + } |
| 115 | + |
104 | 116 | global $wgLiquidThreadsAllowUserControl; |
105 | 117 | if ( !is_null($override) && $wgLiquidThreadsAllowUserControl ) { |
106 | 118 | $isTalkPage = $override; |
— | — | @@ -115,8 +127,8 @@ |
116 | 128 | $article = $article->getId(); |
117 | 129 | } |
118 | 130 | |
119 | | - // Instance cache |
120 | | - if ( isset( self::$userLqtOverride[$article] ) ) { |
| 131 | + // Check instance cache. |
| 132 | + if ( array_key_exists( $article, self::$userLqtOverride ) ) { |
121 | 133 | $cacheVal = self::$userLqtOverride[$article]; |
122 | 134 | |
123 | 135 | return $cacheVal; |
— | — | @@ -143,6 +155,7 @@ |
144 | 156 | $row = $dbr->selectRow( 'page_props', 'pp_value', |
145 | 157 | array( 'pp_propname' => 'use-liquid-threads', |
146 | 158 | 'pp_page' => $article ), __METHOD__ ); |
| 159 | + |
147 | 160 | |
148 | 161 | if ( $row ) { |
149 | 162 | $dbVal = $row->pp_value; |
Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -418,11 +418,6 @@ |
419 | 419 | static function getProtectionTypes( $title, &$types ) { |
420 | 420 | $isLqtPage = LqtDispatch::isLqtPage( $title ); |
421 | 421 | $isThread = $title->getNamespace() == NS_LQT_THREAD; |
422 | | - |
423 | | - // Bulk load is a no-no, causes infinite recursion. |
424 | | - $thread = Threads::withRoot( new Article( $title ), false ); |
425 | | - |
426 | | - $isThread = $isThread && $thread && $thread->isTopmostThread(); |
427 | 422 | |
428 | 423 | if ( !$isLqtPage && !$isThread ) { |
429 | 424 | return true; |
Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -981,11 +981,23 @@ |
982 | 982 | if ( $this->article ) return $this->article; |
983 | 983 | |
984 | 984 | if ( !is_null( $this->articleId ) ) { |
985 | | - $title = Title::newFromID( $this->articleId ); |
| 985 | + if ( isset( self::$articleCacheById[$this->articleId] ) ) { |
| 986 | + return self::$articleCacheById[$this->articleId]; |
| 987 | + } |
| 988 | + |
| 989 | + if ( isset( self::$titleCacheById[$this->articleId] ) ) { |
| 990 | + $title = self::$titleCacheById[$this->articleId]; |
| 991 | + } else { |
| 992 | + $title = Title::newFromID( $this->articleId ); |
| 993 | + } |
| 994 | + |
986 | 995 | if ( $title ) { |
987 | 996 | $article = new Article_LQT_Compat( $title ); |
988 | 997 | } |
| 998 | + |
| 999 | + self::$articleCacheById[$this->articleId] = $article; |
989 | 1000 | } |
| 1001 | + |
990 | 1002 | if ( isset( $article ) && $article->exists() ) { |
991 | 1003 | $this->article = $article; |
992 | 1004 | return $article; |