Enforce disabled caching for *.services.yml

Created on 31 March 2023, over 2 years ago

Problem/Motivation

From what I can tell, even after following all the steps in Disable caching , you still need to run drush cache:rebuild sometimes, for example if you update the *.services.yml and the call in the code:

To reproduce caching, when it should be disabled

In mymodule.services.yml:

services:
  mymodule.example:
    class: Drupal\mymodule\Example

In mymodule.module:

echo \Drupal::service('mymodule.example')->getValue();

Do these steps:

  1. Disable all caches
  2. Change mymodule.example both places to mymodule.example2
  3. Reload the page, and get an error:

    The website encountered an unexpected error. Please try again later.

    Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "mymodule.example2". Did you mean this: "mymodule.example"? in Drupal\Component\DependencyInjection\Container->get() (line 157 of core/lib/Drupal/Component/DependencyInjection/Container.php).

  4. Run drush cache:rebuild, reload the page, and see that it works, and that caching wasn't completely disabled after all

This could be an issue with *.routing.yml as well, see #3342669-8: Reinstalling a moved module throws “ InvalidArgumentException: Class "\Drupal\example\Form\ExampleForm" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition()” .

Proposed resolution

Enforce disabling caching also for *.services.yml

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

10.1

Component
Cache 

Last updated 12 days ago

Created by

🇩🇰Denmark ressa Copenhagen

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

Comments & Activities

Production build 0.71.5 2024