require_once( 'normal/UtfNormal.php' );
$wgTitleInterwikiCache = array();
+$wgTitleCache = array();
+
define ( 'GAID_FOR_UPDATE', 1 );
# Title::newFromTitle maintains a cache to avoid
* @access public
*/
function newFromText( $text, $defaultNamespace = NS_MAIN ) {
+ global $wgTitleCache;
$fname = 'Title::newFromText';
- wfProfileIn( $fname );
if( is_object( $text ) ) {
wfDebugDieBacktrace( 'Title::newFromText given an object' );
*
* In theory these are value objects and won't get changed...
*/
- static $titleCache = array();
- if( $defaultNamespace == NS_MAIN && isset( $titleCache[$text] ) ) {
- wfProfileOut( $fname );
- return $titleCache[$text];
+ if( $defaultNamespace == NS_MAIN && isset( $wgTitleCache[$text] ) ) {
+ return $wgTitleCache[$text];
}
/**
$t->mDbkeyform = str_replace( ' ', '_', $filteredText );
$t->mDefaultNamespace = $defaultNamespace;
+ static $cachedcount = 0 ;
if( $t->secureAndSplit() ) {
if( $defaultNamespace == NS_MAIN ) {
- if( count( $titleCache ) >= MW_TITLECACHE_MAX ) {
+ if( $cachedcount >= MW_TITLECACHE_MAX ) {
# Avoid memory leaks on mass operations...
- $titleCache = array();
+ $wgTitleCache = array();
+ $cachedcount=0;
}
- $titleCache[$text] =& $t;
+ $cachedcount++;
+ $wgTitleCache[$text] =& $t;
}
- wfProfileOut( $fname );
return $t;
} else {
- wfProfileOut( $fname );
$ret = NULL;
return $ret;
}
* @access public
*/
function newFromURL( $url ) {
- global $wgLang, $wgServer;
+ global $wgLegalTitleChars;
$t = new Title();
- # For compatibility with old buggy URLs. "+" is not valid in titles,
+ # For compatibility with old buggy URLs. "+" is usually not valid in titles,
# but some URLs used it as a space replacement and they still come
# from some external search tools.
- $s = str_replace( '+', ' ', $url );
+ if ( strpos( $wgLegalTitleChars, '+' ) === false ) {
+ $url = str_replace( '+', ' ', $url );
+ }
- $t->mDbkeyform = str_replace( ' ', '_', $s );
+ $t->mDbkeyform = str_replace( ' ', '_', $url );
if( $t->secureAndSplit() ) {
return $t;
} else {
* search index
*/
/* static */ function indexTitle( $ns, $title ) {
- global $wgDBminWordLen, $wgContLang;
+ global $wgContLang;
require_once( 'SearchEngine.php' );
$lc = SearchEngine::legalSearchChars() . '&#;';
* @static (arguably)
* @access public
*/
- function getInterwikiLink( $key, $transludeonly = false ) {
+ function getInterwikiLink( $key ) {
global $wgMemc, $wgDBname, $wgInterwikiExpiry, $wgTitleInterwikiCache;
+ global $wgInterwikiCache;
$fname = 'Title::getInterwikiLink';
- wfProfileIn( $fname );
-
$key = strtolower( $key );
$k = $wgDBname.':interwiki:'.$key;
if( array_key_exists( $k, $wgTitleInterwikiCache ) ) {
- wfProfileOut( $fname );
return $wgTitleInterwikiCache[$k]->iw_url;
}
+ if ($wgInterwikiCache) {
+ return Title::getInterwikiCached( $key );
+ }
+
$s = $wgMemc->get( $k );
# Ignore old keys with no iw_local
if( $s && isset( $s->iw_local ) && isset($s->iw_trans)) {
$wgTitleInterwikiCache[$k] = $s;
- wfProfileOut( $fname );
return $s->iw_url;
}
array( 'iw_url', 'iw_local', 'iw_trans' ),
array( 'iw_prefix' => $key ), $fname );
if( !$res ) {
- wfProfileOut( $fname );
return '';
}
$wgMemc->set( $k, $s, $wgInterwikiExpiry );
$wgTitleInterwikiCache[$k] = $s;
- wfProfileOut( $fname );
return $s->iw_url;
}
-
+
+ /**
+ * Fetch interwiki prefix data from local cache in constant database
+ *
+ * More logic is explained in DefaultSettings
+ *
+ * @return string URL of interwiki site
+ * @access public
+ */
+ function getInterwikiCached( $key ) {
+ global $wgDBname, $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
+ global $wgTitleInterwikiCache;
+ static $db, $site;
+
+ if (!$db)
+ $db=dba_open($wgInterwikiCache,'r','cdb');
+ /* Resolve site name */
+ if ($wgInterwikiScopes>=3 and !$site) {
+ $site = dba_fetch("__sites:{$wgDBname}", $db);
+ if ($site=="")
+ $site = $wgInterwikiFallbackSite;
+ }
+ $value = dba_fetch("{$wgDBname}:{$key}", $db);
+ if ($value=='' and $wgInterwikiScopes>=3) {
+ /* try site-level */
+ $value = dba_fetch("_{$site}:{$key}", $db);
+ }
+ if ($value=='' and $wgInterwikiScopes>=2) {
+ /* try globals */
+ $value = dba_fetch("__global:{$key}", $db);
+ }
+ if ($value=='undef')
+ $value='';
+ $s = (object)false;
+ $s->iw_url = '';
+ $s->iw_local = 0;
+ $s->iw_trans = 0;
+ if ($value!='') {
+ list($local,$url)=explode(' ',$value,2);
+ $s->iw_url=$url;
+ $s->iw_local=(int)$local;
+ }
+ $wgTitleInterwikiCache[$wgDBname.':interwiki:'.$key] = $s;
+ return $s->iw_url;
+ }
/**
* Determine whether the object refers to a page within
* this project.
function isTrans() {
global $wgTitleInterwikiCache, $wgDBname;
- if ($this->mInterwiki == '' || !$this->isLocal())
+ if ($this->mInterwiki == '')
return false;
# Make sure key is loaded into cache
$this->getInterwikiLink( $this->mInterwiki );
* @access public
*/
function touchArray( $titles, $timestamp = '' ) {
- global $wgUseFileCache;
if ( count( $titles ) == 0 ) {
return;
if ( $timestamp == '' ) {
$timestamp = $dbw->timestamp();
}
- $page = $dbw->tableName( 'page' );
/*
+ $page = $dbw->tableName( 'page' );
$sql = "UPDATE $page SET page_touched='{$timestamp}' WHERE page_id IN (";
$first = true;
* @return string
* @access public
*/
- function getNsText() {
+ function getNsText() {
global $wgContLang;
return $wgContLang->getNsText( $this->mNamespace );
}
return $text;
}
+ /**
+ * Get the lowest-level subpage name, i.e. the rightmost part after /
+ * @return string Subpage name
+ */
+ function getSubpageText() {
+ global $wgNamespacesWithSubpages;
+ if( $wgNamespacesWithSubpages[ $this->mNamespace ] ) {
+ $parts = explode( '/', $this->mTextform );
+ return( $parts[ count( $parts ) - 1 ] );
+ } else {
+ return( $this->mTextform );
+ }
+ }
+
/**
* Get a URL-encoded title (not an actual URL) including interwiki
* @return string the URL-encoded form
* @access public
*/
function getFullURL( $query = '' ) {
- global $wgContLang, $wgServer;
+ global $wgContLang, $wgServer, $wgRequest;
if ( '' == $this->mInterwiki ) {
- $url = $wgServer . $this->getLocalUrl( $query );
+ $url = $this->getLocalUrl( $query );
+
+ // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc)
+ // Correct fix would be to move the prepending elsewhere.
+ if ($wgRequest->getVal('action') != 'render') {
+ $url = $wgServer . $url;
+ }
} else {
$baseUrl = $this->getInterwikiLink( $this->mInterwiki );
if ( $this->isExternal() ) {
$url = $this->getFullURL();
+ if ( $query ) {
+ // This is currently only used for edit section links in the
+ // context of interwiki transclusion. In theory we should
+ // append the query to the end of any existing query string,
+ // but interwiki transclusion is already broken in that case.
+ $url .= "?$query";
+ }
} else {
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
if ( $query == '' ) {
global $wgActionPaths;
$url = false;
if( !empty( $wgActionPaths ) &&
- preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) )
+ preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) )
{
$action = urldecode( $matches[2] );
if( isset( $wgActionPaths[$action] ) ) {
$url = "{$wgScript}?title={$dbkey}&{$query}";
}
}
-
- if ($wgRequest->getText('action') == 'render') {
+
+ // FIXME: this causes breakage in various places when we
+ // actually expected a local URL and end up with dupe prefixes.
+ if ($wgRequest->getVal('action') == 'render') {
$url = $wgServer . $url;
}
}
*/
function getInternalURL( $query = '' ) {
global $wgInternalServer;
- return $wgInternalServer . $this->getLocalURL( $query );
+ $url = $wgInternalServer . $this->getLocalURL( $query );
+ wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
+ return $url;
}
/**
*/
function isExternal() { return ( '' != $this->mInterwiki ); }
+ /**
+ * Is this page "semi-protected" - the *only* protection is autoconfirm?
+ *
+ * @param string Action to check (default: edit)
+ * @return bool
+ */
+ function isSemiProtected( $action = 'edit' ) {
+ $restrictions = $this->getRestrictions( $action );
+ # We do a full compare because this could be an array
+ foreach( $restrictions as $restriction ) {
+ if( strtolower( $restriction ) != 'autoconfirmed' ) {
+ return( false );
+ }
+ }
+ return( true );
+ }
+
/**
* Does the title correspond to a protected article?
* @param string $what the action the page is protected from,
* @return boolean
* @access public
*/
- function isProtected($action = '') {
+ function isProtected( $action = '' ) {
+ global $wgRestrictionLevels;
if ( -1 == $this->mNamespace ) { return true; }
- if($action == 'edit' || $action == '') {
- $a = $this->getRestrictions("edit");
- if ( in_array( 'sysop', $a ) ) { return true; }
+
+ if( $action == 'edit' || $action == '' ) {
+ $r = $this->getRestrictions( 'edit' );
+ foreach( $wgRestrictionLevels as $level ) {
+ if( in_array( $level, $r ) && $level != '' ) {
+ return( true );
+ }
+ }
}
- if($action == 'move' || $action == '') {
- $a = $this->getRestrictions("move");
- if ( in_array( 'sysop', $a ) ) { return true; }
+
+ if( $action == 'move' || $action == '' ) {
+ $r = $this->getRestrictions( 'move' );
+ foreach( $wgRestrictionLevels as $level ) {
+ if( in_array( $level, $r ) && $level != '' ) {
+ return( true );
+ }
+ }
}
+
return false;
}
wfProfileIn( $fname );
global $wgUser;
+
+ $result = true;
+ if ( !wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) ) ) {
+ wfProfileOut( $fname );
+ return $result;
+ }
+
if( NS_SPECIAL == $this->mNamespace ) {
wfProfileOut( $fname );
return false;
wfProfileOut( $fname );
return false;
}
-
+
if( $this->mDbkeyform == '_' ) {
# FIXME: Is this necessary? Shouldn't be allowed anyway...
wfProfileOut( $fname );
return false;
}
+ if( $action == 'create' ) {
+ if( ( $this->isTalkPage() && !$wgUser->isAllowed( 'createtalk' ) ) ||
+ ( !$this->isTalkPage() && !$wgUser->isAllowed( 'createpage' ) ) ) {
+ return false;
+ }
+ }
+
wfProfileOut( $fname );
return true;
}
function userCanRead() {
global $wgUser;
+ $result = true;
+ if ( !wfRunHooks( 'userCan', array( &$this, &$wgUser, "read", &$result ) ) ) {
+ return $result;
+ }
+
if( $wgUser->isAllowed('read') ) {
return true;
} else {
function isCssJsSubpage() {
return ( NS_USER == $this->mNamespace and preg_match("/\\.(css|js)$/", $this->mTextform ) );
}
+ /**
+ * Is this a *valid* .css or .js subpage of a user page?
+ * Check that the corresponding skin exists
+ */
+ function isValidCssJsSubpage() {
+ global $wgValidSkinNames;
+ return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) );
+ }
+ /**
+ * Trim down a .css or .js subpage title to get the corresponding skin name
+ */
+ function getSkinFromCssJsSubpage() {
+ $subpage = explode( '/', $this->mTextform );
+ $subpage = $subpage[ count( $subpage ) - 1 ];
+ return( str_replace( array( '.css', '.js' ), array( '', '' ), $subpage ) );
+ }
/**
* Is this a .css subpage of a user page?
* @return bool
* @access public
*/
function getArticleID( $flags = 0 ) {
- global $wgLinkCache;
+ $linkCache =& LinkCache::singleton();
if ( $flags & GAID_FOR_UPDATE ) {
- $oldUpdate = $wgLinkCache->forUpdate( true );
- $this->mArticleID = $wgLinkCache->addLinkObj( $this );
- $wgLinkCache->forUpdate( $oldUpdate );
+ $oldUpdate = $linkCache->forUpdate( true );
+ $this->mArticleID = $linkCache->addLinkObj( $this );
+ $linkCache->forUpdate( $oldUpdate );
} else {
if ( -1 == $this->mArticleID ) {
- $this->mArticleID = $wgLinkCache->addLinkObj( $this );
+ $this->mArticleID = $linkCache->addLinkObj( $this );
}
}
return $this->mArticleID;
/**
* This clears some fields in this object, and clears any associated
- * keys in the "bad links" section of $wgLinkCache.
+ * keys in the "bad links" section of the link cache.
*
* - This is called from Article::insertNewArticle() to allow
* loading of the new page_id. It's also called from
* @access public
*/
function resetArticleID( $newid ) {
- global $wgLinkCache;
- $wgLinkCache->clearBadLink( $this->getPrefixedDBkey() );
+ $linkCache =& LinkCache::singleton();
+ $linkCache->clearBadLink( $this->getPrefixedDBkey() );
if ( 0 == $newid ) { $this->mArticleID = -1; }
else { $this->mArticleID = $newid; }
return;
}
- $now = wfTimestampNow();
$dbw =& wfGetDB( DB_MASTER );
$success = $dbw->update( 'page',
array( /* SET */
/* private */ function secureAndSplit() {
global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks;
$fname = 'Title::secureAndSplit';
- wfProfileIn( $fname );
# Initialisation
static $rxTc = false;
$t = trim( $t, '_' );
if ( '' == $t ) {
- wfProfileOut( $fname );
return false;
}
if( false !== strpos( $t, UTF8_REPLACEMENT ) ) {
# Contained illegal UTF-8 sequences or forbidden Unicode chars.
- wfProfileOut( $fname );
return false;
}
if( !$firstPass ) {
# Can't make a local interwiki link to an interwiki link.
# That's just crazy!
- wfProfileOut( $fname );
return false;
}
if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
if( $t == '' ) {
# Can't have an empty self-link
- wfProfileOut( $fname );
return false;
}
$this->mInterwiki = '';
# Do another namespace split...
continue;
}
+
+ # If there's an initial colon after the interwiki, that also
+ # resets the default namespace
+ if ( $t !== '' && $t[0] == ':' ) {
+ $this->mNamespace = NS_MAIN;
+ $t = substr( $t, 1 );
+ }
}
# If there's no recognized interwiki or namespace,
# then let the colon expression be part of the title.
# Reject illegal characters.
#
if( preg_match( $rxTc, $r ) ) {
- wfProfileOut( $fname );
return false;
}
strpos( $r, '/./' ) !== false ||
strpos( $r, '/../' ) !== false ) )
{
- wfProfileOut( $fname );
return false;
}
# We shouldn't need to query the DB for the size.
#$maxSize = $dbr->textFieldSize( 'page', 'page_title' );
if ( strlen( $r ) > 255 ) {
- wfProfileOut( $fname );
return false;
}
if( $t == '' &&
$this->mInterwiki == '' &&
$this->mNamespace != NS_MAIN ) {
- wfProfileOut( $fname );
return false;
}
$this->mTextform = str_replace( '_', ' ', $t );
- wfProfileOut( $fname );
return true;
}
* @return array the Title objects linking here
* @access public
*/
- function getLinksTo( $options = '' ) {
- global $wgLinkCache;
+ function getLinksTo( $options = '', $table = 'pagelinks', $prefix = 'pl' ) {
+ $linkCache =& LinkCache::singleton();
$id = $this->getArticleID();
if ( $options ) {
$db =& wfGetDB( DB_SLAVE );
}
- $res = $db->select( array( 'page', 'pagelinks' ),
+ $res = $db->select( array( 'page', $table ),
array( 'page_namespace', 'page_title', 'page_id' ),
array(
- 'pl_from=page_id',
- 'pl_namespace' => $this->getNamespace(),
- 'pl_title' => $this->getDbKey() ),
+ "{$prefix}_from=page_id",
+ "{$prefix}_namespace" => $this->getNamespace(),
+ "{$prefix}_title" => $this->getDbKey() ),
'Title::getLinksTo',
$options );
if ( $db->numRows( $res ) ) {
while ( $row = $db->fetchObject( $res ) ) {
if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) {
- $wgLinkCache->addGoodLinkObj( $row->page_id, $titleObj );
+ $linkCache->addGoodLinkObj( $row->page_id, $titleObj );
$retVal[] = $titleObj;
}
}
return $retVal;
}
+ /**
+ * Get an array of Title objects using this Title as a template
+ * Also stores the IDs in the link cache.
+ *
+ * @param string $options may be FOR UPDATE
+ * @return array the Title objects linking here
+ * @access public
+ */
+ function getTemplateLinksTo( $options = '' ) {
+ return $this->getLinksTo( $options, 'templatelinks', 'tl' );
+ }
+
/**
* Get an array of Title objects referring to non-existent articles linked from this page
*
* @access public
*/
function getBrokenLinksFrom( $options = '' ) {
- global $wgLinkCache;
-
if ( $options ) {
$db =& wfGetDB( DB_MASTER );
} else {
* @return mixed true on success, message name on failure
* @access public
*/
- function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
+ function isValidMoveOperation( &$nt, $auth = true ) {
global $wgUser;
if( !$this or !$nt ) {
return 'badtitletext';
return 'immobile_namespace';
}
- $fname = 'Title::move';
$oldid = $this->getArticleID();
$newid = $nt->getArticleID();
* @access public
*/
function moveTo( &$nt, $auth = true, $reason = '' ) {
- $err = $this->isValidMoveOperation( $nt, $auth, $reason );
+ $err = $this->isValidMoveOperation( $nt, $auth );
if( is_string( $err ) ) {
return $err;
}
$this->moveOverExistingRedirect( $nt, $reason );
$pageCountChange = 0;
} else { # Target didn't exist, do normal move.
- $this->moveToNewTitle( $nt, $newid, $reason );
+ $this->moveToNewTitle( $nt, $reason );
$pageCountChange = 1;
}
$redirid = $this->getArticleID();
$u->doUpdate();
}
+ global $wgUser;
wfRunHooks( 'TitleMoveComplete', array( &$this, &$nt, &$wgUser, $pageid, $redirid ) );
return true;
}
* @access private
*/
function moveOverExistingRedirect( &$nt, $reason = '' ) {
- global $wgUser, $wgLinkCache, $wgUseSquid, $wgMwRedir;
+ global $wgUser, $wgUseSquid, $wgMwRedir;
$fname = 'Title::moveOverExistingRedirect';
$comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
$newid = $nt->getArticleID();
$oldid = $this->getArticleID();
$dbw =& wfGetDB( DB_MASTER );
- $links = $dbw->tableName( 'links' );
+ $linkCache =& LinkCache::singleton();
# Delete the old redirect. We don't save it to history since
# by definition if we've got here it's rather uninteresting.
$dbw->delete( 'page', array( 'page_id' => $newid ), $fname );
# Save a null revision in the page's history notifying of the move
- $nullRevision = Revision::newNullRevision( $dbw, $oldid,
- wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() ),
- true );
+ $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
$nullRevId = $nullRevision->insertOn( $dbw );
# Change the name of the target page:
/* WHERE */ array( 'page_id' => $oldid ),
$fname
);
- $wgLinkCache->clearLink( $nt->getPrefixedDBkey() );
+ $linkCache->clearLink( $nt->getPrefixedDBkey() );
# Recreate the redirect, this time in the other direction.
$redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
'text' => $redirectText ) );
$revid = $redirectRevision->insertOn( $dbw );
$redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
- $wgLinkCache->clearLink( $this->getPrefixedDBkey() );
+ $linkCache->clearLink( $this->getPrefixedDBkey() );
# Log the move
$log = new LogPage( 'move' );
/**
* Move page to non-existing title.
* @param Title &$nt the new Title
- * @param int &$newid set to be the new article ID
* @access private
*/
- function moveToNewTitle( &$nt, &$newid, $reason = '' ) {
- global $wgUser, $wgLinkCache, $wgUseSquid;
+ function moveToNewTitle( &$nt, $reason = '' ) {
+ global $wgUser, $wgUseSquid;
global $wgMwRedir;
$fname = 'MovePageForm::moveToNewTitle';
$comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
$oldid = $this->getArticleID();
$dbw =& wfGetDB( DB_MASTER );
$now = $dbw->timestamp();
- wfSeedRandom();
$rand = wfRandom();
+ $linkCache =& LinkCache::singleton();
# Save a null revision in the page's history notifying of the move
- $nullRevision = Revision::newNullRevision( $dbw, $oldid,
- wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() ),
- true );
+ $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
$nullRevId = $nullRevision->insertOn( $dbw );
# Rename cur entry
$fname
);
- $wgLinkCache->clearLink( $nt->getPrefixedDBkey() );
+ $linkCache->clearLink( $nt->getPrefixedDBkey() );
# Insert redirect
$redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
'text' => $redirectText ) );
$revid = $redirectRevision->insertOn( $dbw );
$redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
- $wgLinkCache->clearLink( $this->getPrefixedDBkey() );
+ $linkCache->clearLink( $this->getPrefixedDBkey() );
# Log the move
$log = new LogPage( 'move' );
global $wgContLang,$wgUser;
$titlekey = $this->getArticleId();
- $sk =& $wgUser->getSkin();
- $parents = array();
$dbr =& wfGetDB( DB_SLAVE );
$categorylinks = $dbr->tableName( 'categorylinks' );
$parents = $this->getParentCategories();
if($parents != '') {
- foreach($parents as $parent => $current)
- {
+ foreach($parents as $parent => $current) {
if ( array_key_exists( $parent, $children ) ) {
# Circular reference
$stack[$parent] = array();
/**
* Get an associative array for selecting this title from
- * the "cur" table
- *
- * @return array
- * @access public
- */
- function curCond() {
- wfDebugDieBacktrace( 'curCond called' );
- return array( 'cur_namespace' => $this->mNamespace, 'cur_title' => $this->mDbkeyform );
- }
-
- /**
- * Get an associative array for selecting this title from the
- * "old" table
+ * the "page" table
*
* @return array
* @access public
*/
- function oldCond() {
- wfDebugDieBacktrace( 'oldCond called' );
- return array( 'old_namespace' => $this->mNamespace, 'old_title' => $this->mDbkeyform );
+ function pageCond() {
+ return array( 'page_namespace' => $this->mNamespace, 'page_title' => $this->mDbkeyform );
}
/**
* @param Title $title
* @return bool
*/
- function equals( &$title ) {
- return $this->getInterwiki() == $title->getInterwiki()
+ function equals( $title ) {
+ // Note: === is necessary for proper matching of number-like titles.
+ return $this->getInterwiki() === $title->getInterwiki()
&& $this->getNamespace() == $title->getNamespace()
- && $this->getDbkey() == $title->getDbkey();
+ && $this->getDbkey() === $title->getDbkey();
}
/**
/**
* Should a link should be displayed as a known link, just based on its title?
*
- * Currently, a self-link with a fragment, special pages and image pages are in
- * this category. Special pages never exist in the database. Some images do not
- * have description pages in the database, but the description page contains
- * useful history information that the user may want to link to.
+ * Currently, a self-link with a fragment and special pages are in
+ * this category. Special pages never exist in the database.
*/
function isAlwaysKnown() {
return $this->isExternal() || ( 0 == $this->mNamespace && "" == $this->mDbkeyform )
- || NS_SPECIAL == $this->mNamespace || NS_IMAGE == $this->mNamespace;
+ || NS_SPECIAL == $this->mNamespace;
}
/**
'pl_namespace' => $this->getNamespace(),
'pl_title' => $this->getDbKey() ),
$fname );
- if ( 0 == $dbw->numRows( $res ) ) {
- return;
- }
- $arr = array();
$toucharr = array();
while( $row = $dbw->fetchObject( $res ) ) {
$toucharr[] = $row->pl_from;
}
+ $dbw->freeResult( $res );
+
+ if( $this->getNamespace() == NS_CATEGORY ) {
+ // Categories show up in a separate set of links as well
+ $res = $dbw->select( 'categorylinks',
+ array( 'cl_from' ),
+ array( 'cl_to' => $this->getDbKey() ),
+ $fname );
+ while( $row = $dbw->fetchObject( $res ) ) {
+ $toucharr[] = $row->cl_from;
+ }
+ $dbw->freeResult( $res );
+ }
+
if (!count($toucharr))
return;
$dbw->update( 'page', /* SET */ array( 'page_touched' => $dbw->timestamp() ),