[pLog-svn] r5861 - plog/branches/lifetype-1.2/class/data

Jon Daley plogworld at jon.limedaley.com
Wed Aug 29 07:58:53 EDT 2007


 	I need to do it.  I keep forgetting.  I'll get to it tonight.

On Wed, 29 Aug 2007, Oscar Renalias wrote:

> Did you get this to work?
>
> On 8/24/07, Jon Daley <plogworld at jon.limedaley.com> wrote:
>>         Ah.  I was too narrowly focusing on getValue, rather than the
>> constructor.
>>         Yes, that method looks good.  I'll test it on my blog and see how
>> it goes.
>>
>> On Fri, 24 Aug 2007, Oscar Renalias wrote:
>>
>>> I still don't understand :-)
>>>
>>> What I am suggesting is:
>>>
>>> class Request extends Properties
>>> {
>>>  function Request( $request ) {
>>>    if( magic_quotes_gpc()) {
>>>      foreach( $request as $key => $value ) {
>>>        $request[$key] = strip_slashes($value);
>>>      }
>>>    }
>>>    parent::__construct( $request );
>>>  }
>>>  ...
>>> }
>>>
>>> So after this point, we can call getValue(), getFilteredValue(), etc,
>>> and we can be sure that all data has been filtered as expected. Or am
>>> I missing something?
>>>
>>> Oscar
>>>
>>> On 8/24/07, Jon Daley <plogworld at jon.limedaley.com> wrote:
>>>> On Fri, 24 Aug 2007, Oscar Renalias wrote:
>>>>> We can remove the $filter parameter from Properties::getValue() if
>>>>> it's true that it is not being used.
>>>>         The problem is that doesn't make a difference, since there is the
>>>> "|| isset(filterclass) inside getValue()
>>>>
>>>>> We don't need to implement Properties::getUnfilteredValue() because we
>>>>> already have the opposite, Properties::getFilteredValue().
>>>>         getValue and getFilteredValue are basically the same thing.
>>>>
>>>>> But what would you need Properties::filterData() for?
>>>>         Because the data should always be filtered, just after the
>>>> stripslashes() call.  So, request->getValue would look like:
>>>>
>>>> getunfilteredata();
>>>> if(magic_quotes)
>>>>    stripslashes();
>>>> filterData();
>>>>
>>>>> Why don't we just process all values in the request inside the Request
>>>>> constructor, and perform the call to strip_slashes in there rather
>>>>> than in the get[Filtered]Value() methods? In that case we wouldn't
>>>>> need to worry about doing it later, and we could be sure that the data
>>>>> has already been filtered.
>>>>         That sounds fine, it is just duplicating code from inside the
>>>> parent class.
>>>>
>>>> I think you are proposing:
>>>>
>>>> function getValue( $key, $defaultValue = null)
>>>> {
>>>>     if( !isset($this->_props[$key]) ) {
>>>>          $value = $defaultValue;
>>>>     } else {
>>>>          $value = $this->_props[$key];
>>>>     }
>>>>
>>>>     if( get_magic_quotes_gpc() && !is_array( $value ))
>>>>         $value = stripslashes( $value );
>>>>
>>>>     if(isset( $this->_keyFilters[$key] ))
>>>>         $value = $this->_keyFilters[$key]->filter($value);
>>>>
>>>>     return( $value );
>>>> }
>>>>
>>>>
>>>> I think it would be better to not duplicate the code from properties and
>>>> only reference the _props and _keyFilters from inside Properties with a
>>>> getUnfilteredValue() and filterData() which would do the first and third
>>>> blocks of the above code.
>>>>
>>>> _______________________________________________
>>>> 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/
>>
>> Normal people believe that if it ain't broke,
>>     don't fix it.
>> Engineers believe that if it ain't broke,
>>     it doesn't have enough features yet.
>> _______________________________________________
>> 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/

God is holy.  You are not.
-- Harvest 2000


More information about the pLog-svn mailing list