*/
$wgCdnReboundPurgeDelay = 0;
+/**
+ * Cache timeout for the CDN when a response is known to be wrong or incomplete (due to load)
+ * @see $wgSquidMaxage
+ * @since 1.27
+ */
+$wgCdnMaxageSubstitute = 60;
+
/**
* Default maximum age for raw CSS/JS accesses
*
$request->response()->header( "X-Database-Lagged: true" );
wfDebugLog( 'replication', "Lagged DB used; CDN cache TTL limited to $maxAge seconds" );
}
+
+ // Avoid long-term cache pollution due to message cache rebuild timeouts (T133069)
+ if ( MessageCache::singleton()->isDisabled() ) {
+ $maxAge = $config->get( 'CdnMaxageSubstitute' );
+ $context->getOutput()->lowerCdnMaxage( $maxAge );
+ $request->response()->header( "X-Response-Substitute: true" );
+ }
}
/**
protected $mCache;
/**
- * Should mean that database cannot be used, but check
+ * Should mean that database cannot be used, but check
* @var bool $mDisable
*/
protected $mDisable;
$where[] = 'loading FAILED - cache is disabled';
$this->mDisable = true;
$this->mCache = false;
+ wfDebugLog( 'MessageCacheError', __METHOD__ . ": Failed to load $code\n" );
# This used to throw an exception, but that led to nasty side effects like
# the whole wiki being instantly down if the memcached server died
} else {
$this->mDisable = false;
}
+ /**
+ * Whether DB/cache usage is disabled for determining messages
+ *
+ * If so, this typically indicates either:
+ * - a) load() failed to find a cached copy nor query the DB
+ * - b) we are in a special context or error mode that cannot use the DB
+ * If the DB is ignored, any derived HTML output or cached objects may be wrong.
+ * To avoid long-term cache pollution, TTLs can be adjusted accordingly.
+ *
+ * @return bool
+ * @since 1.27
+ */
+ public function isDisabled() {
+ return $this->mDisable;
+ }
+
/**
* Clear all stored messages. Mainly used after a mass rebuild.
*/
$cache = ObjectCache::getMainWANInstance();
$sidebar = $cache->getWithSetCallback(
$cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
- $wgSidebarCacheExpiry,
+ MessageCache::singleton()->isDisabled()
+ ? $cache::TTL_UNCACHEABLE // bug T133069
+ : $wgSidebarCacheExpiry,
$callback,
[ 'lockTSE' => 30 ]
);