[TASK] Provide information about import action in TCEmain to hooks 45/22645/2
authorStefan Galinski <stefan.galinski@gmail.com>
Tue, 27 Nov 2012 01:31:50 +0000 (02:31 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 30 Jul 2013 23:14:52 +0000 (01:14 +0200)
While importing T3D files the TCEmain currently fires the required
processing on records just as if the editor is generating the records. If
extensions hook into TCEmain, there is no way to differenciate this
situation from the regular editing mode - which might provide unexpected
results, i.e. wrong IRRE relations.

Solution is to provide a boolean to indicate that TCEmain has been called
during an import action which extensions could use to recognize this
situation.

Change-Id: I4fe429fb88f8ec24a7fda885f38ddfbdb4a642f5
Resolves: #36031
Releases: 4.5, 4.7, 6.0, 6.1, 6.2
Reviewed-on: https://review.typo3.org/22645
Reviewed-by: Jo Hasenau
Tested-by: Jo Hasenau
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
t3lib/class.t3lib_tcemain.php
typo3/sysext/impexp/class.tx_impexp.php

index 011cb94..0123175 100644 (file)
@@ -233,6 +233,14 @@ class t3lib_TCEmain {
        var $checkStoredRecords_loose = TRUE; // Boolean: If set, values '' and 0 will equal each other when the stored records are checked.
        var $deleteTree = FALSE; // Boolean. If this is set, then a page is deleted by deleting the whole branch under it (user must have deletepermissions to it all). If not set, then the page is deleted ONLY if it has no branch
        var $neverHideAtCopy = FALSE; // Boolean. If set, then the 'hideAtCopy' flag for tables will be ignored.
+
+       /**
+        * If set, then the TCE class has been instantiated during an import action of a T3D
+        *
+        * @var boolean
+        */
+       public $isImporting = FALSE;
+
        var $dontProcessTransformations = FALSE; // Boolean: If set, then transformations are NOT performed on the input.
        var $clear_flexFormData_vDEFbase = FALSE; // Boolean: If set, .vDEFbase values are unset in flexforms.
        var $updateModeL10NdiffData = TRUE; // Boolean/Mixed: TRUE: (traditional) Updates when record is saved. For flexforms, updates if change is made to the localized value. FALSE: Will not update anything. "FORCE_FFUPD" (string): Like TRUE, but will force update to the FlexForm Field
index 8241a72..58fcc47 100755 (executable)
@@ -1204,6 +1204,7 @@ class tx_impexp {
 
                                // Now write to database:
                        $tce = $this->getNewTCE();
+                       $tce->isImporting = TRUE;
                        $this->callHook('before_writeRecordsPages', array(
                                'tce' => &$tce,
                                'data' => &$this->import_data,
@@ -1301,6 +1302,7 @@ class tx_impexp {
 
                        // Now write to database:
                $tce = $this->getNewTCE();
+               $tce->isImporting = TRUE;
                $this->callHook('before_writeRecordsRecords', array(
                        'tce' => &$tce,
                        'data' => &$this->import_data,
@@ -1569,6 +1571,7 @@ class tx_impexp {
                }
                if (count($updateData)) {
                        $tce = $this->getNewTCE();
+                       $tce->isImporting = TRUE;
                        $this->callHook('before_setRelation', array(
                                'tce' => &$tce,
                                'data' => &$updateData,
@@ -1693,6 +1696,7 @@ class tx_impexp {
                }
                if (count($updateData)) {
                        $tce = $this->getNewTCE();
+                       $tce->isImporting = TRUE;
                        $this->callHook('before_setFlexFormRelations', array(
                                'tce' => &$tce,
                                'data' => &$updateData,
@@ -1836,6 +1840,7 @@ class tx_impexp {
 
                        // Now write to database:
                $tce = $this->getNewTCE();
+               $tce->isImporting = TRUE;
                $this->callHook('before_processSoftReferences', array(
                                'tce' => &$tce,
                                'data' => &$inData,
@@ -3330,4 +3335,4 @@ class tx_impexp {
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/class.tx_impexp.php'])) {
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/class.tx_impexp.php']);
 }
-?>
\ No newline at end of file
+?>