Forums / Developer / need to clear cache after delete/purge object in php

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.
...