/** * Checks WORKING processes, and removes from the queue those who are dead * * @return void */ private function cleanupDeadProcesses() { $processes = ezpContentPublishingProcess::fetchProcesses(ezpContentPublishingProcess::STATUS_WORKING); foreach ($processes as $process) { if (!$process->isAlive()) { $process->reset(); } } }
/** * Removes FINISHED processes rows from the db (in one db call) * method self-manages the removal, based on the defined cleanupInterval and cleanupAgeLimit * * @return void */ private function cleanupFinishedProcesses() { if ( time() < ( $this->cleanupLastTime + $this->cleanupInterval ) ) { return; } $processes = count( ezpContentPublishingProcess::fetchProcesses( ezpContentPublishingProcess::STATUS_FINISHED ) ); if ( $processes > 0 ) { //Remove all objects at once // this is required as the MySQL connection might be closed anytime by a fork try { eZDebug::writeNotice( "ASYNC:: removing processes entries marked as STATUS_FINISHED in database."); $db = eZDB::instance(); eZDB::setInstance( null ); $deleteBefore = time() - $this->cleanupAgeLimit; $definition = ezpContentPublishingProcess::definition(); $processTable = $definition['name']; $db->query( "DELETE from ". $processTable. " WHERE status =". ezpContentPublishingProcess::STATUS_FINISHED. " AND finished < ". $deleteBefore ); $this->cleanupLastTime = time(); } catch( eZDBException $e ) { // Do nothing, this will be retried until the DB is back up } } }