contentacms / contenta_jsonapi

Contenta CMS, the decoupled Drupal
http://www.contentacms.org/
GNU General Public License v2.0
328 stars 104 forks source link

JSON API error when opening demo content after install #351

Closed hyperfocus1337 closed 5 years ago

hyperfocus1337 commented 5 years ago

I'm seeing the following error after a clean install of Contenta.

The website encountered an unexpected error. Please try again later.
TypeError: Argument 3 passed to Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel::__construct() must be an instance of Drupal\jsonapi\JsonApiResource\LinkCollection, array given, called in /var/www/html/web/modules/contrib/jsonapi_extras/src/EntityToJsonApi.php on line 124 in Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel->__construct() (line 58 of modules/contrib/jsonapi/src/JsonApiResource/JsonApiDocumentTopLevel.php).
Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel->__construct(Object, Object, Array) (Line: 124)
Drupal\jsonapi_extras\EntityToJsonApi->normalize(Object) (Line: 371)
contenta_enhancements_node_view_alter(Array, Object, Object) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('node_view', Array, Object, Object) (Line: 286)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 220)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 41)
Drupal\jsonapi\StackMiddleware\FormatSetter->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
e0ipso commented 5 years ago

I'm pretty sure this is caused by a cached version of JSON:API Extras in your local composer. Try clearing your composer caches.

https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-

hyperfocus1337 commented 5 years ago

I ran composer clear-cache and cleared drupal cache, ran composer update afterwards but did not fix.

JSON API Extras version 8.x-3.3

hyperfocus1337 commented 5 years ago

Maybe worth noting it happens when viewing the content underneath /admin/content page.

2019-02-09_17-10

I did not notice the similarly named tutorial links under /help/tutorials.

hyperfocus1337 commented 5 years ago

Error also triggers when viewing recipe and embeddable content types, or creating your own content and viewing it.

hyperfocus1337 commented 5 years ago

Tried removing database and installing again with composer run-script install:with-mysql but did not resolve the issue.

e0ipso commented 5 years ago

This was fixed in here. https://www.drupal.org/project/jsonapi_extras/issues/3027768

Can you confirm your build contains that code?

hyperfocus1337 commented 5 years ago

Applying patch mentioned in above issue fixed the problem. Add this to composer to solve:

    "patches": {
      "drupal/jsonapi_extras": {
        "Fix issue": "https://www.drupal.org/files/issues/2019-01-23/jsonapi_extras-doctoplevel_arg3.patch"
      }
    }