From 6a16eee07bae612bae5cc14639b1800ad6978cf8 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Wed, 26 Oct 2022 19:32:49 +0000 Subject: [PATCH] prevent more php8 warnings, fixes #1717 Closes #1717 Merge request studip/studip!1119 --- app/views/calendar/schedule/_entry_schedule.php | 16 ++++++++-------- app/views/calendar/schedule/entry.php | 2 +- lib/calendar/CalendarColumn.class.php | 5 ++++- lib/classes/sidebar/SearchWidget.php | 2 ++ lib/visual.inc.php | 5 +++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/views/calendar/schedule/_entry_schedule.php b/app/views/calendar/schedule/_entry_schedule.php index 6f3d8ffa16b..ad5bbcd6503 100644 --- a/app/views/calendar/schedule/_entry_schedule.php +++ b/app/views/calendar/schedule/_entry_schedule.php @@ -1,5 +1,5 @@ <form class="default" - action="<?= $controller->link_for('calendar/schedule/addentry' . ($show_entry['id'] ? '/' . $show_entry['id'] : '')) ?>" + action="<?= $controller->link_for('calendar/schedule/addentry', $show_entry['id'] ?? null) ?>" method="post" name="edit_entry" onSubmit="return STUDIP.Schedule.checkFormFields()"> <?= CSRFProtection::tokenTag() ?> <fieldset> @@ -22,38 +22,38 @@ <label class="col-2"> <?= _('von') ?> <input class="size-s studip-timepicker" placeholder="HH:mm" type="text" size="2" name="entry_start" - value="<?= $show_entry['start'] ? $show_entry['start_formatted'] : '' ?>" + value="<?= !empty($show_entry['start']) ? $show_entry['start_formatted'] : '' ?>" id="entry-start" data-time-picker> </label> <label class="col-2"> <?= _('bis') ?> <input class="size-s studip-timepicker" placeholder="HH:mm" type="text" size="2" name="entry_end" - value="<?= $show_entry['end'] ? $show_entry['end_formatted'] : '' ?>" + value="<?= !empty($show_entry['end']) ? $show_entry['end_formatted'] : '' ?>" id="entry-end" data-time-picker> </label> <span class="invalid_message"><?= _('Die Endzeit liegt vor der Startzeit!') ?></span> <?= $this->render_partial('calendar/schedule/_colorpicker.php', [ - 'selected' => $show_entry['color'], + 'selected' => $show_entry['color'] ?? null, ]) ?> <label> <?= _('Titel') ?> - <input type="text" name="entry_title" value="<?= htmlReady($show_entry['title']) ?>"> + <input type="text" name="entry_title" value="<?= htmlReady($show_entry['title'] ?? '') ?>"> </label> <label> <?= _('Beschreibung') ?> <textarea name="entry_content" - rows="7"><?= htmlReady($show_entry['content']) ?></textarea> + rows="7"><?= htmlReady($show_entry['content'] ?? '') ?></textarea> </label> </fieldset> <footer data-dialog-button> <?= Studip\Button::createAccept(_('Speichern'), ['style' => 'margin-right: 20px']) ?> - <? if ($show_entry['id']) : ?> + <? if (isset($show_entry['id'])) : ?> <?= Studip\LinkButton::create( _('Löschen'), $controller->url_for('calendar/schedule/delete/'. $show_entry['id']), @@ -61,7 +61,7 @@ ) ?> <? endif ?> - <? if ($show_entry) : ?> + <? if (!empty($show_entry)) : ?> <?= Studip\LinkButton::createCancel( _('Abbrechen'), $controller->url_for('calendar/schedule'), diff --git a/app/views/calendar/schedule/entry.php b/app/views/calendar/schedule/entry.php index b780aae8dd8..66fe58edbb9 100644 --- a/app/views/calendar/schedule/entry.php +++ b/app/views/calendar/schedule/entry.php @@ -1,4 +1,4 @@ -<? if ($show_entry && in_array($show_entry['type'], ['sem', 'virtual']) !== false) : ?> +<? if (!empty($show_entry) && in_array($show_entry['type'], ['sem', 'virtual']) !== false) : ?> <?= $this->render_partial('calendar/schedule/_entry_course.php') ?> <? unset($this->show_entry) ?> <? elseif ($show_entry && $show_entry['type'] == 'inst') : ?> diff --git a/lib/calendar/CalendarColumn.class.php b/lib/calendar/CalendarColumn.class.php index 9292d0cf485..3c071f17608 100644 --- a/lib/calendar/CalendarColumn.class.php +++ b/lib/calendar/CalendarColumn.class.php @@ -333,7 +333,10 @@ class CalendarColumn for ($i = floor($data['start'] / 100); $i <= floor($data['end'] / 100); $i++) { for ($j = 0; $j < 60; $j++) { if (($i * 100) + $j >= $data['start'] && ($i * 100) + $j < $data['end']) { - $group_matrix[($i * 100) + $j]++; + if (!isset($group_matrix[$i * 100 + $j])) { + $group_matrix[$i * 100 + $j] = 0; + } + $group_matrix[$i * 100 + $j]++; } } } diff --git a/lib/classes/sidebar/SearchWidget.php b/lib/classes/sidebar/SearchWidget.php index 71677fb3ae4..40a2eb9e990 100644 --- a/lib/classes/sidebar/SearchWidget.php +++ b/lib/classes/sidebar/SearchWidget.php @@ -159,6 +159,8 @@ class SearchWidget extends SidebarWidget $reset_link = URLHelper::getLink($this->url, array_merge($reset_params, ['reset-search' => 1])); $this->template_variables['reset_link'] = $reset_link; + } else { + $this->template_variables['reset_link'] = false; } $this->template_variables['needles'] = $this->needles; diff --git a/lib/visual.inc.php b/lib/visual.inc.php index 79157c1905f..1c3cd9e16d5 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -285,8 +285,9 @@ function kill_format ($text) { $text = explode("[nop] [/nop]", $text); $i = 0; $all = ''; - foreach ($text as $w) - $all .= $w . $matches[1][$i++]; + foreach ($text as $w) { + $all .= $w . ($matches[1][$i++] ?? ''); + } return $all; } -- GitLab