/**
  * Clears view caches of nodes, parent nodes and relating nodes
  * of content objects with ids contained in $objectIDList.
  * It will use 'viewcache.ini' to determine additional nodes.
  *
  * @see clearObjectViewCache
  *
  * @param array $objectIDList List of object ID
  */
 public static function clearObjectViewCacheArray(array $objectIDList)
 {
     eZDebug::accumulatorStart('node_cleanup_list', '', 'Node cleanup list');
     $nodeList = array();
     foreach ($objectIDList as $objectID) {
         $tempNodeList = self::nodeList($objectID, true);
         if ($tempNodeList !== false) {
             $nodeList = array_merge($nodeList, $tempNodeList);
         }
     }
     $nodeList = array_unique($nodeList);
     eZDebug::accumulatorStop('node_cleanup_list');
     eZDebugSetting::writeDebug('kernel-content-edit', count($nodeList), "count in nodeList");
     if (eZINI::instance()->variable('ContentSettings', 'StaticCache') === 'enabled') {
         $staticCacheHandler = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler')));
         $staticCacheHandler->generateAlwaysUpdatedCache();
         $staticCacheHandler->generateNodeListCache($nodeList);
     }
     eZDebug::accumulatorStart('node_cleanup', '', 'Node cleanup');
     $nodeList = ezpEvent::getInstance()->filter('content/cache', $nodeList);
     eZContentObject::expireComplexViewModeCache();
     $cleanupValue = eZContentCache::calculateCleanupValue(count($nodeList));
     if (eZContentCache::inCleanupThresholdRange($cleanupValue)) {
         eZContentCache::cleanup($nodeList);
     } else {
         eZDebug::writeDebug("Expiring all view cache since list of nodes({$cleanupValue}) exceeds site.ini\\[ContentSettings]\\CacheThreshold", __METHOD__);
         eZContentObject::expireAllViewCache();
     }
     eZDebug::accumulatorStop('node_cleanup');
     return true;
 }
