Insert objects from module clear cache problem

Author Message

H-Works Agency

Wednesday 08 February 2006 3:15:52 am

I have a module that insert content objects.

The problem : when cache is "on" i don't see the objects. I have to "clear content cache" to see the objects under the parent folder.

Why ? Is there a special command to clear cache inside my module's php code ?

How to clear cache in the modules php code, for a certain node ? What is the function syntax to do this ?

My object are inserted correctly, but i can't see them in admin unless i clear content cache.

Thanx

Martin

EZP is Great

Kristof Coomans

Saturday 11 February 2006 1:48:31 am

Hi Martin

This is the code you need:

include_once( 'kernel/classes/ezcontentcachemanager.php' );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );

Aren't you using the publish operation to insert those content objects? If you're using this operation, clearing caches would be done automatically. Or do these content objects already exist and are you creating additional node assignments?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

H-Works Agency

Saturday 11 February 2006 8:24:25 am

Hi Kristof and thanx a lot for your code.

To respond to your question my extension is inserting objects inside one of my root folders, its not creating extra node assignements.

Actually i had hard time finding documentation about inserting an object from an extension, i had to browse contribution to take code as exemple but i didn't know if i used the right procedure but now that you say that the right EZP insert function is auto clearing the cache, i am shure i didn't use the right one because mine doesn't.

What is the "right" function to handle such operations ? I mean the built in ezp function that insert an object somewhere and clear parent's cache automatically ?

Thanx for everything,

Regards,
Martin

EZP is Great

Kristof Coomans

Saturday 11 February 2006 9:51:45 am

After creating node assignments for your object, you should call the publish operation, as mentioned in this thread: http://ez.no/community/forum/general/publish_object_with_php:

$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID, 'version' => $contentObjectVersion ) );

There are other forum threads about programmatically creating content objects, like http://ez.no/community/forum/developer/importing_update_entry_if_it_already_exists, but they're quite hard to find with the search function.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

H-Works Agency

Thursday 16 February 2006 8:00:58 am

I already use this function to insert my object from my module but it doesn't clear the cache...am i missing something ?

$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));

Martin

EZP is Great

H-Works Agency

Thursday 16 February 2006 8:26:21 am

Ok thanx a lot Kristian, in fact my function clear the cache by default, but it was missing this line :

include_once('kernel/classes/ezcontentcachemanager.php');

Martin

EZP is Great

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

eZ debug

Timing: Jan 18 2025 19:06:03
Script start
Timing: Jan 18 2025 19:06:03
Module start 'layout'
Timing: Jan 18 2025 19:06:04
Module start 'content'
Timing: Jan 18 2025 19:06:05
Module end 'content'
Timing: Jan 18 2025 19:06:05
Script end

Main resources:

Total runtime1.4699 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0087 588.0469152.6406
Module start 'layout' 0.00870.0036 740.687539.4766
Module start 'content' 0.01221.4561 780.1641583.8516
Module end 'content' 1.46840.0015 1,364.015616.1250
Script end 1.4699  1,380.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2432160.0002
Check MTime0.00140.0937160.0001
Mysql Total
Database connection0.00080.057410.0008
Mysqli_queries1.390594.5990660.0211
Looping result0.00080.0558640.0000
Template Total1.427497.120.7137
Template load0.00240.166320.0012
Template processing1.425096.945120.7125
Template load and register function0.00010.008110.0001
states
state_id_array0.00220.147410.0022
state_identifier_array0.00330.221520.0016
Override
Cache load0.00220.1486410.0001
Sytem overhead
Fetch class attribute can translate value0.00080.055420.0004
Fetch class attribute name0.00180.121280.0002
XML
Image XML parsing0.00100.066920.0005
class_abstraction
Instantiating content class attribute0.00000.0023120.0000
General
dbfile0.00240.1659230.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 30
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs