fabarea / media

Media management system for TYPO3 CMS
Other
30 stars 25 forks source link

Crash when invoking upgrade wizard in TYPO3 v8 #176

Closed xperseguers closed 7 years ago

xperseguers commented 7 years ago

Upgrade wizard "Execute database migrations on single rows" in Install Tool does that:

Migrate values in database records having "l10n_mode" either set to "exclude" or "mergeIfNotBlank"
Migrate values in sys_file_reference crop field

When launching this upgrade wizard, it crashes after some time with an SQL exception:

Oops, an error occurred!
An exception occurred while executing 'SELECT `uid`, `fileinfo`, `title`, `width`, `height`, `creator_tool`, `download_name`, `creator`, `publisher`, `latitude`, `longitude`, `content_creation_date`, `content_modification_date`, `unit`, `duration`, `color_space`, `pages`, `language`, `related_files`, `pid` FROM `sys_file_metadata` WHERE `uid` = ?' with params [2730]: Unknown column 'fileinfo' in 'field list'

This is due to the wrong override of sys_file_metadata's field fileinfo which gets an additional l10n_mode exclusion in Configuration/TCA/Overrides/sys_file_metadata.php.

This has the side effect of adding this (virtual) column to the SQL list of selected fields, within method \TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::getLocalizationModeExcludeFieldNames(), line 978 and thus leads to the invalid SQL query.

Don't know why this exclusion has been set but if it is really "needed", then this should probably be just changed as a displayCond condition like

'displayCond' => 'FIELD:sys_language_uid:<=:0',

(this kind of change is useful too in some edge-case usage of inline localized records, see https://forge.typo3.org/issues/80944 for info).

xperseguers commented 7 years ago

Suggested patch (sorry for no fork-patch-PR, a bit in a hurry for an actual migration):

diff --git a/Configuration/TCA/Overrides/sys_file_metadata.php b/Configuration/TCA/Overrides/sys_file_metadata.php
index e944bd1..5c9d9fa 100644
--- a/Configuration/TCA/Overrides/sys_file_metadata.php
+++ b/Configuration/TCA/Overrides/sys_file_metadata.php
@@ -14,7 +14,6 @@ $tca = [
     ],
     'columns' => [
         'fileinfo' => [
-            'l10n_mode' => 'exclude',
             'config' => [
                 'type' => 'user',
                 'userFunc' => 'EXT:media/Classes/Backend/TceForms.php:Fab\Media\Backend\TceForms->renderFileUpload',
@@ -31,4 +30,4 @@ $tca = [
         ],
     ],
 ];