Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -11,27 +11,31 @@ |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Get an instance of FlaggedArticle for a given Article or Title object |
| 15 | + * @param mixed $object (Article/Title) |
| 16 | + * @param bool $tryGlobals, check $wgTitle? |
15 | 17 | */ |
16 | | - static function getInstance( $object ) { |
| 18 | + static function getInstance( $object, $tryGlobals = false ) { |
17 | 19 | # If instance already cached, return it! |
18 | 20 | if( isset($object->flaggedRevsArticle) ) { |
19 | 21 | return $object->flaggedRevsArticle; |
20 | 22 | } |
21 | | - global $wgTitle; |
22 | | - # Try and keep things to one object to avoid cache misses... |
23 | | - # If $wgTitle has no instance, give it one! |
24 | | - if( !isset($wgTitle->flaggedRevsArticle) ) { |
25 | | - $article = new Article( $wgTitle ); |
26 | | - $wgTitle->flaggedRevsArticle = new FlaggedArticle( $article ); |
| 23 | + if( $tryGlobals ) { |
| 24 | + global $wgTitle; |
| 25 | + # Try and keep things to one object to avoid cache misses... |
| 26 | + # If $wgTitle has no instance, give it one! |
| 27 | + if( !isset($wgTitle->flaggedRevsArticle) ) { |
| 28 | + $article = new Article( $wgTitle ); |
| 29 | + $wgTitle->flaggedRevsArticle = new FlaggedArticle( $article ); |
| 30 | + } |
| 31 | + # Use $wgTitle's instance if we are dealing with the same article |
| 32 | + if( $object instanceof Title && $object->equals( $wgTitle ) ) { |
| 33 | + $object->flaggedRevsArticle =& $wgTitle->flaggedRevsArticle; |
| 34 | + return $object->flaggedRevsArticle; |
| 35 | + } else if( $object instanceof Article && $object->getTitle()->equals( $wgTitle ) ) { |
| 36 | + $object->flaggedRevsArticle =& $wgTitle->flaggedRevsArticle; |
| 37 | + return $object->flaggedRevsArticle; |
| 38 | + } |
27 | 39 | } |
28 | | - # Use $wgTitle's instance if we are dealing with the same article |
29 | | - if( $object instanceof Title && $object->equals( $wgTitle ) ) { |
30 | | - $object->flaggedRevsArticle =& $wgTitle->flaggedRevsArticle; |
31 | | - return $object->flaggedRevsArticle; |
32 | | - } else if( $object instanceof Article && $object->getTitle()->equals( $wgTitle ) ) { |
33 | | - $object->flaggedRevsArticle =& $wgTitle->flaggedRevsArticle; |
34 | | - return $object->flaggedRevsArticle; |
35 | | - } |
36 | 40 | # For titles, attach instance to the title and give the instance an article parent |
37 | 41 | if( $object instanceof Title ) { |
38 | 42 | $article = new Article( $object ); |
— | — | @@ -323,7 +327,7 @@ |
324 | 328 | $revsSince = FlaggedRevs::getRevCountSince( $this->parent, $frev->getRevId() ); |
325 | 329 | # Get parsed stable version |
326 | 330 | $parserOut = FlaggedRevs::getPageCache( $this->parent ); |
327 | | - if( $parserOut==false ) { |
| 331 | + if( $parserOut == false ) { |
328 | 332 | $text = $frev->getTextForParse(); |
329 | 333 | $parserOut = FlaggedRevs::parseStableText( $this->parent, $text, $frev->getRevId() ); |
330 | 334 | # Update the stable version cache |
— | — | @@ -1115,7 +1119,7 @@ |
1116 | 1120 | * @param Bool $forUpdate, use DB master and avoid page table? |
1117 | 1121 | * @return Row |
1118 | 1122 | */ |
1119 | | - public function getStableRev( $getText=false, $forUpdate=false ) { |
| 1123 | + public function getStableRev( $getText = false, $forUpdate = false ) { |
1120 | 1124 | if( $this->stableRev === false ) { |
1121 | 1125 | return null; // We already looked and found nothing... |
1122 | 1126 | } |
— | — | @@ -1142,7 +1146,7 @@ |
1143 | 1147 | * @param Bool $forUpdate, use DB master? |
1144 | 1148 | * @returns Array (select,override) |
1145 | 1149 | */ |
1146 | | - public function getVisibilitySettings( $forUpdate=false ) { |
| 1150 | + public function getVisibilitySettings( $forUpdate = false ) { |
1147 | 1151 | # Cached results available? |
1148 | 1152 | if( !is_null($this->pageConfig) ) { |
1149 | 1153 | return $this->pageConfig; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -1111,7 +1111,7 @@ |
1112 | 1112 | } |
1113 | 1113 | global $wgScriptPath, $wgJsMimeType, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion; |
1114 | 1114 | |
1115 | | - $flaggedArticle = FlaggedArticle::getInstance( $wgArticle ); |
| 1115 | + $flaggedArticle = FlaggedArticle::getInstance( $wgArticle, true ); |
1116 | 1116 | $stylePath = str_replace( '$wgScriptPath', $wgScriptPath, $wgFlaggedRevsStylePath ); |
1117 | 1117 | $JSparams = self::getJSParams(); |
1118 | 1118 | $frev = $flaggedArticle->getStableRev( true ); |
— | — | @@ -1595,7 +1595,7 @@ |
1596 | 1596 | if( $action != 'move' || !self::isPageReviewable( $title ) ) |
1597 | 1597 | return true; |
1598 | 1598 | |
1599 | | - $flaggedArticle = FlaggedArticle::getInstance( $title ); |
| 1599 | + $flaggedArticle = FlaggedArticle::getInstance( $title, true ); |
1600 | 1600 | $frev = $flaggedArticle->getStableRev(); |
1601 | 1601 | if( !$frev ) |
1602 | 1602 | return true; |
— | — | @@ -1630,7 +1630,7 @@ |
1631 | 1631 | } |
1632 | 1632 | # See if there is a stable version. Also, see if, given the page |
1633 | 1633 | # config and URL params, the page can be overriden. |
1634 | | - $flaggedArticle = FlaggedArticle::getInstance( $title ); |
| 1634 | + $flaggedArticle = FlaggedArticle::getInstance( $title, true ); |
1635 | 1635 | if( $wgTitle && $wgTitle->equals( $title ) ) { |
1636 | 1636 | // Cache stable version while we are at it. |
1637 | 1637 | if( $flaggedArticle->pageOverride() && $flaggedArticle->getStableRev( true ) ) { |
— | — | @@ -2047,7 +2047,7 @@ |
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | public static function imagePageFindFile( $imagePage, &$normalFile, &$displayFile ) { |
2051 | | - $flaggedArticle = FlaggedArticle::getInstance( $imagePage ); |
| 2051 | + $flaggedArticle = FlaggedArticle::getInstance( $imagePage, true ); |
2052 | 2052 | $flaggedArticle->imagePageFindFile( $normalFile, $displayFile ); |
2053 | 2053 | return true; |
2054 | 2054 | } |
— | — | @@ -2055,7 +2055,7 @@ |
2056 | 2056 | static function setActionTabs( $skin, &$contentActions ) { |
2057 | 2057 | global $wgArticle; |
2058 | 2058 | if( $wgArticle ) { |
2059 | | - FlaggedArticle::getInstance( $wgArticle )->setActionTabs( $skin, $contentActions ); |
| 2059 | + FlaggedArticle::getInstance( $wgArticle, true )->setActionTabs( $skin, $contentActions ); |
2060 | 2060 | } |
2061 | 2061 | return true; |
2062 | 2062 | } |
— | — | @@ -2063,13 +2063,13 @@ |
2064 | 2064 | static function setLastModified( $skin, &$tpl ) { |
2065 | 2065 | global $wgArticle; |
2066 | 2066 | if( $wgArticle ) { |
2067 | | - FlaggedArticle::getInstance( $wgArticle )->setLastModified( $skin, $tpl ); |
| 2067 | + FlaggedArticle::getInstance( $wgArticle, true )->setLastModified( $skin, $tpl ); |
2068 | 2068 | } |
2069 | 2069 | return true; |
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | static function onArticleViewHeader( $article, &$outputDone, &$pcache ) { |
2073 | | - $flaggedArticle = FlaggedArticle::getInstance( $article ); |
| 2073 | + $flaggedArticle = FlaggedArticle::getInstance( $article, true ); |
2074 | 2074 | $flaggedArticle->maybeUpdateMainCache( $outputDone, $pcache ); |
2075 | 2075 | $flaggedArticle->setPageContent( $outputDone, $pcache ); |
2076 | 2076 | $flaggedArticle->addPatrolLink( $outputDone, $pcache ); |
— | — | @@ -2079,23 +2079,23 @@ |
2080 | 2080 | static function setPermaLink( $skin, &$navUrls, &$revId, &$id ) { |
2081 | 2081 | global $wgArticle; |
2082 | 2082 | if ( $wgArticle ) { |
2083 | | - FlaggedArticle::getInstance( $wgArticle )->setPermaLink( $skin, $navUrls, $revId, $id ); |
| 2083 | + FlaggedArticle::getInstance( $wgArticle, true )->setPermaLink( $skin, $navUrls, $revId, $id ); |
2084 | 2084 | } |
2085 | 2085 | return true; |
2086 | 2086 | } |
2087 | 2087 | |
2088 | 2088 | static function addToEditView( $editPage ) { |
2089 | | - return FlaggedArticle::getInstance( $editPage->mArticle )->addToEditView( $editPage ); |
| 2089 | + return FlaggedArticle::getInstance( $editPage->mArticle, true )->addToEditView( $editPage ); |
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | static function unreviewedPagesLinks( $category ) { |
2093 | | - return FlaggedArticle::getInstance( $category )->addToCategoryView(); |
| 2093 | + return FlaggedArticle::getInstance( $category, true )->addToCategoryView(); |
2094 | 2094 | } |
2095 | 2095 | |
2096 | 2096 | static function addReviewForm( $out ) { |
2097 | 2097 | global $wgArticle; |
2098 | 2098 | if ( $wgArticle && $out->isArticleRelated() ) { |
2099 | | - FlaggedArticle::getInstance( $wgArticle )->addReviewForm( $out ); |
| 2099 | + FlaggedArticle::getInstance( $wgArticle, true )->addReviewForm( $out ); |
2100 | 2100 | } |
2101 | 2101 | return true; |
2102 | 2102 | } |
— | — | @@ -2103,13 +2103,13 @@ |
2104 | 2104 | static function addVisibilityLink( $out ) { |
2105 | 2105 | global $wgArticle; |
2106 | 2106 | if ( $wgArticle && $out->isArticleRelated() ) { |
2107 | | - FlaggedArticle::getInstance( $wgArticle )->addVisibilityLink( $out ); |
| 2107 | + FlaggedArticle::getInstance( $wgArticle, true )->addVisibilityLink( $out ); |
2108 | 2108 | } |
2109 | 2109 | return true; |
2110 | 2110 | } |
2111 | 2111 | |
2112 | 2112 | static function addToHistQuery( $pager, &$queryInfo ) { |
2113 | | - $flaggedArticle = FlaggedArticle::getInstance( $pager->mPageHistory->getTitle() ); |
| 2113 | + $flaggedArticle = FlaggedArticle::getInstance( $pager->mPageHistory->getTitle(), true ); |
2114 | 2114 | if( $flaggedArticle->isReviewable() ) { |
2115 | 2115 | $queryInfo['tables'][] = 'flaggedrevs'; |
2116 | 2116 | $queryInfo['fields'][] = 'fr_quality'; |
— | — | @@ -2120,26 +2120,26 @@ |
2121 | 2121 | } |
2122 | 2122 | |
2123 | 2123 | static function addToHistLine( $history, $row, &$s ) { |
2124 | | - return FlaggedArticle::getInstance( $history->getArticle() )->addToHistLine( $history, $row, $s ); |
| 2124 | + return FlaggedArticle::getInstance( $history->getArticle(), true )->addToHistLine( $history, $row, $s ); |
2125 | 2125 | } |
2126 | 2126 | |
2127 | 2127 | static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) { |
2128 | | - return FlaggedArticle::getInstance( $hist->getImagePage() )->addToFileHistLine( $hist, $file, $s, $rowClass ); |
| 2128 | + return FlaggedArticle::getInstance( $hist->getImagePage(), true )->addToFileHistLine( $hist, $file, $s, $rowClass ); |
2129 | 2129 | } |
2130 | 2130 | |
2131 | 2131 | static function injectReviewDiffURLParams( $article, &$sectionAnchor, &$extraQuery ) { |
2132 | | - return FlaggedArticle::getInstance( $article )->injectReviewDiffURLParams( $sectionAnchor, $extraQuery ); |
| 2132 | + return FlaggedArticle::getInstance( $article, true )->injectReviewDiffURLParams( $sectionAnchor, $extraQuery ); |
2133 | 2133 | } |
2134 | 2134 | |
2135 | 2135 | static function onDiffViewHeader( $diff, $oldRev, $newRev ) { |
2136 | | - $flaggedArticle = FlaggedArticle::getInstance( $diff->getTitle() ); |
| 2136 | + $flaggedArticle = FlaggedArticle::getInstance( $diff->getTitle(), true ); |
2137 | 2137 | $flaggedArticle->addPatrolAndDiffLink( $diff, $oldRev, $newRev ); |
2138 | 2138 | $flaggedArticle->addDiffNoticeAndIncludes( $diff, $oldRev, $newRev ); |
2139 | 2139 | return true; |
2140 | 2140 | } |
2141 | 2141 | |
2142 | 2142 | static function addRevisionIDField( $editPage, $out ) { |
2143 | | - return FlaggedArticle::getInstance( $editPage->mArticle )->addRevisionIDField( $editPage, $out ); |
| 2143 | + return FlaggedArticle::getInstance( $editPage->mArticle, true )->addRevisionIDField( $editPage, $out ); |
2144 | 2144 | } |
2145 | 2145 | |
2146 | 2146 | static function addBacklogNotice( &$notice ) { |