fix: Umschreiber nennt Bibliotheks-IDs globaler Instanzen nur bei sichtbaren Bibliotheks-IDs (P13)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 17:04:30 +02:00
co-authored by Claude Opus 5.5
parent d7a991d130
commit 65a207488e
4 changed files with 72 additions and 14 deletions
@@ -40,9 +40,10 @@ defined('ABSPATH') || exit;
* that is dropped afterwards (audit L1).
* - Skipped (named, never written): posts loadWritable() refuses (rights, Divi 4, unparsable markup – R8: not
* remaining, so repeated calls end), global instances the change concerns (their library entry is a usage of its
* own), library entries shown on live posts the caller may not edit (P8a), and library entries or Theme Builder
* layouts visible site-wide without revisions (no restore point; a bulk write makes no backup copies). Posts the
* caller may not read are never named, only counted (hidden_count, audit L4).
* own; its ID is named only when DiviPageLoader::libraryIdsVisible(), ruling P13), library entries shown on
* live posts the caller may not edit (P8a), and library entries or Theme Builder layouts visible site-wide
* without revisions (no restore point; a bulk write makes no backup copies). Posts the caller may not read are
* never named, only counted (hidden_count, audit L4).
* - Save scope as in DiviWriter. The rewrite changes attributes only, so a library entry keeps its shape
* (LibraryContent::shapeViolation() needs no check).
* - A failed save after other posts were saved answers partial_write with data.saved; a failure before the first
@@ -232,7 +233,7 @@ class PageRewriter
return null;
}
$result = (new TreeRewrite($rewrite()))->apply($page->index);
$result = (new TreeRewrite($rewrite(), $this->loader->libraryIdsVisible()))->apply($page->index);
foreach ($result['skipped'] as $node) {
$skipped[] = ['post_id' => $id, 'reason' => $node['id'] . ': ' . $node['reason']];
}
+9 -5
View File
@@ -14,11 +14,13 @@ defined('ABSPATH') || exit;
* Applies a NodeRewrite to every block of a NodeIndex, in place (ruling R8): readable blocks are offered to
* rewrite(), a changed one gets its new attributes and then its notes; opaque blocks – global instances, blocks with
* unreadable attributes – are never offered and never changed, but listed as skipped when the strategy says the
* change concerns them (a global module is edited in its library entry). Pure PHP.
* change concerns them (a global module is edited in its library entry). The reason names the library entry's ID
* only with $revealLibraryIds (ruling P13: the caller may see library IDs); otherwise it points to the Divi Builder
* (fail closed). Pure PHP.
*/
final class TreeRewrite
{
public function __construct(private NodeRewrite $rewrite)
public function __construct(private NodeRewrite $rewrite, private bool $revealLibraryIds = false)
{
}
@@ -37,7 +39,7 @@ final class TreeRewrite
if ($block->isOpaque()) {
if ($this->rewrite->concernsInstance($block)) {
$skipped[] = ['id' => $id, 'reason' => self::reason($block)];
$skipped[] = ['id' => $id, 'reason' => $this->reason($block)];
}
continue;
}
@@ -55,11 +57,13 @@ final class TreeRewrite
return ['changed' => $changed, 'warnings' => $warnings, 'skipped' => $skipped];
}
private static function reason(Block $block): string
private function reason(Block $block): string
{
$ref = NodeSummary::globalRef($block);
if ($ref !== null) {
return sprintf('globales Modul – im Bibliothekseintrag %s ändern', $ref['id']);
return $this->revealLibraryIds
? sprintf('globales Modul – im Bibliothekseintrag %s ändern', $ref['id'])
: 'globales Modul – im Divi-Builder ändern';
}
return $block->isGlobal()