Skip to content

Instantly share code, notes, and snippets.

@bvibber
Created September 27, 2011 00:10
Show Gist options
  • Save bvibber/1243845 to your computer and use it in GitHub Desktop.
Save bvibber/1243845 to your computer and use it in GitHub Desktop.
tweak to MessageCache::loadFromDB
Index: includes/cache/MessageCache.php
===================================================================
--- includes/cache/MessageCache.php (revision 98199)
+++ includes/cache/MessageCache.php (working copy)
@@ -428,7 +428,16 @@
);
foreach ( $res as $row ) {
- $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row );
+ $text = Revision::getRevisionText( $row );
+ if( $text === false ) {
+ // Failed to fetch data; possible ES errors?
+ // Store a marker to fetch on-demand as a workaround...
+ $entry = '!TOO BIG';
+ wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$row->page_title} ($code)" );
+ } else {
+ $entry = ' ' . $text;
+ }
+ $cache[$row->page_title] = $entry;
}
foreach ( $mostused as $key ) {
@@ -741,8 +750,13 @@
$revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) );
if ( $revision ) {
$message = $revision->getText();
- $this->mCache[$code][$title] = ' ' . $message;
- $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry );
+ if ($message === false) {
+ // A possibly temporary loading failure.
+ wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title->getDbKey()} ($code)" );
+ } else {
+ $this->mCache[$code][$title] = ' ' . $message;
+ $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry );
+ }
} else {
$message = false;
$this->mCache[$code][$title] = '!NONEXISTENT';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment