X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FMessageCache.php;h=157d88eb34da27cd16dbaee86fc82b27a69bb7b1;hb=9fc202b69496353a1142a692be5aaf158e9ea30c;hp=b669fcd492c1597bf003236fa5d29efb20ace0cb;hpb=7ddab17aac1103fa080b50759ab6ca906caa554e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index b669fcd492..157d88eb34 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -48,7 +48,7 @@ class MessageCache { /** * Process cache of loaded messages that are defined in MediaWiki namespace * - * @var MapCacheLRU Map of (language code => key => " " or "!TOO BIG") + * @var MapCacheLRU Map of (language code => key => " " or "!TOO BIG" or "!ERROR") */ protected $cache; @@ -535,27 +535,33 @@ class MessageCache { } // Set the text for small software-defined messages in the main cache map + $revisionStore = MediaWikiServices::getInstance()->getRevisionStore(); + $revQuery = $revisionStore->getQueryInfo( [ 'page', 'user' ] ); $res = $dbr->select( - [ 'page', 'revision', 'text' ], - [ 'page_title', 'page_latest', 'old_id', 'old_text', 'old_flags' ], - array_merge( $conds, [ 'page_len <= ' . intval( $wgMaxMsgCacheEntrySize ) ] ), + $revQuery['tables'], + $revQuery['fields'], + array_merge( $conds, [ + 'page_len <= ' . intval( $wgMaxMsgCacheEntrySize ), + 'page_latest = rev_id' // get the latest revision only + ] ), __METHOD__ . "($code)-small", [], - [ - 'revision' => [ 'JOIN', 'page_latest=rev_id' ], - 'text' => [ 'JOIN', 'rev_text_id=old_id' ], - ] + $revQuery['joins'] ); foreach ( $res as $row ) { $name = $this->contLang->lcfirst( $row->page_title ); // Include entries/stubs for all keys in $mostused in adaptive mode if ( $wgAdaptiveMessageCache || $this->isMainCacheable( $name, $overridable ) ) { - $text = Revision::getRevisionText( $row ); - if ( $text === false ) { - // Failed to fetch data; possible ES errors? - // Store a marker to fetch on-demand as a workaround... - // TODO Use a differnt marker - $entry = '!TOO BIG'; + try { + $rev = $revisionStore->newRevisionFromRow( $row ); + $content = $rev->getContent( MediaWiki\Revision\SlotRecord::MAIN ); + $text = $this->getMessageTextFromContent( $content ); + } catch ( Exception $ex ) { + $text = false; + } + + if ( !is_string( $text ) ) { + $entry = '!ERROR'; wfDebugLog( 'MessageCache', __METHOD__ @@ -1049,7 +1055,7 @@ class MessageCache { if ( $entry !== null ) { // Message page exists as an override of a software messages if ( substr( $entry, 0, 1 ) === ' ' ) { - // The message exists and is not '!TOO BIG' + // The message exists and is not '!TOO BIG' or '!ERROR' return (string)substr( $entry, 1 ); } elseif ( $entry === '!NONEXISTENT' ) { // The text might be '-' or missing due to some data loss