Skip to content

Skip OAI list records the requester cannot view (fix WSOD on access-restricted content)#2

Open
daniel-dgi wants to merge 1 commit into
libops:2.0.xfrom
daniel-dgi:skip-inaccessible-oai-records
Open

Skip OAI list records the requester cannot view (fix WSOD on access-restricted content)#2
daniel-dgi wants to merge 1 commit into
libops:2.0.xfrom
daniel-dgi:skip-inaccessible-oai-records

Conversation

@daniel-dgi

@daniel-dgi daniel-dgi commented Jun 3, 2026

Copy link
Copy Markdown

Problem

We've been having a cache poisoning problem due to how we use groups and accessc ontrol. A full ListRecords/ListIdentifiers harvest fatals (WSOD) for anonymous harvesters whenever the OAI cache contains a published but access-restricted record (or one that has since been deleted):

Error: Call to a member function hasField() on false in
Drupal\rest_oai_pmh\Plugin\rest\resource\OaiPmh->getHeaderById() (line 553)

Rebuilding the cache doesn't seem to change anything. Poisoned entries will get added back into the cache.

So here's a couple null checks. This fixed the problem for us.

ListRecords and ListIdentifiers iterate cached records and call
getHeaderById()/getRecordById() without checking that the entity
loaded. When a cached record references an entity the current
(anonymous) user cannot view -- e.g. published content protected by
node access (Group, embargo, IP restrictions) -- or one that has since
been deleted, loadEntity() sets $this->entity to FALSE and the
subsequent $this->entity->hasField('changed') call throws "Call to a
member function hasField() on false", white-screening the entire
harvest. Only the list verbs are affected; GetRecord already handles a
FALSE entity gracefully (returns idDoesNotExist).

Guard both loops with `if (empty($this->entity)) { continue; }` so
inaccessible or missing records are skipped rather than fataling,
mirroring the FALSE handling getRecord() already performs.
@daniel-dgi daniel-dgi force-pushed the skip-inaccessible-oai-records branch from ac4bd63 to 1eb425c Compare June 3, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants