From c0e9159c1e228136042c2aa7268056f2adc839ad Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 5 Apr 2022 16:13:56 +0200 Subject: [PATCH] Misc/Fixups * colAddins should be null if not in use * fix index warnings in search + profiler * cast url param 'locale' to int for all uses * fix breadcrumbs for sounds page * fix determining actionOwner for SmartAI --- includes/ajaxHandler/profile.class.php | 4 ++-- includes/kernel.php | 9 ++++++--- includes/smartAI.class.php | 8 ++++++-- includes/utilities.php | 4 ++-- pages/npc.php | 2 +- pages/profile.php | 3 ++- pages/search.php | 2 +- pages/sounds.php | 2 +- template/pages/quest.tpl.php | 3 +-- 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index 64e3654a..163d13d6 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -360,7 +360,7 @@ class AjaxProfile extends AjaxHandler $cuProfile['sourceId'] = $_; } - if ($cuProfile['sourceId']) + if (!empty($cuProfile['sourceId'])) $cuProfile['sourceName'] = DB::Aowow()->selectCell('SELECT name FROM ?_profiler_profiles WHERE id = ?d', $cuProfile['sourceId']); $charId = -1; @@ -420,7 +420,7 @@ class AjaxProfile extends AjaxHandler $itemData[2] = 0; // item sockets are fubar - $nSockets = $items->json[$itemData[1]]['nsockets']; + $nSockets = $items->json[$itemData[1]]['nsockets'] ?? 0; $nSockets += in_array($slot, [SLOT_WAIST, SLOT_WRISTS, SLOT_HANDS]) ? 1 : 0; for ($i = 5; $i < 9; $i++) if ($itemData[$i] > 0 && (!$items->getEntry($itemData[$i]) || $i >= (5 + $nSockets))) diff --git a/includes/kernel.php b/includes/kernel.php index 4a999553..a4814662 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -255,9 +255,12 @@ if (!CLI) // all strings attached.. if (!empty($AoWoWconf['aowow'])) { - if (isset($_GET['locale']) && (int)$_GET['locale'] <= MAX_LOCALES && (int)$_GET['locale'] >= 0) - if (CFG_LOCALES & (1 << $_GET['locale'])) - User::useLocale($_GET['locale']); + if (isset($_GET['locale'])) + { + $loc = intVal($_GET['locale']); + if ($loc <= MAX_LOCALES && $loc >= 0 && (CFG_LOCALES & (1 << $loc))) + User::useLocale($loc); + } Lang::load(User::$localeString); } diff --git a/includes/smartAI.class.php b/includes/smartAI.class.php index 07b648c3..45ceeef2 100644 --- a/includes/smartAI.class.php +++ b/includes/smartAI.class.php @@ -164,7 +164,11 @@ class SmartAI } if ($q) - $result = DB::Aowow()->selectCol(sprintf('SELECT `type` AS ARRAY_KEY, `typeId` FROM ?_spawns WHERE (%s)', implode(') OR (', $q))); + { + $owner = DB::Aowow()->select(sprintf('SELECT `type` AS "0", `typeId` AS "1" FROM ?_spawns WHERE (%s)', implode(') OR (', $q))); + foreach ($owner as [$ty, $id]) + $result[$ty][] = $id; + } } foreach ($smartS as [$st, $eog]) @@ -258,7 +262,7 @@ class SmartAI return self::getOwnerAction($srcType, $entry, $lookup); } - private static function getOwnerAction(int $sourceType, int $entry, array $lookup, ?array $moreInfo = []) : array + private static function getOwnerAction(int $sourceType, int $entry, array $lookup, ?array &$moreInfo = []) : array { if ($entry < 0) // please not individual entities :( return []; diff --git a/includes/utilities.php b/includes/utilities.php index a3a2c056..60d0cc99 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1577,8 +1577,8 @@ abstract class Util } return array( - round($mainHand['gearscore'] * $mh), - round($offHand['gearscore'] * $oh) + round(($mainHand['gearscore'] ?? 0) * $mh), + round(($offHand['gearscore'] ?? 0) * $oh) ); } diff --git a/pages/npc.php b/pages/npc.php index a791b153..178272be 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -621,7 +621,7 @@ class NpcPage extends GenericPage $soldItems = new ItemList(array(['id', $sells])); if (!$soldItems->error) { - $colAddIn = ''; + $colAddIn = null; $extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost']; if ($soldItems->hasSetFields(['condition'])) $extraCols[] = '$Listview.extraCols.condition'; diff --git a/pages/profile.php b/pages/profile.php index d3decda8..e264bb92 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -38,6 +38,7 @@ class ProfilePage extends GenericPage private $isCustom = false; private $profile = null; + private $subject = null; private $rnItr = 0; private $powerTpl = '$WowheadPower.registerProfile(%s, %d, %s);'; @@ -108,7 +109,7 @@ class ProfilePage extends GenericPage $this->notFound(); } // 2) not yet synced but exists on realm (and not a gm character) - else if (!$this->rnItr && ($char = DB::Characters($this->realmId)->selectRow('SELECT c.guid AS realmGUID, c.name, c.race, c.class, c.level, c.gender, g.guildid AS guildGUID, IFNULL(g.name, "") AS guildName, IFNULL(gm.rank, 0) AS guildRank FROM characters c LEFT JOIN guild_member gm ON gm.guid = c.guid LEFT JOIN guild g ON g.guildid = gm.guildid WHERE c.name = ? AND level <= ?d AND (extra_flags & ?d) = 0', Util::ucFirst($this->subjectName), MAX_LEVEL, Profiler::CHAR_GMFLAGS))) + else if (!$this->rnItr && ($char = DB::Characters($this->realmId)->selectRow('SELECT c.guid AS realmGUID, c.name, c.race, c.class, c.level, c.gender, c.at_login, g.guildid AS guildGUID, IFNULL(g.name, "") AS guildName, IFNULL(gm.rank, 0) AS guildRank FROM characters c LEFT JOIN guild_member gm ON gm.guid = c.guid LEFT JOIN guild g ON g.guildid = gm.guildid WHERE c.name = ? AND level <= ?d AND (extra_flags & ?d) = 0', Util::ucFirst($this->subjectName), MAX_LEVEL, Profiler::CHAR_GMFLAGS))) { $char['realm'] = $this->realmId; $char['cuFlags'] = PROFILER_CU_NEEDS_RESYNC; diff --git a/pages/search.php b/pages/search.php index 97243867..8cc86e8e 100644 --- a/pages/search.php +++ b/pages/search.php @@ -640,7 +640,7 @@ class SearchPage extends GenericPage { $multiClass = 0; for ($i = 1; $i <= 10; $i++) - if ($d['reqclass'] & (1 << ($i - 1))) + if (isset($d['reqclass']) && ($d['reqclass'] & (1 << ($i - 1)))) $multiClass++; if ($multiClass > 1) diff --git a/pages/sounds.php b/pages/sounds.php index ea7e382f..28948e48 100644 --- a/pages/sounds.php +++ b/pages/sounds.php @@ -81,7 +81,7 @@ class SoundsPage extends GenericPage { $form = $this->filterObj->getForm(); if (isset($form['ty']) && count($form['ty']) == 1) - $this->path[] = $form['ty']; + $this->path[] = $form['ty'][0]; } } diff --git a/template/pages/quest.tpl.php b/template/pages/quest.tpl.php index 3bb9a83e..3389c82b 100644 --- a/template/pages/quest.tpl.php +++ b/template/pages/quest.tpl.php @@ -132,9 +132,8 @@ if ($this->offerReward && ($this->requestItems || $this->objectives)): rewards): - $offset = 0; - echo '

'.Lang::main('rewards')."

\n"; if (!empty($r['choice'])):