fix: global-edit rules for every library entry that pages show (L2)

Divi renders any referenced et_pb_layout, whatever its scope term. A normal
entry with usages now gets the dry run, confirm, P8a, backup and the
site-wide GlobalItem scope; lit-divi-delete's notice and the library-list
detail name its pages too. The usage scan is the same single query.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 04:14:58 +02:00
co-authored by Claude Opus 5.5
parent 8aacc5dc4f
commit 395049ec97
6 changed files with 117 additions and 36 deletions
+3 -3
View File
@@ -113,10 +113,10 @@ final class LibraryFixtures
}
/**
* GlobalUsages whose query answers $rows (a closure is asked on every call); the rights checks
* GlobalUsages whose query answers $rows (a closure gets the entry ID on every call); the rights checks
* are the real ones, with the post-cache functions stubbed.
*
* @param list<array{id: int, status: string, type: string}>|\Closure(): list<array{id: int, status: string, type: string}> $rows
* @param list<array{id: int, status: string, type: string}>|\Closure(int): list<array{id: int, status: string, type: string}> $rows
*/
public static function usages(array|\Closure $rows, ?DiviRoles $roles = null): GlobalUsages
{
@@ -124,7 +124,7 @@ final class LibraryFixtures
Functions\when('_prime_post_caches')->justReturn(null);
Functions\when('wp_cache_delete')->justReturn(true);
$usages = Mockery::mock(GlobalUsages::class, [null, $roles ?? self::roles()])->makePartial();
$usages->allows('rows')->andReturnUsing(static fn (): array => is_array($rows) ? $rows : $rows());
$usages->allows('rows')->andReturnUsing(static fn (int $id): array => is_array($rows) ? $rows : $rows($id));
return $usages;
}