need to clear cache after delete/purge object in php

Author Message

ludo thomas

Wednesday 25 January 2006 9:39:58 am

Hi!
I call a function that delete object, in a template.
my function is like:

 function deleteobject($something)
    {
	
	$mynodeid=$_GET['mynodeid'];
        $myobjectid=$_GET['myobjectid'];
			
			include_once( "kernel/classes/ezcontentclass.php" );
			
			include_once( "kernel/classes/ezcontentobject.php" );
	 		eZContentObjectTreeNode::remove( $mynodeid );
				
			
			eZContentObject::purge( $myobjectid );
			
			
			
			
        return "votre annonce a bien été supprimmée..";
    }

my probleme is that I have to clear the cahe manually if I want to delete a second object.
After a clear cache I can delete only one object. and after, if i try to delete another one, the return string is displayed, but the object not deleted.

If i configure my site.ini:
[ContentSettings]
ViewCaching=disabled, The problem is resolved.

any idea for having ViewCaching=enabled and my function OK?

ludo thomas

Tuesday 31 January 2006 4:33:06 am

Pleazzzzzz, any hint??

Łukasz Serwatka

Tuesday 31 January 2006 5:09:48 am

Hi

Try with at the end:

//with object_id parameter
eZContentObject::clearCache(  array( $myobjectid ) );

//or leave empty for all objects
eZContentObject::clearCache();

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Kristof Coomans

Tuesday 31 January 2006 5:16:26 am

From which module/view are you calling this function?

Do you want to clear caches for the object that gets removed?

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

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

ludo thomas

Tuesday 31 January 2006 5:46:43 am

THX for your replys.

I have tried these 3 methods.
each time I have this msg: Call to undefined function: clearcache()

I use 3.5 version.

I use this function in a full-view template.
I have a button with this code:

<form action={"desinscription/"|ezurl} method='get'> 
	<input type='hidden' name='test' value="{$node.node_id}" />
		<input type='hidden' name='test2' value="{$node.object.id}"  />
	<input type='submit' class="button forum-account-edit" name='submit'  onClick='return confirm("Attention. Vous Perdrez tous vos credits!!.")' value='Supprimer'>
	 </form>

in the desinscription template I have this:

<h1>Annulation d'une Annonce </h1>

<p>{suprfunction() }</p>

that call for this function (in extension/myextension/autoloads/mysrtingoperators.php

function suprfunction()
    {
	
	$test=$_GET['test'];
   $test2=$_GET['test2'];
			
			
			include_once( "kernel/classes/ezcontentobjecttreenode.php" );
			
			include_once( "kernel/classes/ezcontentobject.php" );

	 		eZContentObjectTreeNode::remove( $test );
				
			
			eZContentObject::purge( $test2 );
			
			

 
			
			
        return "votre annonce a bien été supprimmée..";
    }

Łukasz Serwatka

Tuesday 31 January 2006 5:48:37 am

This method was added in 3.5.3.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

ludo thomas

Tuesday 31 January 2006 5:57:19 am

I use 3.5.1.
Do you have another trick that could permit me to do the same thing?

I use the samefunction in a cronjob, and have no problem.

I just want to remove directly some object from a template....

ludo thomas

Tuesday 31 January 2006 7:28:10 am

after some others try, I think that the problem could be from the GET['var'] I use.
...

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 20:49:35
Script start
Timing: Jan 18 2025 20:49:35
Module start 'layout'
Timing: Jan 18 2025 20:49:35
Module start 'content'
Timing: Jan 18 2025 20:49:36
Module end 'content'
Timing: Jan 18 2025 20:49:36
Script end

Main resources:

Total runtime1.0353 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 588.0625152.6406
Module start 'layout' 0.00740.0032 740.703139.4766
Module start 'content' 0.01061.0233 780.1797659.3125
Module end 'content' 1.03390.0014 1,439.492220.1250
Script end 1.0353  1,459.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3618160.0002
Check MTime0.00130.1295160.0001
Mysql Total
Database connection0.00090.090910.0009
Mysqli_queries0.955792.3093740.0129
Looping result0.00080.0810720.0000
Template Total0.995696.220.4978
Template load0.00220.208720.0011
Template processing0.993495.957420.4967
Template load and register function0.00010.010210.0001
states
state_id_array0.00100.092010.0010
state_identifier_array0.00180.174220.0009
Override
Cache load0.00190.1799530.0000
Sytem overhead
Fetch class attribute can translate value0.00090.085930.0003
Fetch class attribute name0.00110.1051110.0001
XML
Image XML parsing0.00150.145430.0005
class_abstraction
Instantiating content class attribute0.00000.0041160.0000
General
dbfile0.00100.1005300.0000
String conversion0.00000.000940.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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs