From 0f68501a0cf01e9065d3e3c9efcd96e0fd801cac Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Mon, 25 Nov 2024 13:43:42 +0000 Subject: [PATCH] prevent error in strict mode and php warnings, fixes #4902 Closes #4902 Merge request studip/studip!3676 --- app/controllers/massmail/message.php | 2 +- lib/classes/forms/Form.php | 6 +++--- lib/classes/forms/RadioInput.php | 2 +- templates/forms/radio_input.php | 13 ++++++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/massmail/message.php b/app/controllers/massmail/message.php index 62778db8cf8..031072e6850 100644 --- a/app/controllers/massmail/message.php +++ b/app/controllers/massmail/message.php @@ -19,7 +19,7 @@ class Massmail_MessageController extends \AuthenticatedController $message = new \MassMail\MassMailMessage($id); - $temp_id = $id ?: uniqid(md5(time())); + $temp_id = $id ?: md5(uniqid(time())); $folder = $message->findFolder($temp_id); // SearchType needed for course selection diff --git a/lib/classes/forms/Form.php b/lib/classes/forms/Form.php index f9b27cd3cee..58fe47a2a3b 100644 --- a/lib/classes/forms/Form.php +++ b/lib/classes/forms/Form.php @@ -143,14 +143,14 @@ class Form extends Part foreach ((array) $params['types'] as $fieldname => $type) { $params['fields'][$fieldname]['type'] = $type; } - //respect the without param: + // respect the without param: foreach ((array) $params['without'] as $fieldname) { unset($params['fields'][$fieldname]); } $fields = $params['fields']; - //Now initializing the fieldset: - $fieldset = new Fieldset($params['legend'] ?: _("Daten")); + // Now initializing the fieldset: + $fieldset = new Fieldset($params['legend'] ?? _('Daten')); $fieldset->setContextObject($object) ->setCollapsable($params['collapsable'] ?? false) ->setCollapsed($params['collapsed'] ?? false); diff --git a/lib/classes/forms/RadioInput.php b/lib/classes/forms/RadioInput.php index 1945d87cbb8..b02cb6717ad 100644 --- a/lib/classes/forms/RadioInput.php +++ b/lib/classes/forms/RadioInput.php @@ -15,7 +15,7 @@ class RadioInput extends Input $template->required = $this->required; $template->options = $options; $template->attributes = arrayToHtmlAttributes($this->attributes); - $template->orientation = $this->attributes['orientation']; + $template->orientation = $this->attributes['orientation'] ?? null; return $template->render(); } diff --git a/templates/forms/radio_input.php b/templates/forms/radio_input.php index f7636d19cf6..df911b2eda9 100644 --- a/templates/forms/radio_input.php +++ b/templates/forms/radio_input.php @@ -1,5 +1,16 @@ +<?php +/** + * @var string $id + * @var string $name + * @var string $value + * @var string|null $orientation + * @var bool $required + * @var array $options + * @var string $attributes + */ +?> <div class="formpart"> - <section <?= $this->orientation == 'horizontal' ? 'class="hgroup"' : '' ?> id="<?= htmlReady($id) ?>"> + <section <?= $orientation == 'horizontal' ? 'class="hgroup"' : '' ?> id="<?= htmlReady($id) ?>"> <span class="textlabel<?= $required ? ' studiprequired' : '' ?> "> <?= htmlReady($this->title) ?> <? if ($required) : ?> -- GitLab