I Just upgraded my site to drupal 8.6.0 and now when I'am trying to place a bock in a region I'll get an unexpected error.

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\Core\TypedData\TypedDataManager::createFromNameAndData() in Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter->getConfigTypedData() (line 100 of core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php).
Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter->getConfigTypedData() (Line: 65)
Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter->getIterator() (Line: 146)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object, Array, 1) (Line: 99)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object, Array, NULL) (Line: 90)
Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object, Array) (Line: 346)
Drupal\Core\Plugin\Context\ContextDefinition->isSatisfiedBy(Object) (Line: 69)
Drupal\Core\Plugin\Context\ContextHandler->Drupal\Core\Plugin\Context\{closure}(Object)
array_filter(Array, Object) (Line: 70)
Drupal\Core\Plugin\Context\ContextHandler->getMatchingContexts(Array, Object) (Line: 40)
Drupal\Core\Condition\ConditionPluginBase->addContextAssignmentElement(Object, Array) (Line: 55)
Drupal\Core\Condition\ConditionPluginBase->buildConfigurationForm(Array, Object) (Line: 76)
Drupal\domain\Plugin\Condition\Domain->buildConfigurationForm(Array, Object) (Line: 255)
Drupal\block\BlockForm->buildVisibilityInterface(Array, Object) (Line: 142)
Drupal\block\BlockForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 518)
Drupal\Core\Form\FormBuilder->retrieveForm('block_form', Object) (Line: 275)
Drupal\Core\Form\FormBuilder->buildForm('block_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 27)
Drupal\block\Controller\BlockAddController->blockAddConfigureForm('views_block:events-block_1', 'my_theme')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
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: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->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: 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: 665)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

rbosscher created an issue. See original summary.

cilefen’s picture

Priority: Normal » Major
Issue tags: +8.6.0 update

Would you please summarize the upgrade process that happened on the site?

alexpott’s picture

Category: Bug report » Support request

Drupal\Core\TypedData\TypedDataManager::createFromNameAndData() method does exist in core/lib/Drupal/Core/Config/TypedConfigManager.php.

@rbosscher there are a couple of things that come to mind that can cause this:

alexpott’s picture

Category: Support request » Bug report

Oh I'm wrong core/lib/Drupal/Core/TypedData/TypedDataManager.php does not have this method. So the question becomes why did ConfigEntityAdapter->getConfigTypedData() not return the config version.

alexpott’s picture

Looking at the code. \Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter::getTypedDataManager() should return \Drupal::service('config.typed'). That should be the config version. So maybe something in the install is replacing this for some reason.

@rbosscher if you have drush installed can use the php command to run the following code and paste the output here.

$service = \Drupal::service('config.typed');
get_class($service);

Here's the output from a vanilla 8.6.0 install:

>>> $service = \Drupal::service('config.typed');
=> Drupal\Core\Config\TypedConfigManager {#1695
     +"_serviceId": "config.typed",
   }
>>> get_class($service);
=> "Drupal\Core\Config\TypedConfigManager"
rbosscher’s picture

I've upgraded the site with composer.

In the composer.json I altered:

 -        "webflo/drupal-core-require-dev": "~8.5.3"
+        "webflo/drupal-core-require-dev": "~8.6.0"

Next I've run the command:
composer update drupal/core webflo/drupal-core-require-dev --with-dependencies

Package operations: 0 installs, 2 updates, 0 removals
Updates: drupal/core:8.6.0, webflo/drupal-core-require-dev:8.6.0

Next update the database:
drush updb

 [notice] Update started: taxonomy_update_8501
 [ok] Update completed: taxonomy_update_8501
 [notice] Update started: taxonomy_update_8502
 [notice] Update started: taxonomy_update_8502
 [notice] Taxonomy term hierarchy has been converted to default entity reference storage.
 [ok] Update completed: taxonomy_update_8502
 [notice] Update started: taxonomy_update_8503
 [ok] Update completed: taxonomy_update_8503
 [notice] Update started: block_content_update_8600
 [ok] Update completed: block_content_update_8600
 [notice] Update started: comment_update_8600
 [ok] Update completed: comment_update_8600
 [notice] Update started: dblog_update_8600
 [ok] Update completed: dblog_update_8600
 [notice] Update started: menu_link_content_update_8601
 [notice] The publishing status entity key has been added to custom menu links.
 [ok] Update completed: menu_link_content_update_8601
 [notice] Update started: taxonomy_update_8601
 [notice] The publishing status field has been added to taxonomy terms.
 [ok] Update completed: taxonomy_update_8601
 [notice] Update started: block_content_post_update_add_views_reusable_filter
 [ok] Update completed: block_content_post_update_add_views_reusable_filter
 [notice] Update started: datetime_range_post_update_views_string_plugin_id
 [ok] Update completed: datetime_range_post_update_views_string_plugin_id
 [notice] Update started: image_post_update_scale_and_crop_effect_add_anchor
 [ok] Update completed: image_post_update_scale_and_crop_effect_add_anchor
 [notice] Update started: system_post_update_change_delete_action_plugins
 [ok] Update completed: system_post_update_change_delete_action_plugins
 [notice] Update started: system_post_update_extra_fields
 [ok] Update completed: system_post_update_extra_fields
 [notice] Update started: system_post_update_language_item_callback
 [ok] Update completed: system_post_update_language_item_callback
 [notice] Update started: taxonomy_post_update_clear_entity_bundle_field_definitions_cache
 [ok] Update completed: taxonomy_post_update_clear_entity_bundle_field_definitions_cache
 [notice] Update started: taxonomy_post_update_clear_views_data_cache
 [ok] Update completed: taxonomy_post_update_clear_views_data_cache
 [notice] Update started: taxonomy_post_update_handle_publishing_status_addition_in_views
 [ok] Update completed: taxonomy_post_update_handle_publishing_status_addition_in_views
 [success] Finished performing updates.

