Author Topic

Marko Žmak

Thursday 06 January 2011 12:48:38 pm

Comment64857

OK, after further investigation I came to this conclusions...

The solution Bertrand suggested should be extended to disable other caching mechanisms, so it should be like this:

eZINI::instance()->setVariable( 'ContentSettings', 'ViewCaching', 'disabled' );
eZINI::instance()->setVariable( 'ContentSettings', 'StaticCache', 'disabled' );
eZINI::instance()->setVariable( 'ContentSettings', 'PreViewCache', 'disabled' );

The solution gilles suggested can be enhanced a little bit by finding the array value to unset via its name. When set this way works even better that disabling the cache via ini settings.

So I made a better function:

function disableModuleOperation( $moduleName, $operationName, $operationPartName )
{
        if( !isset( $GLOBALS['eZGlobalModuleOperationList'][$moduleName] ) )
        {
                $moduleOperationInfo = new eZModuleOperationInfo( $moduleName, false );
                $moduleOperationInfo->loadDefinition();

                $GLOBALS['eZGlobalModuleOperationList'][$moduleName] = $moduleOperationInfo;
        }

        if (!isset($GLOBALS['eZGlobalModuleOperationList'][$moduleName]->OperationList[$operationName]))
                return;

        $index = -1;

        foreach ($GLOBALS['eZGlobalModuleOperationList'][$moduleName]->OperationList[$operationName]['body'] as $key => $operationPart)
        {
                if ($operationPart['name'] == $operationPartName)
                {
                        $index = $key;
                        break;
                }
        }

        if ($index >= 0)
                unset( $GLOBALS['eZGlobalModuleOperationList'][$moduleName]->OperationList[$operationName]['body'][$index] );
}

which would then be used like this:

disableModuleOperation('content', 'publish', 'clear-object-view-cache');

This is a more safer way to unset a part of the module operation because it relies on the name of the part which is less likely to change than the index.

I also found that there are several other parts that can be excluded when importing objects in a script:

  • pre_publish - if you don't want pre publish triggers to be executed
  • post_publish - if you don't want post publish triggers to be executedh
  • generate-object-view-cache - no preview cache generation
  • create-notification - if you don't want to generate notifications for the imported objects
  • register-search-object - to disable the search indexing (the reindexing can be done after the import)

Furthermore, I found that disabling "register-search-object" gives you the biggest speedup, especially if you're using ezfind. In my case the import went 100 times faster (without exaggeration). And you can always do the complete reindexing after the import.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.