Index: trunk/phase3/includes/Article.php |
— | — | @@ -1897,7 +1897,7 @@ |
1898 | 1898 | * @param $text string |
1899 | 1899 | * @param $cache boolean |
1900 | 1900 | * @param $parserOptions parsing options, defaults to false |
1901 | | - * @return string containing parsed output |
| 1901 | + * @return ParserOutput |
1902 | 1902 | */ |
1903 | 1903 | public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) { |
1904 | 1904 | global $wgParser, $wgEnableParserCache, $wgUseFileCache; |
— | — | @@ -1929,63 +1929,14 @@ |
1930 | 1930 | $wgUseFileCache = false; |
1931 | 1931 | } |
1932 | 1932 | |
1933 | | - $this->doCascadeProtectionUpdates( $this->mParserOutput ); |
| 1933 | + if ( $this->isCurrent() ) { |
| 1934 | + $this->mPage->doCascadeProtectionUpdates( $this->mParserOutput ); |
| 1935 | + } |
1934 | 1936 | |
1935 | 1937 | return $this->mParserOutput; |
1936 | 1938 | } |
1937 | 1939 | |
1938 | 1940 | /** |
1939 | | - * Updates cascading protections |
1940 | | - * |
1941 | | - * @param $parserOutput ParserOutput object, or boolean false |
1942 | | - **/ |
1943 | | - protected function doCascadeProtectionUpdates( $parserOutput ) { |
1944 | | - if ( !$this->isCurrent() || wfReadOnly() || !$this->getTitle()->areRestrictionsCascading() ) { |
1945 | | - return; |
1946 | | - } |
1947 | | - |
1948 | | - // templatelinks table may have become out of sync, |
1949 | | - // especially if using variable-based transclusions. |
1950 | | - // For paranoia, check if things have changed and if |
1951 | | - // so apply updates to the database. This will ensure |
1952 | | - // that cascaded protections apply as soon as the changes |
1953 | | - // are visible. |
1954 | | - |
1955 | | - # Get templates from templatelinks |
1956 | | - $id = $this->getTitle()->getArticleID(); |
1957 | | - |
1958 | | - $tlTemplates = array(); |
1959 | | - |
1960 | | - $dbr = wfGetDB( DB_SLAVE ); |
1961 | | - $res = $dbr->select( array( 'templatelinks' ), |
1962 | | - array( 'tl_namespace', 'tl_title' ), |
1963 | | - array( 'tl_from' => $id ), |
1964 | | - __METHOD__ |
1965 | | - ); |
1966 | | - |
1967 | | - foreach ( $res as $row ) { |
1968 | | - $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true; |
1969 | | - } |
1970 | | - |
1971 | | - # Get templates from parser output. |
1972 | | - $poTemplates = array(); |
1973 | | - foreach ( $parserOutput->getTemplates() as $ns => $templates ) { |
1974 | | - foreach ( $templates as $dbk => $id ) { |
1975 | | - $poTemplates["$ns:$dbk"] = true; |
1976 | | - } |
1977 | | - } |
1978 | | - |
1979 | | - # Get the diff |
1980 | | - $templates_diff = array_diff_key( $poTemplates, $tlTemplates ); |
1981 | | - |
1982 | | - if ( count( $templates_diff ) > 0 ) { |
1983 | | - # Whee, link updates time. |
1984 | | - $u = new LinksUpdate( $this->getTitle(), $parserOutput, false ); |
1985 | | - $u->doUpdate(); |
1986 | | - } |
1987 | | - } |
1988 | | - |
1989 | | - /** |
1990 | 1941 | * Sets the context this Article is executed in |
1991 | 1942 | * |
1992 | 1943 | * @param $context RequestContext |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -2428,6 +2428,57 @@ |
2429 | 2429 | } |
2430 | 2430 | } |
2431 | 2431 | |
| 2432 | + /** |
| 2433 | + * Updates cascading protections |
| 2434 | + * |
| 2435 | + * @param $parserOutput ParserOutput object for the current version |
| 2436 | + **/ |
| 2437 | + public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) { |
| 2438 | + if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) { |
| 2439 | + return; |
| 2440 | + } |
| 2441 | + |
| 2442 | + // templatelinks table may have become out of sync, |
| 2443 | + // especially if using variable-based transclusions. |
| 2444 | + // For paranoia, check if things have changed and if |
| 2445 | + // so apply updates to the database. This will ensure |
| 2446 | + // that cascaded protections apply as soon as the changes |
| 2447 | + // are visible. |
| 2448 | + |
| 2449 | + # Get templates from templatelinks |
| 2450 | + $id = $this->mTitle->getArticleID(); |
| 2451 | + |
| 2452 | + $tlTemplates = array(); |
| 2453 | + |
| 2454 | + $dbr = wfGetDB( DB_SLAVE ); |
| 2455 | + $res = $dbr->select( array( 'templatelinks' ), |
| 2456 | + array( 'tl_namespace', 'tl_title' ), |
| 2457 | + array( 'tl_from' => $id ), |
| 2458 | + __METHOD__ |
| 2459 | + ); |
| 2460 | + |
| 2461 | + foreach ( $res as $row ) { |
| 2462 | + $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true; |
| 2463 | + } |
| 2464 | + |
| 2465 | + # Get templates from parser output. |
| 2466 | + $poTemplates = array(); |
| 2467 | + foreach ( $parserOutput->getTemplates() as $ns => $templates ) { |
| 2468 | + foreach ( $templates as $dbk => $id ) { |
| 2469 | + $poTemplates["$ns:$dbk"] = true; |
| 2470 | + } |
| 2471 | + } |
| 2472 | + |
| 2473 | + # Get the diff |
| 2474 | + $templates_diff = array_diff_key( $poTemplates, $tlTemplates ); |
| 2475 | + |
| 2476 | + if ( count( $templates_diff ) > 0 ) { |
| 2477 | + # Whee, link updates time. |
| 2478 | + $u = new LinksUpdate( $this->mTitle, $parserOutput, false ); |
| 2479 | + $u->doUpdate(); |
| 2480 | + } |
| 2481 | + } |
| 2482 | + |
2432 | 2483 | /* |
2433 | 2484 | * @deprecated since 1.19 |
2434 | 2485 | */ |