Index: trunk/phase3/includes/Article.php |
— | — | @@ -284,18 +284,14 @@ |
285 | 285 | wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" ); |
286 | 286 | return false; |
287 | 287 | } |
288 | | - |
| 288 | + // Revision title doesn't match the page title given? |
289 | 289 | if ( $this->mPage->getID() != $revision->getPage() ) { |
290 | | - $data = $this->mPage->pageDataFromId( wfGetDB( DB_SLAVE ), $revision->getPage() ); |
291 | | - |
292 | | - if ( !$data ) { |
| 290 | + $function = array( get_class( $this->mPage ), 'newFromID' ); |
| 291 | + $this->mPage = call_user_func( $function, $revision->getPage() ); |
| 292 | + if ( !$this->mPage->getId() ) { |
293 | 293 | wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" ); |
294 | 294 | return false; |
295 | 295 | } |
296 | | - |
297 | | - $title = Title::makeTitle( $data->page_namespace, $data->page_title ); |
298 | | - $this->mPage = new WikiPage( $title ); |
299 | | - $this->mPage->loadPageData( $data ); |
300 | 296 | } |
301 | 297 | } else { |
302 | 298 | if ( $this->mPage->getLatest() === false ) { |
— | — | @@ -1931,10 +1927,61 @@ |
1932 | 1928 | global $wgOut; |
1933 | 1929 | |
1934 | 1930 | $this->mParserOutput = $this->getOutputFromWikitext( $text, $cache, $parserOptions ); |
| 1931 | + |
| 1932 | + $this->doCascadeProtectionUpdates( $this->mParserOutput ); |
| 1933 | + |
1935 | 1934 | $wgOut->addParserOutput( $this->mParserOutput ); |
1936 | 1935 | } |
1937 | 1936 | |
1938 | 1937 | /** |
| 1938 | + * Lightweight method to get the parser output for a page, checking the parser cache |
| 1939 | + * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to |
| 1940 | + * consider, so it's not appropriate to use there. |
| 1941 | + * |
| 1942 | + * @since 1.16 (r52326) for LiquidThreads |
| 1943 | + * |
| 1944 | + * @param $oldid mixed integer Revision ID or null |
| 1945 | + * @param $user User The relevant user |
| 1946 | + * @return ParserOutput or false if the given revsion ID is not found |
| 1947 | + */ |
| 1948 | + public function getParserOutput( $oldid = null, User $user = null ) { |
| 1949 | + global $wgEnableParserCache, $wgUser; |
| 1950 | + $user = is_null( $user ) ? $wgUser : $user; |
| 1951 | + |
| 1952 | + // Should the parser cache be used? |
| 1953 | + $useParserCache = $wgEnableParserCache && |
| 1954 | + $user->getStubThreshold() == 0 && |
| 1955 | + $this->mPage->exists() && |
| 1956 | + $oldid === null; |
| 1957 | + |
| 1958 | + wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
| 1959 | + |
| 1960 | + if ( $user->getStubThreshold() ) { |
| 1961 | + wfIncrStats( 'pcache_miss_stub' ); |
| 1962 | + } |
| 1963 | + |
| 1964 | + if ( $useParserCache ) { |
| 1965 | + $parserOutput = ParserCache::singleton()->get( $this, $this->mPage->getParserOptions() ); |
| 1966 | + if ( $parserOutput !== false ) { |
| 1967 | + return $parserOutput; |
| 1968 | + } |
| 1969 | + } |
| 1970 | + |
| 1971 | + // Cache miss; parse and output it. |
| 1972 | + if ( $oldid === null ) { |
| 1973 | + $text = $this->mPage->getRawText(); |
| 1974 | + } else { |
| 1975 | + $rev = Revision::newFromTitle( $this->getTitle(), $oldid ); |
| 1976 | + if ( $rev === null ) { |
| 1977 | + return false; |
| 1978 | + } |
| 1979 | + $text = $rev->getText(); |
| 1980 | + } |
| 1981 | + |
| 1982 | + return $this->getOutputFromWikitext( $text, $useParserCache ); |
| 1983 | + } |
| 1984 | + |
| 1985 | + /** |
1939 | 1986 | * This does all the heavy lifting for outputWikitext, except it returns the parser |
1940 | 1987 | * output instead of sending it straight to $wgOut. Makes things nice and simple for, |
1941 | 1988 | * say, embedding thread pages within a discussion system (LiquidThreads) |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -277,7 +277,7 @@ |
278 | 278 | * @param $title Title object |
279 | 279 | * @return mixed Database result resource, or false on failure |
280 | 280 | */ |
281 | | - protected function pageDataFromTitle( $dbr, $title ) { |
| 281 | + public function pageDataFromTitle( $dbr, $title ) { |
282 | 282 | return $this->pageData( $dbr, array( |
283 | 283 | 'page_namespace' => $title->getNamespace(), |
284 | 284 | 'page_title' => $title->getDBkey() ) ); |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | * @param $id Integer |
292 | 292 | * @return mixed Database result resource, or false on failure |
293 | 293 | */ |
294 | | - protected function pageDataFromId( $dbr, $id ) { |
| 294 | + public function pageDataFromId( $dbr, $id ) { |
295 | 295 | return $this->pageData( $dbr, array( 'page_id' => $id ) ); |
296 | 296 | } |
297 | 297 | |
— | — | @@ -2408,54 +2408,6 @@ |
2409 | 2409 | } |
2410 | 2410 | } |
2411 | 2411 | |
2412 | | - /** |
2413 | | - * Lightweight method to get the parser output for a page, checking the parser cache |
2414 | | - * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to |
2415 | | - * consider, so it's not appropriate to use there. |
2416 | | - * |
2417 | | - * @since 1.16 (r52326) for LiquidThreads |
2418 | | - * |
2419 | | - * @param $oldid mixed integer Revision ID or null |
2420 | | - * @param $user User The relevant user |
2421 | | - * @return ParserOutput or false if the given revsion ID is not found |
2422 | | - */ |
2423 | | - public function getParserOutput( $oldid = null, User $user = null ) { |
2424 | | - global $wgEnableParserCache, $wgUser; |
2425 | | - $user = is_null( $user ) ? $wgUser : $user; |
2426 | | - |
2427 | | - // Should the parser cache be used? |
2428 | | - $useParserCache = $wgEnableParserCache && |
2429 | | - $user->getStubThreshold() == 0 && |
2430 | | - $this->exists() && |
2431 | | - $oldid === null; |
2432 | | - |
2433 | | - wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
2434 | | - |
2435 | | - if ( $user->getStubThreshold() ) { |
2436 | | - wfIncrStats( 'pcache_miss_stub' ); |
2437 | | - } |
2438 | | - |
2439 | | - if ( $useParserCache ) { |
2440 | | - $parserOutput = ParserCache::singleton()->get( $this, $this->getParserOptions() ); |
2441 | | - if ( $parserOutput !== false ) { |
2442 | | - return $parserOutput; |
2443 | | - } |
2444 | | - } |
2445 | | - |
2446 | | - // Cache miss; parse and output it. |
2447 | | - if ( $oldid === null ) { |
2448 | | - $text = $this->getRawText(); |
2449 | | - } else { |
2450 | | - $rev = Revision::newFromTitle( $this->getTitle(), $oldid ); |
2451 | | - if ( $rev === null ) { |
2452 | | - return false; |
2453 | | - } |
2454 | | - $text = $rev->getText(); |
2455 | | - } |
2456 | | - |
2457 | | - return $this->getOutputFromWikitext( $text, $useParserCache ); |
2458 | | - } |
2459 | | - |
2460 | 2412 | /* |
2461 | 2413 | * @deprecated since 1.19 |
2462 | 2414 | */ |