Skip to content

Commit

Permalink
Merge pull request #1139 from glye/ezp-23908_expiry_php_race_condition
Browse files Browse the repository at this point in the history
Fix EZP-23908: expiry.php race condition
  • Loading branch information
glye committed Jan 26, 2015
2 parents 1621d93 + aca99a1 commit c7caced
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 c7caced

Please sign in to comment.