The __construct() of \Drupal\jsonapi_extras\EntityToJsonApi has the following code:

    assert(is_string($jsonapi_base_path));
    assert($jsonapi_base_path[0] === '/');
    assert(substr($jsonapi_base_path, -1) !== '/');
    $this->jsonApiBasePath = $jsonapi_base_path;

It means that $jsonapi_base_path shouldn't start from and end by a slash. However, the calculateContext() method expects that $this->jsonApiBasePath is ended by a slash.

$path = sprintf('%s%s/%s', $this->jsonApiBasePath, $resource_path, $entity->uuid());

Also, why jsonapi and jsonapi_extras have exactly same (symbol-to-symbol) EntityToJsonApi? The jsonapi.entity.to_jsonapi service uses \Drupal\jsonapi\EntityToJsonApi when jsonapi_extras disabled and \Drupal\jsonapi_extras\EntityToJsonApi oterwise. It would be logically to have a decorator (in current scenario the dublucating services just isn't needed).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BR0kEN created an issue. See original summary.

BR0kEN’s picture

Well, I wasn't right for 100% but the problem exists. The \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType::getPath() returns a value without leading slash.

BR0kEN’s picture

Assigned: BR0kEN » Unassigned
Status: Active » Needs review
FileSize
10.38 KB

Remove duplicating functionality of jsonapi.

BR0kEN’s picture

FileSize
926 bytes

The previous patch is completely incorrect since I haven't checked that jsonapi is no longer has the functionality that I've considered as duplicated.

e0ipso’s picture

Status: Needs review » Reviewed & tested by the community

I'm in for some resiliency.

  • e0ipso committed 2fc4fc8 on 8.x-2.x authored by BR0kEN
    Issue #2995093 by BR0kEN, e0ipso: Invalid handling of the "...
e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.