Fix Warning: Undefined array key properties

Created on 12 June 2023, over 1 year ago
Updated 10 September 2023, about 1 year ago

Problem/Motivation

Facing the following warning after finishing install and after clearing the Drupal cache

Warning: Undefined array key "properties" in Drupal\sdc\Component\ComponentValidator->nullifyClassPropsSchema() (line 289 of core/modules/sdc/src/Component/ComponentValidator.php).
Drupal\sdc\Component\ComponentValidator->nullifyClassPropsSchema(Array, Array) (Line: 96)
Drupal\sdc\Component\ComponentValidator->validateDefinition(Array, ) (Line: 345)
Drupal\sdc\ComponentPluginManager->isValidDefinition(Array) (Line: 252)
Drupal\sdc\ComponentPluginManager->Drupal\sdc\{closure}(Array) (Line: 56)
Drupal\Component\Assertion\Inspector::assertAll(Object, Array) (Line: 253)
Drupal\sdc\ComponentPluginManager->alterDefinitions(Array) (Line: 295)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 138)
Drupal\sdc\ComponentPluginManager->find('varbase_components:input') (Line: 75)
Drupal\sdc\Twig\TwigComponentLoader->exists('varbase_components:input') (Line: 88)
Twig\Loader\ChainLoader->getCacheKey('varbase_components:input') (Line: 264)
Twig\Environment->getTemplateClass('varbase_components:input', NULL) (Line: 204)
Drupal\Core\Template\TwigEnvironment->getTemplateClass('varbase_components:input') (Line: 319)
Twig\Template->loadTemplate('varbase_components:input', 'themes/contrib/vartheme_bs5/templates/form/input.html.twig', 1) (Line: 39)
__TwigTemplate_b035b8e9dafd8f6c43f23761f1b1f804->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('themes/contrib/vartheme_bs5/templates/form/input.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('input', Array) (Line: 436)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 39)
__TwigTemplate_fbc3f5bf6a404e4a4120b497b075f03f->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('modules/contrib/webform/templates/webform-submission-form.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('webform_submission_form', Array) (Line: 436)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 583)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\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: 171)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 54)
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: 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)
Warning: foreach() argument must be of type array|object, null given in Drupal\sdc\Component\ComponentValidator->nullifyClassPropsSchema() (line 289 of core/modules/sdc/src/Component/ComponentValidator.php).
Drupal\sdc\Component\ComponentValidator->nullifyClassPropsSchema(Array, Array) (Line: 96)
Drupal\sdc\Component\ComponentValidator->validateDefinition(Array, ) (Line: 345)
Drupal\sdc\ComponentPluginManager->isValidDefinition(Array) (Line: 252)
Drupal\sdc\ComponentPluginManager->Drupal\sdc\{closure}(Array) (Line: 56)
Drupal\Component\Assertion\Inspector::assertAll(Object, Array) (Line: 253)
Drupal\sdc\ComponentPluginManager->alterDefinitions(Array) (Line: 295)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 138)
Drupal\sdc\ComponentPluginManager->find('varbase_components:input') (Line: 75)
Drupal\sdc\Twig\TwigComponentLoader->exists('varbase_components:input') (Line: 88)
Twig\Loader\ChainLoader->getCacheKey('varbase_components:input') (Line: 264)
Twig\Environment->getTemplateClass('varbase_components:input', NULL) (Line: 204)
Drupal\Core\Template\TwigEnvironment->getTemplateClass('varbase_components:input') (Line: 319)
Twig\Template->loadTemplate('varbase_components:input', 'themes/contrib/vartheme_bs5/templates/form/input.html.twig', 1) (Line: 39)
__TwigTemplate_b035b8e9dafd8f6c43f23761f1b1f804->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('themes/contrib/vartheme_bs5/templates/form/input.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('input', Array) (Line: 436)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 449)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 39)
__TwigTemplate_fbc3f5bf6a404e4a4120b497b075f03f->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('modules/contrib/webform/templates/webform-submission-form.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('webform_submission_form', Array) (Line: 436)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 583)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\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: 171)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 54)
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: 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)




Proposed resolution

Manage the right values for

props:
  type: object
  properties:
    attributes:
      type: Drupal\Core\Template\Attribute

As of Components without props, with a schema

# Everything from the Full example applies here. We are focusing in the props
# for this example.

# Even when we have no props, we need to add a schema of an empty object for them.
props:
  type: object
  additionalProperties: false
  properties: {}
Having number of schema sources like
SDC contrib one
$schema: https://git.drupalcode.org/project/sdc/-/raw/1.x/src/metadata.schema.json
SDC from Drupal core one
$schema: https://git.drupalcode.org/project/drupal/-/raw/10.1.x/core/modules/sdc/src/metadata.schema.json

Following with latest demos on SDC from maintainers, which they did not add it in the .component.yml
Experimenting with this option as Varbase Components may end up having a general metadata.schema.json if custom types are needed.

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Addition/Change/Update/Fix to this project
  • ✅ Testing to ensure no regression
  • ✅ Automated unit/functional testing coverage
  • ➖ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ✅ Accessibility and Readability
  • ✅ Code review from 1 Varbase core team member
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Update Release Notes and Update Helper on new feature change/addition
  • ✅ Release Varbase 10.0.0-beta1 , varbase_components-2.0.0-alpha6

Varbase update type

  • ✅ No Update
  • ➖ Optional Update
  • ➖ Forced Update
  • ➖ Forced Update if Unchanged

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • Issue #3366308 : Fixed Warning: Undefined array key properties
🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇯🇴Jordan Rajab Natshah Jordan

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

Comments & Activities

Production build 0.71.5 2024