From 6cb1849473792bd73dbfb6265d363f149f687572 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Aug 2026 03:03:10 +0900 Subject: fix(plugin): resolve review findings in the plugin activation flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InstallationManager::execute now takes &self (the mock recorder moved into a RefCell) and its callers hold only shared borrows: plugin registration inside a batch re-enters the same manager handle through Composer::getInstallationManager()->getInstallPath(), which panicked on the RefCell re-borrow under the &mut shape — the same re-entrancy the repository side already fixed, unreachable from the ported tests because they call PluginInstaller::install directly like PHPUnit does. The worker-side InstalledVersions mirror now matches the full tail of FilesystemRepository::write: unconditional reload plus the reflection-based selfDir/installedIsLocalDir restore. The previous class_exists(false) guard rested on a lazy-load assumption that does not hold in the worker (its real ClassLoader only knows the Composer checkout's vendor dir, so a later lazy load would read the checkout's installed.php, not the project's); the mirror is now skipped only when the class is not autoloadable at all, i.e. no plugin runtime and hence no observer code. Boot-time seeding stays TODO(plugin). Also from the review: registered_plugins entries are removed only after the deactivate/uninstall loop (PHP unsets last, and a throw must leave the entry observable); extra.class keeps associative-array values and fails loudly on non-strings instead of silently dropping them; the two discarded write() results now propagate (they carry the reload-push failure); register_package's allow-plugins skip message is DEBUG like the addPlugin side; the loader-eviction divergence of REGISTERED_LOADERS and the lossy UTF-8 spots carry searchable markers; the test-only proxy downcast follows the __ naming rule; the R-table dispatch clones the entity out instead of holding the table borrow across the handler; the IO/PartialComposer stubs turn a plugin-side `new NullIO()` into an explicit error instead of an ArgumentCountError; and the empty() emulation covers float 0.0. Co-Authored-By: Claude Fable 5 --- .../shirabe/src/repository/filesystem_repository.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/repository') diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index b2a2530e..1949803b 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -343,18 +343,21 @@ impl FilesystemRepository { ); // make sure the in memory state is up to date with on disk - // The upstream in-process reload is split in two here: the Rust-side mirror below, - // and a push into the PHP worker where the real observers (plugins) live. The push - // is skipped when no worker is running — with no child there is nothing that could - // observe the stale state, and the worker glue additionally ignores it while the - // class is not loaded there (a later lazy load reads the freshly written - // installed.php, matching upstream observations in every case). + // The upstream in-process reload/selfDir/installedIsLocalDir tail is mirrored + // twice: into the Rust-side statics below, and into the PHP worker where the real + // observers (plugins) live. The push is skipped when no worker is running — with no + // child there is nothing that could observe the state; the glue skips it only when + // the class is not even autoloadable there (no Composer PHP runtime = no observer + // code either). if shirabe_php_rpc::worker_is_running() { crate::event_dispatcher::unwrap_php_result(shirabe_php_rpc::call_function( "__shirabe_installed_versions_reload", - vec![shirabe_php_rpc::PluginValue::from_php_mixed( - &PhpMixed::Array(versions.clone()), - )], + vec![ + shirabe_php_rpc::PluginValue::from_php_mixed(&PhpMixed::Array( + versions.clone(), + )), + shirabe_php_rpc::PluginValue::string(repo_dir.clone()), + ], ))?; } InstalledVersions::reload(versions); -- cgit v1.3.1