From: Aaron Schulz Date: Thu, 1 Feb 2018 00:47:09 +0000 (-0800) Subject: Make interim WAN cache key deactivation logic broader X-Git-Tag: 1.31.0-rc.0~730^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=d5354b4a3a96f8e8d6c12eda9c7fa8a954f3ee7e;p=lhc%2Fweb%2Fwiklou.git Make interim WAN cache key deactivation logic broader * This is how it was before d5aa846d8, which accidentally changed the behavior. The WAN cache call in Setup.php was too coupled to the ChronologyProtector cookies. It made the assumption that DB positions and cookies are stored even when there are no replica databases setup (which changed in that patch). * Check the "UseDC" cookie instead, which is already set in exactly the cases this logic should apply. Bug: T185328 Change-Id: I4dd2a6ca6cdead0052d59be86e6030dbe01f141b --- diff --git a/includes/Setup.php b/includes/Setup.php index 01f67c8caf..c9fe8d0fe8 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -736,20 +736,22 @@ if ( !$wgDBerrorLogTZ ) { // Initialize the request object in $wgRequest $wgRequest = RequestContext::getMain()->getRequest(); // BackCompat -// Set user IP/agent information for causal consistency purposes. -// The cpPosIndex cookie has no prefix and is set by MediaWiki::preOutputCommit(). -$cpPosIndex = $wgRequest->getInt( 'cpPosIndex', (int)$wgRequest->getCookie( 'cpPosIndex', '' ) ); +// Set user IP/agent information for agent session consistency purposes MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [ 'IPAddress' => $wgRequest->getIP(), 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ), 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' ), - 'ChronologyPositionIndex' => $cpPosIndex + // The cpPosIndex cookie has no prefix and is set by MediaWiki::preOutputCommit() + 'ChronologyPositionIndex' => + $wgRequest->getInt( 'cpPosIndex', (int)$wgRequest->getCookie( 'cpPosIndex', '' ) ) ] ); -// Make sure that caching does not compromise the consistency improvements -if ( $cpPosIndex ) { +// Make sure that object caching does not undermine the ChronologyProtector improvements +if ( $wgRequest->getCookie( 'UseDC', '' ) === 'master' ) { + // The user is pinned to the primary DC, meaning that they made recent changes which should + // be reflected in their subsequent web requests. Avoid the use of interim cache keys because + // they use a blind TTL and could be stale if an object changes twice in a short time span. MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching( false ); } -unset( $cpPosIndex ); // Useful debug output if ( $wgCommandLineMode ) {