- // Try loading the message from the database
- $dbr = wfGetDB( DB_REPLICA );
- $cacheOpts = Database::getCacheSetOptions( $dbr );
- // Use newKnownCurrent() to avoid querying revision/user tables
- $titleObj = Title::makeTitle( NS_MEDIAWIKI, $title );
- if ( $titleObj->getLatestRevID() ) {
- $revision = Revision::newKnownCurrent(
- $dbr,
- $titleObj
- );
- } else {
- $revision = false;
- }
+ $this->cache->setField( $code, $title, '!NONEXISTENT' );
+
+ return false;
+ }
+
+ /**
+ * @param string $dbKey
+ * @param string $code
+ * @param string $hash
+ * @return string Either " <MESSAGE>" or "!NONEXISTANT"
+ */
+ private function loadCachedMessagePageEntry( $dbKey, $code, $hash ) {
+ return $this->wanCache->getWithSetCallback(
+ $this->bigMessageCacheKey( $hash, $dbKey ),
+ $this->mExpiry,
+ function ( $oldValue, &$ttl, &$setOpts ) use ( $dbKey, $code ) {
+ // Try loading the message from the database
+ $dbr = wfGetDB( DB_REPLICA );
+ $setOpts += Database::getCacheSetOptions( $dbr );
+ // Use newKnownCurrent() to avoid querying revision/user tables
+ $title = Title::makeTitle( NS_MEDIAWIKI, $dbKey );
+ $revision = Revision::newKnownCurrent( $dbr, $title );
+ if ( !$revision ) {
+ return '!NONEXISTENT';
+ }
+ $content = $revision->getContent();
+ if ( $content ) {
+ $message = $this->getMessageTextFromContent( $content );
+ } else {
+ LoggerFactory::getInstance( 'MessageCache' )->warning(
+ __METHOD__ . ': failed to load page text for \'{titleKey}\'',
+ [ 'titleKey' => $dbKey, 'code' => $code ]
+ );
+ $message = null;
+ }