Issue Bug Closed

#102105Undefined array key "reverseProxyIP"

John Miller 10/06/23, 13:33 updated 02/03/24, 10:50

Description

This error is being thrown around by the ExtensionManagementUtility::loadBaseTca() function in the loadBaseTca() method of the \TYPO3\CMS\Core\Core\Bootstrap.

*Problem*
Array values are being checked improperly.

Some package TCA files being required in the \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::buildBaseTcaFromSingleFiles() method loops (for both TCA and override TCA) are causing this issue. These TCA files contain keys and even variables whose values are being harvested from non-existent globals multi-dimensional keys.

*Example 1:*
@vendor/typo3/cms-core/Configuration/TCA/pages.php@ contains this line
@[‘label’=>$GLOBALS[‘TYPO3_CONF_VARS’][‘FE’][‘hidePagesIfNotTranslatedByDefault’] ? ‘LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.2a’ : ‘LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.2’],@

If ‘@hidePagesIfNotTranslatedByDefault@’ is not defined, the error is thrown.

*Example 2:*
@vendor/typo3/cms-core/Classes/Resource/Driver/DriverRegistry.php@ contains this line in its constructor
@$driverConfigurations=$GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘fal’][‘registeredDrivers’];@
which also throws the error if ‘@registeredDrivers@’ is undefined.

Solution
  1. Predicate optional settings such as the ones mentioned above. In example 1, such as using isset() isset($GLOBALS['TYPO3_CONF_VARS']['FE']['hidePagesIfNotTranslatedByDefault']) ? ... and in example 2, $driverConfigurations=$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredDrivers'] ?? []; would be good enough to prevent the error.
  2. Use a the try block in the include closures of the \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::buildBaseTcaFromSingleFiles() method and log or throw out the proper message, such as "undefined array key 'fal'" as it should be with example 2 above in order to know the real problem.
References
  1. https://stackoverflow.com/questions/16675753/php-fastest-way-to-handle-undefined-array-key

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.