fix big chunk of PHP 8.0 warnings

This commit is contained in:
Ralf Becker 2021-10-21 10:39:30 +02:00
parent 3f5af3eeb2
commit b1af39be37
31 changed files with 83 additions and 79 deletions

View File

@ -166,8 +166,8 @@ class Sql
$data['account_id'] = -$data['account_id']; $data['account_id'] = -$data['account_id'];
$data['mailAllowed'] = true; $data['mailAllowed'] = true;
} }
if (!$data['account_firstname']) $data['account_firstname'] = $data['account_lid']; if (empty($data['account_firstname'])) $data['account_firstname'] = $data['account_lid'];
if (!$data['account_lastname']) if (empty($data['account_lastname']))
{ {
$data['account_lastname'] = $data['account_type'] == 'g' ? 'Group' : 'User'; $data['account_lastname'] = $data['account_type'] == 'g' ? 'Group' : 'User';
// if we call lang() before the translation-class is correctly setup, // if we call lang() before the translation-class is correctly setup,
@ -177,7 +177,7 @@ class Sql
$data['account_lastname'] = lang($data['account_lastname']); $data['account_lastname'] = lang($data['account_lastname']);
} }
} }
if (!$data['account_fullname']) $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname']; if (empty($data['account_fullname'])) $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
return $data; return $data;
} }

View File

@ -74,7 +74,7 @@ class Acl
*/ */
function __construct($account_id = null) function __construct($account_id = null)
{ {
if (is_object($GLOBALS['egw_setup']->db)) if (isset($GLOBALS['egw_setup']) && is_object($GLOBALS['egw_setup']->db))
{ {
$this->db = $GLOBALS['egw_setup']->db; $this->db = $GLOBALS['egw_setup']->db;
} }
@ -481,6 +481,10 @@ class Acl
'acl_appname' => $appname, 'acl_appname' => $appname,
),__LINE__,__FILE__) as $row) ),__LINE__,__FILE__) as $row)
{ {
if (!isset($rights[$row['acl_location']]))
{
$rights[$row['acl_location']] = 0;
}
$rights[$row['acl_location']] |= $row['acl_rights']; $rights[$row['acl_location']] |= $row['acl_rights'];
} }
return $rights; return $rights;

View File

