From 858a75dc66c62a57703ffc1d1a6da31ccbac2acc Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 21 Nov 2026 19:43:03 +0100 Subject: [PATCH] Address 'returning a value from a constructor is deprecated' warnings --- controllers/EditAsset.php | 3 ++- controllers/EditUser.php | 34 +++++++++++++++++++++++------- controllers/ProvideAutoSuggest.php | 10 +++++++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/controllers/EditAsset.php b/controllers/EditAsset.php index 26b99fc..b50da54 100644 --- a/controllers/EditAsset.php +++ b/controllers/EditAsset.php @@ -89,7 +89,8 @@ class EditAsset extends HTMLController if (isset($_GET['updatethumb'])) { $image = $asset->getImage(); - return $this->updateThumb($image); + $this->updateThumb($image); + return; } // Key info diff --git a/controllers/EditUser.php b/controllers/EditUser.php index 089dca6..6445349 100644 --- a/controllers/EditUser.php +++ b/controllers/EditUser.php @@ -129,7 +129,10 @@ class EditUser extends HTMLController // Anything missing? if (!empty($form->getMissing())) - return $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'danger')); + { + $formview->adopt(new Alert('Some data missing', 'Please fill out the following fields: ' . implode(', ', $form->getMissing()), 'danger')); + return; + } $data = $form->getData(); @@ -150,18 +153,30 @@ class EditUser extends HTMLController // If it looks like an e-mail address... if (!empty($data['emailaddress']) && !preg_match('~^[^ ]+@[^ ]+\.[a-z]+$~', $data['emailaddress'])) - return $formview->adopt(new Alert('Email addresses invalid', 'The email address you entered is not a valid email address.', 'danger')); + { + $formview->adopt(new Alert('Email addresses invalid', 'The email address you entered is not a valid email address.', 'danger')); + return; + } // Check whether email address is already linked to an account in the database -- just not to the account we happen to be editing, of course. elseif (!empty($data['emailaddress']) && Member::exists($data['emailaddress']) && !($id_user && $user->getEmailAddress() == $data['emailaddress'])) - return $formview->adopt(new Alert('Email address already in use', 'Another account is already using the e-mail address you entered.', 'danger')); + { + $formview->adopt(new Alert('Email address already in use', 'Another account is already using the e-mail address you entered.', 'danger')); + return; + } // Setting passwords? We'll need two! if (!$id_user || !empty($data['password1']) && !empty($data['password2'])) { if (strlen($data['password1']) < 6 || !preg_match('~[^A-z]~', $data['password1'])) - return $formview->adopt(new Alert('Password not acceptable', 'Please fill in a password that is at least six characters long and contains at least one non-alphabetic character (e.g. a number or symbol).', 'danger')); + { + $formview->adopt(new Alert('Password not acceptable', 'Please fill in a password that is at least six characters long and contains at least one non-alphabetic character (e.g. a number or symbol).', 'danger')); + return; + } elseif ($data['password1'] !== $data['password2']) - return $formview->adopt(new Alert('Passwords do not match', 'The passwords you entered do not match. Please try again.', 'danger')); + { + $formview->adopt(new Alert('Passwords do not match', 'The passwords you entered do not match. Please try again.', 'danger')); + return; + } else $data['password'] = $data['password1']; @@ -171,9 +186,12 @@ class EditUser extends HTMLController // Creating a new user? if (!$id_user) { - $return = Member::createNew($data); - if ($return === false) - return $formview->adopt(new Alert('Cannot create this user', 'Something went wrong while creating the user...', 'danger')); + $newUser = Member::createNew($data); + if ($newUser === false) + { + $formview->adopt(new Alert('Cannot create this user', 'Something went wrong while creating the user...', 'danger')); + return; + } if (isset($_POST['submit_and_new'])) { diff --git a/controllers/ProvideAutoSuggest.php b/controllers/ProvideAutoSuggest.php index 732eaa5..b41b120 100644 --- a/controllers/ProvideAutoSuggest.php +++ b/controllers/ProvideAutoSuggest.php @@ -18,10 +18,16 @@ class ProvideAutoSuggest extends JSONController throw new UnexpectedValueException('Unsupported autosuggest request.'); if ($_REQUEST['type'] === 'tags' && isset($_REQUEST['data'])) - return $this->handleTagSearch(); + { + $this->handleTagSearch(); + return; + } if ($_REQUEST['type'] === 'createtag' && isset($_REQUEST['tag'])) - return $this->handleTagCreation(); + { + $this->handleTagCreation(); + return; + } } private function handleTagSearch()