From 3c43a3f2d36bb524c201910664b044a1e35aae5a Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Tue, 30 Jan 2024 00:25:50 +0100 Subject: [PATCH] Return an integer when checking time ID by stored rewrite --- src/NodaIDGetter.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/NodaIDGetter.php b/src/NodaIDGetter.php index 4aafa6f..6742a59 100644 --- a/src/NodaIDGetter.php +++ b/src/NodaIDGetter.php @@ -711,11 +711,11 @@ final class NodaIDGetter { * @param string $lang Language to check in. * @param string $name Name of the time to search for. * - * @return array + * @return integer */ - public static function getTimeIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):array { + public static function getTimeIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):int { - if (empty($name)) return []; + if (empty($name)) return 0; $output = []; @@ -725,9 +725,10 @@ final class NodaIDGetter { WHERE `language` = ? AND `input_name` = ?", "ss", $lang, $name); - while ($timeRewriteData = $timeRewriteResult->fetch_row()) { - $output[] = $timeRewriteData[0]; + if ($timeRewriteData = $timeRewriteResult->fetch_row()) { + $output = (int)$timeRewriteData[0]; } + else $output = 0; $timeRewriteResult->close(); @@ -943,7 +944,7 @@ final class NodaIDGetter { } if (!empty($timeIdByRewrite = self::getTimeIDByRewrite($mysqli_noda, $lang, $name))) { - return end($timeIdByRewrite); + return $timeIdByRewrite; } if ($instance !== "") {