fix(audit M1): Update-/Move-Warnung nur für Inhalte, die vorher zur Schleifen-Kette passten (kein Alarm für ACF-Optionen); Tests für Update und Kettenwarnung beim Move
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
bb5487082e
commit
3a89b15b59
@@ -78,8 +78,9 @@ final class PresetRestorePlanner implements RestorePlanner
|
||||
}
|
||||
|
||||
/**
|
||||
* Audit L4: the pages using a preset the restore touches in any way, also re-created ones (spec §4 step 4, ruling P8a); a default
|
||||
* preset also counts its implicit users (like lit/divi-presets-delete). The orphan warning stays (spec §5).
|
||||
* Audit L4: the pages using a preset the restore touches in any way, also re-created ones (spec §4 step 4,
|
||||
* ruling P8a); a default preset also counts its implicit users (like lit/divi-presets-delete). The orphan
|
||||
* warning stays (spec §5).
|
||||
*
|
||||
* @param list<array<string, mixed>> $diff
|
||||
*/
|
||||
|
||||
@@ -11,8 +11,8 @@ defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* The usages a snapshot restore has to report (audit L4, spec §4 step 4): the pages that use an entry the restore
|
||||
* changes, removes, (de)activates or re-creates (an old ID that pages still reference) – DesignChange then blocks the confirmed restore for pages the caller may not edit
|
||||
* (ruling P8a) and the dry run lists them as "affected".
|
||||
* changes, removes, (de)activates or re-creates (an old ID that pages still reference) – DesignChange then blocks
|
||||
* the confirmed restore for pages the caller may not edit (ruling P8a) and the dry run lists them as "affected".
|
||||
*/
|
||||
final class RestoreUsages
|
||||
{
|
||||
|
||||
@@ -170,7 +170,8 @@ abstract class DiviWriteAbility implements Ability, RequiresDiviFeatures
|
||||
|
||||
/**
|
||||
* Whether moving or changing loop content from $from to $to needs a warning: the kind changes, or (audit M1)
|
||||
* a loop option no longer fits the whole chain – meta key options are checked against every enclosing loop.
|
||||
* a loop option that fitted before no longer fits the whole chain – meta key options are checked against every
|
||||
* enclosing loop. Content that never fitted (ACF repeater options, unknown loops) is not the move's doing.
|
||||
*
|
||||
* @param list<string> $names
|
||||
*/
|
||||
@@ -181,7 +182,10 @@ abstract class DiviWriteAbility implements Ability, RequiresDiviFeatures
|
||||
}
|
||||
|
||||
return $from->kind() !== $to->kind()
|
||||
|| array_filter($names, static fn (string $name): bool => ! $to->fits($name)) !== [];
|
||||
|| array_filter(
|
||||
$names,
|
||||
static fn (string $name): bool => $from->fits($name) && ! $to->fits($name)
|
||||
) !== [];
|
||||
}
|
||||
|
||||
/** @param list<string> $names */
|
||||
|
||||
@@ -480,4 +480,54 @@ final class DiviLoopWriteTest extends DiviWriteAbilityTestCase
|
||||
self::assertStringContainsString($right, self::problems($updated));
|
||||
self::assertSame([], $this->saved);
|
||||
}
|
||||
|
||||
private function usePage(string $content): void
|
||||
{
|
||||
$this->original = $content;
|
||||
$this->post->post_content = $content;
|
||||
}
|
||||
|
||||
/** Re-review: content that never fitted its loop (ACF repeater options) is no reason for a warning on an update. */
|
||||
public function testUpdatingALoopContainerDoesNotWarnForContentThatNeverFitted(): void
|
||||
{
|
||||
$acf = VariableRef::serialize('content', 'loop_acf_name', ['before' => '', 'after' => '']);
|
||||
$text = self::block('text', ['content' => ['innerContent' => ['desktop' => ['value' => $acf]]]]);
|
||||
$repeater = ['enable' => 'on', 'queryType' => 'repeater_team'];
|
||||
$this->usePage('<!-- wp:divi/placeholder -->' . self::block('section', self::loop($repeater), self::block(
|
||||
'row',
|
||||
[],
|
||||
self::block('column', [], $text)
|
||||
)) . '<!-- /wp:divi/placeholder -->');
|
||||
|
||||
$result = $this->changeAll([[
|
||||
'id' => 's0',
|
||||
'attrs' => ['module.decoration.background' => ['desktop' => ['color' => '#ff0000']]],
|
||||
]]);
|
||||
|
||||
self::assertTrue($result['ok'], (string) json_encode($result));
|
||||
self::assertStringNotContainsString('Schleife', implode(' | ', $result['warnings']));
|
||||
}
|
||||
|
||||
/** Re-review (M1): a moved loop with a post meta key option takes the outer term loop into its chain – warned. */
|
||||
public function testMovingALoopWithMetaKeyContentUnderAnotherKindOfLoopWarns(): void
|
||||
{
|
||||
$meta = VariableRef::serialize(
|
||||
'content',
|
||||
'loop_post_meta_key_manual_custom_field',
|
||||
['before' => '', 'after' => '']
|
||||
);
|
||||
$own = self::block('text', self::loop(self::POST_LOOP) + [
|
||||
'content' => ['innerContent' => ['desktop' => ['value' => $meta]]],
|
||||
]);
|
||||
$termColumn = self::block('column', self::loop(self::TERM_LOOP), self::text('y'));
|
||||
$this->usePage('<!-- wp:divi/placeholder -->' . self::block('section', [], self::block('row', [], implode('', [
|
||||
self::block('column', [], $own),
|
||||
$termColumn,
|
||||
]))) . '<!-- /wp:divi/placeholder -->');
|
||||
|
||||
$result = $this->moveNode(['id' => 's0.r0.c0.m0', 'parent' => 's0.r0.c1']);
|
||||
|
||||
self::assertTrue($result['ok'], (string) json_encode($result));
|
||||
self::assertStringContainsString('loop_post_meta_key_manual_custom_field', implode(' | ', $result['warnings']));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user