From: Alexander Ebert Date: Sun, 5 Jan 2020 19:08:00 +0000 (+0100) Subject: Workaround for the search for objects matching multiple tags X-Git-Tag: 5.2.1~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4365453a201a9f14bd8bac77d75078599b5cfca1;p=GitHub%2FWoltLab%2FWCF.git Workaround for the search for objects matching multiple tags --- 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}"; + } +}