[dev] IMP error - prefs not set correctly on login

Jon Parise jon@horde.org
Wed, 3 Apr 2002 17:39:18 -0500


---------------------- multipart/mixed attachment
On Tue, Apr 02, 2002 at 03:09:49AM -0700, Michael M Slusarz wrote:

> It's taken me an hour and a half to figure out this bug.  grrrr. :)

Welcome to developer-land. =)
 
> HOWEVER, setDefaults() keeps track of all prefs files loaded
> via a static variable ($completed) - thus, it kicks out of the
> function without loading ANY of the defaults from the storage
> driver.

[snip]
 
> Of course, this defeats the purpose of ensuring that the
> defaults are only read once.  This is some core Horde stuff, so
> I will let someone who knows better figure out what to do with
> this.

Chuck and I seem to agree that the issue is related to the use of
a static variable which gets shared between multiple Prefs class
instances.  Neither of us has investigated in detail yet, but the
attached patch may provide the solution (completely untested).
It replaces the static variable with an instance variable
instead.

Let me know if this fixes the problems you're seeing.

-- 
Jon Parise (jon@csh.rit.edu)  .  Information Technology (2001)
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

---------------------- multipart/mixed attachment
Index: Prefs.php
===================================================================
RCS file: /repository/horde/lib/Prefs.php,v
retrieving revision 1.63
diff -u -r1.63 Prefs.php
--- Prefs.php	21 Mar 2002 16:41:17 -0000	1.63
+++ Prefs.php	3 Apr 2002 22:25:00 -0000
@@ -60,6 +60,13 @@
     var $caching = false;
 
     /**
+     * Array of boolean flags indicating whether the default preferences
+     * stored in the given file have been loaded.
+     * @var boolean $defaults
+     */
+    var $defaults = array();
+
+    /**
      * Attempts to return a concrete Prefs instance based on $driver.
      *
      * @param string $driver    The type of concrete Prefs subclass to return.
@@ -175,12 +182,9 @@
      */
     function setDefaults($filename)
     {
-        /* Ensure that the defaults are only read once. */
-        static $completed;
-        if (!empty($completed[$filename])) {
+        /* Ensure that the defaults from this file are only read once. */
+        if (!empty($this->defaults[$filename])) {
             return;
-        } else {
-            $completed[$filename] = true;
         }
 
         if (!@is_readable($filename)) return;
@@ -208,6 +212,9 @@
                 $this->add($pref, $pvals['value'], $mask);
             }
         }
+
+        /* Indicate that the defaults from this file have been loaded. */
+        $this->defaults[$filename] = true;
 
         /* If the cache is already filled, don't overwrite it with the
            defaults we've just read in. */

---------------------- multipart/mixed attachment--


>From scarr@progbits.com Date: Wed,  3 Apr 2002 16:43:44 -0600
Return-Path: <scarr@progbits.com>
Mailing-List: contact dev-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list dev@lists.horde.org
Received: (qmail 14280 invoked from network); 3 Apr 2002 22:42:43 -0000
Received: from unknown (HELO progbits.com) (208.13.79.180)
  by clark.horde.org with SMTP; 3 Apr 2002 22:42:43 -0000
Received: from nobody by progbits.com with local (Exim 3.34 #1)
	id 16stTk-0003om-00
	for dev@lists.horde.org; Wed, 03 Apr 2002 16:43:44 -0600
Received: from 12.107.242.5 ( [12.107.242.5])
	as user scarr@progbits.com by mail.progbits.com with HTTP;
	Wed,  3 Apr 2002 16:43:44 -0600
Message-ID: <1017873824.3cab85a07a130@mail.progbits.com>
Date: Wed,  3 Apr 2002 16:43:44 -0600
From: Scott Carr <scarr@progbits.com>
To: dev@lists.horde.org
References: <1017862356.3cab58d4cd174@progbits.com> <1017871804.3cab7dbc95076@www.midworld.org>
In-Reply-To: <1017871804.3cab7dbc95076@www.midworld.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.1-cvs
X-Originating-IP: 12.107.242.5
Sender: nobody <nobody@progbits.com>
Subject: Re: [dev] Possible New Project:  Juno

As a start:

*  Double Entry Style  (Matching GNUCash for future import/export)
*  Parent/Child Style Accounts  (Matching GNUCash as well)
*  Auto-Remind for Future Bills
*  Horde Screen showing:  Total in account, Future Bills Count and Total $ for
Week and For Month

Possible Future features:
*  Auto-Enter for Auto-Remind bills - User selects a Auto-Remind and hits
enter/save and it is added to the Register.
*  Auto-Haras (sp?) for bills past due
*  Income/Expense Report
*  Chart of Account Report
*  Other reports that are decided upon
*  Link an Entry with a Contact in Address Book
-- 
Scott Carr
OpenOffice.org
Whiteboard-Doc Maintainer
http://whiteboard.openoffice.org/doc/


Quoting Quinn Wilson <qwilson@midworld.org>:

> I'm interested. What sort of functionality were you envisioning? features
> etc.. 
> 
> Quoting Scott Carr <scarr@progbits.com>:
> 
> > I have been thinking of creating a Checkbook module for Horde.  I am in
> > need of
> > a Checkbook program that is web-based, that can easily be managed from
> > different
> > locations, and that has the ability to remind of transactions and so
> forth.
> >  I
> > think Horde would be the perfect foundation for it.
> > 
> > I was thinking of calling the Project "Juno", after the Roman Goddess of
> > Finance.
> > 
> > Has anybody started a project like this?  Does anyone want to help? 
> > -- 
> > Scott Carr
> > OpenOffice.org
> > Whiteboard-Doc Maintainer
> > http://whiteboard.openoffice.org/doc/
> > 
> > 
> > 
> > 
> > 
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> > 
> > -- 
> > Horde Developers mailing list: http://horde.org/
> > Frequently Asked Questions: http://horde.org/faq/
> > To unsubscribe, mail: dev-unsubscribe@lists.horde.org
> > 
> 
> 
> ~
> ~
> :qwilson@midworld.org - Lunky C++; Lunky do {;}
> 
> -- 
> Horde Developers mailing list: http://horde.org/
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: dev-unsubscribe@lists.horde.org
> 
> 


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/