Skip to content

Commit

Permalink
[BUGFIX] Do not add error in TypoScriptParser if modifier returns null
Browse files Browse the repository at this point in the history
Currently, the TypoScriptParser adds an error when
the result of a modifier is null. This is, because
the line is not set to a new value in such a case
and the following switch statement is not expecting
a line with a value modifier.

This has been fixed by skipping further checks on
the value, if the modifier returns null.

Resolves: #94109
Releases: master, 11.5
Change-Id: I28ae1570a5b0b4fc5ad667bacd86a17234aa1c60
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72420
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
ochorocho authored and lolli42 committed Dec 2, 2021
1 parent 047d3a2 commit 1717a1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Expand Up @@ -309,6 +309,8 @@ protected function parseSub(array &$setup)
$newValue = $this->executeValueModifier($tsFunc, $tsFuncArg, $val[0]);
if (isset($newValue)) {
$line = '= ' . $newValue;
} else {
continue;
}
}
switch ($line[0]) {
Expand Down
Expand Up @@ -1263,4 +1263,18 @@ public function parseNextKeySegmentReturnsCorrectNextKeySegmentDataProvider(): a
],
];
}

/**
* @test
*/
public function typoScriptWithModifierReturningNullDoesNotCreateErrors(): void
{
$typoScript = '
foo = bar
foo := getEnv(NON_EXISTING_ENV)
';

$this->typoScriptParser->parse($typoScript);
self::assertEmpty($this->typoScriptParser->errors);
}
}

0 comments on commit 1717a1b

Please sign in to comment.