fixed PHP Strict Standards: config::save_value must be declared static to be used static (no longer allowing non-static usage!)

This commit is contained in:
Ralf Becker 2012-07-14 08:57:29 +00:00
parent bcc60cfc3d
commit cd65835d47
3 changed files with 31 additions and 18 deletions

View File

@ -1426,8 +1426,7 @@ function calendar_upgrade1_0_1_007()
function calendar_upgrade1_0_1_008()
{
$config =& CreateObject('phpgwapi.config','calendar');
$config_data = $config->read_repository();
$config_data = config::read('calendar');
if (isset($config_data['fields'])) // old custom fields
{
$customfields = array();
@ -1446,10 +1445,9 @@ function calendar_upgrade1_0_1_008()
}
if (count($customfields))
{
$config->save_value('customfields',$customfields);
config::save_value('customfields', $customfields, 'calendar');
}
$config->delete_value('fields');
$config->save_repository(); // delete_value does not save
config::save_value('fields', null, 'calendar');
}
$GLOBALS['setup_info']['calendar']['currentver'] = '1.0.1.009';
return $GLOBALS['setup_info']['calendar']['currentver'];

View File

@ -570,8 +570,7 @@
// store text as default
if (isset($_POST['set_as_default']))
{
$config = new config('felamimail');
$config->save_value('default_vacation_text',$_POST['vacation_text'],'felamimail');
config::save_value('default_vacation_text', $_POST['vacation_text'], 'felamimail');
}
$this->t->set_var('set_as_default','<input type="submit" name="set_as_default" value="'.htmlspecialchars(lang('Set as default')).'" />');
}

View File

@ -2,8 +2,6 @@
/**
* eGW's application configuration in a centralized location
*
* This allows eGroupWare to use php or database sessions
*
* @link www.egroupware.org
* @author Joseph Engo <jengo@phpgroupware.org> original class Copyright (C) 2000, 2001 Joseph Engo
* @author Ralf Becker <ralfbecker@outdoor-training.de>
@ -91,13 +89,13 @@ class config
self::$db->lock(array(config::TABLE));
foreach($this->config_data as $name => $value)
{
$this->save_value($name,$value);
self::save_value($name, $value, $this->appname, false);
}
foreach(self::$configs[$this->appname] as $name => $value)
{
if (!isset($this->config_data[$name])) // has been deleted
{
self::$db->delete(config::TABLE,array('config_app'=>$this->appname,'config_name'=>$name),__LINE__,__FILE__);
self::save_value($name, null, $this->appname, false);
}
}
self::$db->unlock();
@ -113,17 +111,21 @@ class config
/**
* updates or insert a single config-value direct into the database
*
* Can be used static, if $app given!
* Can (under recent PHP version) only be used static!
* Use $this->value() or $this->delete_value() together with $this->save_repository() for non-static usage.
*
* @param string $name name of the config-value
* @param mixed $value content, empty or null values are not saved, but deleted
* @param string $app=null app-name, defaults to $this->appname set via the constructor
* @param string $app app-name (depreacted to use default of $this->appname set via the constructor!)
* @param boolean $update_cache=true update instance cache and for phpgwapi invalidate session-cache
* @throws egw_exception_wrong_parameter if no $app parameter given for static call
* @return boolean|int true if no change, else number of affected rows
*/
/* static */ function save_value($name,$value,$app=null)
static function save_value($name, $value, $app, $update_cache=true)
{
if (!$app && (!isset($this) || !is_a($this,__CLASS__)))
{
throw new egw_exception_assertion_failed('$app parameter required for static call of config::save_value($name,$value,$app)!');
throw new egw_exception_wrong_parameter('$app parameter required for static call of config::save_value($name,$value,$app)!');
}
//echo "<p>config::save_value('$name','".print_r($value,True)."','$app')</p>\n";
if (!$app || isset($this) && is_a($this,__CLASS__) && $app == $this->appname)
@ -152,9 +154,23 @@ class config
if (!isset($value) || $value === '')
{
if (isset(self::$configs[$app])) unset(self::$configs[$app][$name]);
return self::$db->delete(config::TABLE,array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
self::$db->delete(config::TABLE,array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
}
return self::$db->insert(config::TABLE,array('config_value'=>$value),array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
else
{
self::$configs[$app][$name] = $value;
if(is_array($value)) $value = serialize($value);
self::$db->insert(config::TABLE,array('config_value'=>$value),array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
}
if ($update_cache)
{
if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited
{
$GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server])
}
egw_cache::setInstance(__CLASS__, 'configs', self::$configs);
}
return self::$db->affected_rows();
}
/**
@ -223,7 +239,7 @@ class config
// manually retrieve the string lengths of the serialized array if unserialize failed
$test = @unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.mb_strlen('$2','8bit').':\"$2\";'", $value));
}
$config[$name] = is_array($test) ? $test : $value;
}
}