Project

General

Profile

Actions

Bug #85784

closed

setting fieldInformation by TCA overrides throws error

Added by Gerhard Huber over 6 years ago. Updated about 6 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 #1

Updated by Gerhard Huber over 6 years ago

  • Priority changed from Should have to Must have
  • PHP Version deleted (7.1)
Actions #2

Updated by Georg Ringer over 6 years ago

  • Description updated (diff)
Actions #3

Updated by Benni Mack over 6 years ago

  • Status changed from New to Needs Feedback

Hey Gerhard,

looks like you want to add a new field "keywords" to "sys_category".

However


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

Says, you want to add a new field "description" before "keywords" which is not possible, since "keywords" does not exist, so method argument 3+4 need to be reversed, I'd say.

Actions #4

Updated by Gerhard Huber over 6 years ago

Benni Mack wrote:

Hey Gerhard,

looks like you want to add a new field "keywords" to "sys_category".

However

[...]

Says, you want to add a new field "description" before "keywords" which is not possible, since "keywords" does not exist, so method argument 3+4 need to be reversed, I'd say.

Hey Benni,
thanks for answering, but that changes anything.
Documentation says: addFieldsToAllPalettesOfField(string $table, string $field, string $addFields, string $insertionPosition='')
=> so the statement \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToAllPalettesOfField('sys_category','description','keywords'); adds the field "keywords" to all palettes that contain the field 'description'. That was my intention, but that's not the point.

The problem is, when using the field configuration "fieldInformation", that DependencyOrderingService throws an error.

        'config' => [
            'type' => 'text',
            'fieldInformation' => [
                'html' => 'Zeile 1', 
            ],
        ],

My provided solution solves the problem.
So please read my first post devotedly and feel free to integrate it in core.

:D

Cheers,
Gerhard

Actions #5

Updated by Susanne Moog about 6 years ago

  • Target version changed from 8.7.19 to Candidate for patchlevel
Actions #6

Updated by Christian Kuhn about 6 years ago

  • Status changed from Needs Feedback to Rejected

Something is wrong with your TCA definition: fieldInformation is an array of arrays, example form sysext/core/Configuration/TCA/be_users.php:

222:                'fieldInformation' => [
223-                    'adminIsSystemMaintainer' => [
224-                        'renderType' => 'adminIsSystemMaintainer',
225-                    ],
226-                ],
Actions

Also available in: Atom PDF