From: Aaron Schulz Date: Fri, 9 Feb 2018 19:28:59 +0000 (-0800) Subject: Avoid pointless DB_MASTER connections in User::clearSharedCache() X-Git-Tag: 1.31.0-rc.0~650^2 X-Git-Url: http://git.cyclocoop.org/data/%27%20.%20mediabox_timestamp%28find_in_path%28%27javascript/%7B%24www_url%7Dadmin/compta/operations/%40%20%27info_etape_suivante_2%27%20=%3E%20%27You%20can%20move%20on%20to%20the%20next%20step.%27%2C%20%27info_exceptions_proxy%27%20=%3E%20%27Exceptions%20for%20the%20proxy%27%2C%20%27info_exportation_base%27%20=%3E%20%27export%20database%20to%20%40archive%40%27%2C-%27info_facilite_suivi_activite%27%20=%3E%20%27To%20simplify%20monitoring%20of%20the%20site/%27s%20editorial;-%20%20activities%2C%20SPIP%20can%20send%20rmail%20notifications%2C%20e.g.%20to%20an%20editors/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=36dfd18409e414f4df2aef016753a8cb637b6bac;p=lhc%2Fweb%2Fwiklou.git Avoid pointless DB_MASTER connections in User::clearSharedCache() Change-Id: Ifc4f489cea4460185cb2d8317f174cabd67f5862 --- diff --git a/includes/user/User.php b/includes/user/User.php index 97035c2dab..eeade49db6 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -2509,12 +2509,17 @@ class User implements IDBAccessObject, UserIdentity { if ( $mode === 'refresh' ) { $cache->delete( $key, 1 ); } else { - wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle( - function () use ( $cache, $key ) { - $cache->delete( $key ); - }, - __METHOD__ - ); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); + if ( $lb->hasOrMadeRecentMasterChanges() ) { + $lb->getConnection( DB_MASTER )->onTransactionPreCommitOrIdle( + function () use ( $cache, $key ) { + $cache->delete( $key ); + }, + __METHOD__ + ); + } else { + $cache->delete( $key ); + } } }