Skip to content

Commit

Permalink
Fix EZP-23908: expiry.php race condition
Browse files Browse the repository at this point in the history
Restore timestamps before saving, to reduce chance of race condition issues
Simplified redundant code
Removed unneeded parenthesis
  • Loading branch information
glye committed Jan 26, 2015
1 parent 1621d93 commit aca99a1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/ezutils/classes/ezexpiryhandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( "<?php\n\$Timestamps = " . var_export( $this->Timestamps, true ) . ";\n?>", 'expirycache', false, true );
Expand Down

0 comments on commit aca99a1

Please sign in to comment.