Skip to content

Commit 6a9dc08

Browse files
committed
[TASK] Prevent fluid 1st run bug
On first run fluid uses same VH instances on sub render processes, so we extract data from $this->arguments array before the call to $this->renderChilds() happens, so we have a local copy of the arguments needed. Talked issue to Fluid Team. Resolve: #632 Release: 12.1.0
1 parent a32930c commit 6a9dc08

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

Classes/ViewHelpers/ArrayVariableViewHelper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ public function initializeArguments()
2424
*/
2525
public function render()
2626
{
27+
$nameOfArray = $this->arguments['name'];
28+
$nameOfKey = $this->arguments['key'];
29+
2730
$value = ($this->arguments['value'] ?? $this->renderChildren());
2831

2932
$container = [];
3033

31-
if ($this->renderingContext->getVariableProvider()->exists($this->arguments['name'])) {
32-
$container = $this->renderingContext->getVariableProvider()->get($this->arguments['name']);
34+
if ($this->renderingContext->getVariableProvider()->exists($nameOfArray)) {
35+
$container = $this->renderingContext->getVariableProvider()->get($nameOfArray);
3336
}
37+
$container = ArrayUtility::setValueByPath($container, $nameOfKey, $value, '.');
3438

35-
$container = ArrayUtility::setValueByPath($container, $this->arguments['key'], $value, '.');
36-
37-
$this->renderingContext->getVariableProvider()->add($this->arguments['name'], $container);
39+
$this->renderingContext->getVariableProvider()->add($nameOfArray, $container);
3840
}
3941
}

Classes/ViewHelpers/Format/StripTagsViewHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ public function initializeArguments()
109109
*/
110110
public function render()
111111
{
112-
$value = $this->renderChildren();
113112
$allowedTags = $this->arguments['allowedTags'];
113+
$whitespaces = $this->arguments['whitespace'];
114+
$value = $this->renderChildren();
114115
if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) {
115116
return $value;
116117
}
117118
$value = (string)$value;
118-
if ($this->arguments['whitespace']) {
119+
if ($whitespaces) {
119120
$value = preg_replace('/(\S)<\//', '\1 </', $value);
120121
}
121122
return strip_tags($value, $allowedTags);

Classes/ViewHelpers/Format/WordLengthViewHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ public function initializeArguments()
4343
*/
4444
public function render()
4545
{
46+
$maxCharacter = $this->arguments['maxCharacters'];
47+
4648
$value = $this->renderChildren();
4749

4850
if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) {
4951
return $value;
5052
}
5153

52-
return preg_replace('/(\S{' . $this->arguments['maxCharacters'] . '})/', '\1 ', (string)$value);
54+
return preg_replace('/(\S{' . $maxCharacter . '})/', '\1 ', (string)$value);
5355
}
5456
}

Classes/ViewHelpers/SplitIntoArrayViewHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public function initializeArguments()
2525
public function render()
2626
{
2727
$pattern = $this->arguments['pattern'] ?? ($this->arguments['delimiterDecimal'] ? '\x' . dechex($this->arguments['delimiterDecimal']) : '');
28-
$value = $this->arguments['value'] ?? $this->renderChildren() ?? '';
29-
$limit = $this->arguments['limit'] ?? -1;
3028
// mb_split default is -1
29+
$limit = $this->arguments['limit'] ?? -1;
30+
$value = $this->arguments['value'] ?? $this->renderChildren() ?? '';
3131

3232
$result = mb_split($pattern, $value, $limit);
3333

0 commit comments

Comments
 (0)