Undeclared dependency

Created on 10 July 2023, over 1 year ago
Updated 12 July 2023, over 1 year ago

Problem/Motivation

I installed 3.1.0 on a non-Opigno D10 site and got this:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "opigno_statistics.user_stats_manager". in Drupal\Component\DependencyInjection\Container->get() (line 157 of core/lib/Drupal/Component/DependencyInjection/Container.php).

Steps to reproduce

Install on a non-Opigno site.

Proposed resolution

The exception starts on this line in artistotle.theme:
$stats_service = \Drupal::service('opigno_statistics.user_stats_manager');

You could either use hasService first to make sure the service exists, or declare the opigno module that has that service as a dependency.

The same aristotle_preprocess_user function that has the problem also calls UserStatisticsManager::getDefaultUserPicture without checking if that class exists.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.1

Component

Code

Created by

🇺🇸United States TolstoyDotCom L.A.

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

Comments & Activities

  • Issue created by @TolstoyDotCom
  • 🇮🇳India Yogesh Kambari

    Hi,
    It has come to my attention that the problem cannot be resolved effectively without considering the dependency on the opigno_statistic module. Themes are primarily responsible for the presentation layer and should not handle module dependencies.
    Here is quick fix to address above issue.

  • 🇺🇸United States TolstoyDotCom L.A.

    That patch works, but I couldn't help but polish the lily.

Production build 0.71.5 2024