From aca99a1fb1a3e32f2a2aa9586f118dada895398b Mon Sep 17 00:00:00 2001 From: Gunnstein Lye Date: Tue, 20 Jan 2015 13:49:50 +0100 Subject: [PATCH] Fix EZP-23908: expiry.php race condition Restore timestamps before saving, to reduce chance of race condition issues Simplified redundant code Removed unneeded parenthesis --- lib/ezutils/classes/ezexpiryhandler.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/ezutils/classes/ezexpiryhandler.php b/lib/ezutils/classes/ezexpiryhandler.php index de30359421c..2c4fb482116 100644 --- a/lib/ezutils/classes/ezexpiryhandler.php +++ b/lib/ezutils/classes/ezexpiryhandler.php @@ -61,6 +61,24 @@ static function fetchData( $path ) */ function store() { + if ( !$this->IsModified ) + { + return; + } + + // EZP-23908: Restore timestamps before saving, to reduce chance of race condition issues + $modifiedTimestamps = $this->Timestamps; + $this->restore(); + + // Apply timestamps that have been added or modified in this process + foreach ( $modifiedTimestamps as $name => $value ) + { + if ( $value > self::getTimestamp( $name, 0 ) ) + { + $this->setTimestamp( $name, $value ); + } + } + if ( $this->IsModified ) { $this->CacheFile->storeContents( "Timestamps, true ) . ";\n?>", 'expirycache', false, true );