SparqlEntityStorageGraphHandler::getEntityTypeGraphUris violates interface contract

Created on 4 August 2023, over 1 year ago

Problem/Motivation

The way how SparqlEntityStorageGraphHandler::getEntityTypeGraphUris() is implemented violates SparqlEntityStorageGraphHandlerInterface::getEntityTypeGraphUris(): the underlying code assumes that EntityTypeBundleInfoInterface::getBundleInfo() returns a non-empty array, but in case of missing entity types (or not-yet-installed entity types for example) it returns an empty array.

This means the foreach loop inside the first condition's body won't create the corresponding entity type ID key in SparqlEntityStorageGraphHandler::$cache['definitions'], which means the storage handler will throw exception if it is asked to load a missing entity - but the contact with EntityStorageInterface::load() contraints to return a NULL in these cases.

Steps to reproduce

1. Install RDF Entity.
2. Try load a missing entity with RDF::load('foo-bar-baz');

Proposed resolution

Ensure SparqlEntityStorageGraphHandler::getEntityTypeGraphUris() always returns array, e.g. $this->cache['structure'][$entity_type_id] gets always set inside the first condition in SparqlEntityStorageGraphHandler::getEntityTypeGraphUris().

Remaining tasks

A triage and a review.

User interface changes

Nothing.

API changes

Nothing.

Data model changes

Nothing.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary huzooka Hungary πŸ‡­πŸ‡ΊπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024