$this->doPostOutputShutdown( 'normal' );
}
+ /**
+ * @see MediaWiki::preOutputCommit()
+ * @since 1.26
+ */
+ public function doPreOutputCommit() {
+ self::preOutputCommit( $this->context );
+ }
+
/**
* This function commits all DB changes as needed before
* the user can receive a response (in case commit fails)
*
- * @since 1.26
+ * @param IContextSource $context
+ * @since 1.27
*/
- public function doPreOutputCommit() {
+ public static function preOutputCommit( IContextSource $context ) {
// Either all DBs should commit or none
ignore_user_abort( true );
// Set a cookie to tell all CDN edge nodes to "stick" the user to the
// DC that handles this POST request (e.g. the "master" data center)
- $request = $this->context->getRequest();
+ $request = $context->getRequest();
+ $config = $context->getConfig();
if ( $request->wasPosted() && $factory->hasOrMadeRecentMasterChanges() ) {
- $expires = time() + $this->config->get( 'DataCenterUpdateStickTTL' );
- $request->response()->setCookie( 'UseDC', 'master', $expires );
+ $expires = time() + $config->get( 'DataCenterUpdateStickTTL' );
+ $request->response()->setCookie( 'UseDC', 'master', $expires, array( 'prefix' => '' ) );
}
// Avoid letting a few seconds of slave lag cause a month of stale data
if ( $factory->laggedSlaveUsed() ) {
- $maxAge = $this->config->get( 'CdnMaxageLagged' );
- $this->context->getOutput()->lowerCdnMaxage( $maxAge );
+ $maxAge = $config->get( 'CdnMaxageLagged' );
+ $context->getOutput()->lowerCdnMaxage( $maxAge );
$request->response()->header( "X-Database-Lagged: true" );
wfDebugLog( 'replication', "Lagged DB used; CDN cache TTL limited to $maxAge seconds" );
}
// Log the request whether or not there was an error
$this->logRequest( microtime( true ) - $t );
+ // Commit DBs and send any related cookies and headers
+ MediaWiki::preOutputCommit( $this->getContext() );
+
// Send cache headers after any code which might generate an error, to
// avoid sending public cache headers for errors.
$this->sendCacheHeaders( $isError );