[development] low hanging fruit for Drupal 6: variable defaults

Syscrusher syscrusher at 4th.com
Thu May 3 22:33:39 UTC 2007


On Thursday 03 May 2007 17:01, Dries Buytaert wrote:
> How about this:
> 
> define('site_name', 'example');
> 
> function variable_get($name) {
>    $value = db_result(db_query(...));
>    return $value ? $value : constant($name);
> }
> 
> print variable_get('site_name');

What happens if you have a variable whose default is TRUE but for which the
set value is FALSE at the moment? I think in that case

       return $value ? $value : constant($name);

is going to give you the constant instead of the perfectly-valid assigned value,
isn't it?

Scott

-- 
-------------------------------------------------------------------------------
Syscrusher (Scott Courtney)          Drupal page:   http://drupal.org/user/9184
syscrusher at 4th dot com            Home page:     http://4th.com/   


More information about the development mailing list