Project

General

Profile

Actions

Bug #85784

closed

setting fieldInformation by TCA overrides throws error

Added by Gerhard Huber over 5 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
Backend User Interface
Start date:
2018-08-08
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I added my own column with fieldInformation to TCA using this code

//create columns
$column = array (
    'keywords' => [
        'exclude' => '0',
        'label' => 'myLabel',
        'config' => [
            'type' => 'text',
            'fieldInformation' => [
                'html' => 'Zeile 1', 
            ],
        ],
    ],
);

//add column to TCA
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
    'sys_category',
    $column
    );

//add Field to Palette
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToAllPalettesOfField(
    'sys_category', 
    'description', 
    'keywords');

DependencyOrderingService threw an error.

 #1476107295: PHP Warning: Illegal string offset 'before' in D:\Projekte\CMS\Typo3Source\typo3_src-8.7.18\typo3\sysext\core\Classes\Service\DependencyOrderingService.php line 271 (More information)

 TYPO3\CMS\Core\Error\Exception thrown in file
 D:\Projekte\CMS\Typo3Source\typo3_src-8.7.18\typo3\sysext\core\Classes\Error\ErrorHandler.php in line 107.

Solution:

Namespace: TYPO3\CMS\Core\Service
Class: DependencyOrderingService
File: typo3/sysext/core/Classes/Services/DependencyOrderingService.php

Check if $dependencies[$id][$beforeKey] and $dependencies[$id][$afterKey] are set before iterating.

98: foreach ($identifiers as $id) {
99:   //Check if $dependencies[$id][$beforeKey] is set before iterating.
100:  if (isset($dependencies[$id][$beforeKey])) {
101:    foreach ($dependencies[$id][$beforeKey] as $beforeId) {
102:      $dependencyGraph[$beforeId][$id] = true;
103:    }
104:  }
105:  //Check if $dependencies[$id][$afterKey] is set before iterating.
106:  if (isset($dependencies[$id][$afterKey])) {
107:    foreach ($dependencies[$id][$afterKey] as $afterId) {
108:      $dependencyGraph[$id][$afterId] = true;
109:    }
110:  }
111:}

Check if $dependency is array. in case of fieldInformation it only is a string

271: protected function prepareDependencies(array $dependencies, $beforeKey = 'before', $afterKey = 'after')
272: {
273:   $preparedDependencies = [];
274:   foreach ($dependencies as $id => $dependency) {
275      //check if $dependency is array
276:     if (is_array($dependency)) {
277:       foreach ([ $beforeKey, $afterKey ] as $relation) {
278:         if (!isset($dependency[$relation]) || !is_array($dependency[$relation])) {
279:           $dependency[$relation] = [];
280:         }
281:         // add all missing, but referenced identifiers to the $dependency list
282:         foreach ($dependency[$relation] as $dependingId) {
283:           if (!isset($dependencies[$dependingId]) && !isset($preparedDependencies[$dependingId])) {
284:             $preparedDependencies[$dependingId] = [
285:               $beforeKey => [],
286:               $afterKey => []
287:             ];
288:           }
289:         }
290:       }
291:     }
292:     $preparedDependencies[$id] = $dependency;
293:   }
294:   return $preparedDependencies;
295: }

Namespace: TYPO3\CMS\Backend\Form\NodeExpansion
Class: FieldInformation
File: typo3/sysext/backend/Classes/Form/NodeExpansion/FieldInformation.php

assign orderedFieldInformation to result

50: //assign to result
51: $result = $orderedFieldInformation;
Actions

Also available in: Atom PDF