Forums / Developer / Insert objects from module clear cache problem

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

eZ debug

Timing: Jan 20 2025 21:05:53
Script start
Timing: Jan 20 2025 21:05:53
Module start 'content'
Timing: Jan 20 2025 21:05:53
Module end 'content'
Timing: Jan 20 2025 21:05:53
Script end

Main resources:

Total runtime0.0250 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 587.8438180.8125
Module start 'content' 0.00810.0070 768.6563102.0547
Module end 'content' 0.01510.0098 870.710978.7031
Script end 0.0249  949.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002610.3533120.0002
Check MTime0.00135.0884120.0001
Mysql Total
Database connection0.00093.740410.0009
Mysqli_queries0.003915.661240.0010
Looping result0.00000.076420.0000
Template Total0.009337.310.0093
Template load0.00114.532710.0011
Template processing0.008232.722010.0082
Override
Cache load0.00083.267810.0008
General
dbfile0.004919.5964100.0005
String conversion0.00000.024830.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs