Skip to content

Commit

Permalink
[TASK] Clarify variable scope withing TCA files (#4754) (#4757)
Browse files Browse the repository at this point in the history
* [TASK] Clarify variable scope withing TCA files (#4754)

References /issues/4756
Releases: main,12.4

* Fix versionadded note introduction

* remove change in Makefile

* Update Documentation/ExtensionArchitecture/FileStructure/Configuration/TCA/Index.rst

* Update Documentation/ExtensionArchitecture/FileStructure/Configuration/TCA/Index.rst

* Update Index.rst

---------

Co-authored-by: Chris Müller <[email protected]>
Co-authored-by: Lina Wolf <[email protected]>
  • Loading branch information
3 people committed Sep 13, 2024
1 parent 90d1499 commit af18607
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ The folder :file:`EXT:my_extension/Configuration/TCA/` may contain or override
All files in this directory are automatically included during the TYPO3
:ref:`bootstrap <bootstrapping>`.

.. versionadded:: 12.0
Files within :file:`Configuration/TCA/` files are loaded within a dedicated scope.
This means that variables defined in those files cannot leak to any other
TCA file during the TCA compilation process.

.. note::
In TYPO3 v11 and below, variables declared in these files were in a shared scope,
with the risk of a leakage to the following files. The use of :php:`call_user_func()`
wrap was a common workaround.

:file:`<tablename>.php`
=======================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

declare(strict_types=1);

call_user_func(static function () {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'fe_users',
'tx_myextension_options, tx_myextension_special',
'',
'after:password',
);
});
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'fe_users',
'tx_myextension_options, tx_myextension_special',
'',
'after:password',
);
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ will usually take effect without any special measures.
Loading order also matters if you have multiple extensions overriding the same field,
probably even contradicting each other.

.. versionadded:: 12.0
Files within :file:`Configuration/TCA/` files are loaded within a dedicated scope.
This means that variables defined in those files can't leak into the following files.

.. note::
In TYPO3 v11 and below, variables declared in these files were in a shared scope,
with the risk of a leakage to the following files. The use of :php:`call_user_func`
wrap was a common workaround.

For more information about an extension's structure, please refer to the
:ref:`extension architecture <extension-architecture>` chapter.
Expand Down

0 comments on commit af18607

Please sign in to comment.