From 67670358407b4bb527d42b6059ce39cbd2402b2b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 3 Oct 2018 18:01:29 -0400 Subject: [PATCH] Make UID clock drift error have more details. Change-Id: Ic682e48b06161c2a286f5da9016f4831ee72a31e --- includes/utils/UIDGenerator.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/utils/UIDGenerator.php b/includes/utils/UIDGenerator.php index 52740c9952..4b5410e2f1 100644 --- a/includes/utils/UIDGenerator.php +++ b/includes/utils/UIDGenerator.php @@ -475,11 +475,12 @@ class UIDGenerator { // microtime() and gettimeofday() can drift from time() at least on Windows. // The drift is immediate for processes running while the system clock changes. // time() does not have this problem. See https://bugs.php.net/bug.php?id=42659. - if ( abs( time() - $time[0] ) >= 2 ) { + $drift = time() - $time[0]; + if ( abs( $drift ) >= 2 ) { // We don't want processes using too high or low timestamps to avoid duplicate // UIDs and clock sequence number churn. This process should just be restarted. flock( $handle, LOCK_UN ); // abort - throw new RuntimeException( "Process clock is outdated or drifted." ); + throw new RuntimeException( "Process clock is outdated or drifted ({$drift}s)." ); } // If microtime() is synced and a clock change was detected, then the clock went back if ( $clockChanged ) { -- 2.20.1