Fixes for a couple of embarrassing bugs I should have caught in testing. Brion and...
authorAndrew Garrett <werdna@users.mediawiki.org>
Thu, 11 Jan 2007 00:31:04 +0000 (00:31 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Thu, 11 Jan 2007 00:31:04 +0000 (00:31 +0000)
includes/Article.php
includes/ProtectionForm.php
includes/Title.php
maintenance/updaters.inc

index bf6127a..2aa733d 100644 (file)
@@ -1649,7 +1649,7 @@ class Article {
                $updated = Article::flattenRestrictions( $limit );
                
                $changed = ( $current != $updated );
-               $changed = $changed || ($this->mTitle->getRestrictionCascadingFlags() != $cascade);
+               $changed = $changed || ($this->mTitle->areRestrictionsCascading() != $cascade);
                $protect = ( $updated != '' );
                
                # If nothing's changed, do nothing
@@ -2798,6 +2798,7 @@ class Article {
        /**
         * Add the primary page-view wikitext to the output buffer
         * Saves the text into the parser cache if possible.
+        * Updates templatelinks if it is out of date.
         *
         * @param string  $text
         * @param Article $article
@@ -2806,12 +2807,10 @@ class Article {
        public function outputWikiText( $text, $cache = true ) {
                global $wgParser, $wgUser, $wgOut;
 
-               $article = $this;
-
                $popts = $wgOut->parserOptions();
                $popts->setTidy(true);
-               $parserOutput = $wgParser->parse( $text, $article->mTitle,
-                       $popts, true, true, $this->mRevisionId );
+               $parserOutput = $wgParser->parse( $text, $this->mTitle,
+                       $popts, true, true, $this->getRevIdFetched() );
                $popts->setTidy(false);
                if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
                        $parserCache =& ParserCache::singleton();
@@ -2821,11 +2820,25 @@ class Article {
                if ( !wfReadOnly() ) {
 
                        # Get templates from templatelinks
-                       $tlTemplates_titles = $this->getUsedTemplates();
+                       $result = array();
+                       $id = $this->mTitle->getArticleID();
+
+                       if( $id == 0 ) {
+                               $tlTemplates = array();
+                       }
 
-                       $tlTemplates = array ();
-                       foreach( $tlTemplates_titles as $template_title) {
-                               $tlTemplates[] = $template_title->getDBkey();
+                       $dbr =& wfGetDB( DB_SLAVE );
+                       $res = $dbr->select( array( 'templatelinks' ),
+                               array( 'tl_namespace', 'tl_title' ),
+                               array( 'tl_from' => $id ),
+                               'Article:getUsedTemplates' );
+
+                       if ( false !== $res ) {
+                               if ( $dbr->numRows( $res ) ) {
+                                       while ( $row = $dbr->fetchObject( $res ) ) {
+                                               $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ;
+                                       }
+                               }
                        }
 
                        # Get templates from parser output.
index 53e2af3..1f71a1f 100644 (file)
@@ -39,7 +39,7 @@ class ProtectionForm {
                                // but the db allows multiples separated by commas.
                                $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
                        }
-                       $this->mCascade = $this->mTitle->getRestrictionCascadingFlags() & 1;
+                       $this->mCascade = $this->mTitle->areRestrictionsCascading();
                }
 
                // The form will be available in read-only to show levels.
index 99cc45a..191d77e 100644 (file)
@@ -17,6 +17,9 @@ define ( 'GAID_FOR_UPDATE', 1 );
 # reset the cache.
 define( 'MW_TITLECACHE_MAX', 1000 );
 
+# Constants for pr_cascade bitfield
+define( 'CASCADE', 1 );
+
 /**
  * Title class
  * - Represents a title, which may contain an interwiki designation or namespace
@@ -50,7 +53,7 @@ class Title {
        var $mArticleID;          # Article ID, fetched from the link cache on demand
        var $mLatestID;         # ID of most recent revision
        var $mRestrictions;       # Array of groups allowed to edit this article
-       var $mCascadeRestrictionFlags;
+       var $mCascadeRestriction;
        var $mRestrictionsLoaded; # Boolean for initialisation on demand
        var $mPrefixedText;       # Text form including namespace/interwiki, initialised on demand
        var $mDefaultNamespace;   # Namespace index when there is no namespace
@@ -1328,7 +1331,7 @@ class Title {
        function isCascadeProtectedImage() {
                global $wgEnableCascadingProtection;
                if (!$wgEnableCascadingProtection)
-                       return;
+                       return false;
 
                wfProfileIn(__METHOD__);
 
@@ -1340,8 +1343,6 @@ class Title {
 
                $res = $dbr->select( $tables, $cols, $where_clauses, __METHOD__);
 
-               //die($dbr->numRows($res));
-
                if ($dbr->numRows($res)) {
                        wfProfileOut(__METHOD__);
                        return true;
@@ -1360,7 +1361,7 @@ class Title {
        function isCascadeProtectedPage() {
                global $wgEnableCascadingProtection;
                if (!$wgEnableCascadingProtection)
-                       return;
+                       return false;
 
                wfProfileIn(__METHOD__);
 
@@ -1381,12 +1382,12 @@ class Title {
                }
        }
 
-       function getRestrictionCascadingFlags() {
+       function areRestrictionsCascading() {
                if (!$this->mRestrictionsLoaded) {
                        $this->loadRestrictions();
                }
 
-               return $this->mCascadeRestrictionFlags;
+               return $this->mCascadeRestriction;
        }
 
        /**
@@ -1411,7 +1412,7 @@ class Title {
 
                        $this->mRestrictions[$row->pr_type] = explode( ',', trim( $row->pr_level ) );
 
-                       $this->mCascadeRestrictionFlags |= $row->pr_cascade;
+                       $this->mCascadeRestriction |= $row->pr_cascade;
                }
 
                $this->mRestrictionsLoaded = true;
index 9e6433f..1570a65 100644 (file)
@@ -37,7 +37,6 @@ $wgNewTables = array(
        array( 'filearchive',   'patch-filearchive.sql' ),
        array( 'redirect',      'patch-redirect.sql' ),
        array( 'querycachetwo', 'patch-querycachetwo.sql' ),
-#      array( 'page_restrictions', 'patch-page_restrictions.sql' ),
 );
 
 $wgNewFields = array(