Skip to content

Commit

Permalink
Merge pull request ezsystems#1133 from joaoinacio/async_publishing_ex…
Browse files Browse the repository at this point in the history
…piry

Fix EZP-23870: async publishing caused stale expiry timestamps.
  • Loading branch information
João Inácio committed Jan 14, 2015
2 parents 19b001c + e31c64d commit 1621d93
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions kernel/private/classes/ezpcontentpublishingqueueprocessor.php
Expand Up @@ -33,6 +33,9 @@ public function __construct()
$this->cleanupInterval = $this->contentINI->variable( 'PublishingSettings', 'AsynchronousCleanupInterval' );
$this->cleanupAgeLimit = $this->contentINI->variable( 'PublishingSettings', 'AsynchronousCleanupAgeLimit' );

// initiate current time for cache refresh
$this->lastRefreshTimestamp = time();

// Queue reader handler
$this->queueReader = $this->contentINI->variable( 'PublishingSettings', 'AsynchronousPublishingQueueReader' );
$reflection = new ReflectionClass( $this->queueReader );
Expand Down Expand Up @@ -109,6 +112,8 @@ public function run()
'async.log'
);

$this->refreshCacheStateInfo();

$pid = $publishingItem->publish();
pcntl_signal( SIGINT, $this->signalHandler );
$this->currentJobs[$pid] = $publishingItem;
Expand Down Expand Up @@ -138,6 +143,22 @@ public function run()
}
}

/**
* Refreshes/reloads cache and other state information periodically.
*/
private function refreshCacheStateInfo()
{
if ( time() < ( $this->lastRefreshTimestamp + $this->sleepInterval ) )
{
return;
}

// Reload expiry timestamps
eZExpiryHandler::instance()->restore();

$this->lastRefreshTimestamp = time();
}

/**
* Checks WORKING processes, and removes from the queue those who are dead
*
Expand Down Expand Up @@ -353,6 +374,12 @@ private function getNextItem()
*/
private $cleanupLastTime;

/**
* Time counter for refresh of cache/state information
* @var int
*/
private $lastRefreshTimestamp;

/**
* Interval for cleanup of finished processes. Default value is 12 hours in seconds
* @var int
Expand Down

0 comments on commit 1621d93

Please sign in to comment.