[FOLLOWUP][TASK] Remove column sys_file_reference.sorting 07/55107/3
authorOliver Hader <oliver@typo3.org>
Sat, 16 Dec 2017 10:23:37 +0000 (11:23 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 16 Dec 2017 14:03:24 +0000 (15:03 +0100)
Table sys_file_reference is used as "inline 1:n foreign_field" composite
assiciation and is processed in RelationHandler methods readForeignField
and writeForeignField. Albeit it looks like an MM table it still is a
regular TCA table being used as an entity with further attributes.

That's why this follow-up reverts the changes in file RelationHandler.php
that have been introduced in 728bfc194f46651ac70725d8aa6b476dac777765.

Related: #83160
Releases: master
Change-Id: I4b7a78a0ee494af9492996e81c2b631c29832cc6
Reviewed-on: https://review.typo3.org/55107
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/Database/RelationHandler.php

index 5106a97..435212c 100644 (file)
@@ -556,7 +556,7 @@ class RelationHandler
             // Default
             $uidLocal_field = 'uid_local';
             $uidForeign_field = 'uid_foreign';
-            $sorting_field = $tableName === 'sys_file_reference' ? '' : 'sorting';
+            $sorting_field = 'sorting';
         }
         if ($this->MM_table_where) {
             $queryBuilder->andWhere(
@@ -574,9 +574,7 @@ class RelationHandler
                 $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)
             )
         );
-        if (!empty($sorting_field)) {
-            $queryBuilder->orderBy($sorting_field);
-        }
+        $queryBuilder->orderBy($sorting_field);
         $statement = $queryBuilder->execute();
         while ($row = $statement->fetch()) {
             // Default
@@ -618,7 +616,7 @@ class RelationHandler
             // default
             $uidLocal_field = 'uid_local';
             $uidForeign_field = 'uid_foreign';
-            $sorting_field = $MM_tableName === 'sys_file_reference' ? '' : 'sorting';
+            $sorting_field = 'sorting';
         }
         // If there are tables...
         $tableC = count($this->tableArray);
@@ -654,10 +652,9 @@ class RelationHandler
                 ->where($queryBuilder->expr()->eq(
                     $uidLocal_field,
                     $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
-                ));
-            if (!empty($sorting_field)) {
-                $queryBuilder->orderBy($sorting_field);
-            }
+                ))
+                ->orderBy($sorting_field);
+
             if ($prep) {
                 $queryBuilder->addSelect('tablenames');
             }
@@ -754,9 +751,7 @@ class RelationHandler
                     $insertFields = $this->MM_insert_fields;
                     $insertFields[$uidLocal_field] = $uid;
                     $insertFields[$uidForeign_field] = $val['id'];
-                    if (!empty($sorting_field)) {
-                        $insertFields[$sorting_field] = $c;
-                    }
+                    $insertFields[$sorting_field] = $c;
                     if ($tablename) {
                         $insertFields['tablenames'] = $tablename;
                         $insertFields = $this->completeOppositeUsageValues($tablename, $insertFields);