X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=blobdiff_plain;f=includes%2FTitle.php;h=0f458395774dd1ab1c32b6443da18e9b17c1c442;hb=de398a4395f1ca23c107401fadbac880fcef4c57;hp=82e79b379c009e3af7b2a2beed4c81cf458bbc0a;hpb=ba32e133e97b0f1f6b9ddb7e3c7a9cc79d0be977;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 82e79b379c..0f45839577 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -437,6 +437,7 @@ class Title implements LinkTarget, IDBAccessObject { } else { $title = null; } + return $title; } @@ -3254,8 +3255,9 @@ class Title implements LinkTarget, IDBAccessObject { } if ( $this->mOldRestrictions === false ) { - $this->mOldRestrictions = $dbr->selectField( 'page', 'page_restrictions', - [ 'page_id' => $this->getArticleID() ], __METHOD__ ); + $linkCache = MediaWikiServices::getInstance()->getLinkCache(); + $linkCache->addLinkObj( $this ); # in case we already had an article ID + $this->mOldRestrictions = $linkCache->getGoodLinkFieldObj( $this, 'restrictions' ); } if ( $this->mOldRestrictions != '' ) { @@ -3340,12 +3342,17 @@ class Title implements LinkTarget, IDBAccessObject { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $rows = $cache->getWithSetCallback( // Page protections always leave a new null revision - $cache->makeKey( 'page-restrictions', $id, $this->getLatestRevID() ), + $cache->makeKey( 'page-restrictions', 'v1', $id, $this->getLatestRevID() ), $cache::TTL_DAY, function ( $curValue, &$ttl, array &$setOpts ) use ( $loadRestrictionsFromDb ) { $dbr = wfGetDB( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); + if ( $lb->hasOrMadeRecentMasterChanges() ) { + // @TODO: cleanup Title cache and caller assumption mess in general + $ttl = WANObjectCache::TTL_UNCACHEABLE; + } return $loadRestrictionsFromDb( $dbr ); } @@ -3720,6 +3727,7 @@ class Title implements LinkTarget, IDBAccessObject { // @todo: get rid of secureAndSplit, refactor parsing code. // @note: getTitleParser() returns a TitleParser implementation which does not have a // splitTitleString method, but the only implementation (MediaWikiTitleCodec) does + /** @var MediaWikiTitleCodec $titleCodec */ $titleCodec = MediaWikiServices::getInstance()->getTitleParser(); // MalformedTitleException can be thrown here $parts = $titleCodec->splitTitleString( $this->mDbkeyform, $this->mDefaultNamespace ); @@ -4995,9 +5003,7 @@ class Title implements LinkTarget, IDBAccessObject { public function canUseNoindex() { global $wgExemptFromUserRobotsControl; - $bannedNamespaces = is_null( $wgExemptFromUserRobotsControl ) - ? MWNamespace::getContentNamespaces() - : $wgExemptFromUserRobotsControl; + $bannedNamespaces = $wgExemptFromUserRobotsControl ?? MWNamespace::getContentNamespaces(); return !in_array( $this->mNamespace, $bannedNamespaces ); }