Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292509

Support entities that are neither content nor config entities

$
0
0

Problem/Motivation

By design the module exposes resources for every entity type in the system. However, if a module contains an entity which does not implement ContentEntityTypeInterface or ConfigEntityTypeInterface, a WSOD/HTTP 500 error is thrown when the module is installed or the cache is rebuilt or JSONAPI resources are visited. The log contains the follow error:

LogicException: Only content and config entity types are supported. in Drupal\jsonapi\ResourceType\ResourceTypeRepository->getAllFieldNames() (line 285 of /var/www/html//modules/contrib/jsonapi/src/ResourceType/ResourceTypeRepository.php).

The same as a JSONAPI response:

title	"Internal Server Error"
status	"500"
detail	"Only content and config entity types are supported."

It might not be the usual use case to support non-content/config entities, but it would be nice to handle them in a way that doesn't break the system, like excluding them from resources and relationships.

Steps to reproduce

Enable either
* The entity_test module after you have applied the test_only patch from this issue or
* the Apigee Edge module or
* the Brightcove Video connect module

and visit the /jsonapi route.

Proposed resolution

MR3548 contains a fix that adds support for fieldable entities - basically it widens the content entity support. All previous existing tests in core proves that everything keeps working. It also introduces a very basic, best effort fieldable entity implementation in the entity_test module to prove whenever that module is enabled (it is enabled in several JSONAPI tests) the above describe problem occurs without the fix. (Dedicated tests for the fieldable entity are not even needed to prove the issue.)
#3344705: Improve fieldable entity test/example class was opened as a follow up to improve and extend the fieldable entity implementation and maybe refactor/write more tests that leverages this new implementation.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

[#3343351]


Viewing all articles
Browse latest Browse all 292509

Trending Articles