Problem/Motivation

I'm working right now in a multi-domain / multi-country and multi-language platform based in Drupal 9. I was receiving a WSOD (White Screen of Death) in my local Drupal installation when I was trying to enable the Domain Language Detection and Selection options. It was strange, because the module marked availability for Drupal 9 but it is not working.

Steps to reproduce

Steps

  1. Enable Domain-related modules in your Drupal installation and create a set of domains.
  2. Download and enable domain_lang module from [https://www.drupal.org/project/domain_lang](https://www.drupal.org/project/domain_lang), using Composer and drush, as usual.
  3. Go to path: `/admin/config/domain` and click in Operations, then select "Language detection and selection" for a domain from your domains list.
  4. You will get a WSOD (White Screen Of Death) in your Drupal installation. When you go to `/admin/reports/dblog` you will see an error just like this:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: 
You have requested a non-existent service "entity.manager".   
in Drupal\Component\DependencyInjection\Container->get()   
(line 151 in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php).

Proposed resolution

This is happening due to a specific change in the last versions of Drupal 8.x: The `entity.manager` service was marked as deprecrated in former versions of Drupal 8.8.x and finally was replaced by the service `entity_type.manager`-> https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/Drupa..., just as we can see at: https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal%3A...

Deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.  
Use \Drupal::entityTypeManager() instead in most cases.   
If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface,  
see the deprecated \Drupal\Core\Entity\EntityManager   
to find the correct interface or service.

Remaining tasks

Looking for the use of the deprecated service, I found something in file DomainLangNegotiationConfigureForm.php in the create method, line 83.

/**
 * {@inheritdoc}
 */
public static function create(ContainerInterface $container) {
  $entity_manager = $container->get('entity.manager');
  $block_storage = $entity_manager->hasHandler('block', 'storage') ? $entity_manager->getStorage('block') : NULL;

Then I made the next change:


public static function create(ContainerInterface $container) {
-  $entity_manager = $container->get('entity.manager');
+  $entity_manager = $container->get('entity_type.manager');

this solved the problem and eliminated the Exception and the WOSD in my Drupal installation.

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

davidjguru created an issue. See original summary.

davidjguru’s picture

davidjguru’s picture

Status: Active » Needs review

davidjguru’s picture

Assigned: davidjguru » Unassigned
jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

This works!

  • Antonnavi committed 39e8af4 on 8.x-1.x authored by davidjguru
    Issue #3182720 by davidjguru, jhedstrom: Deprecated service for Drupal 9...
antonnavi’s picture

Hello all here!

Thank You for help!

antonnavi’s picture

Version: 8.x-1.0-beta4 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

spuky’s picture

Please Make a new Release Dev Version is working with D9 but Release version is not altough it states it does

willeaton’s picture

Yes, please, lets create a new beta version so we don't have to use a dev version in production!