@alexpot

I've runned the script:

drush php

Psy Shell v0.9.8 (PHP 7.2.6 — cli) by Justin Hileman
$service = \Drupal::service('config.typed');
get_class($service);=> Drupal\Core\Config\TypedConfigManager {#872
     +"_serviceId": "config.typed",
   }

=> "Drupal\Core\Config\TypedConfigManager"
rbosscher’s picture

Thank you for the quick response BTW

Meanwhile I've restarted the webserver.
Manually cleared the opcache and drupal cache.
But unfortunately no luck

I do see a difference in the line numbers?

TypedConfigManager {#1695 VS TypedConfigManager {#872

alexpott’s picture

@rbosscher thank you for the extra information.
I've tested placing block after the upgrade and I can not reproduce the error. There might be some module that is causing problems - if you could paste the list of modules that you have installed that'd be great The output of the command drush config-get core.extension module is the easiest way to get that.

Again looking at the code I have a hunch that \Drupal\Core\Plugin\Context\Context::createFromContext() might be causing this somehow because it is copying type data managers between contexts.

  /**
   * {@inheritdoc}
   */
  public static function createFromContext(ContextInterface $old_context, $value) {
    $context = new static($old_context->getContextDefinition(), $value);
    $context->addCacheableDependency($old_context);
    if (method_exists($old_context, 'getTypedDataManager')) {
      $context->setTypedDataManager($old_context->getTypedDataManager());
    }
    return $context;
  }

You could try commenting out the line $context->setTypedDataManager($old_context->getTypedDataManager()); and let us know if it fixes the issue.

ohmdesbois’s picture

Emptying the caches, updating the entities and the base do not solve the problem.
I tried to disable the modules one by one to determine which one is problematic, without success at the moment.

rbosscher’s picture

Meanwhile I have it working again.
I found the problem as follows:

In the file \core\lib\Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter.php
I added the following two print_r
These gave some intell in what the function was doing.

  /**
   * Gets typed data for config entity.
   *
   * @return \Drupal\Core\TypedData\ComplexDataInterface
   *   The typed data.
   */
  protected function getConfigTypedData() {
    
    
    
+    print_r($this->entity->getConfigDependencyName());
+   print_r($this->entity->toArray());
    
    
    
    return $this->getTypedDataManager()->createFromNameAndData($this->entity->getConfigDependencyName(), $this->entity->toArray());
  }

It turned out to show some information about the domain domain module
I've upgraded that to the latest dev and I was able to place the blocks in the regions again.

So still not sure why, but for me it has solved it.

alexpott’s picture

@rbosscher thanks for finding that out and sharing your fix.

@ohmdesbois are you using the domain module as well and does upgrading that module fix the issue for you too?

jmaties’s picture

Same issue, but also i can't configure blocks.

alexpott’s picture

@jmaties are you using domain? There might be some module that is causing problems - if you could paste the list of modules that you have installed that'd be great The output of the command drush config-get core.extension module is the easiest way to get that. Any extra information you can provide would be most welcome.

jmaties’s picture

Yes i use domain, but i disable this without success:

'core.extension:module':
admin_toolbar: 0
automated_cron: 0
block: 0
block_class: 0
block_content: 0
breakpoint: 0
ckeditor: 0
config: 0
config_translation: 0
ctools: 0
datetime: 0
dblog: 0
devel: 0
devel_generate: 0
domain: 0
domain_access: 0
domain_config: 0
domain_content: 0
domain_site_settings: 0
domain_theme_switch: 0
editor: 0
entity_reference_revisions: 0
field: 0
field_group: 0
field_ui: 0
file: 0
filter: 0
history: 0
image: 0
kint: 0
language: 0
link: 0
locale: 0
media: 0
menu_link_attributes: 0
menu_ui: 0
moringa_varios: 0
node: 0
options: 0
path: 0
rdf: 0
shortcut: 0
svg_image: 0
system: 0
taxonomy: 0
text: 0
token: 0
toolbar: 0
twig_tweak: 0
twig_vardumper: 0
update: 0
user: 0
views_block_area: 0
views_fieldsets: 0
views_load_more: 0
views_ui: 0
webform: 0
webform_ui: 0
menu_link_content: 1
pathauto: 1
content_translation: 10
views: 10
paragraphs: 11

jmaties’s picture

I have disabled all domain modules and it work...
This is maybe a domain bug?

rbosscher’s picture

I think so, have you tried the latest dev: https://www.drupal.org/project/domain/releases/8.x-1.x-dev That helped me around the problem

jmaties’s picture

Yes, with dev version work fine ;)

Thanks

alexpott’s picture

After message @agentrickard about this in slack, @berdir pointed me to #2982183: Conflict between TypedDataManager and TypedConfigManager in ConfigEntityAdapter - so this is a duplicate.

ohmdesbois’s picture

@alexpott No, I do not use the domain module.
Is it interresing that I post the list of modules used?