webksde / ddev-vscode-devcontainer-drupal-template

Drupal DDEV based development container with attached Visual Studio Code
23 stars 3 forks source link

Composer class auto-loader won't notice changing directory even with "classmap-authoritative" disabled #100

Closed joshsedl closed 2 years ago

joshsedl commented 2 years ago

Current Behavior

Installing ddev with a Drupal recipe, installing a module and changing the folder name of the module will lead to Drupal not finding the classes inside the renamed module folder.

Expected Behavior

Renaming the folder should not lead to Drupal not knowing where to load the module from.

Current workaround:

Create a apc_cache.ini inside ".ddev/php" and set "apc.enabled = 0".

Steps To Reproduce

Install ddev with a Drupal recipe. Install a Drupal module or create your own module and install it. Change the Drupal module folder name. Anything else? The Problem is composer, but we do not know exactly why.

Problem

Composer's class autoloader loads the class paths statically, so if we change the directory, the old path is still saved. At first we thought the "classmap-authoritative" composer setting would be the problem, since it is stated here: https://getcomposer.org/doc/articles/autoloader-optimization.md#how-to-run-it--2 that the described Problem arises, when having "classmap-authoritative" set to true. This was already disabled for our environment, though. We also tried setting "apcu-autoloader" to false and "optimize-autoloader" to false, nothing....

Even trying to clear all kind of caches (drupal cache, apcu cache, etc.) would not solve the Problem.

The only working workaround was setting "apc.enabled" to 0 inside a php.ini file. I am not sure if this is a composer bug, so I post the issue here.

joshsedl commented 2 years ago

Fixed in https://github.com/webksde/ddev-vscode-devcontainer-drupal9-template/commit/3fc10088fdc0845960b423ed773f70e05b945f96