示例#2
0
         if ($node === null) {
             return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
         }
         if ($object === null) {
             return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
         }
         if (!$object->attribute('can_read')) {
             return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
         }
         if (!$node->attribute('can_pdf')) {
             return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
         }
         if ($node->attribute('is_invisible') && !eZContentObjectTreeNode::showInvisibleNodes()) {
             return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
         }
         $cachePathInfo = eZContentCache::cachePathInfo($designSetting, $NodeID, 'pdf', $language, $Offset, $roleList, $discountList, $layout, false, array('view_parameters' => $viewParameters));
         $node = eZContentObjectTreeNode::fetch($NodeID);
         contentPDFGenerate($cachePathInfo['path'], $node, false, $viewCacheEnabled, $LanguageCode, $viewParameters);
         if ($viewCacheEnabled) {
             eZDebugSetting::writeDebug('kernel-content-pdf-cache', 'cache written', 'content/pdf');
         }
         contentPDFPassthrough($cachePathInfo['path']);
     }
     break;
 case eZModuleOperationInfo::STATUS_HALTED:
     if (isset($operationResult['redirect_url'])) {
         $Module->redirectTo($operationResult['redirect_url']);
         return;
     } else {
         if (isset($operationResult['result'])) {
             $result = $operationResult['result'];
    static function store( $siteDesign, $objectID, $classID, $classIdentifier,
                    $nodeID, $parentNodeID, $nodeDepth, $urlAlias, $viewMode, $sectionID,
                    $language, $offset, $roleList, $discountList, $layout, $navigationPartIdentifier,
                    $result, $cacheTTL = -1,
                    $parameters = array() )
    {
        $cachePathInfo = eZContentCache::cachePathInfo( $siteDesign, $nodeID, $viewMode, $language, $offset, $roleList, $discountList,
                                                        $layout, false, $parameters );
        $cacheDir = $cachePathInfo['dir'];
        $cacheFile = $cachePathInfo['file'];

        $serializeArray = array();

        if ( isset( $parameters['view_parameters']['offset'] ) )
        {
            $offset = $parameters['view_parameters']['offset'];
        }
        $viewParameters = false;
        if ( isset( $parameters['view_parameters'] ) )
        {
            $viewParameters = $parameters['view_parameters'];
        }
        $contentInfo = array( 'site_design' => $siteDesign,
                              'node_id' => $nodeID,
                              'parent_node_id' => $parentNodeID,
                              'node_depth' => $nodeDepth,
                              'url_alias' => $urlAlias,
                              'object_id' => $objectID,
                              'class_id' => $classID,
                              'class_identifier' => $classIdentifier,
                              'navigation_part' => $navigationPartIdentifier,
                              'viewmode' => $viewMode,
                              'language' => $language,
                              'offset' => $offset,
                              'view_parameters' => $viewParameters,
                              'role_list' => $roleList,
                              'discount_list' => $discountList,
                              'section_id' => $result['section_id'] );

        $serializeArray['content_info'] = $contentInfo;

        foreach ( array( 'path', 'node_id', 'section_id', 'navigation_part' ) as $item )
        {
            if ( isset( $result[$item] ) )
            {
                $serializeArray[$item] = $result[$item];
            }
        }

        $serializeArray['cache_ttl'] = $cacheTTL;

        $serializeArray['cache_code_date'] = self::CODE_DATE;
        $serializeArray['content'] = $result['content'];

        $serializeString = serialize( $serializeArray );

        if ( !file_exists( $cacheDir ) )
        {
            eZDir::mkdir( $cacheDir, false, true );
        }

        $path = $cacheDir . '/' . $cacheFile;
        $uniqid = md5( uniqid( 'ezpcache'. getmypid(), true ) );

        $file = eZClusterFileHandler::instance( "$cacheDir/$uniqid" );
        $file->storeContents( $serializeString, 'viewcache', 'pdf' );
        $file->move( $path );

        return true;
    }
 static function move($nodeID, $newParentNodeID)
 {
     $result = false;
     if (!is_numeric($nodeID) || !is_numeric($newParentNodeID)) {
         return false;
     }
     $node = eZContentObjectTreeNode::fetch($nodeID);
     if (!$node) {
         return false;
     }
     $object = $node->object();
     if (!$object) {
         return false;
     }
     $objectID = $object->attribute('id');
     $oldParentNode = $node->fetchParent();
     $oldParentObject = $oldParentNode->object();
     // clear user policy cache if this is a user object
     if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) {
         eZUser::purgeUserCacheByUserId($object->attribute('id'));
     }
     // clear cache for old placement.
     // If child count exceeds threshold, do nothing here, and instead clear all view cache at the end.
     $childCountInThresholdRange = eZContentCache::inCleanupThresholdRange($node->childrenCount(false));
     if ($childCountInThresholdRange) {
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     }
     $db = eZDB::instance();
     $db->begin();
     $node->move($newParentNodeID);
     $newNode = eZContentObjectTreeNode::fetchNode($objectID, $newParentNodeID);
     if ($newNode) {
         $newNode->updateSubTreePath(true, true);
         if ($newNode->attribute('main_node_id') == $newNode->attribute('node_id')) {
             // If the main node is moved we need to check if the section ID must change
             $newParentNode = $newNode->fetchParent();
             $newParentObject = $newParentNode->object();
             if ($object->attribute('section_id') != $newParentObject->attribute('section_id')) {
                 eZContentObjectTreeNode::assignSectionToSubTree($newNode->attribute('main_node_id'), $newParentObject->attribute('section_id'), $oldParentObject->attribute('section_id'));
             }
         }
         // modify assignment
         $curVersion = $object->attribute('current_version');
         $nodeAssignment = eZNodeAssignment::fetch($objectID, $curVersion, $oldParentNode->attribute('node_id'));
         if ($nodeAssignment) {
             $nodeAssignment->setAttribute('parent_node', $newParentNodeID);
             $nodeAssignment->setAttribute('op_code', eZNodeAssignment::OP_CODE_MOVE);
             $nodeAssignment->store();
             // update search index specifying we are doing a move operation
             $nodeIDList = array($nodeID);
             eZSearch::removeNodeAssignment($node->attribute('main_node_id'), $newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList);
             eZSearch::addNodeAssignment($newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList, true);
         }
         $result = true;
     } else {
         eZDebug::writeError("Node {$nodeID} was moved to {$newParentNodeID} but fetching the new node failed");
     }
     $db->commit();
     // clear cache for new placement.
     // If child count exceeds threshold, clear all view cache instead.
     if ($childCountInThresholdRange) {
         eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     } else {
         eZContentCacheManager::clearAllContentCache();
     }
     return $result;
 }
 static function clearObjectViewCache($objectID, $versionNum = true, $additionalNodeList = false)
 {
     eZDebug::accumulatorStart('node_cleanup_list', '', 'Node cleanup list');
     $nodeList = eZContentCacheManager::nodeList($objectID, $versionNum);
     if ($nodeList === false and !is_array($additionalNodeList)) {
         return false;
     }
     if ($nodeList === false) {
         $nodeList = array();
     }
     if (is_array($additionalNodeList)) {
         array_splice($nodeList, count($nodeList), 0, $additionalNodeList);
     }
     if (count($nodeList) == 0) {
         return false;
     }
     $nodeList = array_unique($nodeList);
     eZDebug::accumulatorStop('node_cleanup_list');
     eZDebugSetting::writeDebug('kernel-content-edit', count($nodeList), "count in nodeList");
     $ini = eZINI::instance();
     if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
         $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
         $options = new ezpExtensionOptions($optionArray);
         $staticCacheHandler = eZExtension::getHandlerClass($options);
         $staticCacheHandler->generateAlwaysUpdatedCache();
         $staticCacheHandler->generateNodeListCache($nodeList);
     }
     eZDebug::accumulatorStart('node_cleanup', '', 'Node cleanup');
     $nodeList = ezpEvent::getInstance()->filter('content/cache', $nodeList);
     eZContentObject::expireComplexViewModeCache();
     $cleanupValue = eZContentCache::calculateCleanupValue(count($nodeList));
     if (eZContentCache::inCleanupThresholdRange($cleanupValue)) {
         eZContentCache::cleanup($nodeList);
     } else {
         eZDebug::writeDebug("Expiring all view cache since list of nodes({$cleanupValue}) related to object({$objectID}) exeeds site.ini\\[ContentSettings]\\CacheThreshold", __METHOD__);
         eZContentObject::expireAllViewCache();
     }
     eZDebug::accumulatorStop('node_cleanup');
     return true;
 }
     if (strlen($urlAlias) == 0) {
         if ($indexPage[0] == '/') {
             $indexPage = substr($indexPage, 1);
         }
         $urlAlias = $indexPage;
     }
     $destinationURLArray = explode('/', $urlAlias);
     // do we need to clear ViewCache ?
     // content/view/<viewmode>/<nodeID>
     if (isset($destinationURLArray[3])) {
         $nodeID = $destinationURLArray[3];
         // 0 => false
         // 1 => true or top level node
         // you do not want that
         if (is_numeric($nodeID) and $nodeID > 1) {
             eZContentCache::cleanup(array($nodeID));
             eZDebug::writeNotice('Clearing ViewCache for object ' . $nodeID, 'eZSIBlockFunction::process');
         }
     }
 }
 $cli->output('Calling ' . $cli->stylize('emphasize', $pageURL) . ' : ', false);
 $updatedPageList[] = $pageURL;
 // regenerating si blocks by calling the page
 // storing the results is useless
 if (!callPage($pageURL)) {
     $cli->output($cli->stylize('red', 'FAILED'));
     removeFileIfNeeded($expiredBlock, $db);
 } else {
     $sql = "SELECT mtime FROM ezsi_files WHERE namehash = '" . $expiredBlock['namehash'] . "'";
     $rows = $db->arrayQuery($sql);
     if ($rows[0]['mtime'] > $expiredBlock['mtime']) {
    static function clearObjectViewCache( $objectIDList, $versionNum = true, $additionalNodeList = false )
    {
        eZDebug::accumulatorStart( 'node_cleanup_list', '', 'Node cleanup list' );

        $nodeList = array();
        foreach ($objectIDList as $objectID)
        {
        	$tmp = eZContentCacheManager::nodeList( $objectID, $versionNum );
        	if (is_array($tmp) )
        	{
        		$nodeList = array_merge($nodeList, $tmp);
        	}
    	}

        if ( $nodeList === false and !is_array( $additionalNodeList ) )
        {
            return false;
        }

        if ( $nodeList === false )
        {
            $nodeList = array();
        }

        if ( is_array( $additionalNodeList ) )
        {
            array_splice( $nodeList, count( $nodeList ), 0, $additionalNodeList );
        }

        if ( count( $nodeList ) == 0 )
        {
            return false;
        }

        $nodeList = array_unique( $nodeList );

        eZDebug::accumulatorStop( 'node_cleanup_list' );

        eZDebugSetting::writeDebug( 'kernel-content-edit', count( $nodeList ), "count in nodeList" );

        $ini = eZINI::instance();
        if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' )
        {
            $staticCache = new eZStaticCache();
            $staticCache->generateAlwaysUpdatedCache();
            $staticCache->generateNodeListCache( $nodeList );
        }

        eZDebug::accumulatorStart( 'node_cleanup', '', 'Node cleanup' );

        eZContentObject::expireComplexViewModeCache();
        $cleanupValue = eZContentCache::calculateCleanupValue( count( $nodeList ) );

        if ( eZContentCache::inCleanupThresholdRange( $cleanupValue ) )
        {
            eZContentCache::cleanup( $nodeList );
        }
        else
        {
            eZContentObject::expireAllViewCache();
        }

        eZDebug::accumulatorStop( 'node_cleanup' );
        return true;
    }