* API: is_a compatibility vs. php5.3.8 resolving to instanceof operator for most common basic classes

This commit is contained in:
Klaus Leithoff 2011-09-26 10:01:53 +00:00
parent 9edce957d1
commit ad9df848d0
6 changed files with 21 additions and 13 deletions

View File

@ -49,7 +49,7 @@ class auth
$this->backend = new $backend_class; $this->backend = new $backend_class;
if (!is_a($this->backend,'auth_backend')) if (!($this->backend instanceof auth_backend))
{ {
throw new egw_exception_assertion_failed("Auth backend class $backend_class is NO auth_backend!"); throw new egw_exception_assertion_failed("Auth backend class $backend_class is NO auth_backend!");
} }

View File

@ -1374,9 +1374,9 @@ class egw_db
{ {
case 'int': case 'int':
// if DateTime object given, convert it to a unix timestamp (NOT converting the timezone!) // if DateTime object given, convert it to a unix timestamp (NOT converting the timezone!)
if (is_object($value) && is_a($value,'DateTime')) if (is_object($value) && ($value instanceof DateTime))
{ {
return is_a($value,'egw_time') ? $value->format('ts') : egw_time::to($value,'ts'); return ($value instanceof egw_time) ? $value->format('ts') : egw_time::to($value,'ts');
} }
case 'auto': case 'auto':
// atm. (php5.2) php has only 32bit integers, it converts everything else to float. // atm. (php5.2) php has only 32bit integers, it converts everything else to float.
@ -1410,14 +1410,14 @@ class egw_db
break; // handled like strings break; // handled like strings
case 'date': case 'date':
// if DateTime object given, convert it (NOT converting the timezone!) // if DateTime object given, convert it (NOT converting the timezone!)
if (is_object($value) && is_a($value,'DateTime')) if (is_object($value) && ($value instanceof DateTime))
{ {
return $this->Link_ID->qstr($value->format('Y-m-d')); return $this->Link_ID->qstr($value->format('Y-m-d'));
} }
return $this->Link_ID->DBDate($value); return $this->Link_ID->DBDate($value);
case 'timestamp': case 'timestamp':
// if DateTime object given, convert it (NOT converting the timezone!) // if DateTime object given, convert it (NOT converting the timezone!)
if (is_object($value) && is_a($value,'DateTime')) if (is_object($value) && ($value instanceof DateTime))
{ {
return $this->Link_ID->qstr($value->format('Y-m-d H:i:s')); return $this->Link_ID->qstr($value->format('Y-m-d H:i:s'));
} }

View File

@ -149,7 +149,7 @@ class egw_time extends DateTime
break; break;
case 'object': case 'object':
if (is_a($time,'DateTime')) if ($time instanceof DateTime)
{ {
parent::__construct($time->format('Y-m-d H:i:s'),$time->getTimezone()); parent::__construct($time->format('Y-m-d H:i:s'),$time->getTimezone());
$this->setTimezone($tz); $this->setTimezone($tz);
@ -269,7 +269,8 @@ class egw_time extends DateTime
*/ */
public static function server2user($time,$type=null) public static function server2user($time,$type=null)
{ {
if (!is_a($time,$typeof='egw_time')) $typeof='egw_time';
if (!($time instanceof egw_time))
{ {
try try
{ {
@ -297,7 +298,8 @@ class egw_time extends DateTime
*/ */
public static function user2server($time,$type=null) public static function user2server($time,$type=null)
{ {
if (!is_a($time,$typeof='egw_time')) $typeof='egw_time';
if (!($time instanceof egw_time))
{ {
try try
{ {
@ -327,7 +329,7 @@ class egw_time extends DateTime
*/ */
public static function to($time='now',$type='') public static function to($time='now',$type='')
{ {
if (!is_a($time,'egw_time')) if (!($time instanceof egw_time))
{ {
try try
{ {
@ -390,7 +392,7 @@ class egw_time extends DateTime
*/ */
public static function tz_offset_s($time='now') public static function tz_offset_s($time='now')
{ {
if (!is_a($time,'DateTime')) $time = new egw_time($time); if (!($time instanceof DateTime)) $time = new egw_time($time);
return egw_time::$user_timezone->getOffset($time) - egw_time::$server_timezone->getOffset($time); return egw_time::$user_timezone->getOffset($time) - egw_time::$server_timezone->getOffset($time);
} }

View File

@ -51,7 +51,7 @@ class ldap
*/ */
function getLDAPServerInfo($_host) function getLDAPServerInfo($_host)
{ {
if(is_a($this->ldapServerInfo[$_host], 'ldapserverinfo')) if($this->ldapServerInfo[$_host] instanceof ldapserverinfo)
{ {
return $this->ldapServerInfo[$_host]; return $this->ldapServerInfo[$_host];
} }

View File

@ -312,6 +312,7 @@ class preferences
$this->forced[$app] = $value; $this->forced[$app] = $value;
break; break;
case self::DEFAULT_ID: case self::DEFAULT_ID:
//if ($app=='common') error_log(__METHOD__.__LINE__.array2string($value));
$this->default[$app] = $value; $this->default[$app] = $value;
break; break;
case $this->account_id: // user case $this->account_id: // user
@ -354,6 +355,7 @@ class preferences
{ {
if (!isset($this->data[$app][$var]) || $this->data[$app][$var] === '') if (!isset($this->data[$app][$var]) || $this->data[$app][$var] === '')
{ {
//if ($var=='remote_application_url') error_log(__METHOD__.__LINE__.' default for '.$var.' with '.$value);
$this->data[$app][$var] = $value; $this->data[$app][$var] = $value;
} }
} }
@ -384,6 +386,10 @@ class preferences
echo 'group<pre>'; print_r($this->group); echo "</pre>\n"; echo 'group<pre>'; print_r($this->group); echo "</pre>\n";
echo 'effectiv<pre>'; print_r($this->data); echo "</pre>\n"; echo 'effectiv<pre>'; print_r($this->data); echo "</pre>\n";
} }
//error_log(__METHOD__.__LINE__.'->user: remote_application_url:'.array2string($this->user['common']['remote_application_url']));
//error_log(__METHOD__.__LINE__.'->default: remote_application_url:'.array2string($this->default['common']['remote_application_url']));
//error_log(__METHOD__.__LINE__.'->forced: remote_application_url:'.array2string($this->forced['common']['remote_application_url']));
//error_log(__METHOD__.__LINE__.'->effective: remote_application_url:'.array2string($this->data['common']['remote_application_url']));
$this->check_set_tz_offset(); $this->check_set_tz_offset();
return $this->data; return $this->data;
@ -405,7 +411,7 @@ class preferences
//echo "<p>".__METHOD__."() tz=$prefs[tz] --> tz_offset={$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']}</p>\n"; //echo "<p>".__METHOD__."() tz=$prefs[tz] --> tz_offset={$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']}</p>\n";
// ToDo: get rid of that // ToDo: get rid of that
if (isset($GLOBALS['egw']) && is_a($GLOBALS['egw'],'egw')) if (isset($GLOBALS['egw']) && ($GLOBALS['egw'] instanceof egw))
{ {
$GLOBALS['egw']->unset_datetime(); // to force an update $GLOBALS['egw']->unset_datetime(); // to force an update
} }

View File

@ -78,7 +78,7 @@ if (egw_session::init_handler())
} }
$GLOBALS['egw'] = unserialize($_SESSION[egw_session::EGW_OBJECT_CACHE]); $GLOBALS['egw'] = unserialize($_SESSION[egw_session::EGW_OBJECT_CACHE]);
if (is_object($GLOBALS['egw']) && is_a($GLOBALS['egw'], 'egw')) // only egw object has wakeup2, setups egw_minimal eg. has not! if (is_object($GLOBALS['egw']) && ($GLOBALS['egw'] instanceof egw)) // only egw object has wakeup2, setups egw_minimal eg. has not!
{ {
$GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app) $GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app)