PHP 8 fixes

Reviewers: #hkccp_developers

Differential Revision: https://git.kolab.org/D4016
This commit is contained in:
Christian Mollekopf 2023-01-25 14:58:01 +01:00 committed by Aleksander Machniak
parent de4e56a561
commit bac56c4cd1
13 changed files with 43 additions and 37 deletions

View file

@ -385,7 +385,7 @@ class kolab_contacts extends rcube_addressbook
$this->sortindex = array_merge($this->sortindex, $local_sortindex); $this->sortindex = array_merge($this->sortindex, $local_sortindex);
} }
} }
else if (is_array($this->filter['ids'])) { else if ($this->filter && is_array($this->filter['ids'])) {
$ids = $this->filter['ids']; $ids = $this->filter['ids'];
if (count($ids)) { if (count($ids)) {
$uids = array_map(array($this, 'id2uid'), $this->filter['ids']); $uids = array_map(array($this, 'id2uid'), $this->filter['ids']);
@ -1134,13 +1134,13 @@ class kolab_contacts extends rcube_addressbook
switch ($this->sort_col) { switch ($this->sort_col) {
case 'name': case 'name':
$str = $rec['name'] . $rec['prefix']; $str = ($rec['name'] ?? null) . ($rec['prefix'] ?? null);
case 'firstname': case 'firstname':
$str .= $rec['firstname'] . $rec['middlename'] . $rec['surname']; $str .= ($rec['firstname'] ?? null) . ($rec['middlename'] ?? null) . ($rec['surname'] ?? null);
break; break;
case 'surname': case 'surname':
$str = $rec['surname'] . $rec['firstname'] . $rec['middlename']; $str = ($rec['surname'] ?? null) . ($rec['firstname'] ?? null) . ($rec['middlename'] ?? null);
break; break;
default: default:
@ -1148,7 +1148,9 @@ class kolab_contacts extends rcube_addressbook
break; break;
} }
$str .= is_array($rec['email']) ? $rec['email'][0] : $rec['email']; if ($rec['email'] ?? null) {
$str .= is_array($rec['email']) ? $rec['email'][0] : $rec['email'];
}
return mb_strtolower($str); return mb_strtolower($str);
} }
@ -1262,7 +1264,7 @@ class kolab_contacts extends rcube_addressbook
// convert email, website, phone values // convert email, website, phone values
foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) { foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) {
if (is_array($record[$col])) { if (is_array($record[$col] ?? null)) {
$values = $record[$col]; $values = $record[$col];
unset($record[$col]); unset($record[$col]);
foreach ((array)$values as $i => $val) { foreach ((array)$values as $i => $val) {
@ -1272,7 +1274,7 @@ class kolab_contacts extends rcube_addressbook
} }
} }
if (is_array($record['address'])) { if (is_array($record['address'] ?? null)) {
$addresses = $record['address']; $addresses = $record['address'];
unset($record['address']); unset($record['address']);
foreach ($addresses as $i => $adr) { foreach ($addresses as $i => $adr) {
@ -1288,7 +1290,7 @@ class kolab_contacts extends rcube_addressbook
} }
// photo is stored as separate attachment // photo is stored as separate attachment
if ($record['photo'] && strlen($record['photo']) < 255 && !empty($record['_attachments'][$record['photo']])) { if (($record['photo'] ?? null) && strlen($record['photo']) < 255 && !empty($record['_attachments'][$record['photo']])) {
$att = $record['_attachments'][$record['photo']]; $att = $record['_attachments'][$record['photo']];
// only fetch photo content if requested // only fetch photo content if requested
if ($this->action == 'photo') { if ($this->action == 'photo') {

View file

@ -240,7 +240,7 @@ class kolab_addressbook extends rcube_plugin
$source = $data[$id]; $source = $data[$id];
$is_collapsed = strpos($this->rc->config->get('collapsed_abooks',''), '&'.rawurlencode($id).'&') !== false; $is_collapsed = strpos($this->rc->config->get('collapsed_abooks',''), '&'.rawurlencode($id).'&') !== false;
if ($folder->virtual) { if (!empty($folder->virtual)) {
$source = $this->driver->abook_prop($folder->id, $folder); $source = $this->driver->abook_prop($folder->id, $folder);
} }
else if (empty($source)) { else if (empty($source)) {

View file

@ -656,7 +656,7 @@ class kolab_auth extends rcube_plugin
// User name for identity (first log in) // User name for identity (first log in)
foreach ((array)$name_attr as $field) { foreach ((array)$name_attr as $field) {
$name = is_array($record[$field]) ? $record[$field][0] : $record[$field]; $name = is_array($record[$field] ?? null) ? $record[$field][0] : ($record[$field] ?? null);
if (!empty($name)) { if (!empty($name)) {
$this->data['user_name'] = $name; $this->data['user_name'] = $name;
break; break;

View file

@ -28,6 +28,7 @@ class kolab_files_engine
private $rc; private $rc;
private $url; private $url;
private $url_srv; private $url_srv;
private $filetypes_style;
private $timeout = 600; private $timeout = 600;
private $files_sort_cols = array('name', 'mtime', 'size'); private $files_sort_cols = array('name', 'mtime', 'size');
private $sessions_sort_cols = array('name'); private $sessions_sort_cols = array('name');
@ -145,7 +146,7 @@ class kolab_files_engine
$this->rc->output->set_env('files_api_version', $caps['VERSION'] ?? 3); $this->rc->output->set_env('files_api_version', $caps['VERSION'] ?? 3);
$this->rc->output->set_env('files_user', $this->rc->get_user_name()); $this->rc->output->set_env('files_user', $this->rc->get_user_name());
if ($caps['DOCEDIT']) { if ($caps['DOCEDIT'] ?? false) {
$this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice', $this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice',
'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice', 'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice',
'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment', 'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment',
@ -729,7 +730,7 @@ class kolab_files_engine
{ {
$prefix = 'kolab_' . $type . '_'; $prefix = 'kolab_' . $type . '_';
$c_prefix = 'kolab_files_' . ($type != 'files' ? $type : '') . '_'; $c_prefix = 'kolab_files_' . ($type != 'files' ? $type : '') . '_';
$skin_path = $_SESSION['skin_path']; $skin_path = $_SESSION['skin_path'] ?? null;
// check to see if we have some settings for sorting // check to see if we have some settings for sorting
$sort_col = $_SESSION[$prefix . 'sort_col']; $sort_col = $_SESSION[$prefix . 'sort_col'];
@ -789,7 +790,7 @@ class kolab_files_engine
'title' => $this->plugin->gettext('sortby') 'title' => $this->plugin->gettext('sortby')
), $col_name); ), $col_name);
} }
else if ($col_name[0] != '<') { else if (empty($col_name) || $col_name[0] != '<') {
$col_name = '<span class="' . $col .'">' . $col_name . '</span>'; $col_name = '<span class="' . $col .'">' . $col_name . '</span>';
} }
@ -870,7 +871,7 @@ class kolab_files_engine
$attrib['id'] = 'filepreviewframe'; $attrib['id'] = 'filepreviewframe';
} }
if ($frame = $this->file_data['viewer']['frame']) { if ($frame = ($this->file_data['viewer']['frame'] ?? null)) {
return $frame; return $frame;
} }
@ -895,6 +896,7 @@ class kolab_files_engine
$attrib['src'] = $href; $attrib['src'] = $href;
$attrib['onload'] = 'kolab_files_frame_load(this)'; $attrib['onload'] = 'kolab_files_frame_load(this)';
$form = null;
// editor requires additional arguments via POST // editor requires additional arguments via POST
if (!empty($this->file_data['viewer']['post'])) { if (!empty($this->file_data['viewer']['post'])) {
$attrib['src'] = 'program/resources/blank.gif'; $attrib['src'] = 'program/resources/blank.gif';
@ -966,8 +968,8 @@ class kolab_files_engine
*/ */
public function get_api_token($configure = true) public function get_api_token($configure = true)
{ {
$token = $_SESSION['kolab_files_token']; $token = $_SESSION['kolab_files_token'] ?? null;
$time = $_SESSION['kolab_files_time']; $time = $_SESSION['kolab_files_time'] ?? null;
if ($token && time() - $this->timeout < $time) { if ($token && time() - $this->timeout < $time) {
if (time() - $time <= $this->timeout / 2) { if (time() - $time <= $this->timeout / 2) {
@ -1059,7 +1061,7 @@ class kolab_files_engine
} }
} }
if ($_SESSION['kolab_files_caps']['MANTICORE'] || $_SESSION['kolab_files_caps']['WOPI']) { if (($_SESSION['kolab_files_caps']['MANTICORE'] ?? false) || ($_SESSION['kolab_files_caps']['WOPI'] ?? false)) {
$_SESSION['kolab_files_caps']['DOCEDIT'] = true; $_SESSION['kolab_files_caps']['DOCEDIT'] = true;
$_SESSION['kolab_files_caps']['DOCTYPE'] = $_SESSION['kolab_files_caps']['MANTICORE'] ? 'manticore' : 'wopi'; $_SESSION['kolab_files_caps']['DOCTYPE'] = $_SESSION['kolab_files_caps']['MANTICORE'] ? 'manticore' : 'wopi';
} }
@ -1135,8 +1137,8 @@ class kolab_files_engine
// Configure session // Configure session
$query = array( $query = array(
'method' => 'configure', 'method' => 'configure',
'timezone' => $prefs['timezone'] ?: $this->rc->config->get('timezone'), 'timezone' => $prefs['timezone'] ?? $this->rc->config->get('timezone'),
'date_format' => $prefs['date_long'] ?: $this->rc->config->get('date_long', 'Y-m-d H:i'), 'date_format' => $prefs['date_long'] ?? $this->rc->config->get('date_long', 'Y-m-d H:i'),
); );
$request = $this->get_request($query, $token); $request = $this->get_request($query, $token);
@ -1643,11 +1645,13 @@ class kolab_files_engine
$placeholder = $this->rc->output->asset_url('program/resources/blank.gif'); $placeholder = $this->rc->output->asset_url('program/resources/blank.gif');
if ($this->file_data['viewer']['wopi']) { $editor_type = null;
$got_editor = null;
if ($this->file_data['viewer']['wopi'] ?? false) {
$editor_type = 'wopi'; $editor_type = 'wopi';
$got_editor = ($viewer & 4); $got_editor = ($viewer & 4);
} }
else if ($this->file_data['viewer']['manticore']) { else if ($this->file_data['viewer']['manticore'] ?? false) {
$editor_type = 'manticore'; $editor_type = 'manticore';
$got_editor = ($viewer & 4); $got_editor = ($viewer & 4);
} }

View file

@ -324,7 +324,7 @@ class kolab_folders extends rcube_plugin
$ctype = trim(rcube_utils::get_input_value('_ctype', rcube_utils::INPUT_POST)); $ctype = trim(rcube_utils::get_input_value('_ctype', rcube_utils::INPUT_POST));
$subtype = trim(rcube_utils::get_input_value('_subtype', rcube_utils::INPUT_POST)); $subtype = trim(rcube_utils::get_input_value('_subtype', rcube_utils::INPUT_POST));
$mbox = $args['record']['name']; $mbox = $args['record']['name'];
$old_mbox = $args['record']['oldname']; $old_mbox = $args['record']['oldname'] ?? null;
$subscribe = $args['record']['subscribe']; $subscribe = $args['record']['subscribe'];
if (empty($ctype)) { if (empty($ctype)) {

View file

@ -95,7 +95,7 @@ class kolab_notes extends rcube_plugin
} }
// add 'Append note' item to message menu // add 'Append note' item to message menu
if ($this->api->output->type == 'html' && $_REQUEST['_rel'] != 'note') { if ($this->api->output->type == 'html' && ($_REQUEST['_rel'] ?? null) != 'note') {
$this->api->add_content(html::tag('li', array('role' => 'menuitem'), $this->api->add_content(html::tag('li', array('role' => 'menuitem'),
$this->api->output->button(array( $this->api->output->button(array(
'command' => 'append-kolab-note', 'command' => 'append-kolab-note',
@ -112,7 +112,7 @@ class kolab_notes extends rcube_plugin
} }
} }
if (!$this->rc->output->ajax_call && !$this->rc->output->env['framed']) { if (!$this->rc->output->ajax_call && !($this->rc->output->env['framed'] ?? null)) {
$this->load_ui(); $this->load_ui();
} }
@ -243,7 +243,7 @@ class kolab_notes extends rcube_plugin
'parent' => $parent_id, 'parent' => $parent_id,
); );
} }
else if ($folder->virtual) { else if (!empty($folder->virtual)) {
$lists[$list_id] = array( $lists[$list_id] = array(
'id' => $list_id, 'id' => $list_id,
'name' => $fullname, 'name' => $fullname,

View file

@ -457,7 +457,7 @@ class kolab_ldap extends rcube_ldap_generic
$entry['displayname'] = rcube_addressbook::compose_search_name( $entry['displayname'] = rcube_addressbook::compose_search_name(
$entry, $entry,
$entry['email'], $entry['email'],
$entry['name'], $entry['name'] ?? null,
$this->conf['kolab_auth_user_displayname'] $this->conf['kolab_auth_user_displayname']
); );
} }

View file

@ -624,7 +624,7 @@ class kolab_storage
} }
} }
if ($data = $metadata[$folder]) { if ($data = $metadata[$folder] ?? null) {
if (($name = $data[self::NAME_KEY_PRIVATE]) || ($name = $data[self::NAME_KEY_SHARED])) { if (($name = $data[self::NAME_KEY_PRIVATE]) || ($name = $data[self::NAME_KEY_SHARED])) {
return $name; return $name;
} }
@ -649,6 +649,7 @@ class kolab_storage
$found = false; $found = false;
$namespace = self::$imap->get_namespace(); $namespace = self::$imap->get_namespace();
$prefix = null;
if (!empty($namespace['shared'])) { if (!empty($namespace['shared'])) {
foreach ($namespace['shared'] as $ns) { foreach ($namespace['shared'] as $ns) {
@ -910,7 +911,7 @@ class kolab_storage
// Filter folders list // Filter folders list
foreach ($folders as $idx => $folder) { foreach ($folders as $idx => $folder) {
$type = $folderdata[$folder]; $type = $folderdata[$folder] ?? null;
if ($filter == 'mail' && empty($type)) { if ($filter == 'mail' && empty($type)) {
continue; continue;
@ -964,7 +965,7 @@ class kolab_storage
$folders = self::$imap->list_folders_subscribed($root, $mbox); $folders = self::$imap->list_folders_subscribed($root, $mbox);
// add temporarily subscribed folders // add temporarily subscribed folders
if ($filter != 'mail' && self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'])) { if ($filter != 'mail' && self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'] ?? null)) {
$folders = array_unique(array_merge($folders, $_SESSION['kolab_subscribed_folders'])); $folders = array_unique(array_merge($folders, $_SESSION['kolab_subscribed_folders']));
} }
@ -1695,7 +1696,7 @@ class kolab_storage
} }
$token = $folder_id; $token = $folder_id;
if ($domain && strpos($find, '@') === false) { if ($domain && strpos($token, '@') === false) {
$token .= '@' . $domain; $token .= '@' . $domain;
} }

View file

@ -440,7 +440,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
if (!is_array($objects)) { if (!is_array($objects)) {
rcube::raise_error([ rcube::raise_error([
'code' => 900, 'code' => 900,
'message' => "Failed to fetch {$href}" 'message' => "Failed to fetch {$this->href}"
], true); ], true);
return false; return false;
} }

View file

@ -225,7 +225,7 @@ abstract class kolab_storage_folder_api
{ {
// color is defined in folder METADATA // color is defined in folder METADATA
$metadata = $this->get_metadata(); $metadata = $this->get_metadata();
if (($color = $metadata[kolab_storage::COLOR_KEY_PRIVATE]) || ($color = $metadata[kolab_storage::COLOR_KEY_SHARED])) { if (($color = $metadata[kolab_storage::COLOR_KEY_PRIVATE] ?? null) || ($color = $metadata[kolab_storage::COLOR_KEY_SHARED] ?? null)) {
return $color; return $color;
} }

View file

@ -23,8 +23,6 @@
*/ */
class kolab_storage_folder_virtual extends kolab_storage_folder_api class kolab_storage_folder_virtual extends kolab_storage_folder_api
{ {
public $virtual = true;
protected $displayname; protected $displayname;
public function __construct($name, $dispname, $ns, $parent = '') public function __construct($name, $dispname, $ns, $parent = '')
@ -34,6 +32,7 @@ class kolab_storage_folder_virtual extends kolab_storage_folder_api
$this->namespace = $ns; $this->namespace = $ns;
$this->parent = $parent; $this->parent = $parent;
$this->displayname = $dispname; $this->displayname = $dispname;
$this->virtual = true;
} }
/** /**

View file

@ -379,7 +379,7 @@ class libkolab extends rcube_plugin
'reset-command' => 'non-existing-command', 'reset-command' => 'non-existing-command',
); );
if ($attrib['label-domain'] && !strpos($attrib['buttontitle'], '.')) { if (($attrib['label-domain'] ?? null) && !strpos($attrib['buttontitle'], '.')) {
$attrib['buttontitle'] = $attrib['label-domain'] . '.' . $attrib['buttontitle']; $attrib['buttontitle'] = $attrib['label-domain'] . '.' . $attrib['buttontitle'];
} }

View file

@ -150,7 +150,7 @@ class tasklist_kolab_driver extends tasklist_driver
'owner' => $folder->get_owner(), 'owner' => $folder->get_owner(),
'parentfolder' => $folder->get_parent(), 'parentfolder' => $folder->get_parent(),
'default' => $folder->default, 'default' => $folder->default,
'virtual' => $folder->virtual, 'virtual' => !empty($folder->virtual),
'children' => true, // TODO: determine if that folder indeed has child folders 'children' => true, // TODO: determine if that folder indeed has child folders
'subscribed' => (bool)$folder->is_subscribed(), 'subscribed' => (bool)$folder->is_subscribed(),
'removable' => !$folder->default, 'removable' => !$folder->default,
@ -224,7 +224,7 @@ class tasklist_kolab_driver extends tasklist_driver
'parent' => $parent_id, 'parent' => $parent_id,
); );
} }
else if ($folder->virtual) { else if (!empty($folder->virtual)) {
$lists[$list_id] = array( $lists[$list_id] = array(
'id' => $list_id, 'id' => $list_id,
'name' => $fullname, 'name' => $fullname,