diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-07 20:51:59 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-07 20:51:59 +0900 |
| commit | cd9e4a2b67cdea258e1daa2d9d830b7643bc19bb (patch) | |
| tree | e3dd09ac9f471b3c3900f61a6e5d58d9636dab45 /crates/shirabe/src/installer.rs | |
| parent | 427e059e4ffc6ce5ff130c803f9e533b7c125089 (diff) | |
| download | php-shirabe-cd9e4a2b67cdea258e1daa2d9d830b7643bc19bb.tar.gz php-shirabe-cd9e4a2b67cdea258e1daa2d9d830b7643bc19bb.tar.zst php-shirabe-cd9e4a2b67cdea258e1daa2d9d830b7643bc19bb.zip | |
fix(autoload-generator): survive listeners that re-enter dump()
AutoloadGenerator::dump dispatches PRE_AUTOLOAD_DUMP / POST_AUTOLOAD_DUMP, and
EventDispatcher::make_autoloader answers those by walking back into the Composer
graph -- the local repository, the installation manager, and the generator
itself. Installer::run held mutable borrows of all three across the dump call,
so any plugin subscribing to either event panicked with "RefCell already
borrowed" before its listener ran.
dump() and build_package_map() now take the local repository, the installation
manager and the locker as shared handles instead of &mut dyn, and the borrow is
taken where it is used.
The generator itself is re-entered, not just borrowed twice: PHP listeners reach
it through Composer::getAutoloadGenerator() and call setDevMode() while dump()
is running, and make_autoloader asks the same object for a package map. That is
not expressible behind &mut self, so the mutable state moves into Cell/RefCell
fields and the whole AutoloadGeneratorInterface takes &self.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer.rs')
| -rw-r--r-- | crates/shirabe/src/installer.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index 091fb35f..9028af88 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -392,30 +392,27 @@ impl Installer { } self.autoload_generator - .borrow_mut() + .borrow() .set_class_map_authoritative(self.class_map_authoritative); self.autoload_generator - .borrow_mut() + .borrow() .set_apcu(self.apcu_autoloader, self.apcu_autoloader_prefix.clone()); self.autoload_generator - .borrow_mut() + .borrow() .set_run_scripts(self.run_scripts); self.autoload_generator - .borrow_mut() + .borrow() .set_platform_requirement_filter(self.platform_requirement_filter.clone()); let local_repo_handle = self.repository_manager.borrow().get_local_repository(); - let mut local_repo_ref = local_repo_handle.borrow_mut(); - self.autoload_generator.borrow_mut().dump( + self.autoload_generator.borrow().dump( &self.config.borrow(), - local_repo_ref - .as_installed_repository_interface_mut() - .unwrap(), + local_repo_handle, self.package.clone(), - &mut *self.installation_manager.borrow_mut(), + self.installation_manager.clone(), "composer", self.optimize_autoloader, None, - Some(&mut *self.locker.borrow_mut()), + Some(self.locker.clone()), false, )?; } |
