From cd9e4a2b67cdea258e1daa2d9d830b7643bc19bb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 7 Aug 2026 20:51:59 +0900 Subject: 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) --- crates/shirabe/src/event_dispatcher/event_dispatcher.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/event_dispatcher') diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 5043610b..1480188a 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -1541,7 +1541,7 @@ try {{ .map(|e| e.is_dev_mode()) }); if let Some(dev_mode) = dev_mode { - generator.borrow_mut().set_dev_mode(dev_mode); + generator.borrow().set_dev_mode(dev_mode); if dev_mode { hash_input.push_str("/dev"); } @@ -1556,7 +1556,7 @@ try {{ let installation_manager = composer.borrow().get_installation_manager(); let package_map = generator.borrow().build_package_map( - &mut *installation_manager.borrow_mut(), + installation_manager.clone(), package.clone(), packages, )?; -- cgit v1.3.1