@ -232,7 +232,7 @@ class Asyncservice
{ {
if ((string)$t == '*') $t = '*/1'; if ((string)$t == '*') $t = '*/1';
list($one,$inc) = $arr = explode('/',$t); list($one,$inc) = $arr = explode('/',$t)+[null,null];
if (!(is_numeric($one) && count($arr) == 1 || if (!(is_numeric($one) && count($arr) == 1 ||
count($arr) == 2 && is_numeric($inc))) count($arr) == 2 && is_numeric($inc)))
@ -247,7 +247,7 @@ class Asyncservice
} }
else else
{ {
list($min,$max) = $arr = explode('-',$one); list($min,$max) = $arr = explode('-',$one)+[null,null];
if (empty($one) || $one == '*') if (empty($one) || $one == '*')
{ {
$min = $min_unit[$u]; $min = $min_unit[$u];

View File

@ -207,8 +207,8 @@ class Contacts extends Contacts\Storage
$this->default_private = substr($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ?? '',-1) == 'p'; $this->default_private = substr($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] ?? '',-1) == 'p';
if ($this->default_addressbook > 0 && $this->default_addressbook != $this->user && if ($this->default_addressbook > 0 && $this->default_addressbook != $this->user &&
($this->default_private || ($this->default_private ||
$this->default_addressbook == (int)$GLOBALS['egw']->preferences->forced['addressbook']['add_default'] || $this->default_addressbook == (int)($GLOBALS['egw']->preferences->forced['addressbook']['add_default'] ?? 0) ||
$this->default_addressbook == (int)$GLOBALS['egw']->preferences->default['addressbook']['add_default'])) $this->default_addressbook == (int)($GLOBALS['egw']->preferences->default['addressbook']['add_default'] ?? 0)))
{ {
$this->default_addressbook = $this->user; // admin set a default or forced pref for personal addressbook $this->default_addressbook = $this->user; // admin set a default or forced pref for personal addressbook
} }

View File

@ -1601,7 +1601,7 @@ class Db
} }
if (empty($column_definitions)) if (empty($column_definitions))
{ {
$column_definitions = $this->column_definitions; $column_definitions = $this->column_definitions ?? null;
} }
if ($this->Debug) echo "<p>db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre>\n"; if ($this->Debug) echo "<p>db::column_data_implode('$glue',".print_r($array,True).",'$use_key',".print_r($only,True).",<pre>".print_r($column_definitions,True)."</pre>\n";
@ -2164,7 +2164,7 @@ class Db
} }
if (is_array($where)) if (is_array($where))
{ {
$where = $this->column_data_implode(' AND ',$where,True,False,$table_def['fd']); $where = $this->column_data_implode(' AND ',$where,True,False, $table_def ? $table_def['fd'] : null);
} }
if (self::$tablealiases && isset(self::$tablealiases[$table])) if (self::$tablealiases && isset(self::$tablealiases[$table]))
{ {

View File

@ -39,7 +39,7 @@ class Applications
*/ */
function __construct($account_id = '') function __construct($account_id = '')
{ {
if (is_object($GLOBALS['egw_setup']) && is_object($GLOBALS['egw_setup']->db)) if (isset($GLOBALS['egw_setup']) && is_object($GLOBALS['egw_setup']->db))
{ {
$this->db = $GLOBALS['egw_setup']->db; $this->db = $GLOBALS['egw_setup']->db;
} }

View File

@ -92,7 +92,7 @@ class Grid extends Box
{ {
$cname = self::form_name($cname, $this->id, $expand); $cname = self::form_name($cname, $this->id, $expand);
} }
if($cname && (!empty($expand['cname']) && $expand['cname'] !== $cname || !$expand['cname'])) if ($cname && (empty($expand['cname']) || $expand['cname'] !== $cname))
{ {
$expand['cont'] =& self::get_array(self::$request->content, $cname); $expand['cont'] =& self::get_array(self::$request->content, $cname);
$expand['cname'] = $cname; $expand['cname'] = $cname;

View File

@ -87,7 +87,7 @@ class Link extends Etemplate\Widget
// ToDo: implement on client-side // ToDo: implement on client-side
if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application');
if($attrs['type'] == 'link-list') if (!empty($attrs['type']) && $attrs['type'] === 'link-list')
{ {
$app = $value['to_app']; $app = $value['to_app'];
$id = $value['to_id']; $id = $value['to_id'];

View File

@ -317,10 +317,10 @@ class Select extends Etemplate\Widget
{ {
// Check selection preference, we may be able to skip reading some data // Check selection preference, we may be able to skip reading some data
$select_pref = $GLOBALS['egw_info']['user']['preferences']['common']['account_selection']; $select_pref = $GLOBALS['egw_info']['user']['preferences']['common']['account_selection'];
if($this->attrs['type'] == 'select-account' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $select_pref == 'none') if($this->attrs['type'] == 'select-account' && empty($GLOBALS['egw_info']['user']['apps']['admin']) && $select_pref == 'none')
{ {
// Preserve but do not send the value if preference is 'none' // Preserve but do not send the value if preference is 'none'
self::$request->preserv[$this->id] = self::$request->content[$this->id]; self::$request->preserv[$this->id] = self::$request->content[$this->id] ?? null;
unset(self::$request->content[$this->id]); unset(self::$request->content[$this->id]);
$this->attrs['readonly'] = true; $this->attrs['readonly'] = true;
} }
@ -335,7 +335,7 @@ class Select extends Etemplate\Widget
if (!isset($form_names_done[$form_name]) && if (!isset($form_names_done[$form_name]) &&
($type_options = self::typeOptions($this, ($type_options = self::typeOptions($this,
// typeOptions thinks # of rows is the first thing in options // typeOptions thinks # of rows is the first thing in options
(!empty($this->attrs['rows']) && !empty($this->attrs['options']) && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ? $this->attrs['rows'].','.$this->attrs['options'] : $this->attrs['options']), (!empty($this->attrs['rows']) && !empty($this->attrs['options']) && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ? $this->attrs['rows'].','.$this->attrs['options'] : ($this->attrs['options']??null)),
$no_lang, $this->attrs['readonly'] ?? false, self::get_array(self::$request->content, $form_name), $form_name))) $no_lang, $this->attrs['readonly'] ?? false, self::get_array(self::$request->content, $form_name), $form_name)))
{ {
self::fix_encoded_options($type_options); self::fix_encoded_options($type_options);

View File

@ -85,7 +85,7 @@ class Tabbox extends Etemplate\Widget
{ {
foreach($this->children[1]->children as $tab) foreach($this->children[1]->children as $tab)
{ {
if($readonlys[$tab->id]) if (!empty($readonlys[$tab->id]))
{ {
$tab->attrs['disabled'] = $readonlys[$tab->id]; $tab->attrs['disabled'] = $readonlys[$tab->id];
} }

View File

@ -42,7 +42,7 @@ class Vfs extends File
$form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content)); $form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content));
if (!empty($this->attrs['path'])) if (!empty($this->attrs['path']))
{ {
$path = self::expand_name($this->attrs['path'],$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); $path = self::expand_name($this->attrs['path'], $expand['c']??null, $expand['row'], $expand['c_']??null, $expand['row_']??null, $expand['cont']);
} }
else else
{ {

View File

@ -70,17 +70,17 @@ class Html
{ {
$additionalQuote="";//at the end, ... $additionalQuote="";//at the end, ...
// only one &quot at the end is found. chance is, it is not belonging to the URL // only one &quot at the end is found. chance is, it is not belonging to the URL
if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')===false) if (!empty($match[5]) && $match[5]===';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')===false)
{ {
$match[4] = substr($match[4],0,strpos($match[4],'&quot',strlen($match[4])-6)); $match[4] = substr($match[4],0,strpos($match[4],'&quot',strlen($match[4])-6));
$additionalQuote = "&quot;"; $additionalQuote = "&quot;";
} }
// if there is quoted stuff within the URL then we have at least one more &quot; in match[4], so chance is the last &quot is matched by the one within // if there is quoted stuff within the URL then we have at least one more &quot; in match[4], so chance is the last &quot is matched by the one within
if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')!==false) if (!empty($match[5]) && $match[5]===';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')!==false)
{ {
$match[4] .= $match[5]; $match[4] .= $match[5];
} }
if ($match[5]==';'&&$match[4]=="&quot") if (!empty($match[5]) && $match[5]===';' && $match[4]==="&quot")
{ {
$match[4] =''; $match[4] ='';
$additionalQuote = "&quot;"; $additionalQuote = "&quot;";
@ -101,18 +101,18 @@ class Html
$result4 = preg_replace_callback( $Expr, function ($match) { $result4 = preg_replace_callback( $Expr, function ($match) {
//error_log(__METHOD__.__LINE__.array2string($match)); //error_log(__METHOD__.__LINE__.array2string($match));
$match += [null,null,null,null]; $match += [null,null,null,null];
if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false) if (!empty($match[4]) && $match[4]===';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false)
{ {
$match[3] = substr($match[3],0,strpos($match[3],'&gt',strlen($match[3])-4)); $match[3] = substr($match[3],0,strpos($match[3],'&gt',strlen($match[3])-4));
$match[4] = "&gt;"; $match[4] = "&gt;";
} }
if ($match[4]==';'&&$match[3]=="&gt") if (!empty($match[4]) && $match[4]===';' && $match[3]=="&gt")
{ {
$match[3] =''; $match[3] ='';
$match[4] = "&gt;"; $match[4] = "&gt;";
} }
//error_log(__METHOD__.__LINE__.array2string($match)); //error_log(__METHOD__.__LINE__.array2string($match));
return $match[1]."<a href=\"https://www".$match[2].$match[3]."\" target=\"_blank\">"."www".$match[2].$match[3]."</a>".$match[4]; return $match[1]."<a href=\"https://www".$match[2].$match[3]."\" target=\"_blank\">"."www".$match[2].$match[3]."</a>".($match[4]??'');
}, $result3 ); }, $result3 );
} }
return $result4; return $result4;

View File

@ -182,7 +182,7 @@ class Image
} }
$app_map =& $map['vfs']; $app_map =& $map['vfs'];
if (true) $app_map = array(); if (true) $app_map = array();
if (($dir = $GLOBALS['egw_info']['server']['vfs_image_dir']) && Vfs::file_exists($dir) && Vfs::is_readable($dir)) if (!empty($dir = $GLOBALS['egw_info']['server']['vfs_image_dir']) && Vfs::file_exists($dir) && Vfs::is_readable($dir))
{ {
foreach(Vfs::find($dir) as $img) foreach(Vfs::find($dir) as $img)
{ {

View File

@ -1527,7 +1527,7 @@ class Link extends Link\Storage
{ {
self::notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data); self::notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data);
} }
if($data[Link::OLD_LINK_TITLE] && Json\Response::isJSONResponse()) if (!empty($data[Link::OLD_LINK_TITLE]) && Json\Response::isJSONResponse())
{ {
// Update client side with new title // Update client side with new title
Json\Response::get()->apply('egw.link_title_callback',array(array($app => array($id => self::title($app, $id))))); Json\Response::get()->apply('egw.link_title_callback',array(array($app => array($id => self::title($app, $id)))));

View File

@ -213,7 +213,7 @@ class Mail
} }
if ($_oldImapServerObject instanceof Mail\Imap) if ($_oldImapServerObject instanceof Mail\Imap)
{ {
if (!is_object(self::$instances[$_profileID])) if (!isset(self::$instances[$_profileID]))
{ {
self::$instances[$_profileID] = new Mail('utf-8',false,$_profileID,false,$_reuseCache); self::$instances[$_profileID] = new Mail('utf-8',false,$_profileID,false,$_reuseCache);
} }
@ -1113,7 +1113,7 @@ class Mail
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent));
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft));
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template));
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId] ?? [];
if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId]))
return $_specialUseFolders[$this->icServer->ImapServerId]; return $_specialUseFolders[$this->icServer->ImapServerId];
$_specialUseFolders[$this->icServer->ImapServerId]=array(); $_specialUseFolders[$this->icServer->ImapServerId]=array();

View File

@ -154,10 +154,10 @@ class Imap extends Horde_Imap_Client_Socket implements Imap\PushIface
$this->params = $params; $this->params = $params;
$this->isAdminConnection = $_adminConnection; $this->isAdminConnection = $_adminConnection;
$this->enableSieve = (boolean)$this->params['acc_sieve_enabled']; $this->enableSieve = (boolean)$this->params['acc_sieve_enabled'];
$this->loginType = $this->params['acc_imap_logintype']; $this->loginType = $this->params['acc_imap_logintype'] ?? null;
$this->domainName = $this->params['acc_domain']; $this->domainName = $this->params['acc_domain'] ?? null;
if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']??self::getTimeOut ();
// Horde use locale for translation of error messages // Horde use locale for translation of error messages
// need to set LC_CTYPE for charachter classification (eg. Umlauts) // need to set LC_CTYPE for charachter classification (eg. Umlauts)

View File

@ -1554,7 +1554,7 @@ class Session
{ {
foreach(explode('&', $extravars) as $expr) foreach(explode('&', $extravars) as $expr)
{ {
list($var,$val) = explode('=', $expr,2); list($var,$val) = explode('=', $expr,2)+[null,null];
if (strpos($val,'%26') != false) $val = str_replace('%26','&',$val); // make sure to not double encode & if (strpos($val,'%26') != false) $val = str_replace('%26','&',$val); // make sure to not double encode &
if (substr($var,-2) == '[]') if (substr($var,-2) == '[]')
{ {

View File

@ -965,7 +965,7 @@ class Base
} }
} }
$num_rows = 0; // as spec. in max_matches in the user-prefs $num_rows = 0; // as spec. in max_matches in the user-prefs
if (is_array($start)) list($start,$num_rows) = $start; if (is_array($start)) list($start,$num_rows) = $start+[null,null];
// fix GROUP BY clause to contain all non-aggregate selected columns // fix GROUP BY clause to contain all non-aggregate selected columns
if ($order_by && stripos($order_by,'GROUP BY') !== false) if ($order_by && stripos($order_by,'GROUP BY') !== false)
@ -1106,8 +1106,8 @@ class Base
$query[$db_col] = ''; $query[$db_col] = '';
} }
} }
elseif ($wildcard || $criteria[$col][0] == '!' || elseif ($wildcard || is_string($criteria[$col]) && ($criteria[$col][0] == '!' ||
is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false)) (strpos($criteria[$col],'*') !== false || strpos($criteria[$col],'?') !== false)))
{ {
// if search pattern alread contains a wildcard, do NOT add further ones automatic // if search pattern alread contains a wildcard, do NOT add further ones automatic
if (is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false)) if (is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false))

View File

@ -62,7 +62,7 @@ class History
$this->appname = $appname ?: $GLOBALS['egw_info']['flags']['currentapp']; $this->appname = $appname ?: $GLOBALS['egw_info']['flags']['currentapp'];
$this->user = $user ?: $GLOBALS['egw_info']['user']['account_id']; $this->user = $user ?: $GLOBALS['egw_info']['user']['account_id'];
if(is_object($GLOBALS['egw_setup']->db)) if (isset($GLOBALS['egw_setup']) && is_object($GLOBALS['egw_setup']->db))
{ {
$this->db = $GLOBALS['egw_setup']->db; $this->db = $GLOBALS['egw_setup']->db;
} }

View File

@ -2832,7 +2832,7 @@ abstract class Merge
); );
// Check for a configured preferred directory // Check for a configured preferred directory
if(($pref = $GLOBALS['egw_info']['user']['preferences'][$this->get_app()][Merge::PREF_STORE_LOCATION]) && Vfs::is_writable($pref)) if(!empty($pref = $GLOBALS['egw_info']['user']['preferences'][$this->get_app()][Merge::PREF_STORE_LOCATION]) && Vfs::is_writable($pref))
{ {
$target = $pref; $target = $pref;
} }

View File

@ -435,7 +435,7 @@ abstract class Tracking
$this->historylog = new History($this->app, $this->user); $this->historylog = new History($this->app, $this->user);
} }
// log user-agent and session-action // log user-agent and session-action
if ($GLOBALS['egw_info']['server']['log_user_agent_action'] && ($changed_fields || !$old)) if (!empty($GLOBALS['egw_info']['server']['log_user_agent_action']) && ($changed_fields || !$old))
{ {
$this->historylog->add('user_agent_action', $data[$this->id_field], $this->historylog->add('user_agent_action', $data[$this->id_field],
$_SERVER['HTTP_USER_AGENT'], $_SESSION[Api\Session::EGW_SESSION_VAR]['session_action']); $_SERVER['HTTP_USER_AGENT'], $_SESSION[Api\Session::EGW_SESSION_VAR]['session_action']);
@ -509,7 +509,7 @@ abstract class Tracking
$changed_fields = array(); $changed_fields = array();
foreach($this->field2history as $name => $status) foreach($this->field2history as $name => $status)
{ {
if (!$old[$name] && !$data[$name]) continue; // treat all sorts of empty equally if (empty($old[$name]) && empty($data[$name])) continue; // treat all sorts of empty equally
if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed
@ -544,7 +544,7 @@ abstract class Tracking
} }
foreach($data as $name => $value) foreach($data as $name => $value)
{ {
if ($name[0] == '#' && $name[1] == '#' && $value !== $old[$name]) if (isset($name[0]) && $name[0] == '#' && $name[1] == '#' && $value !== $old[$name])
{ {
$changed_fields[] = $name; $changed_fields[] = $name;
} }
@ -843,7 +843,7 @@ abstract class Tracking
$notification->set_reply_to($reply_to); $notification->set_reply_to($reply_to);
$notification->set_subject($subject); $notification->set_subject($subject);
$notification->set_links(array($link)); $notification->set_links(array($link));
$notification->set_popupdata($link['app'], $link); $notification->set_popupdata($link?$link['app']:null, $link);
if ($attachments && is_array($attachments)) if ($attachments && is_array($attachments))
{ {
$notification->set_attachments($attachments); $notification->set_attachments($attachments);
@ -938,9 +938,9 @@ abstract class Tracking
$sender = $name ? $name.' <'.$email.'>' : $email; $sender = $name ? $name.' <'.$email.'>' : $email;
} }
} }
elseif(!$sender) elseif (!$sender)
{ {
$sender = 'EGroupware '.lang($this->app).' <noreply@'.$GLOBALS['egw_info']['server']['mail_suffix'].'>'; $sender = 'EGroupware '.lang($this->app).' <noreply@'.($GLOBALS['egw_info']['server']['mail_suffix']??'nodomain.org').'>';
} }
//echo "<p>".__METHOD__."()='".htmlspecialchars($sender)."'</p>\n"; //echo "<p>".__METHOD__."()='".htmlspecialchars($sender)."'</p>\n";
return $sender; return $sender;

View File

@ -283,7 +283,7 @@ class Translation
self::add_app($apps); self::add_app($apps);
} }
$phrase = static::translate($message, $vars); $phrase = static::translate($message, $vars);
if($old_lang) if (!empty($old_lang))
{ {
$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $old_lang; $GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $old_lang;
self::init(true); self::init(true);

View File

@ -427,7 +427,7 @@ class Vfs extends Vfs\Base
self::_check_add($options,$path,$result); self::_check_add($options,$path,$result);
} }
if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 && if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 &&
$options['depth'] < $options['maxdepth'])) && ($options['depth'] ?? 0) < $options['maxdepth'])) &&
($dir = @opendir($path, $context))) ($dir = @opendir($path, $context)))
{ {
while(($fname = readdir($dir)) !== false) while(($fname = readdir($dir)) !== false)
@ -1296,7 +1296,7 @@ class Vfs extends Vfs\Base
$b = explode('/',$b_str); $b = explode('/',$b_str);
$ret = implode('/',array_merge($a,$b)); $ret = implode('/',array_merge($a,$b));
} }
return $ret.($query ? (strpos($url,'?')===false ? '?' : '&').$query : ''); return $ret.(isset($query) ? (strpos($url,'?')===false ? '?' : '&').$query : '');
} }
/** /**
@ -2043,7 +2043,7 @@ class Vfs extends Vfs\Base
} }
else else
{ {
$ret = ($context ? copy($tmp_name, self::PREFIX.$target, $context) : $ret = (isset($context) ? copy($tmp_name, self::PREFIX.$target, $context) :
copy($tmp_name, self::PREFIX.$target)) ? copy($tmp_name, self::PREFIX.$target)) ?
self::stat($target) : false; self::stat($target) : false;
} }

View File

@ -573,7 +573,7 @@ class Base
{ {
return __CLASS__; return __CLASS__;
} }
list($app, $app_scheme) = explode('.', $scheme); list($app, $app_scheme) = explode('.', $scheme)+[null,null];
foreach(array( foreach(array(
empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\' . ucfirst($scheme) . '\\StreamWrapper' : // streamwrapper in Api\Vfs empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\' . ucfirst($scheme) . '\\StreamWrapper' : // streamwrapper in Api\Vfs
'EGroupware\\' . ucfirst($app) . '\\Vfs\\' . ucfirst($app_scheme) . '\\StreamWrapper', 'EGroupware\\' . ucfirst($app) . '\\Vfs\\' . ucfirst($app_scheme) . '\\StreamWrapper',

View File

@ -262,7 +262,7 @@ class StreamWrapper extends LinksParent
if($path[0] != '/') if($path[0] != '/')
{ {
if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY); if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY);
$path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : ''); $path = Vfs::parse_url($path,PHP_URL_PATH).(!empty($query) ? '?'.$query : '');
} }
list(,$apps,$app,$id) = explode('/',$path); list(,$apps,$app,$id) = explode('/',$path);

View File

@ -310,7 +310,7 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface
{ {
if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
// if creating a new file as root eg. via (docker exec) filemanager/cli.php do NOT create files unreadable by webserver // if creating a new file as root eg. via (docker exec) filemanager/cli.php do NOT create files unreadable by webserver
if ($new_file && function_exists('posix_getuid') && !posix_getuid()) if (!empty($new_file) && function_exists('posix_getuid') && !posix_getuid())
{ {
umask(0666); umask(0666);
} }
@ -1628,7 +1628,7 @@ GROUP BY A.fs_id';
// first check our stat-cache for the ids // first check our stat-cache for the ids
foreach(self::$stat_cache as $path => $stat) foreach(self::$stat_cache as $path => $stat)
{ {
if (($key = array_search($stat['fs_id'],$ids)) !== false) if ($stat && ($key = array_search($stat['fs_id'],$ids)) !== false)
{ {
$pathes[$stat['fs_id']] = $path; $pathes[$stat['fs_id']] = $path;
unset($ids[$key]); unset($ids[$key]);
@ -1948,7 +1948,7 @@ GROUP BY A.fs_id';
} }
if (!is_array($path_ids)) if (!is_array($path_ids))
{ {
$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props $props = isset($row) && !empty($props[$row['fs_id']]) ? $props[$row['fs_id']] : []; // return empty array for no props
} }
elseif ($props && isset($stat) && is_array($id2path = self::id2path(array_keys($props)))) // need to map fs_id's to pathes elseif ($props && isset($stat) && is_array($id2path = self::id2path(array_keys($props)))) // need to map fs_id's to pathes
{ {

View File

@ -209,7 +209,7 @@ class StreamWrapper extends Base implements StreamWrapperIface
// are we requested to treat the opened file as new file (only for files opened NOT for reading) // are we requested to treat the opened file as new file (only for files opened NOT for reading)
if ($mode[0] != 'r' && !$this->opened_stream_is_new && $this->context && if ($mode[0] != 'r' && !$this->opened_stream_is_new && $this->context &&
($opts = stream_context_get_options($this->context)) && ($opts = stream_context_get_options($this->context)) &&
$opts['options'][self::SCHEME]['treat_as_new']) !empty($opts['options'][self::SCHEME]['treat_as_new']))
{ {
$this->opened_stream_is_new = true; $this->opened_stream_is_new = true;
//error_log(__METHOD__."($path,$mode,...) stat=$stat, context=".array2string($opts)." --> ".array2string($this->opened_stream_is_new)); //error_log(__METHOD__."($path,$mode,...) stat=$stat, context=".array2string($opts)." --> ".array2string($this->opened_stream_is_new));
@ -994,7 +994,7 @@ class StreamWrapper extends Base implements StreamWrapperIface
if (Vfs::$user != $GLOBALS['egw_info']['user']['account_id']) if (Vfs::$user != $GLOBALS['egw_info']['user']['account_id'])
{ {
$prefs = new Api\Preferences(Vfs::$user); $prefs = new Api\Preferences(Vfs::$user);
$vfs_fstab = $prefs->data['common']['vfs_fstab']; $vfs_fstab = $prefs->data['common']['vfs_fstab'] ?? [];
} }
else else
{ {

View File

@ -117,7 +117,7 @@ trait UserContextTrait
} }
// if we check writable and have a readonly mount --> return false, as backends dont know about r/o url parameter // if we check writable and have a readonly mount --> return false, as backends dont know about r/o url parameter
if ($check == Vfs::WRITABLE && Vfs\StreamWrapper::url_is_readonly($stat['url'])) if ($check == Vfs::WRITABLE && Vfs\StreamWrapper::url_is_readonly($stat['url'] ?? null))
{ {
//error_log(__METHOD__."(path=$path, check=writable, ...) failed because mount is readonly"); //error_log(__METHOD__."(path=$path, check=writable, ...) failed because mount is readonly");
return false; return false;
@ -125,7 +125,7 @@ trait UserContextTrait
// check if we use an EGroupwre stream wrapper, or a stock php one // check if we use an EGroupwre stream wrapper, or a stock php one
// if it's not an EGroupware one, we can NOT use uid, gid and mode! // if it's not an EGroupware one, we can NOT use uid, gid and mode!
if (($scheme = Vfs::parse_url($stat['url'], PHP_URL_SCHEME)) && !(class_exists(Vfs::scheme2class($scheme)))) if (($scheme = Vfs::parse_url($stat['url'] ?? null, PHP_URL_SCHEME)) && !(class_exists(Vfs::scheme2class($scheme))))
{ {
switch($check) switch($check)
{ {

View File

@ -193,7 +193,7 @@ class filemanager_merge extends Api\Storage\Merge
if(is_array($link)) if(is_array($link))
{ {
// Directories have their internal protocol in path here // Directories have their internal protocol in path here
if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; if (!empty($link['path']) && strpos($link['path'], '://') !== false) $link['path'] = $file['path'];
$link = Api\Session::link('/index.php', $link); $link = Api\Session::link('/index.php', $link);
} }
else else
@ -215,7 +215,7 @@ class filemanager_merge extends Api\Storage\Merge
if(!$value) $value = ''; if(!$value) $value = '';
$info['$$' . ($prefix ? $prefix . '/' : '') . $key . '$$'] = $value; $info['$$' . ($prefix ? $prefix . '/' : '') . $key . '$$'] = $value;
} }
if($app_placeholders) if (!empty($app_placeholders) && is_array($app_placeholders))
{ {
$info = array_merge($app_placeholders, $info); $info = array_merge($app_placeholders, $info);
} }

View File

@ -320,7 +320,7 @@ class importexport_export_csv implements importexport_iface_export_record
list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
// Add in any fields that are keys to another app // Add in any fields that are keys to another app
foreach((array)$fields['links'] as $link_field => $app) foreach($fields['links'] ?? [] as $link_field => $app)
{ {
if(is_numeric($link_field)) continue; if(is_numeric($link_field)) continue;
$links[$link_field] = $app; $links[$link_field] = $app;
@ -332,7 +332,7 @@ class importexport_export_csv implements importexport_iface_export_record
// Not quite a recursive merge, since only one level // Not quite a recursive merge, since only one level
foreach($fields as $type => &$list) foreach($fields as $type => &$list)
{ {
if($c_fields[$type]) if (!empty($c_fields[$type]))
{ {
$list = array_merge($c_fields[$type], $list); $list = array_merge($c_fields[$type], $list);
unset($c_fields[$type]); unset($c_fields[$type]);
@ -341,7 +341,7 @@ class importexport_export_csv implements importexport_iface_export_record
$fields += $c_fields; $fields += $c_fields;
$selects += $c_selects; $selects += $c_selects;
} }
foreach((array)$fields['select'] as $name) foreach($fields['select'] ?? [] as $name)
{ {
if($record->$name != null && is_array($selects) && $selects[$name]) if($record->$name != null && is_array($selects) && $selects[$name])
{ {
@ -366,7 +366,7 @@ class importexport_export_csv implements importexport_iface_export_record
$record->$name = ''; $record->$name = '';
} }
} }
foreach((array)$fields['links'] as $name) { foreach($fields['links'] ?? [] as $name) {
if($record->$name) { if($record->$name) {
if(is_numeric($record->$name) && !$links[$name]) { if(is_numeric($record->$name) && !$links[$name]) {
$link = Link::get_link($record->$name); $link = Link::get_link($record->$name);
@ -387,7 +387,7 @@ class importexport_export_csv implements importexport_iface_export_record
$record->$name = ''; $record->$name = '';
} }
} }
foreach((array)$fields['select-account'] as $name) { foreach($fields['select-account'] ?? [] as $name) {
// Compare against null to deal with empty arrays // Compare against null to deal with empty arrays
if ($record->$name !== null) { if ($record->$name !== null) {
if(is_array($record->$name)) { if(is_array($record->$name)) {
@ -405,25 +405,25 @@ class importexport_export_csv implements importexport_iface_export_record
$record->$name = ''; $record->$name = '';
} }
} }
foreach((array)$fields['select-bool'] as $name) { foreach($fields['select-bool'] ?? [] as $name) {
if($record->$name !== null) { if($record->$name !== null) {
$record->$name = $record->$name ? lang('Yes') : lang('No'); $record->$name = $record->$name ? lang('Yes') : lang('No');
} }
} }
foreach((array)$fields['date-time'] as $name) { foreach($fields['date-time'] ?? [] as $name) {
//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
if (!$record->$name) $record->$name = ''; if (!$record->$name) $record->$name = '';
} }
foreach((array)$fields['date'] as $name) { foreach($fields['date'] ?? [] as $name) {
//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
if (!$record->$name) $record->$name = ''; if (!$record->$name) $record->$name = '';
} }
foreach((array)$fields['float'] as $name) foreach($fields['float'] ?? [] as $name)
{ {
static $dec_separator,$thousands_separator; static $dec_separator,$thousands_separator;
if (is_null($dec_separator)) if (is_null($dec_separator))
@ -445,7 +445,7 @@ class importexport_export_csv implements importexport_iface_export_record
} }
// Some custom methods for conversion // Some custom methods for conversion
foreach((array)$methods as $name => $method) { foreach($methods ?? [] as $name => $method) {
if ($record->$name) if ($record->$name)
{ {
if(is_string($method)) if(is_string($method))

View File

@ -784,9 +784,9 @@ class infolog_so
'event' => 'calendar' 'event' => 'calendar'
); );
// query children independent of action // query children independent of action
if ((string)$query['col_filter']['info_id_parent'] === '') if (empty($query['col_filter']['info_id_parent']))
{ {
$action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : $query['action']; $action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : ($query['action'] ?? null);
if ($action) if ($action)
{ {
$links = Link\Storage::get_links($action=='sp'?'infolog':$action, $links = Link\Storage::get_links($action=='sp'?'infolog':$action,
@ -833,10 +833,10 @@ class infolog_so
$ordermethod = 'ORDER BY info_datemodified DESC'; // newest first $ordermethod = 'ORDER BY info_datemodified DESC'; // newest first
} }
$filtermethod = $no_acl ? '1=1' : $this->aclFilter($query['filter']); $filtermethod = $no_acl ? '1=1' : $this->aclFilter($query['filter']);
if (!$query['col_filter']['info_status']) $filtermethod .= $this->statusFilter($query['filter']); if (empty($query['col_filter']['info_status'])) $filtermethod .= $this->statusFilter($query['filter']);
$filtermethod .= $this->dateFilter($query['filter']); $filtermethod .= $this->dateFilter($query['filter']);
$cfcolfilter=0; $cfcolfilter=0;
if (is_array($query['col_filter'])) if (isset($query['col_filter']) && is_array($query['col_filter']))
{ {
foreach($query['col_filter'] as $col => $data) foreach($query['col_filter'] as $col => $data)
{ {
@ -894,15 +894,15 @@ class infolog_so
} }
//echo "<p>filtermethod='$filtermethod'</p>"; //echo "<p>filtermethod='$filtermethod'</p>";
if ((int)$query['cat_id']) if (!empty($query['cat_id']) && (int)$query['cat_id'])
{ {
$categories = new Api\Categories('','infolog'); $categories = new Api\Categories('','infolog');
$cats = $categories->return_all_children((int)$query['cat_id']); $cats = $categories->return_all_children((int)$query['cat_id']);
$filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']); $filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']);
} }
$join = $distinct = ''; $join = $distinct = '';
if ($query['query']) $query['search'] = $query['query']; // allow both names if (!empty($query['query'])) $query['search'] = $query['query']; // allow both names
if ($query['search']) // we search in _from, _subject, _des and _extra_value for $query if (!empty($query['search'])) // we search in _from, _subject, _des and _extra_value for $query
{ {
$columns = array('info_from','info_location','info_subject'); $columns = array('info_from','info_location','info_subject');
// at the moment MaxDB 7.5 cant cast nor search text columns, it's suppost to change in 7.6 // at the moment MaxDB 7.5 cant cast nor search text columns, it's suppost to change in 7.6
@ -924,7 +924,7 @@ class infolog_so
$join .= " LEFT JOIN $this->users_table attendees ON main.info_id=attendees.info_id AND attendees.info_res_deleted IS NULL"; $join .= " LEFT JOIN $this->users_table attendees ON main.info_id=attendees.info_id AND attendees.info_res_deleted IS NULL";
$group_by = ' GROUP BY main.info_id '; $group_by = ' GROUP BY main.info_id ';
// check if $query['append'] already contains a GROUP BY clause // check if $query['append'] already contains a GROUP BY clause
if (stripos($query['append'], 'group by') !== false) if (!empty($query['append']) && stripos($query['append'], 'group by') !== false)
{ {
$query['append'] .= ',main.info_id '; $query['append'] .= ',main.info_id ';
} }
@ -943,7 +943,7 @@ class infolog_so
$ids = array( ); $ids = array( );
if ($action == '' || $action == 'sp' || count($links)) if ($action == '' || $action == 'sp' || count($links))
{ {
$sql_query = "FROM $this->info_table main $join WHERE ($filtermethod $pid $sql_query) $link_extra"; $sql_query = "FROM $this->info_table main $join WHERE ($filtermethod $pid ".($sql_query ?? '').') '.($link_extra??'');
#error_log("infolog.so.search:\n" . print_r($sql_query, true)); #error_log("infolog.so.search:\n" . print_r($sql_query, true));
if ($this->db->Type == 'mysql' && (float)$this->db->ServerInfo['version'] >= 4.0) if ($this->db->Type == 'mysql' && (float)$this->db->ServerInfo['version'] >= 4.0)
@ -984,7 +984,7 @@ class infolog_so
$cols .= ','.$this->db->group_concat('attendees.info_res_attendee').' AS info_cc'; $cols .= ','.$this->db->group_concat('attendees.info_res_attendee').' AS info_cc';
$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query. $rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.
$query['append'].$ordermethod,__LINE__,__FILE__, $query['append'].$ordermethod,__LINE__,__FILE__,
(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC); (int)($query['start']??0),isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n"; //echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
if ($mysql_calc_rows) if ($mysql_calc_rows)
@ -1011,7 +1011,7 @@ class infolog_so
$ids[$info['info_id']] = $info; $ids[$info['info_id']] = $info;
} }
static $index_load_cfs = null; static $index_load_cfs = null;
if (is_null($index_load_cfs) && $query['col_filter']['info_type']) if (is_null($index_load_cfs) && !empty($query['col_filter']['info_type']))
{ {
$config_data = Api\Config::read('infolog'); $config_data = Api\Config::read('infolog');
$index_load_cfs = $config_data['index_load_cfs']; $index_load_cfs = $config_data['index_load_cfs'];