Composer require/remove vendor code does not update autoloader (APCu cached)

Created on 31 August 2021, over 3 years ago
Updated 18 April 2025, 24 days ago

Problem/Motivation

Drupal changes the composer autoloader APCu cache prefix when a module is un(installed) and when the Drupal Core version is changed. It does not change, and the cache is not cleared, when code is added or removed from the vendor directory by composer.

This means classes that have been `class_exist` looked for previously, but are now added, are still not found. And would causes classes that have been previously loaded and removed still to have a location returned.

This was noticed by the strange behavior of geocoder plugins, where when their code dependency is installed with composer they aren't detected "How to add Gecoder 3.x providers" 🐛 How to add Gecoder 3.x providers Needs review which as you'll see cause quite some confusion. The chanced upon solutions not being very clear in the comments: install some other module; allow access to, and visit core/rebuild.php; or clear APCu (by for example restarting webserver).

I added a comment on that issue that details some of the further issues, and where the core code is that makes the cache key 🐛 How to add Gecoder 3.x providers Needs review .

Steps to reproduce

With APCu enabled. Either follow the geocoder example by adding a plugin after visiting the configuration page in the lifetime of the APCu cache; or similarly use code that checks if `class_exists` that does or does not, and add or remove as appropriate it using composer, and then check again.

Proposed resolution

No proposed resolution - yet - see first comment for thoughts.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

composer

Created by

🇳🇱Netherlands ekes

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024