X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FTitle.php;h=849707e38b91bb11191bddc4941d9843d41a1994;hb=d37ab34a870ec65b5cd678882ffdff4a8795f8dd;hp=34966686b9cbc16d3f3125e5ccef1b6944f1344f;hpb=8a2be2c599d6361cee2f93219cb4b8f03d2c8189;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 34966686b9..849707e38b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -38,7 +38,7 @@ use MediaWiki\MediaWikiServices; */ class Title implements LinkTarget, IDBAccessObject { /** @var MapCacheLRU */ - static private $titleCache = null; + private static $titleCache = null; /** * Title::newFromText maintains a cache to avoid expensive re-normalization of @@ -205,7 +205,7 @@ class Title implements LinkTarget, IDBAccessObject { } /** - * @access protected + * @protected */ function __construct() { } @@ -767,23 +767,6 @@ class Title implements LinkTarget, IDBAccessObject { return $name; } - /** - * Escape a text fragment, say from a link, for a URL - * - * @deprecated since 1.30, use Sanitizer::escapeIdForLink() or escapeIdForExternalInterwiki() - * - * @param string $fragment Containing a URL or link fragment (after the "#") - * @return string Escaped string - */ - static function escapeFragmentForURL( $fragment ) { - wfDeprecated( __METHOD__, '1.30' ); - # Note that we don't urlencode the fragment. urlencoded Unicode - # fragments appear not to work in IE (at least up to 7) or in at least - # one version of Opera 9.x. The W3C validator, for one, doesn't seem - # to care if they aren't encoded. - return Sanitizer::escapeId( $fragment, 'noninitial' ); - } - /** * Callback for usort() to do title sorts by (namespace, title) * @@ -1071,17 +1054,6 @@ class Title implements LinkTarget, IDBAccessObject { getNsText( MWNamespace::getTalk( $this->mNamespace ) ); } - /** - * Can this title have a corresponding talk page? - * - * @deprecated since 1.30, use canHaveTalkPage() instead. - * - * @return bool True if this title either is a talk page or can have a talk page associated. - */ - public function canTalk() { - return $this->canHaveTalkPage(); - } - /** * Can this title have a corresponding talk page? * @@ -1308,17 +1280,6 @@ class Title implements LinkTarget, IDBAccessObject { ); } - /** - * @return bool - * @deprecated Since 1.31; use ::isSiteConfigPage() instead (which also checks for JSON pages) - */ - public function isCssOrJsPage() { - wfDeprecated( __METHOD__, '1.31' ); - return ( NS_MEDIAWIKI == $this->mNamespace - && ( $this->hasContentModel( CONTENT_MODEL_CSS ) - || $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) ) ); - } - /** * Is this a "config" (.css, .json, or .js) sub-page of a user page? * @@ -1333,17 +1294,6 @@ class Title implements LinkTarget, IDBAccessObject { ); } - /** - * @return bool - * @deprecated Since 1.31; use ::isUserConfigPage() instead (which also checks for JSON pages) - */ - public function isCssJsSubpage() { - wfDeprecated( __METHOD__, '1.31' ); - return ( NS_USER == $this->mNamespace && $this->isSubpage() - && ( $this->hasContentModel( CONTENT_MODEL_CSS ) - || $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) ) ); - } - /** * Trim down a .css, .json, or .js subpage title to get the corresponding skin name * @@ -1360,15 +1310,6 @@ class Title implements LinkTarget, IDBAccessObject { return substr( $subpage, 0, $lastdot ); } - /** - * @deprecated Since 1.31; use ::getSkinFromConfigSubpage() instead - * @return string Containing skin name from .css, .json, or .js subpage title - */ - public function getSkinFromCssJsSubpage() { - wfDeprecated( __METHOD__, '1.31' ); - return $this->getSkinFromConfigSubpage(); - } - /** * Is this a CSS "config" sub-page of a user page? * @@ -1383,15 +1324,6 @@ class Title implements LinkTarget, IDBAccessObject { ); } - /** - * @deprecated Since 1.31; use ::isUserCssConfigPage() - * @return bool - */ - public function isCssSubpage() { - wfDeprecated( __METHOD__, '1.31' ); - return $this->isUserCssConfigPage(); - } - /** * Is this a JSON "config" sub-page of a user page? * @@ -1420,15 +1352,6 @@ class Title implements LinkTarget, IDBAccessObject { ); } - /** - * @deprecated Since 1.31; use ::isUserJsConfigPage() - * @return bool - */ - public function isJsSubpage() { - wfDeprecated( __METHOD__, '1.31' ); - return $this->isUserJsConfigPage(); - } - /** * Is this a sitewide CSS "config" page? * @@ -1609,11 +1532,15 @@ class Title implements LinkTarget, IDBAccessObject { public function getFragmentForURL() { if ( !$this->hasFragment() ) { return ''; - } elseif ( $this->isExternal() - && !self::getInterwikiLookup()->fetch( $this->mInterwiki )->isLocal() - ) { - return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->mFragment ); + } elseif ( $this->isExternal() ) { + // Note: If the interwiki is unknown, it's treated as a namespace on the local wiki, + // so we treat it like a local interwiki. + $interwiki = self::getInterwikiLookup()->fetch( $this->mInterwiki ); + if ( $interwiki && !$interwiki->isLocal() ) { + return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->mFragment ); + } } + return '#' . Sanitizer::escapeIdForLink( $this->mFragment ); } @@ -1831,7 +1758,7 @@ class Title implements LinkTarget, IDBAccessObject { * @endcode * * @param string $text The subpage name to add to the title - * @return Title Subpage title + * @return Title|null Subpage title, or null on an error * @since 1.20 */ public function getSubpage( $text ) { @@ -2699,20 +2626,28 @@ class Title implements LinkTarget, IDBAccessObject { } // Determine if the user is blocked from this action on this page. - // What gets passed into this method is a user right, not an action nmae. + // What gets passed into this method is a user right, not an action name. // There is no way to instantiate an action by restriction. However, this // will get the action where the restriction is the same. This may result // in actions being blocked that shouldn't be. + $actionObj = null; if ( Action::exists( $action ) ) { + // Clone the title to prevent mutations to this object which is done + // by Title::loadFromRow() in WikiPage::loadFromRow(). + $page = WikiPage::factory( clone $this ); + // Creating an action will perform several database queries to ensure that + // the action has not been overridden by the content type. // @todo FIXME: Pass the relevant context into this function. - $action = Action::factory( $action, WikiPage::factory( $this ), RequestContext::getMain() ); - } else { - $action = null; + $actionObj = Action::factory( $action, $page, RequestContext::getMain() ); + // Ensure that the retrieved action matches the restriction. + if ( $actionObj && $actionObj->getRestriction() !== $action ) { + $actionObj = null; + } } // If no action object is returned, assume that the action requires unblock // which is the default. - if ( !$action || $action->requiresUnblock() ) { + if ( !$actionObj || $actionObj->requiresUnblock() ) { if ( $user->isBlockedFrom( $this, $useReplica ) ) { // @todo FIXME: Pass the relevant context into this function. $errors[] = $block @@ -4008,13 +3943,6 @@ class Title implements LinkTarget, IDBAccessObject { return $urls; } - /** - * @deprecated since 1.27 use getCdnUrls() - */ - public function getSquidURLs() { - return $this->getCdnUrls(); - } - /** * Purge all applicable CDN URLs */