Fix PHP8 warnings

This commit is contained in:
Aleksander Machniak 2023-07-28 14:07:18 +02:00
parent fa7f7324e8
commit 83fd802cc4
5 changed files with 30 additions and 25 deletions

View file

@ -2331,8 +2331,8 @@ $("#rcmfd_new_category").keypress(function(event) {
private function write_preprocess(&$event, $action) private function write_preprocess(&$event, $action)
{ {
// Remove double timezone specification (T2313) // Remove double timezone specification (T2313)
$event['start'] = preg_replace('/\s*\(.*\)/', '', $event['start']); $event['start'] = preg_replace('/\s*\(.*\)/', '', $event['start'] ?? '');
$event['end'] = preg_replace('/\s*\(.*\)/', '', $event['end']); $event['end'] = preg_replace('/\s*\(.*\)/', '', $event['end'] ?? '');
// convert dates into DateTime objects in user's current timezone // convert dates into DateTime objects in user's current timezone
$event['start'] = new DateTime($event['start'], $this->timezone); $event['start'] = new DateTime($event['start'], $this->timezone);
@ -3386,7 +3386,7 @@ $("#rcmfd_new_category").keypress(function(event) {
'uid' => $event['uid'], 'uid' => $event['uid'],
'_instance' => isset($event['_instance']) ? $event['_instance'] : null, '_instance' => isset($event['_instance']) ? $event['_instance'] : null,
'changed' => is_object($event['changed']) ? $event['changed']->format('U') : 0, 'changed' => is_object($event['changed']) ? $event['changed']->format('U') : 0,
'sequence' => intval($event['sequence']), 'sequence' => intval($event['sequence'] ?? 0),
'fallback' => strtoupper((string) $status), 'fallback' => strtoupper((string) $status),
'method' => $event['_method'], 'method' => $event['_method'],
'task' => 'calendar', 'task' => 'calendar',

View file

@ -891,7 +891,7 @@ class kolab_delegation_engine
} }
// add Sender: header with current user default identity // add Sender: header with current user default identity
if ($context) { if (!empty($context)) {
$identity = $this->rc->user->get_identity(); $identity = $this->rc->user->get_identity();
$sender = format_email_recipient($identity['email'], $identity['name']); $sender = format_email_recipient($identity['email'], $identity['name']);

View file

@ -1230,7 +1230,7 @@ class kolab_notes extends rcube_plugin
*/ */
public function mail_message_load($p) public function mail_message_load($p)
{ {
if (!$p['object']->headers->others['x-kolab-type']) { if (empty($p['object']->headers->others['x-kolab-type'])) {
$this->message_notes = $this->get_message_notes($p['object']->headers, $p['object']->folder); $this->message_notes = $this->get_message_notes($p['object']->headers, $p['object']->folder);
} }
} }

View file

@ -401,8 +401,8 @@ class libcalendaring_itip
$emails = $this->lib->get_user_emails(); $emails = $this->lib->get_user_emails();
foreach ($existing['attendees'] as $attendee) { foreach ($existing['attendees'] as $attendee) {
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) { if (!empty($attendee['email']) && in_array(strtolower($attendee['email']), $emails)) {
$status = strtoupper($attendee['status']); $status = !empty($attendee['status']) ? strtoupper($attendee['status']) : '';
break; break;
} }
} }
@ -619,12 +619,12 @@ class libcalendaring_itip
$rsvp_buttons = ''; $rsvp_buttons = '';
// pass some metadata about the event and trigger the asynchronous status check // pass some metadata about the event and trigger the asynchronous status check
$changed = is_object($event['changed']) ? $event['changed'] : $message_date; $changed = !empty($event['changed']) && is_object($event['changed']) ? $event['changed'] : $message_date;
$metadata = array( $metadata = array(
'uid' => $event['uid'], 'uid' => $event['uid'],
'_instance' => isset($event['_instance']) ? $event['_instance'] : null, '_instance' => isset($event['_instance']) ? $event['_instance'] : null,
'changed' => $changed ? $changed->format('U') : 0, 'changed' => $changed ? $changed->format('U') : 0,
'sequence' => intval($event['sequence']), 'sequence' => intval($event['sequence'] ?? 0),
'method' => $method, 'method' => $method,
'task' => $task, 'task' => $task,
'mime_id' => $mime_id, 'mime_id' => $mime_id,
@ -683,7 +683,7 @@ class libcalendaring_itip
// when receiving iTip REQUEST messages: // when receiving iTip REQUEST messages:
else if ($method == 'REQUEST') { else if ($method == 'REQUEST') {
$emails = $this->lib->get_user_emails(); $emails = $this->lib->get_user_emails();
$title = $event['sequence'] > 0 ? $this->gettext('itipupdate') : $this->gettext('itipinvitation'); $title = !empty($event['sequence']) ? $this->gettext('itipupdate') : $this->gettext('itipinvitation');
$metadata['rsvp'] = true; $metadata['rsvp'] = true;
if (is_object($event['start'])) { if (is_object($event['start'])) {
@ -983,17 +983,17 @@ class libcalendaring_itip
*/ */
public static function get_custom_property($event, $name) public static function get_custom_property($event, $name)
{ {
$ret = false; $ret = false;
if (is_array($event['x-custom'])) { if (is_array($event['x-custom'])) {
array_walk($event['x-custom'], function($prop, $i) use ($name, &$ret) { array_walk($event['x-custom'], function($prop, $i) use ($name, &$ret) {
if (strcasecmp($prop[0], $name) === 0) { if (strcasecmp($prop[0], $name) === 0) {
$ret = $prop[1]; $ret = $prop[1];
} }
}); });
} }
return $ret; return $ret;
} }
/** /**
@ -1010,7 +1010,8 @@ class libcalendaring_itip
/** /**
* Find an attendee that is not the organizer and has an email matching $email_field * Find an attendee that is not the organizer and has an email matching $email_field
*/ */
public function find_attendee_by_email($attendees, $email_field, $email, $email_utf = null) { public function find_attendee_by_email($attendees, $email_field, $email, $email_utf = null)
{
foreach ($attendees as $_attendee) { foreach ($attendees as $_attendee) {
if (!empty($attendee['role']) && $attendee['role'] == 'ORGANIZER') { if (!empty($attendee['role']) && $attendee['role'] == 'ORGANIZER') {
continue; continue;
@ -1019,16 +1020,19 @@ class libcalendaring_itip
return $attendee; return $attendee;
} }
} }
return null; return null;
} }
/** /**
* Find the replying attendee in a REPLY * Find the replying attendee in a REPLY
*/ */
public static function find_reply_attendee($event) { public static function find_reply_attendee($event)
{
// remove the organizer // remove the organizer
$itip_attendees = array_filter($event['attendees'], function($item) { return $item['role'] != 'ORGANIZER' && !empty($item['email']); }); $itip_attendees = array_filter($event['attendees'], function($item) {
$attendee = null; return (empty($item['role']) || $item['role'] != 'ORGANIZER') && !empty($item['email']);
});
// According to rfc there should only be one attendee for a REPLY // According to rfc there should only be one attendee for a REPLY
if (count($itip_attendees) == 1) { if (count($itip_attendees) == 1) {

View file

@ -552,7 +552,8 @@ abstract class kolab_format_xcal extends kolab_format
} }
else { else {
// action == DISPLAY // action == DISPLAY
$alarm = new Alarm(strval(!empty($valarm['summary']) ? $valarm['summary'] : $object['title'])); $title = !empty($valarm['summary']) ? $valarm['summary'] : ($object['title'] ?? '');
$alarm = new Alarm($title);
} }
if ($valarm['trigger'] instanceof DateTimeInterface) { if ($valarm['trigger'] instanceof DateTimeInterface) {
@ -638,7 +639,7 @@ abstract class kolab_format_xcal extends kolab_format
*/ */
public function get_reference_date() public function get_reference_date()
{ {
if ($this->data['start'] && $this->data['start'] instanceof DateTimeInterface) { if (!empty($this->data['start']) && $this->data['start'] instanceof DateTimeInterface) {
return $this->data['start']; return $this->data['start'];
} }