Skip to content

Commit 8b02bec

Browse files
authored
Merge pull request #40 from evs-xsarus/bugfix/avoid-calculation
Avoid calculating the path_hint fails
2 parents b368319 + 8fec018 commit 8b02bec

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Plugin/ConfigFieldPlugin.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class ConfigFieldPlugin
3939
*/
4040
private $request;
4141

42-
/**
43-
* @var array<string>
44-
*/
45-
private $handledFields = [];
42+
/**
43+
* @var bool
44+
*/
45+
private $isProcessing = false;
4646

4747
public function __construct(
4848
Escaper $escaper,
@@ -103,15 +103,14 @@ public function afterGetData(
103103
return $result;
104104
}
105105

106-
// make sure we only calculate the path hint once
107-
// there is a known issue with a plugin from the MultiSafepay module (FieldPlugin) that can cause an infinite loop
108-
// this solves it by calculating the field's object hash and making sure we only call getPath once per Field
109-
$fieldObjectHash = spl_object_hash($subject);
110-
if (!in_array($fieldObjectHash, $this->handledFields, true)) {
111-
$this->handledFields[] = $fieldObjectHash;
106+
// to avoid a potential infinite loop, we keep a flag to see if we are already handling this particular field
107+
if (!$this->isProcessing) {
108+
$this->isProcessing = true;
112109

113-
$result['path_hint'] = '<small>' . __('Path: <code>%1</code>', $this->getPath($subject) . '</small>');
114-
}
110+
$result['path_hint'] = '<small>' . __('Path: <code>%1</code>', $this->getPath($subject) . '</small>');
111+
112+
$this->isProcessing = false;
113+
}
115114

116115
return $result;
117116
}

0 commit comments

Comments
 (0)