From 5d0148033cba3a36372f993db57a9959879c3597 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Tue, 21 Feb 2023 08:54:06 +0000 Subject: [PATCH] prevent php8 warnings (fourth batch of changes), re #2193 Merge request studip/studip!1426 --- app/views/admin/plugin/edit_automaticupdate.php | 12 ++++++------ lib/classes/LockRules.class.php | 7 +++---- lib/functions.php | 13 +++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/views/admin/plugin/edit_automaticupdate.php b/app/views/admin/plugin/edit_automaticupdate.php index 2831427e88a..7e87c319a19 100644 --- a/app/views/admin/plugin/edit_automaticupdate.php +++ b/app/views/admin/plugin/edit_automaticupdate.php @@ -3,8 +3,7 @@ * @var Admin_PluginController $controller * @var array $plugin */ -?> -<? + if (mb_strpos($_SERVER['SERVER_NAME'], ':') !== false) { list($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']) = explode(':', $_SERVER['SERVER_NAME']); @@ -26,7 +25,7 @@ if ($_SERVER['HTTPS'] == 'on' && $_SERVER['SERVER_PORT'] != 443 || <?= $m ?> <? endforeach ?> </div> -<form action="<?= $controller->url_for('admin/plugin/edit_automaticupdate/'.$plugin['id']) ?>" method="post" class="default" data-dialog="size=auto;reload-on-close"> +<form action="<?= $controller->link_for('admin/plugin/edit_automaticupdate', $plugin['id'] ?? null) ?>" method="post" class="default" data-dialog="size=auto;reload-on-close"> <?= CSRFProtection::tokenTag() ?> <input type="hidden" name="studip_ticket" value="<?= get_ticket() ?>"> <?= MessageBox::info(_("Sie können gitlab, github.com oder dem neuen Stud.IP-Plugin-Marktplatz mitteilen, dass Ihr Stud.IP per Webhook über Änderungen im Code des Plugins benachrichtigt werden soll.")) ?> @@ -34,15 +33,16 @@ if ($_SERVER['HTTPS'] == 'on' && $_SERVER['SERVER_PORT'] != 443 || <legend><?= _("Einstellungen von Stud.IP") ?></legend> <label> <?= _("URL, von der das Plugin als ZIP-Datei bezogen werden soll") ?> - <input type="url" name="automatic_update_url" value="<?= htmlReady($plugin['automatic_update_url']) ?>"> + <input type="url" name="automatic_update_url" value="<?= htmlReady($plugin['automatic_update_url'] ?? '') ?>"> </label> <label> <?= _("Automatisches Update absichern über Sicherheitstoken (optional)") ?> - <input type="checkbox" name="use_security_token" value="1"<?= $plugin['automatic_update_secret'] || !$plugin['automatic_update_url'] ? " checked" : "" ?>> + <input type="checkbox" name="use_security_token" value="1" + <?= !empty($plugin['automatic_update_secret']) || empty($plugin['automatic_update_url']) ? " checked" : "" ?>> </label> </fieldset> - <? if ($plugin['automatic_update_url']) : ?> + <? if (!empty($plugin['automatic_update_url'])) : ?> <fieldset> <legend><?= _("Daten für das bereitstellende System") ?></legend> <p class="info"> diff --git a/lib/classes/LockRules.class.php b/lib/classes/LockRules.class.php index 48a43790a74..59679db6258 100644 --- a/lib/classes/LockRules.class.php +++ b/lib/classes/LockRules.class.php @@ -85,7 +85,8 @@ class LockRules { */ public static function getObjectRule($object_id, $renew = false, $object_type = null) { - if(!array_key_exists($object_id, self::$lockmap) || $renew) { + if (!array_key_exists($object_id, self::$lockmap) || $renew) { + self::$lockmap[$object_id] = null; if ($object_type === null) { $object_type = get_object_type($object_id, words('sem inst user')); } @@ -98,12 +99,10 @@ class LockRules { if ($lr) { self::$lockmap[$object_id] = $lr->getId(); self::$lockrules[$lr->getId()] = $lr; - } else { - self::$lockmap[$object_id] = null; } } } - return self::$lockmap[$object_id] ? self::$lockrules[self::$lockmap[$object_id]] : null; + return self::$lockrules[self::$lockmap[$object_id]] ?? null; } /** diff --git a/lib/functions.php b/lib/functions.php index bce4215064b..e5ac0c957bb 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -73,15 +73,16 @@ function get_object_name($range_id, $object_type) $statement->execute([$range_id]); $row = $statement->fetch(PDO::FETCH_ASSOC); - if ($SEM_TYPE[$row['status']]['name'] == $SEM_TYPE_MISC_NAME) { + if (!$row) { + $name = _('Unbekannt'); $type = _('Veranstaltung'); } else { - $type = $SEM_TYPE[$row['status']]['name']; - } - if (!$type) { - $type = _('Veranstaltung'); + $name = $row['Name']; + $type = $SEM_TYPE[$row['status']]['name'] ?? _('Veranstaltung'); + if ($type === $SEM_TYPE_MISC_NAME) { + $type = _('Veranstaltung'); + } } - $name = $row['Name']; } else if ($object_type == 'inst' || $object_type == 'fak') { $query = "SELECT type, Name FROM Institute WHERE Institut_id = ?"; $statement = DBManager::get()->prepare($query); -- GitLab