TypeError in schemadotorg_jsonld on Update to 1.0.0-alpha12 from 1.0.0-alpha10

Created on 30 November 2023, about 1 year ago
Updated 2 December 2023, about 1 year ago

Problem/Motivation

After updating the schemadotorg module from version 1.0.0-alpha10 to 1.0.0-alpha12, I'm encountering a TypeError on all my project using Schema.org Blueprints module. The sites were functioning correctly prior to this update.

The website encountered an unexpected error. Please try again later.

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 293 of modules/contrib/schemadotorg/modules/schemadotorg_jsonld/src/SchemaDotOrgJsonLdManager.php).
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdManager->hasSchemaUrl(Object) (Line: 178)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->buildMappedEntity(Object) (Line: 103)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->buildEntity(Object) (Line: 77)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->build() (Line: 37)
schemadotorg_jsonld_page_attachments_alter(Array, NULL, NULL) (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('page_attachments', Array) (Line: 319)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 285)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 286)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 91)
Drupal\next\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
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(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 68)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

1. Update the schemadotorg module from version 1.0.0-alpha10 to 1.0.0-alpha12.
2. Navigate to any page on the site or perform an action that triggers the error.

Proposed resolution

It seems that schemadotorg_jsonld/src/SchemaDotOrgJsonLdManager.php has got a lot of modification since the alpha-10 version. Not sure what is going wrong. Any help is welcome.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡°πŸ‡¬Kyrgyzstan dan_metille

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

Comments & Activities

  • Issue created by @dan_metille
  • Status changed to Closed: outdated about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    The module is still in alpha release, and update hooks are NOT provided.

    You need to manually import the below config file to add the missing configuration setting.

    https://git.drupalcode.org/project/schemadotorg/-/blob/1.0.x/modules/sch...

  • πŸ‡°πŸ‡¬Kyrgyzstan dan_metille

    I understand that the module is still in alpha release, and thanks for all the work and the support!

    Now I notice the warning message below, new with alpha-12. Is there also a way to fix it?

    Warning: foreach() argument must be of type array|object, null given in Drupal\schemadotorg_cer\SchemaDotOrgCorrespondingReferenceManager->mappingDefaultsAlter() (line 51 of modules/contrib/schemadotorg/modules/schemadotorg_cer/src/SchemaDotOrgCorrespondingReferenceManager.php).
    Drupal\schemadotorg_cer\SchemaDotOrgCorrespondingReferenceManager->mappingDefaultsAlter(Array, 'node', 'article', 'Article') (Line: 20)
    schemadotorg_cer_schemadotorg_mapping_defaults_alter(Array, 'node', 'article', 'Article') (Line: 114)
    Drupal\schemadotorg\SchemaDotOrgMappingManager->Drupal\schemadotorg\{closure}(Object, 'schemadotorg_cer') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('schemadotorg_mapping_defaults_alter', Object) (Line: 115)
    Drupal\schemadotorg\SchemaDotOrgMappingManager->getMappingDefaults('node', 'article', 'Article') (Line: 405)
    Drupal\schemadotorg_ui\Form\SchemaDotOrgUiMappingForm->buildFieldTypeForm(Array, Object) (Line: 184)
    Drupal\schemadotorg_ui\Form\SchemaDotOrgUiMappingForm->form(Array, Object) (Line: 107)
    Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('schemadotorg_mapping_edit_form', Object) (Line: 283)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
    Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 68)
    Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    Thanks for help.

Production build 0.71.5 2024