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

eZ debug

Timing: Jan 18 2025 18:31:45
Script start
Timing: Jan 18 2025 18:31:45
Module start 'content'
Timing: Jan 18 2025 18:31:46
Module end 'content'
Timing: Jan 18 2025 18:31:46
Script end

Main resources:

Total runtime0.7661 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 587.8594180.8125
Module start 'content' 0.00610.6427 768.6719664.4063
Module end 'content' 0.64880.1173 1,433.0781345.0547
Script end 0.7660  1,778.1328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.5754210.0002
Check MTime0.00150.1906210.0001
Mysql Total
Database connection0.00080.100610.0008
Mysqli_queries0.673287.86892110.0032
Looping result0.00200.26352090.0000
Template Total0.741396.820.3706
Template load0.00160.212920.0008
Template processing0.739796.546420.3698
Template load and register function0.00010.014010.0001
states
state_id_array0.00070.089310.0007
state_identifier_array0.00130.172520.0007
Override
Cache load0.00150.1931530.0000
Sytem overhead
Fetch class attribute can translate value0.00090.123940.0002
Fetch class attribute name0.00200.2646110.0002
XML
Image XML parsing0.00220.290640.0006
class_abstraction
Instantiating content class attribute0.00000.0049160.0000
General
dbfile0.00470.6089410.0001
String conversion0.00000.003830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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