fix(4e-review M1): Update unterscheidet Composer und Zweitdurchlauf nach der ganzen Schleifen-Kette (LoopScope::key)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
b91c356a28
commit
8be2f5e558
@@ -94,6 +94,18 @@ final class LoopScope
|
||||
return $this->queryType === null ? [] : [$this->kind(), ...$this->outerKinds];
|
||||
}
|
||||
|
||||
/**
|
||||
* Identity of the context: the loop and the kinds of its whole chain (audit M1). Two scopes with the same key
|
||||
* resolve every loop_* reference the same way; no loop is "-|".
|
||||
*/
|
||||
public function key(): string
|
||||
{
|
||||
return ($this->queryType ?? '-') . '|' . implode(',', array_map(
|
||||
static fn (?string $kind): string => $kind ?? '?',
|
||||
$this->kinds()
|
||||
));
|
||||
}
|
||||
|
||||
/** Whether there is a loop whose loop_* options the tools allow. */
|
||||
public function active(): bool
|
||||
{
|
||||
|
||||
@@ -231,7 +231,7 @@ final class DiviUpdateAbility extends DiviWriteAbility
|
||||
*/
|
||||
private static function composeInLoops(NodeIndex $index, DiviComposition $composition, array $pending): array
|
||||
{
|
||||
/** @var array<string, Composer> $composers query type ('' = no loop) => Composer of that scope */
|
||||
/** @var array<string, Composer> $composers LoopScope::key() => Composer of that scope */
|
||||
$composers = [];
|
||||
$scopes = [];
|
||||
$results = [];
|
||||
@@ -247,7 +247,7 @@ final class DiviUpdateAbility extends DiviWriteAbility
|
||||
}
|
||||
foreach ($pending as $position => [$block, $change, $field]) {
|
||||
$scope = self::loopAt($index, $block, $newAttrs);
|
||||
if ($scope->queryType() !== $scopes[$position]->queryType()) {
|
||||
if ($scope->key() !== $scopes[$position]->key()) {
|
||||
$results[$position] = self::composerFor($composition, $scope, $composers)
|
||||
->update($block, $change, $field);
|
||||
}
|
||||
@@ -256,9 +256,9 @@ final class DiviUpdateAbility extends DiviWriteAbility
|
||||
return $results;
|
||||
}
|
||||
|
||||
/** @param array<string, Composer> $composers One Composer per loop scope (S31 as reworded by X3). */
|
||||
/** @param array<string, Composer> $composers One Composer per loop context, chain included (S31 as reworded by X3). */
|
||||
private static function composerFor(DiviComposition $composition, LoopScope $scope, array &$composers): Composer
|
||||
{
|
||||
return $composers[$scope->queryType() ?? ''] ??= $composition->inLoop($scope)->composer();
|
||||
return $composers[$scope->key()] ??= $composition->inLoop($scope)->composer();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user