From 4365453a201a9f14bd8bac77d75078599b5cfca1 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 5 Jan 2020 20:08:00 +0100 Subject: [PATCH] Workaround for the search for objects matching multiple tags --- .../tagging/TTaggedObjectList.class.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/tagging/TTaggedObjectList.class.php diff --git a/wcfsetup/install/files/lib/system/tagging/TTaggedObjectList.class.php b/wcfsetup/install/files/lib/system/tagging/TTaggedObjectList.class.php new file mode 100644 index 0000000000..742367ae91 --- /dev/null +++ b/wcfsetup/install/files/lib/system/tagging/TTaggedObjectList.class.php @@ -0,0 +1,33 @@ + + * @package WoltLabSuite\Core\System\Tagging + */ +trait TTaggedObjectList { + /** + * Processes the `$orderBy` parameters to inject the parameter into the `GROUP BY` parameter. + * + * @param string $groupBy + * @param string $orderBy + * @return string + */ + protected function getGroupByFromOrderBy($groupBy, $orderBy) { + if (!empty($orderBy)) { + $orderBy = explode(',', $orderBy); + $orderBy = array_map(function ($order) { + return StringUtil::trim(preg_replace('~\s+(?:ASC|DESC)\s*$~i', '', $order)); + }, $orderBy); + + $orderBy = ', ' . implode(', ', $orderBy); + } + + return "GROUP BY {$groupBy}{$orderBy}"; + } +} -- 2.20.1