[dev] PATCH Fix last login not saving every time.

Amith Varghese amith@xalan.com
08 Aug 2002 10:34:10 -0400


Thanks! I've been wondering if anyone knew about this.  However, I'm not
sure if it's the right fix.  I'm sure it fixes the problem, but from the
looks of the patch you are manually calling store() to save the
last_login preference.  However, from the phpdoc for store() is the
following

* This function will be run at the end of every request as a shutdown
* function (registered by the Prefs:: constructor).  All prefs with
* the dirty bit set will be saved to the storage backend at this time;
* thus, there is no need to manually call $prefs->store() every time
* a preference is changed.

However in this patch you are manually calling store() which according
to the comment is a no-no.  I think the bigger problem lies in how
register_shutdown_function works because it seems that when the callback
is executed, it doesn't have access to the modified _prefs hash. 
Instead it reads whatever was loaded in the beginning  This is what i've
observed from my debugging, but I could be wrong.

Amith

On Thu, 2002-08-08 at 10:09, Mike Cochrane wrote:
> This is a fix for the last login not saving and for new users so it displays
> 'Never' correctly.
> 
> - Mike :-)
> 
> Index: imp/lib/Session.php
> ===================================================================
> RCS file: /httpd/horde/imp/lib/Session.php,v
> retrieving revision 1.8
> diff -I$Horde -I$Revision -I$Date -u -r1.8 Session.php
> --- imp/lib/Session.php	2002/08/06 02:32:54	1.8
> +++ imp/lib/Session.php	2002/08/08 14:07:22
> @@ -186,7 +186,7 @@
>              /* Display user's last login time if requested. */
>              /* Optional UNIX date style: "D M j H:i:s T Y" */
>              if ($prefs->getValue('show_last_login')) {
> -                if (empty($last_login)) {
> +                if (empty($last_login) || $last_login == 0) {
>                      $notification->push(_("Last login: Never"), 'horde.message');
>                  } else {
>                      $notification->push(sprintf(_("Last login: %s"),
> strftime(_("%c"), $last_login)), 'horde.message');
> @@ -210,7 +210,8 @@
>  
>              /* Store the current login timestamp now. */
>              $prefs->setValue('last_login', time());
> -
> +            $prefs->store();
> +            
>              $_SESSION['imp']['_login'] = null;
>          }
>      }
> 
> -------------------------------------------------------------------------
> This mail sent from Mike's CVS HEAD install of IMP: http://horde.org/imp/
> 
> 
> -- 
> Horde developers mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: dev-unsubscribe@lists.horde.org
>