Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS

SVN: [39062] trunk/phase3/includes/Title.php

 

 

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded


nikerabbit at svn

Aug 10, 2008, 3:30 AM

Post #1 of 1 (49 views)
Permalink
SVN: [39062] trunk/phase3/includes/Title.php

Revision: 39062
Author: nikerabbit
Date: 2008-08-10 10:30:52 +0000 (Sun, 10 Aug 2008)

Log Message:
-----------
* Whitespace fixes
* Avoid running some queries multiple times by caching the result
- Title::isDeleted is called twice when viewing a page that does not exist by SkinTemplate::buildContentActionUrls and Skin::getUndeleteLink
- Title::getTitleProtections is called twice when viewing a page that does not exist by SkinTemplate::buildContentActionUrls and efUniversalEditLink

Modified Paths:
--------------
trunk/phase3/includes/Title.php

Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php 2008-08-10 10:16:19 UTC (rev 39061)
+++ trunk/phase3/includes/Title.php 2008-08-10 10:30:52 UTC (rev 39062)
@@ -45,28 +45,29 @@
* @private
*/

- var $mTextform = ''; # Text form (spaces not underscores) of the main part
- var $mUrlform = ''; # URL-encoded form of the main part
- var $mDbkeyform = ''; # Main part with underscores
+ var $mTextform = ''; # Text form (spaces not underscores) of the main part
+ var $mUrlform = ''; # URL-encoded form of the main part
+ var $mDbkeyform = ''; # Main part with underscores
var $mUserCaseDBKey; # DB key with the initial letter in the case specified by the user
var $mNamespace = NS_MAIN; # Namespace index, i.e. one of the NS_xxxx constants
- var $mInterwiki = ''; # Interwiki prefix (or null string)
- var $mFragment; # Title fragment (i.e. the bit after the #)
+ var $mInterwiki = ''; # Interwiki prefix (or null string)
+ var $mFragment; # Title fragment (i.e. the bit after the #)
var $mArticleID = -1; # Article ID, fetched from the link cache on demand
var $mLatestID = false; # ID of most recent revision
var $mRestrictions = array(); # Array of groups allowed to edit this article
var $mOldRestrictions = false;
- var $mCascadeRestriction; # Cascade restrictions on this page to included templates and images?
- var $mRestrictionsExpiry; # When do the restrictions on this page expire?
+ var $mCascadeRestriction; # Cascade restrictions on this page to included templates and images?
+ var $mRestrictionsExpiry; # When do the restrictions on this page expire?
var $mHasCascadingRestrictions; # Are cascading restrictions in effect on this page?
var $mCascadeRestrictionSources; # Where are the cascading restrictions coming from on this page?
var $mRestrictionsLoaded = false; # Boolean for initialisation on demand
- var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
+ var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
+
# Don't change the following default, NS_MAIN is hardcoded in several
# places. See bug 696.
var $mDefaultNamespace = NS_MAIN; # Namespace index when there is no namespace
- # Zero except in {{transclusion}} tags
- var $mWatched = null; # Is $wgUser watching this page? null if unfilled, accessed through userIsWatching()
+ # Zero except in {{transclusion}} tags
+ var $mWatched = null; # Is $wgUser watching this page? null if unfilled, accessed through userIsWatching()
var $mLength = -1; # The page length, 0 for special pages
var $mRedirect = null; # Is the article at this title a redirect?
/**#@-*/
@@ -1339,15 +1340,28 @@
return false;
}

+ wfDebug( wfBacktrace() );
+
+ // Cache to avoid multiple database queries for the same title
+ if ( isset($this->mProtections) ) {
+ return $this->mProtections;
+ }
+
+ $conds = array(
+ 'pt_namespace' => $this->getNamespace(),
+ 'pt_title' => $this->getDBkey()
+ );
+
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'protected_titles', '*',
- array ('pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey()) );
+ $res = $dbr->select( 'protected_titles', '*', $conds, __METHOD__ );

if ($row = $dbr->fetchRow( $res )) {
- return $row;
+ $this->mProtections = $row;
} else {
- return false;
+ $this->mProtections = false;
}
+
+ return $this->mProtections;
}

public function updateTitleProtection( $create_perm, $reason, $expiry ) {
@@ -1879,19 +1893,30 @@
* @return int the number of archived revisions
*/
public function isDeleted() {
- $fname = 'Title::isDeleted';
if ( $this->getNamespace() < 0 ) {
- $n = 0;
- } else {
- $dbr = wfGetDB( DB_SLAVE );
- $n = $dbr->selectField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
- 'ar_title' => $this->getDBkey() ), $fname );
- if( $this->getNamespace() == NS_IMAGE ) {
- $n += $dbr->selectField( 'filearchive', 'COUNT(*)',
- array( 'fa_name' => $this->getDBkey() ), $fname );
- }
+ return 0;
}
- return (int)$n;
+
+ // Cache to avoid multiple queries for the same title
+ if ( isset($this->mIsDeleted) ) {
+ return $this->mIsDeleted;
+ }
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $aConds = array(
+ 'ar_namespace' => $this->getNamespace(),
+ 'ar_title' => $this->getDBkey()
+ );
+ $n = $dbr->selectField( 'archive', 'COUNT(*)', $aConds, __METHOD__ );
+
+ if ( $this->getNamespace() == NS_IMAGE ) {
+ $faConds = array( 'fa_name' => $this->getDBkey() );
+ $n += $dbr->selectField( 'filearchive', 'COUNT(*)', $faConds , __METHOD__ );
+ }
+
+ $this->mIsDeleted = (int) $n;
+
+ return $this->mIsDeleted;
}

/**



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS [at] lists
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.