fix: library entries read as not found without the library right (P12)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 01:07:53 +02:00
co-authored by Claude Opus 5.5
parent 48ecc627aa
commit 681bb755ff
5 changed files with 50 additions and 13 deletions
@@ -51,7 +51,9 @@ class LibraryAccess
/**
* The library entry $postId after the checks for reading, or their refusal; null when $postId
* names no library entry (the caller goes on with PostGuard). With the library hidden (ruling
* P9), an entry is refused exactly like an ID that does not exist – before any rights check.
* P9) or without the library right at all (ruling P12), an entry is refused exactly like an ID
* that does not exist, so its type and existence stay unknown; only a user with the library
* right who lacks edit_post on the entry gets forbidden (like pages).
*/
public function item(mixed $postId, bool $forWrite): WP_Post|WP_Error|null
{
@@ -61,7 +63,7 @@ class LibraryAccess
return null;
}
if ($this->visible !== null && ! ($this->visible)()) {
if (($this->visible !== null && ! ($this->visible)()) || $this->canList() !== null) {
return PostGuard::notFound((int) $post->ID);
}