diff --git a/api/src/Accounts/Sql.php b/api/src/Accounts/Sql.php index 24efe40cec..25e999439a 100644 --- a/api/src/Accounts/Sql.php +++ b/api/src/Accounts/Sql.php @@ -436,12 +436,12 @@ class Sql ); // fetch order of account_fullname from Api\Accounts::format_username - if (strpos($param['order'],'account_fullname') !== false) + if (strpos($param['order'] ?? '','account_fullname') !== false) { $param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/',',',str_replace(array('[',']'),'', Api\Accounts::format_username('account_lid','account_firstname','account_lastname'))), $param['order']); } - $order = str_replace(array_keys($order2contact),array_values($order2contact),$param['order']); + $order = str_replace(array_keys($order2contact),array_values($order2contact),$param['order'] ?? ''); // allways add 'account_lid' if (strpos($order, 'account_lid') === false) diff --git a/api/src/DateTime.php b/api/src/DateTime.php index d0aecbd213..852977f209 100644 --- a/api/src/DateTime.php +++ b/api/src/DateTime.php @@ -189,11 +189,11 @@ class DateTime extends \DateTime * * @param DateInterval|string $interval eg. '1 day', '-2 weeks' */ - public function add($interval) + public function add($interval) : \DateTime { if (is_string($interval)) $interval = DateInterval::createFromDateString($interval); - parent::add($interval); + return parent::add($interval); } /** @@ -344,6 +344,7 @@ class DateTime extends \DateTime * true = date only, false = time only as in user prefs, '' = date+time as in user prefs, 'utc'=regular timestamp in UTC * @return int|string|array|datetime see $type */ + #[\ReturnTypeWillChange] public function format($type='') { switch((string)$type) @@ -758,4 +759,4 @@ class DateTime extends \DateTime return $ret_user_tzs; } } -DateTime::init(); +DateTime::init(); \ No newline at end of file diff --git a/api/src/Db.php b/api/src/Db.php index a6ece4875f..aa90ff2dfb 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -1603,7 +1603,7 @@ class Db $value = DateTime::user2server($value,'string'); } // truncate to long strings for varchar(X) columns as PostgreSQL and newer MySQL/MariaDB given an error otherwise - if (!is_null($length) && mb_strlen($value) > $length) + if (isset($length) && isset($value) && mb_strlen($value) > $length) { $value = mb_substr($value, 0, $length); } @@ -1615,7 +1615,7 @@ class Db // (MariaDB 10.1 does the replacement automatic, 10.0 cuts everything off behind and MySQL gives an error) // (MariaDB 10.3 gives an error too: Incorrect string value: '\xF0\x9F\x98\x8A\x0AW...') // Changing charset to utf8mb4 requires schema update, shortening of some indexes and probably have negative impact on performace! - if (substr($this->Type, 0, 5) == 'mysql') + if (isset($value) && substr($this->Type, 0, 5) === 'mysql') { $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value); } diff --git a/api/src/Header/UserAgent.php b/api/src/Header/UserAgent.php index 81f2d18662..4fa2855b00 100644 --- a/api/src/Header/UserAgent.php +++ b/api/src/Header/UserAgent.php @@ -98,9 +98,9 @@ class UserAgent { // should be Ok for all HTML 4 compatible browsers $parts = $all_parts = null; - if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts)) + if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'] ?? '',$parts)) { - preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$all_parts,PREG_SET_ORDER); + preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'] ?? '',$all_parts,PREG_SET_ORDER); $parts = array_pop($all_parts); foreach($all_parts as $p) { @@ -112,7 +112,7 @@ class UserAgent } } list(,self::$user_agent,self::$ua_version) = $parts; - if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera'; + if ((self::$user_agent = strtolower(self::$user_agent ?? '')) == 'version') self::$user_agent = 'opera'; // IE no longer reports MSIE, but "Trident/7.0; rv:11.0" if (self::$user_agent=='trident') { @@ -133,9 +133,9 @@ class UserAgent self::$ua_version = '12.0'; } self::$ua_mobile = preg_match('/(iPhone|iPod|iPad|Android|SymbianOS|Blackberry|Kindle|Opera Mobi|Windows Phone)/i', - $_SERVER['HTTP_USER_AGENT'], $matches) ? strtolower($matches[1]) : null; + $_SERVER['HTTP_USER_AGENT'] ?? '', $matches) ? strtolower($matches[1]) : null; //error_log("HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]', UserAgent: '".self::$user_agent."', Version: '".self::$ua_version."', isMobile=".array2string(self::$ua_mobile)); } } -UserAgent::_init_static(); +UserAgent::_init_static(); \ No newline at end of file diff --git a/api/src/Mail/Account.php b/api/src/Mail/Account.php index 6e8a7d1b47..b77f76f6a8 100644 --- a/api/src/Mail/Account.php +++ b/api/src/Mail/Account.php @@ -1245,7 +1245,7 @@ class Account implements \ArrayAccess $backup = array(); foreach(array('acc_smtp_type', 'acc_imap_type') as $attr) { - if (substr($data[$attr], 0, $ns_len) == __NAMESPACE__.'\\') + if (substr($data[$attr] ?? '', 0, $ns_len) == __NAMESPACE__.'\\') { $backup[$attr] = $data[$attr]; $data[$attr] = substr($data[$attr], $ns_len); diff --git a/api/src/Session.php b/api/src/Session.php index 1e9b6f04d3..1a038b8ff7 100644 --- a/api/src/Session.php +++ b/api/src/Session.php @@ -1582,7 +1582,7 @@ class Session } else { - $query[] = $key.'='.urlencode($value); + $query[] = $key.'='.urlencode($value ?? ''); } } $ret_url .= '?' . implode('&',$query); diff --git a/api/src/Storage/Merge.php b/api/src/Storage/Merge.php index 57906cb9bf..ff69c378d3 100644 --- a/api/src/Storage/Merge.php +++ b/api/src/Storage/Merge.php @@ -2062,7 +2062,7 @@ abstract class Merge * @return string with error-message on error * @throws Api\Exception */ - public function merge_file($document, $ids, &$name = '', $dirs = '', &$header) + public function merge_file($document, $ids, &$name = '', $dirs = '', &$header = null) { //error_log(__METHOD__."('$document', ".array2string($ids).", '$name', dirs='$dirs') ->".function_backtrace()); if(($error = $this->check_document($document, $dirs))) diff --git a/importexport/inc/class.importexport_definitions_bo.inc.php b/importexport/inc/class.importexport_definitions_bo.inc.php index 62bf782460..aa3885172b 100644 --- a/importexport/inc/class.importexport_definitions_bo.inc.php +++ b/importexport/inc/class.importexport_definitions_bo.inc.php @@ -250,7 +250,7 @@ class importexport_definitions_bo { $definition = new importexport_definition( $definition_data['name'] ); // Only update if the imported is newer - if(strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0) + if(!$definition->modified || strtotime($definition->modified) < strtotime($definition_data['modified'])) { $definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL; @@ -358,5 +358,4 @@ class importexport_definitions_bo { } -} - +} \ No newline at end of file diff --git a/importexport/inc/class.importexport_helper_functions.inc.php b/importexport/inc/class.importexport_helper_functions.inc.php index b032a6c262..f6e019b06c 100755 --- a/importexport/inc/class.importexport_helper_functions.inc.php +++ b/importexport/inc/class.importexport_helper_functions.inc.php @@ -127,7 +127,7 @@ class importexport_helper_functions { * @return mixed comma seperated list or array with ids */ public static function account_name2id( &$_account_lids ) { - $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids ); + $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids ?? '' ); $skip = false; foreach ( $account_lids as $key => $account_lid ) { if($skip) { @@ -777,4 +777,4 @@ class importexport_helper_functions { } return null; } -} // end of importexport_helper_functions +} // end of importexport_helper_functions \ No newline at end of file diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index c4d0b06b28..6b9b4077a6 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -831,8 +831,8 @@ class setup echo'
Input values: ' . 'A="'.$a.'", B="'.$b.'"'; } - $newa = str_replace('pre','.',$a); - $newb = str_replace('pre','.',$b); + $newa = str_replace('pre','.', $a ?? ''); + $newb = str_replace('pre','.', $b ?? ''); $testa = explode('.',$newa); if(@$testa[1] == '') { diff --git a/setup/inc/class.setup_cmd_config.inc.php b/setup/inc/class.setup_cmd_config.inc.php index 890accaa39..8647813e1f 100644 --- a/setup/inc/class.setup_cmd_config.inc.php +++ b/setup/inc/class.setup_cmd_config.inc.php @@ -348,10 +348,10 @@ class setup_cmd_config extends setup_cmd */ function _save_mail_account(array $data) { - // convert ssl textual values to nummerical ones used in Api\Mail\Account + // convert ssl textual values to numerical ones used in Api\Mail\Account foreach(array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) { - switch(strtolower($data[$name])) + switch(strtolower($data[$name] ?? '')) { case 'no': $data[$name] = Api\Mail\Account::SSL_NONE; break; case 'starttls': $data[$name] = Api\Mail\Account::SSL_STARTTLS; break; @@ -562,4 +562,4 @@ class setup_cmd_config extends setup_cmd } } } -} +} \ No newline at end of file diff --git a/setup/inc/class.setup_cmd_header.inc.php b/setup/inc/class.setup_cmd_header.inc.php index 67e430004d..92129ee5ed 100644 --- a/setup/inc/class.setup_cmd_header.inc.php +++ b/setup/inc/class.setup_cmd_header.inc.php @@ -341,7 +341,7 @@ class setup_cmd_header extends setup_cmd } elseif ($value !== '') { - self::_set_global(str_replace('@', $domain, $type), $name, $value); + self::_set_global(str_replace('@', $domain ?? '', $type), $name, $value); if ($type == 'egw_info/server/server_root') { self::_set_global('egw_info/server/include_root', $name, $value); diff --git a/setup/inc/class.setup_detection.inc.php b/setup/inc/class.setup_detection.inc.php index 0744ba36c3..f57a3c7fbc 100755 --- a/setup/inc/class.setup_detection.inc.php +++ b/setup/inc/class.setup_detection.inc.php @@ -199,7 +199,7 @@ class setup_detection { $major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue); $tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp); - $tmp2 = explode('.',$currentver); $minor = array_pop($tmp2); + $tmp2 = explode('.', $currentver ?? ''); $minor = array_pop($tmp2); if ($major == $major_depsvalue && $minor <= $minor_depsvalue) { $setup_info['depends'][$depkey]['status'] = True;