X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=fc99b5867fe4a8d07d00ee7b50578e35aaa92a16;hb=2979f0b6;hp=d0af17939f1103d1dfdf2737ea8ef0a431e35a2f;hpb=e4fc0b772130dd520f98b1db9e9313215569239e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d0af17939f..fc99b5867f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3798,11 +3798,14 @@ function wfGetNull() { * in maintenance scripts, to avoid causing too much lag. Of course, this is * a no-op if there are no slaves. * - * @param int|bool $maxLag (deprecated) + * @param float|null $ifWritesSince Only wait if writes were done since this UNIX timestamp * @param string|bool $wiki Wiki identifier accepted by wfGetLB * @param string|bool $cluster Cluster name accepted by LBFactory. Default: false. */ -function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) { +function wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = false ) { + // B/C: first argument used to be "max seconds of lag"; ignore such values + $ifWritesSince = ( $ifWritesSince > 1e9 ) ? $ifWritesSince : false; + if ( $cluster !== false ) { $lb = wfGetLBFactory()->getExternalLB( $cluster ); } else { @@ -3812,7 +3815,13 @@ function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) { // bug 27975 - Don't try to wait for slaves if there are none // Prevents permission error when getting master position if ( $lb->getServerCount() > 1 ) { + if ( $ifWritesSince && !$lb->isOpen( DB_MASTER ) ) { + return; // assume no writes done + } $dbw = $lb->getConnection( DB_MASTER, array(), $wiki ); + if ( $ifWritesSince && $dbw->lastDoneWrites() < $ifWritesSince ) { + return; // no writes since the last wait + } $pos = $dbw->getMasterPos(); // The DBMS may not support getMasterPos() or the whole // load balancer might be fake (e.g. $wgAllDBsAreLocalhost).