Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jrockowitz created an issue. See original summary.

jrockowitz’s picture

Title: Improve additional type handling » Improve additional type JSON-LD handling

  • jrockowitz committed dcc5e9fa on 1.0.x
    [#3548302] feat: Improve additional type JSON-LD handling
    
jrockowitz’s picture

Status: Active » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

ultimike’s picture

When trying out the latest -dev release (after this MR), I went to the /admin/config/schemadotorg/settings/types page and received this fatal error:

The website encountered an unexpected error. Try again later.

TypeError: Drupal\schemadotorg\Element\SchemaDotOrgSettings::yamlEncodeFromConfig(): Argument #1 ($value) must be of type array, null given, called in /var/www/html/web/core/lib/Drupal/Core/Form/ConfigTarget.php on line 188 in Drupal\schemadotorg\Element\SchemaDotOrgSettings::yamlEncodeFromConfig() (line 248 of modules/contrib/schemadotorg/src/Element/SchemaDotOrgSettings.php).
Drupal\Core\Form\ConfigTarget->getValue() (Line: 113)
Drupal\Core\Form\ConfigFormBase->loadDefaultValuesFromConfig() (Line: 117)
Drupal\Core\Form\ConfigFormBase->loadDefaultValuesFromConfig() (Line: 117)
Drupal\Core\Form\ConfigFormBase->loadDefaultValuesFromConfig()
call_user_func_array() (Line: 1010)
Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 571)
Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Maybe the jsonld_values value isn't initialized properly?

I tried adding jsonld_values: { } to my local schemadotorg_additional_type.settings config, to no avail.

-mike

jrockowitz’s picture

Did you run `drush updb`?

  • e2bfd34c committed on 1.0.x
    [#3548302] feat: Improve additional type JSON-LD handling
    
    By:...
jrockowitz’s picture

Yep, the update hook is missing. I commited the fix the 1.0.x-dev.

ultimike’s picture

Status: Fixed » Needs work

I did some debugging and I think the issue is with ignored_types from schemadotorg_additional_type.settings - I ran out of time before I found a reasonable fix.

I can circumvent the issue by adding |NULL to the $value argument of:

  public static function yamlEncodeFromConfig(array<strong>|NULL</strong> $value): string {
    $yaml = $value ? Yaml::encode($value) : '';
    // Remove return after array delimiter.
    $yaml = preg_replace('#((?:\n|^)[ ]*-)\n[ ]+(\w|[\'"])#', '\1 \2', $yaml);
    return $yaml;
  }

-mike

ultimike’s picture

Status: Needs work » Fixed

Setting back to Fixed, as I think this was just a bad config issue on my part.

As part of my earlier debugging attempts with this, I had manually added an ignored_types: {} to my active config. At some point after adding this is when I ran the update hooks and I think this is where things went just a teeny bit sideways for me.

I just did the following and all appears to be working fine on my local now:

  1. Removed my manually added ignored_types: {}
  2. Temporarily renamed the schemadotorg_additional_type_update_10003() and schemadotorg_additional_type_update_10004() hooks to schemadotorg_additional_type_update_10013() and schemadotorg_additional_type_update_10023(), and then re-ran database updates.

Sorry for the false alarm!

thanks,
-mike

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

jrockowitz’s picture

Yeh, I was also looking into this and couldn't reproduce the bug.

Status: Fixed » Closed (fixed)

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