Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons.php error: watchout #4647

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions Documentation/ApiOverview/Icon/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ The file needs to return a PHP configuration array with the following keys:
:language: php
:caption: EXT:my_extension/Configuration/Icons.php

.. attention::
Do not overwrite the $icons variable in this file. This can lead to the error:
brotkrueml marked this conversation as resolved.
Show resolved Hide resolved
"Fatal error: Uncaught Error: Call to a member function exchangeArray() on array in typo3/cms-core/Classes/Package/AbstractServiceProvider.php"
(assuming you replaced the $icons variable with an array)
:ref:`As with all .php files getting included by TYPO3, you should use a closure/anonymous function to encapsulate variables. <configuration_php_use_closures>`

.. index:: Icon API; IconProviderInterface

Icon provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,38 @@ file with all configuration of other extensions.
:php:`$_EXTKEY` option **must** be kept within an extension's
:ref:`ext_emconf.php <extension-declaration>` file.

- You **do not have to** use a directly called closure function after dropping
TYPO3 v10.4 support.

.. _configuration_php_use_closures:

Safety with Closures
====================
You **do not have to** use a directly called closure function after dropping
TYPO3 v10.4 support. But it is still recommended in other included files to
wrap them in a function.

.. literalinclude:: _function_wrap.php
:language: php

This is a list of those files where wrapping is still
recommended:

- ext_localconf.php (kinda fine since 8.7)
- ext_tables.php (kinda fine since 8.7)
- Configuration/RequestMiddlewares.php (fixed with 13.2)
- Configuration/Backend/Routes.php (fixed with 13.2)
- Configuration/Backend/AjaxRoutes.php (fixed with 13.2)
- Configuration/Backend/Modules.php (fixed with 13.2)
- Configuration/Backend/DashboardPresets.php (fixed with 13.2)
- Configuration/Backend/DashboardPresets.php (fixed with 13.2)
- Configuration/Backend/DashboardPresets.php (fixed with 13.2)
- Configuration/ContentSecurityPolicies.php (fixed with 13.2)
- Configuration/Icons.php (fixed with 13.2)
- Configuration/ExpressionLanguage.php
- Configuration/Backend/T3editor/Modes.php
- Configuration/Backend/T3editor/Addons.php
- Configuration/Extbase/Persistence/Classes.php
- ext_emconf.php (funnily here you have to overwrite the $EM_CONF variable)


The following example contains the complete code:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
return call_user_func(function () {
//code
});
//or
$function = function () {
//code
};
return $function();