function unLock(eZContentObject $object) { $filterConds = array('action' => 'creating_translation', 'param' => $object->attribute('id')); $rows = eZPersistentObject::fetchObjectList(eZPendingActions::definition(), null, $filterConds); foreach ($rows as $row) { $row->remove(); } }
/** * Unit test for good eZPersistentObject (ORM) implementation for ezsite_data table */ public function testORMImplementation() { $def = eZPendingActions::definition(); $this->assertEquals('eZPendingActions', $def['class_name']); $this->assertEquals('ezpending_actions', $def['name']); $fields = $def['fields']; $this->assertArrayHasKey('action', $fields); $this->assertArrayHasKey('created', $fields); $this->assertArrayHasKey('param', $fields); }
/** * Same test as {@link self::testRemovePendingSearchSeveralNodesForObject()}, with not all nodes removed * Use case * -------- * 1. If all nodes are removed, pending action must also be removed * 2. If NOT all nodes are removed (at least one node remaining for object), pending action must NOT be removed (case tested here) * * @group issue_17932 */ public function testRemovePendingSearchNotAllNodesRemoved() { $this->folder->addNode( 43 ); $folderObjectID = $this->folder->object->attribute( 'id' ); $aNodeID = array( $this->folder->nodes[0]->attribute( 'node_id' ) ); // Only delete the first node eZContentOperationCollection::deleteObject( $aNodeID ); $filterConds = array( 'action' => 'index_object', 'param' => $folderObjectID ); $pendingCount = eZPersistentObject::count( eZPendingActions::definition(), $filterConds ); self::assertGreaterThan( 0, $pendingCount, "eZContentOperationCollection::deleteObject() must remove pending action for object #$folderObjectID as all nodes have been removed" ); }
/** * Clears view cache for imported content objects. * ObjectIDs are stored in 'ezpending_actions' table, with {@link SQLIContent::ACTION_CLEAR_CACHE} action */ public static function viewCacheClear() { $db = eZDB::instance(); $isCli = isset($_SERVER['argv']); $output = null; $progressBar = null; $i = 0; $conds = array('action' => SQLIContent::ACTION_CLEAR_CACHE); $limit = array('offset' => 0, 'length' => 50); $count = (int) eZPersistentObject::count(eZPendingActions::definition(), $conds); if ($isCli && $count > 0) { // Progress bar implementation $output = new ezcConsoleOutput(); $output->outputLine('Starting to clear view cache for imported objects...'); $progressBarOptions = array('emptyChar' => ' ', 'barChar' => '='); $progressBar = new ezcConsoleProgressbar($output, $count, $progressBarOptions); $progressBar->start(); } /* * To avoid fatal errors due to memory exhaustion, pending actions are fetched by packets */ do { $aObjectsToClear = eZPendingActions::fetchObjectList(eZPendingActions::definition(), null, $conds, null, $limit); $jMax = count($aObjectsToClear); if ($jMax > 0) { for ($j = 0; $j < $jMax; ++$j) { if ($isCli) { $progressBar->advance(); } $db->begin(); eZContentCacheManager::clearContentCacheIfNeeded((int) $aObjectsToClear[$j]->attribute('param')); $aObjectsToClear[$j]->remove(); $db->commit(); $i++; } } unset($aObjectsToClear); eZContentObject::clearCache(); if (eZINI::instance('site.ini')->variable('ContentSettings', 'StaticCache') == 'enabled') { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); $staticCacheHandler::executeActions(); } } while ($i < $count); if ($isCli && $count > 0) { $progressBar->finish(); $output->outputLine(); } }