fix PHP Deprecated errors visible in egroupware-docker-install.log

This commit is contained in:
ralf 2023-01-26 10:42:18 +01:00
parent 0fe421658e
commit 55054024b6
13 changed files with 27 additions and 27 deletions

View File

@ -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)

View File

@ -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();

View File

@ -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);
}

View File

@ -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();

View File

@ -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);

View File

@ -1582,7 +1582,7 @@ class Session
}
else
{
$query[] = $key.'='.urlencode($value);
$query[] = $key.'='.urlencode($value ?? '');
}
}
$ret_url .= '?' . implode('&',$query);

View File

@ -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)))

View File

@ -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 {
}
}
}

View File

@ -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

View File

@ -831,8 +831,8 @@ class setup
echo'<br>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] == '')
{

View File

@ -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
}
}
}
}
}

View File

@ -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);

View File

@ -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;