Forums / Developer / [eZ 4.0.0] Extension works once

[eZ 4.0.0] Extension works once

Author Message

Damien MARTIN

Monday 05 January 2009 6:24:15 am

Hi everybody !

I have a problem with an extension that I'm writing.

The problem is that my fetch is only done when eZ put the page in cache. Once the page is stored, the method from the extension is not called.

<b>Function_definition.php</b>

<?php
	
	$FunctionList['forum_visiter'] = array(
	
		'name' => 'forum_visiter',
		'operation_types' => array(),
		'call_method' => array( 
		
			'include_file' => 'extension/damien/modules/damien/forum.php',
			'class' => 'Forum',
			'method' => 'visiter' ),
			
		'parameter_type' => 'standard',
		'parameters' => array(
		
			array( 	'name' => 'utilisateur', 'type' => 'string', 'required' => true ),
			array( 	'name' => 'topic', 'type' => 'string', 'required' => false )
		
		)
	
	);
	
?>

<b>forum.php</b>

<?php
	
	class Forum {
		
		/**
		 * Rajoute une entrée dans la base de données pour dire quand un utilisateur a été voir un sujet pour la derniere fois
		 * \arg $utilisateur ID de l'utilisateur
		 * \arg $topic ID du noeud correspondant au topic
		 * \return Rien d'utile : true tout le temps
		 */
		function visiter($utilisateur, $topic){
			
			echo "<p>Forum::visiter()</p>";
			
			mysql_connect("xxxxxxxxxx", "xxxxxxxxx", "xxxxxxxxx");
			mysql_select_db("xxxxxxxxx");
			 
			$res = mysql_query("SELECT * FROM visites WHERE id_utilisateur = $utilisateur AND id_topic = $topic");
			
			if(mysql_num_rows($res) > 0)
				$sql = "UPDATE visites SET id_utilisateur = $utilisateur, id_topic = $topic, date_visite = ".time();
			else
				$sql = "INSERT INTO visites (id_utilisateur, id_topic, date_visite) VALUES ($utilisateur, $topic, ".time().")";
			
			mysql_query($sql);
			
			return array("result" => true);
			
		}
		
	}
 
?>

<b>What does it should do ?</b>

When I call the fetch method 'forum_visiter', it should update a database. And it works ! Untill the page is not cached...

Could you give me the reason of this strange behaviour (and how to correct it) ?

Thank in advance

Björn Dieding@xrow.de

Monday 05 January 2009 8:54:52 am

hi you have two options.

either you disable the viewcache for that page

or

you write a new module that you call after the page is loaded. I would do this with a fake js request.

<script type="text/javascript" charset="utf-8" src={concat('view/count/',$node.node_id)|ezurl}></script>

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Damien MARTIN

Tuesday 06 January 2009 1:37:00 am

I resolved the problem using

{set-block scope=root variable=cache_ttl}0{/set-block}

like you said in your answer.

Thank you very much Björn.

eZ debug

Timing: Jan 20 2025 05:03:44
Script start
Timing: Jan 20 2025 05:03:44
Module start 'content'
Timing: Jan 20 2025 05:03:45
Module end 'content'
Timing: Jan 20 2025 05:03:45
Script end

Main resources:

Total runtime1.0767 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.9531180.8359
Module start 'content' 0.00560.8897 769.7891553.8984
Module end 'content' 0.89530.1813 1,323.6875337.0625
Script end 1.0766  1,660.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3695210.0002
Check MTime0.00140.1286210.0001
Mysql Total
Database connection0.00070.066610.0007
Mysqli_queries0.973290.39241940.0050
Looping result0.00210.19861920.0000
Template Total1.046497.220.5232
Template load0.00210.198620.0011
Template processing1.044296.987720.5221
Template load and register function0.00010.010910.0001
states
state_id_array0.00140.127610.0014
state_identifier_array0.00140.127020.0007
Override
Cache load0.00180.1680280.0001
Sytem overhead
Fetch class attribute can translate value0.00220.205730.0007
Fetch class attribute name0.00110.105050.0002
XML
Image XML parsing0.00160.144830.0005
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.02622.4320330.0008
String conversion0.00000.001830.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/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: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs