[BUGFIX] Clean up inconsistent data from import 04/46004/2
authorBernhard Kraft <kraft@webconsulting.at>
Sat, 16 Jan 2016 09:45:59 +0000 (09:45 +0000)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 16 Jan 2016 12:11:33 +0000 (13:11 +0100)
When importing a T3D or XML file the loaded data has to get cleansed
first. The "extensionDependencies" array for example may contain an
empty string which will cause a non-correct warning message in the
importers warning tab.

A new method "cleanupImportData" takes care to bring import data into
an acceptable format.

Resolves: #72761
Releases: master, 7.6
Change-Id: I79dcccb92f453902b4b83be243d2f89af711246c
Reviewed-on: https://review.typo3.org/45993
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
(cherry picked from commit 6c9573c7e90bfb9392e69ac849eab4c1d66d5597)
Reviewed-on: https://review.typo3.org/46004

typo3/sysext/impexp/Classes/Import.php
typo3/sysext/impexp/Classes/ImportExport.php

index 341c903..faea558 100644 (file)
@@ -2100,10 +2100,10 @@ class Import extends ImportExport
      */
     public function loadInit()
     {
+        $this->cleanupImportData();
         $this->relStaticTables = (array)$this->dat['header']['relStaticTables'];
         $this->excludeMap = (array)$this->dat['header']['excludeMap'];
         $this->softrefCfg = (array)$this->dat['header']['softrefCfg'];
-        $this->extensionDependencies = (array)$this->dat['header']['extensionDependencies'];
         $this->fixCharsets();
         if (
             isset($this->dat['header']['meta']['TYPO3_version'])
@@ -2115,6 +2115,16 @@ class Import extends ImportExport
     }
 
     /**
+     * Cleanses any inconsistent states which can occur in imported T3D/XML
+     *
+     * @return void
+     */
+    protected function cleanupImportData()
+    {
+        $this->dat['header']['extensionDependencies'] = array_filter($this->dat['header']['extensionDependencies']);
+    }
+
+    /**
      * Fix charset of import memory if different from system charset
      *
      * @return void
index 6982d52..f93328b 100644 (file)
@@ -288,7 +288,7 @@ abstract class ImportExport
         // Check extension dependencies:
         if (is_array($this->dat['header']['extensionDependencies'])) {
             foreach ($this->dat['header']['extensionDependencies'] as $extKey) {
-                if (!empty($extKey) && !ExtensionManagementUtility::isLoaded($extKey)) {
+                if (!ExtensionManagementUtility::isLoaded($extKey)) {
                     $this->error('DEPENDENCY: The extension with key "' . $extKey . '" must be installed!');
                 }
             }