Skip to content

Commit b6d2a58

Browse files
authored
[TASK] Clarify limits of null coalescing operator ?? (#1574)
Releases: main, 13.4
1 parent 75e6687 commit b6d2a58

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Documentation/Syntax/Conditions/Index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ in TSconfig from "site settings". A simple example if this constant
115115
page.10.value = Page uid is 42
116116
[end]
117117
118+
.. note::
119+
120+
Using the `Null coalescing operator ?? <https://docs.typo3.org/permalink/t3tsref:typoscript-syntax-syntax-null-coalescing>`_
121+
with constants used within conditions is not possible.
122+
118123
.. _typoscript-syntax-end-condition-nesting:
119124

120125
Nesting conditions via TypoScript imports
@@ -165,7 +170,6 @@ backend:
165170
# Now
166171
[getTSFE()?.id == 123]
167172
168-
169173
.. _typoscript-syntax-syntax-value:
170174

171175
Allowed criteria in TypoScript conditions

Documentation/Syntax/Operators/Index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ parenthesis. These predefined functions are available:
316316
The section :ref:`EvaluateModifierFunctionEvent <t3coreapi:EvaluateModifierFunctionEvent>`
317317
provides an example and the API.
318318

319+
320+
.. _typoscript-syntax-syntax-null-coalescing:
321+
319322
Null coalescing operator `??` for TypoScript constants
320323
=======================================================
321324

@@ -333,3 +336,17 @@ Example that evaluates to `$config.oldThing` if set, otherwise the newer setting
333336
:caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript
334337
335338
plugin.tx_myext.settings.example = {$config.oldThing ?? $myext.thing}
339+
340+
The null coalescing operator cannot be used in conditions. Use
341+
`or <https://docs.typo3.org/permalink/t3tsref:typoscript-syntax-end-condition-or>`_
342+
instead:
343+
344+
.. code-block:: typoscript
345+
:caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript
346+
347+
# Wrong
348+
# [{$config.oldThing ?? $myext.thing} == 5]
349+
350+
# Right
351+
[{$config.oldThing} == 5 or {$myext.thing} == 5]
352+

0 commit comments

Comments
 (0)