[BUGFIX] ORDER BY wrongly quotes argument if a number is used
authorPatrick Schriner <pschriner@gmx.de>
Thu, 7 Apr 2011 20:05:32 +0000 (22:05 +0200)
committerXavier Perseguers <typo3@perseguers.ch>
Mon, 11 Apr 2011 07:22:14 +0000 (09:22 +0200)
If ORDER BY {n} is used with a number instead of a field name (or compound
table + field name), then the number should not be quoted. This type of
clauses is typically used by Extbase.

Change-Id: I4e0f8ecd265c3bde3f1da59b1ea53de8382c11b5
Resolves: #25489
Branches: DBAL_1-3, DBAL_1-2

typo3/sysext/dbal/class.ux_t3lib_db.php

index 0747af3..d2ef92a 100644 (file)
@@ -1912,8 +1912,11 @@ class ux_t3lib_DB extends t3lib_DB {
         */
        protected function _quoteOrderBy(array $orderBy) {
                foreach ($orderBy as $k => $v) {
+                       if ($orderBy[$k]['table'] === '' && $v['field'] !== '' && ctype_digit($v['field'])) {
+                               continue;
+                       }
                        $orderBy[$k]['field'] = $this->quoteName($orderBy[$k]['field']);
-                       if ($orderBy[$k]['table'] != '') {
+                       if ($orderBy[$k]['table'] !== '') {
                                $orderBy[$k]['table'] = $this->quoteName($orderBy[$k]['table']);
                        }
                }