Alternative to $user->lastVisit() with ezpSessionHandlerPHP

Author Message

Benjamin Lorteau

Monday 14 March 2011 9:11:07 am

Hi everybody,

I recently upgraded to 4.4, but I encountered some problems with login and remembering login tied with session management.

Here I have a new regression to submit to your consideration. I un a site/forum that rely heavily on the content/newcontent feature, which is based on the user's last visit timestamp. Unfortunately, with the new session handler, this timestamp is updated every time the user load a page, cancelling the new content system.

My question is : how can I replace $user->lastVisit() in my scripts to get the old behavior (last time the user logged in) ?

Thanks in advance !

eZ Publish personal project : http://www.aeriesguard.com [fr]

André R.

Tuesday 15 March 2011 5:31:48 am

(re edit) Added your issue to the issue tracker here:

http://issues.ez.no/IssueView.php?Id=18144&activeItem=1

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

André R.

Tuesday 15 March 2011 5:59:35 am

Might have a patch for this to make sure eZUser does not update last visit ts:

diff --git a/lib/ezsession/classes/ezpsessionhandlerphp.php b/lib/ezsession/classes/ezpsessionhandlerphp.php
index 72c574e340a7c8158e19333bcf787e1edd7bc35a..cf199c8ac3996a640c6097874a311e8284f23121 100644
--- a/lib/ezsession/classes/ezpsessionhandlerphp.php
+++ b/lib/ezsession/classes/ezpsessionhandlerphp.php
@@ -28,6 +28,8 @@ class ezpSessionHandlerPHP extends ezpSessionHandler
         {
             ini_set("session.gc_maxlifetime", $ini->variable('Session', 'SessionTimeout') );
         }
+        // make sure eZUser does not update lastVisit on every request and only on login
+        $GLOBALS['eZSessionIdleTime'] = 0;
         return true;
     }
 

Edit: This issue has been fixed and commit is available here (for stable-4.4): https://github.com/ezsystems/ezpublish/commit/fdf56b18b35df841f232f9e1f4f8c43506fd0621

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Benjamin Lorteau

Tuesday 15 March 2011 6:54:52 am

This fix worked for me, and I'm using ezUser::updateLastVisit() to manually update the users' last visit timestamp.

Thanks a lot Andre !

(Topic marked as solved)

eZ Publish personal project : http://www.aeriesguard.com [fr]

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 00:51:09
Script start
Timing: Jan 18 2025 00:51:09
Module start 'layout'
Timing: Jan 18 2025 00:51:09
Module start 'content'
Timing: Jan 18 2025 00:51:11
Module end 'content'
Timing: Jan 18 2025 00:51:11
Script end

Main resources:

Total runtime1.6307 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.1563152.6563
Module start 'layout' 0.00560.0044 740.812539.5156
Module start 'content' 0.01001.6192 780.3281559.6328
Module end 'content' 1.62920.0015 1,339.960916.0938
Script end 1.6307  1,356.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2030160.0002
Check MTime0.00150.0895160.0001
Mysql Total
Database connection0.00060.039810.0006
Mysqli_queries1.570096.2781630.0249
Looping result0.00070.0422610.0000
Template Total1.582297.020.7911
Template load0.00200.124220.0010
Template processing1.580196.896520.7901
Template load and register function0.00010.006210.0001
states
state_id_array0.00290.176910.0029
state_identifier_array0.00190.118420.0010
Override
Cache load0.00160.1011270.0001
Sytem overhead
Fetch class attribute can translate value0.00060.038820.0003
Fetch class attribute name0.00150.090260.0002
XML
Image XML parsing0.00140.084620.0007
class_abstraction
Instantiating content class attribute0.00000.001180.0000
General
dbfile0.00120.0748230.0001
String conversion0.00000.000740.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/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: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs