X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FTitle.php;h=3dd37d71788a554b3d645b417fdc794130caa45c;hb=d4c4c9edc7966c293e6128b217e8603223bcc1a7;hp=72c21fc33709dbd2a4e3ea2f2106916091c57f3f;hpb=aff17edd95620bff595dfa88013b422b38b1db2a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 72c21fc337..3dd37d7178 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -22,6 +22,7 @@ * @file */ use MediaWiki\Linker\LinkTarget; +use MediaWiki\Interwiki\InterwikiLookup; use MediaWiki\MediaWikiServices; /** @@ -170,6 +171,18 @@ class Title implements LinkTarget { return MediaWikiServices::getInstance()->getTitleFormatter(); } + /** + * B/C kludge: provide an InterwikiLookup for use by Title. + * Ideally, Title would have no methods that need this. + * Avoid usage of this singleton by using TitleValue + * and the associated services when possible. + * + * @return InterwikiLookup + */ + private static function getInterwikiLookup() { + return MediaWikiServices::getInstance()->getInterwikiLookup(); + } + /** * @access protected */ @@ -760,7 +773,7 @@ class Title implements LinkTarget { */ public function isLocal() { if ( $this->isExternal() ) { - $iw = Interwiki::fetch( $this->mInterwiki ); + $iw = self::getInterwikiLookup()->fetch( $this->mInterwiki ); if ( $iw ) { return $iw->isLocal(); } @@ -808,7 +821,7 @@ class Title implements LinkTarget { return false; } - return Interwiki::fetch( $this->mInterwiki )->isTranscludable(); + return self::getInterwikiLookup()->fetch( $this->mInterwiki )->isTranscludable(); } /** @@ -821,7 +834,7 @@ class Title implements LinkTarget { return false; } - return Interwiki::fetch( $this->mInterwiki )->getWikiID(); + return self::getInterwikiLookup()->fetch( $this->mInterwiki )->getWikiID(); } /** @@ -1677,7 +1690,7 @@ class Title implements LinkTarget { $query = self::fixUrlQueryArgs( $query, $query2 ); - $interwiki = Interwiki::fetch( $this->mInterwiki ); + $interwiki = self::getInterwikiLookup()->fetch( $this->mInterwiki ); if ( $interwiki ) { $namespace = $this->getNsText(); if ( $namespace != '' ) { @@ -1716,7 +1729,7 @@ class Title implements LinkTarget { if ( $url === false && $wgVariantArticlePath && preg_match( '/^variant=([^&]*)$/', $query, $matches ) - && $wgContLang->getCode() === $this->getPageLanguage()->getCode() + && $this->getPageLanguage()->equals( $wgContLang ) && $this->getPageLanguage()->hasVariants() ) { $variant = urldecode( $matches[1] ); @@ -2973,6 +2986,8 @@ class Title implements LinkTarget { /** * Purge expired restrictions from the page_restrictions table + * + * This will purge no more than $wgUpdateRowsPerQuery page_restrictions rows */ static function purgeExpiredRestrictions() { if ( wfReadOnly() ) { @@ -2983,11 +2998,24 @@ class Title implements LinkTarget { wfGetDB( DB_MASTER ), __METHOD__, function ( IDatabase $dbw, $fname ) { - $dbw->delete( + $config = MediaWikiServices::getInstance()->getMainConfig(); + $ids = $dbw->selectFieldValues( 'page_restrictions', + 'pr_id', [ 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ], - $fname + $fname, + [ 'LIMIT' => $config->get( 'UpdateRowsPerQuery' ) ] // T135470 ); + if ( $ids ) { + $dbw->delete( 'page_restrictions', [ 'pr_id' => $ids ], $fname ); + } + } + ) ); + + DeferredUpdates::addUpdate( new AtomicSectionUpdate( + wfGetDB( DB_MASTER ), + __METHOD__, + function ( IDatabase $dbw, $fname ) { $dbw->delete( 'protected_titles', [ 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ], @@ -4343,7 +4371,6 @@ class Title implements LinkTarget { $conds = $this->pageCond(); $dbw->onTransactionIdle( function () use ( $dbw, $conds, $method, $purgeTime ) { $dbTimestamp = $dbw->timestamp( $purgeTime ?: time() ); - $dbw->update( 'page', [ 'page_touched' => $dbTimestamp ], @@ -4526,10 +4553,10 @@ class Title implements LinkTarget { * @return bool */ public function canUseNoindex() { - global $wgContentNamespaces, $wgExemptFromUserRobotsControl; + global $wgExemptFromUserRobotsControl; $bannedNamespaces = is_null( $wgExemptFromUserRobotsControl ) - ? $wgContentNamespaces + ? MWNamespace::getContentNamespaces() : $wgExemptFromUserRobotsControl; return !in_array( $this->mNamespace, $bannedNamespaces );