r19097 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19096‎ | r19097 | r19098 >
Date:00:31, 11 January 2007
Author:werdna
Status:old
Tags:
Comment:
Fixes for a couple of embarrassing bugs I should have caught in testing. Brion and Tim save the day...
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updaters.inc
@@ -37,7 +37,6 @@
3838 array( 'filearchive', 'patch-filearchive.sql' ),
3939 array( 'redirect', 'patch-redirect.sql' ),
4040 array( 'querycachetwo', 'patch-querycachetwo.sql' ),
41 -# array( 'page_restrictions', 'patch-page_restrictions.sql' ),
4241 );
4342
4443 $wgNewFields = array(
Index: trunk/phase3/includes/ProtectionForm.php
@@ -39,7 +39,7 @@
4040 // but the db allows multiples separated by commas.
4141 $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
4242 }
43 - $this->mCascade = $this->mTitle->getRestrictionCascadingFlags() & 1;
 43+ $this->mCascade = $this->mTitle->areRestrictionsCascading();
4444 }
4545
4646 // The form will be available in read-only to show levels.
Index: trunk/phase3/includes/Article.php
@@ -1649,7 +1649,7 @@
16501650 $updated = Article::flattenRestrictions( $limit );
16511651
16521652 $changed = ( $current != $updated );
1653 - $changed = $changed || ($this->mTitle->getRestrictionCascadingFlags() != $cascade);
 1653+ $changed = $changed || ($this->mTitle->areRestrictionsCascading() != $cascade);
16541654 $protect = ( $updated != '' );
16551655
16561656 # If nothing's changed, do nothing
@@ -2798,6 +2798,7 @@
27992799 /**
28002800 * Add the primary page-view wikitext to the output buffer
28012801 * Saves the text into the parser cache if possible.
 2802+ * Updates templatelinks if it is out of date.
28022803 *
28032804 * @param string $text
28042805 * @param Article $article
@@ -2806,12 +2807,10 @@
28072808 public function outputWikiText( $text, $cache = true ) {
28082809 global $wgParser, $wgUser, $wgOut;
28092810
2810 - $article = $this;
2811 -
28122811 $popts = $wgOut->parserOptions();
28132812 $popts->setTidy(true);
2814 - $parserOutput = $wgParser->parse( $text, $article->mTitle,
2815 - $popts, true, true, $this->mRevisionId );
 2813+ $parserOutput = $wgParser->parse( $text, $this->mTitle,
 2814+ $popts, true, true, $this->getRevIdFetched() );
28162815 $popts->setTidy(false);
28172816 if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
28182817 $parserCache =& ParserCache::singleton();
@@ -2821,13 +2820,27 @@
28222821 if ( !wfReadOnly() ) {
28232822
28242823 # Get templates from templatelinks
2825 - $tlTemplates_titles = $this->getUsedTemplates();
 2824+ $result = array();
 2825+ $id = $this->mTitle->getArticleID();
28262826
2827 - $tlTemplates = array ();
2828 - foreach( $tlTemplates_titles as $template_title) {
2829 - $tlTemplates[] = $template_title->getDBkey();
 2827+ if( $id == 0 ) {
 2828+ $tlTemplates = array();
28302829 }
28312830
 2831+ $dbr =& wfGetDB( DB_SLAVE );
 2832+ $res = $dbr->select( array( 'templatelinks' ),
 2833+ array( 'tl_namespace', 'tl_title' ),
 2834+ array( 'tl_from' => $id ),
 2835+ 'Article:getUsedTemplates' );
 2836+
 2837+ if ( false !== $res ) {
 2838+ if ( $dbr->numRows( $res ) ) {
 2839+ while ( $row = $dbr->fetchObject( $res ) ) {
 2840+ $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ;
 2841+ }
 2842+ }
 2843+ }
 2844+
28322845 # Get templates from parser output.
28332846 $poTemplates_allns = $parserOutput->getTemplates();
28342847
Index: trunk/phase3/includes/Title.php
@@ -17,6 +17,9 @@
1818 # reset the cache.
1919 define( 'MW_TITLECACHE_MAX', 1000 );
2020
 21+# Constants for pr_cascade bitfield
 22+define( 'CASCADE', 1 );
 23+
2124 /**
2225 * Title class
2326 * - Represents a title, which may contain an interwiki designation or namespace
@@ -50,7 +53,7 @@
5154 var $mArticleID; # Article ID, fetched from the link cache on demand
5255 var $mLatestID; # ID of most recent revision
5356 var $mRestrictions; # Array of groups allowed to edit this article
54 - var $mCascadeRestrictionFlags;
 57+ var $mCascadeRestriction;
5558 var $mRestrictionsLoaded; # Boolean for initialisation on demand
5659 var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
5760 var $mDefaultNamespace; # Namespace index when there is no namespace
@@ -1328,7 +1331,7 @@
13291332 function isCascadeProtectedImage() {
13301333 global $wgEnableCascadingProtection;
13311334 if (!$wgEnableCascadingProtection)
1332 - return;
 1335+ return false;
13331336
13341337 wfProfileIn(__METHOD__);
13351338
@@ -1340,8 +1343,6 @@
13411344
13421345 $res = $dbr->select( $tables, $cols, $where_clauses, __METHOD__);
13431346
1344 - //die($dbr->numRows($res));
1345 -
13461347 if ($dbr->numRows($res)) {
13471348 wfProfileOut(__METHOD__);
13481349 return true;
@@ -1360,7 +1361,7 @@
13611362 function isCascadeProtectedPage() {
13621363 global $wgEnableCascadingProtection;
13631364 if (!$wgEnableCascadingProtection)
1364 - return;
 1365+ return false;
13651366
13661367 wfProfileIn(__METHOD__);
13671368
@@ -1381,12 +1382,12 @@
13821383 }
13831384 }
13841385
1385 - function getRestrictionCascadingFlags() {
 1386+ function areRestrictionsCascading() {
13861387 if (!$this->mRestrictionsLoaded) {
13871388 $this->loadRestrictions();
13881389 }
13891390
1390 - return $this->mCascadeRestrictionFlags;
 1391+ return $this->mCascadeRestriction;
13911392 }
13921393
13931394 /**
@@ -1411,7 +1412,7 @@
14121413
14131414 $this->mRestrictions[$row->pr_type] = explode( ',', trim( $row->pr_level ) );
14141415
1415 - $this->mCascadeRestrictionFlags |= $row->pr_cascade;
 1416+ $this->mCascadeRestriction |= $row->pr_cascade;
14161417 }
14171418
14181419 $this->mRestrictionsLoaded = true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r60488Remove unprefixed constant "CASCADE" due to risk of conflicts. It was added i...tstarling06:44, 30 December 2009