[pLog-svn] r6112 - plog/branches/lifetype-1.2/class/config

Jon Daley plogworld at jon.limedaley.com
Thu Jan 3 12:15:47 EST 2008


 	The === might make it better.  All I care about is that you should 
be able to set a config value to (null, "", false, 0) in the database or 
in the file without the defaultValue overwriting it.

On Fri, 4 Jan 2008, Mark Wu wrote:
> BTW, I just check the class configDBStorage, configFileStorage and
> Properties...
>
> The getValue() behavior in  configDBStraoge and configFileStraoge is the
> same before your modification.
>
> Both of them, does not allow "" and null.
>
> Maybe we should change original method from
>
> if ($this->_data[$key] == "" || $this->_data[$key] == null) {
>
> to
>
> if ($this->_data[$key] === "" || $this->_data[$key] === null) {
>
> It is more close what we want.
>
> ================
>
> But, the getValue() in Properties is different, it allow null, "", false and
> 0...
>
> Mark
>
>
>> -----Original Message-----
>> From: Mark Wu [mailto:markplace at gmail.com]
>> Sent: Friday, January 04, 2008 12:30 AM
>> To: 'LifeType Developer List'
>> Subject: RE: [pLog-svn] r6112 -
>> plog/branches/lifetype-1.2/class/config
>>
>> HI Jon:
>>
>> I know it is abnormal, but shits always happend. Especially
>> in development version ... :)
>>
>> As I told you, I can adapt this,if there is no other place
>> have this kind of problem ...
>>
>> If you think it works well in 1.2, I think I can apply this
>> to 2.0 any time.
>>
>> Mark
>>
>>> -----Original Message-----
>>> From: plog-svn-bounces at devel.lifetype.net
>>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Jon Daley
>>> Sent: Thursday, January 03, 2008 11:57 PM
>>> To: LifeType Developer List
>>> Subject: Re: [pLog-svn] r6112 -
>>> plog/branches/lifetype-1.2/class/config
>>>
>>> That's what I thought.  Where does db_driver get set?  Only in the
>>> config file?  Do you have a db_driver = "" in your config
>> file?  That
>>> shouldn't ever happen to a regular user, since we wouldn't ship the
>>> config file with that value blank?
>>>
>>> On Thu, 3 Jan 2008, Mark Wu wrote:
>>>
>>>> Hi Jon:
>>>>
>>>> See \class\database\ltdb.class.php line 65 ...
>>>>
>>>> $driver = $fileConfig->getValue( "db_driver",
>>> DEFAULT_DATABASE_DRIVER
>>>> );
>>>>
>>>> $db = PDb::getDriver( $driver );
>>>>
>>>> **$driver  will be "", becasue $config['db_driver'] exist, and
>>>> isset($config['db_driver'] ) will return true, the default
>>> value won't
>>>> assign to $db_driver.
>>>>
>>>> If we want to adapt your fix, then we should change the
>>> above code to:
>>>>
>>>> $driver = $fileConfig->getValue( "db_driver" ); if($driver == "" )
>>>> 	$driver = DEFAULT_DATABASE_DRIVER
>>>>
>>>> As I told you, I can adapt this change, but I can not
>> make sure how
>>>> many this kind of problem exist in  2.0  :(
>>>>
>>>> So, I revert it in 2.0 becasue I can take care other
>>> problems first ...
>>>>
>>>> If you think there is no problem in 1.2, then I think I can
>>> adapt this
>>>> change any time.
>>>>
>>>> Mark
>>>>
>>>>> -----Original Message-----
>>>>> From: plog-svn-bounces at devel.lifetype.net
>>>>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf
>> Of Jon Daley
>>>>> Sent: Thursday, January 03, 2008 11:32 PM
>>>>> To: LifeType Developer List
>>>>> Subject: Re: [pLog-svn] r6112 -
>>>>> plog/branches/lifetype-1.2/class/config
>>>>>
>>>>>  	Can you show me the file that doesn't work?  Maybe the
>>> pdb should
>>>>> have a $val = getValue(db_driver); if($val == "")
>>>>>    $val = "mysql";
>>>>>
>>>>> or whatever?
>>>>>
>>>>> Maybe the configfile needs the isset() check like the
>>> configdb has?
>>>>> Oh, right - it does, because the code in configdb and
>>> properties is
>>>>> duplicated.
>>>>>
>>>>> So, you are saying the config file explicitly sets it to
>> null, but
>>>>> you want it to ignore that, and set a different value?  I
>>> think that
>>>>> should be done in the pdb driver file.
>>>>>
>>>>> I think if the config file is explicitly set to a value,
>> the code
>>>>> should use that value.  If they don't set the value at
>>> all, then the
>>>>> default value should be used.
>>>>>
>>>>>
>>>>> On Thu, 3 Jan 2008, Mark Wu wrote:
>>>>>
>>>>>> Hi Jon:
>>>>>>
>>>>>> I think your fix is okay in most case.
>>>>>>
>>>>>> The probolem is becasue in 2.0 PDB class, we need to set
>>>>> the default
>>>>>> db driver if the $config['db_drvier'] = '';
>>>>>>
>>>>>> With your fix, the db_driver will always be empty and no
>>>>> way to assign
>>>>>> it to the default value for example 'mysql', becasue the
>>>>>> $config['db_drvier'] does exist, isset() will return true...
>>>>>>
>>>>>> So, I have to revert your fix in 2.0.
>>>>>>
>>>>>> and, I also have no idea  this fix cause any problems in
>>>>> 1.2 or not ....
>>>>>>
>>>>>> If you can make sure it won't cause any problem in 1.2, I
>>>>> think I can
>>>>>> apply this change to 2.0, and modify PDB to adapt this change.
>>>>>>
>>>>>> Mark
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: plog-svn-bounces at devel.lifetype.net
>>>>>>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf
>>> Of Jon Daley
>>>>>>> Sent: Thursday, January 03, 2008 9:10 PM
>>>>>>> To: LifeType Developer List
>>>>>>> Subject: Re: [pLog-svn] r6112 -
>>>>>>> plog/branches/lifetype-1.2/class/config
>>>>>>>
>>>>>>> I see that I didn't copy the code from
>> configdbstorage, since it
>>>>>>> looked more complex than was needed.  Perhaps you want to
>>>>> copy that
>>>>>>> code directly?
>>>>>>>
>>>>>>> On Thu, 3 Jan 2008, Jon Daley wrote:
>>>>>>>
>>>>>>>> What problems does it cause?
>>>>>>>>
>>>>>>>> The bug that it fixes is that you can't set any value in a
>>>>>>>> configuration file to 0 or false, if the code provides
>>> a default.
>>>>>>>> This code is simply copying the code change from
>>>>>>> configdbstorage - we
>>>>>>>> fixed that a long time ago, and never noticed that we
>>> should have
>>>>>>>> copied it into file storage as well.
>>>>>>>>
>>>>>>>> On Thu, 3 Jan 2008, Mark Wu wrote:
>>>>>>>>
>>>>>>>>> Hi Jon:
>>>>>>>>>
>>>>>>>>> When did  you meet this bug?
>>>>>>>>>
>>>>>>>>> this change casue a big problem in 2.0 and takes me
>>>>>>> several hours to
>>>>>>>>> track why the problem happend ....
>>>>>>>>>
>>>>>>>>> I am not sure this change will cause any problems in 1.2
>>>>>>> or not. But,
>>>>>>>>> I will revert it  in 2.0 first to make 2.0-dev works ...
>>>>>>>>>
>>>>>>>>> Mark
>>>>>>>>>
>>>>>>>>>> -----Original Message-----
>>>>>>>>>> From: plog-svn-bounces at devel.lifetype.net
>>>>>>>>>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of
>>>>>>>>>> jondaley at devel.lifetype.net
>>>>>>>>>> Sent: Sunday, December 16, 2007 1:48 AM
>>>>>>>>>> To: plog-svn at devel.lifetype.net
>>>>>>>>>> Subject: [pLog-svn] r6112 -
>>>>>>> plog/branches/lifetype-1.2/class/config
>>>>>>>>>>
>>>>>>>>>> Author: jondaley
>>>>>>>>>> Date: 2007-12-15 12:47:42 -0500 (Sat, 15 Dec 2007)
>>> New Revision:
>>>>>>>>>> 6112
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>
>>> plog/branches/lifetype-1.2/class/config/configfilestorage.class.php
>>>>>>>>>> Log:
>>>>>>>>>> fixed bug where you couldn't use 0 or false in file
>>>>> based config
>>>>>>>>>> files, else the default value would always be used.
>>>>>>>>>> Removed getTempFolder() function, since the parent
>>>>> class already
>>>>>>>>>> defines it identically
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>>>
>>>>>>>
>>> plog/branches/lifetype-1.2/class/config/configfilestorage.class.php
>>>>>>>>>>
>>>>>>>
>>> ===================================================================
>>>>>>>>>> ---
>>>>>>>>>> plog/branches/lifetype-1.2/class/config/configfilestorage.cl
>>>>>>>>>> ass.php	2007-12-15 17:17:34 UTC (rev 6111)
>>>>>>>>>> +++
>>>>>>>>>> plog/branches/lifetype-1.2/class/config/configfilestorage.cl
>>>>>>>>>> ass.php	2007-12-15 17:47:42 UTC (rev 6112)
>>>>>>>>>> @@ -64,7 +64,6 @@
>>>>>>>>>>                  $this->_props = new Properties();
>>>>>>>>>>                  $result = false;
>>>>>>>>>>              }
>>>>>>>>>> -
>>>>>>>>>>              return( $result );
>>>>>>>>>>          }
>>>>>>>>>>
>>>>>>>>>> @@ -248,10 +247,7 @@
>>>>>>>>>>
>>>>>>>>>>          function getValue( $key, $defaultValue = null )
>>>>>>>>>>          {
>>>>>>>>>> -        	$value = $this->_props->getValue( $key );
>>>>>>>>>> -            if( $value == "" || $value == null )
>>>>>>>>>> -            	if(isset($defaultValue))
>>>>>>>>>> -                	$value = $defaultValue;
>>>>>>>>>> +        	$value = $this->_props->getValue( $key,
>>>>> $defaultValue );
>>>>>>>>>>
>>>>>>>>>>              return $value;
>>>>>>>>>>          }
>>>>>>>>>> @@ -299,19 +295,5 @@
>>>>>>>>>>
>>>>>>>>>>              return true;
>>>>>>>>>>          }
>>>>>>>>>> -
>>>>>>>>>> -        /**
>>>>>>>>>> -         * shortcut for one of the most sought after config
>>>>>>>>>> keys: temp_folder
>>>>>>>>>> -         *
>>>>>>>>>> -         * not really needed, but it makes my life easier
>>>>>>>>>> since I never remember
>>>>>>>>>> -         * whether it is tmp_folder, temp_folder, temp_dir,
>>>>>>>>>> or whatever :)
>>>>>>>>>> -         *
>>>>>>>>>> -         * @return The name of the folder used for
>>>>>>> temporary storage
>>>>>>>>>> -         */
>>>>>>>>>> -		function getTempFolder()
>>>>>>>>>> -        {
>>>>>>>>>> -            return $this->getValue( "temp_folder" );
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>>  	}
>>>>>>>>>>  ?>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> pLog-svn mailing list
>>>>>>>>>> pLog-svn at devel.lifetype.net
>>>>>>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> pLog-svn mailing list
>>>>>>>>> pLog-svn at devel.lifetype.net
>>>>>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Jon Daley
>>>>>>>> http://jon.limedaley.com/
>>>>>>>>
>>>>>>>> He who asks is a fool for five minutes, but he who
>> does not ask
>>>>>>>> remains a fool forever.
>>>>>>>> -- Chinese proverb
>>>>>>>> _______________________________________________
>>>>>>>> pLog-svn mailing list
>>>>>>>> pLog-svn at devel.lifetype.net
>>>>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Jon Daley
>>>>>>> http://jon.limedaley.com/
>>>>>>>
>>>>>>> Always be sincere, even when you don't mean it.
>>>>>>> -- Irene Peter
>>>>>>> _______________________________________________
>>>>>>> pLog-svn mailing list
>>>>>>> pLog-svn at devel.lifetype.net
>>>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>>>
>>>>>> _______________________________________________
>>>>>> pLog-svn mailing list
>>>>>> pLog-svn at devel.lifetype.net
>>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>>>
>>>>>
>>>>> --
>>>>> Jon Daley
>>>>> http://jon.limedaley.com/
>>>>>
>>>>> The cure for boredom is curiosity.  There is no cure for
>> curiosity.
>>>>> -- Ellen Parr
>>>>> _______________________________________________
>>>>> pLog-svn mailing list
>>>>> pLog-svn at devel.lifetype.net
>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>
>>>> _______________________________________________
>>>> pLog-svn mailing list
>>>> pLog-svn at devel.lifetype.net
>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>
>>>
>>> --
>>> Jon Daley
>>> http://jon.limedaley.com/
>>>
>>> There cannot be a crisis next week.  My schedule is already full.
>>> -- Henry Kissinger
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>

-- 
Jon Daley
http://jon.limedaley.com/

A journey of a thousand sites begins with a single click.


More information about the pLog-svn mailing list