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:
Jan-Niclas Loosen
2026-10-20 00:14:57 +02:00
co-authored by Claude Sonnet 5.5
parent bb5487082e
commit 3a89b15b59
4 changed files with 61 additions and 6 deletions
@@ -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 */