[BUGFIX] Update tstamp on writeForeignField if any foreign value has changed. (IRRE) 17/44617/5
authorSebastian Mazza <sebastian@mazza.at>
Sun, 15 Nov 2015 02:22:39 +0000 (03:22 +0100)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Mon, 23 Nov 2015 15:02:26 +0000 (16:02 +0100)
This patch solves the problem where the timestamp in the column tstamp
was not updated when the sorting of the inline list (IRRE) would change.
It also updates the tstamp if one of the following fields change:
foreign_field, foreign_table_field, symmetric_field or one of the
foreign_match_fields.

Resolves: #71138
Releases: master
Change-Id: I3c9143dfd7bc2dca3ce5eb1dbe1f8e71561ebf66
Reviewed-on: https://review.typo3.org/44617
Reviewed-by: Oliver Eglseder <typo3org@vxvr.de>
Tested-by: Oliver Eglseder <typo3org@vxvr.de>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/core/Classes/Database/RelationHandler.php

index e95c550..737664f 100644 (file)
@@ -931,6 +931,25 @@ class RelationHandler
                 }
                 // Update accordant fields in the database:
                 if (!empty($updateValues)) {
+                    // Update tstamp if any foreign field value has changed
+                    if (!empty($GLOBALS['TCA'][$table]['ctrl']['tstamp'])) {
+                        $currentRow = BackendUtility::getRecord($table, $uid, implode(',', array_keys($updateValues)) , '', true);
+                        $needTstampUpdate = false;
+                        if (empty($currentRow)) {
+                            $needTstampUpdate = true;
+                        } else {
+                            foreach ($currentRow as $field => $curValue) {
+                                if ((string)$curValue !== (string)$updateValues[$field]) {
+                                    $needTstampUpdate = true;
+                                    break;
+                                }
+                            }
+                        }
+                        if ($needTstampUpdate) {
+                            $updateValues[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
+                        }
+                    }
+
                     $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . (int)$uid, $updateValues);
                     $this->updateRefIndex($table, $uid);
                 }