From 90d9b1dc0035a70dab76d520b9dcd14ec57273ad Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 24 Jul 2026 20:23:42 +0900 Subject: fix(event-dispatcher): invoke Closure listeners instead of always failing is_callable RequireCommand registers an inline listener on InstallerEvents::PRE_OPERATIONS_EXEC to track dependency_resolution_completed, mirroring PHP's `function () use (&$dependencyResolutionCompleted) { ... }`. This is Composer's own code, not a Plugin subscriber, but it went through the shared non-string-callable path, which checked is_callable() against a hardcoded PhpMixed::Null and always failed, breaking every `require` that reaches the install step. Callable::Closure now carries the actual Rc instead of being a data-less placeholder, and is invoked directly (Closures are always callable in PHP). The ArrayCallable path used by future Plugin subscribers is untouched. Un-ignoring the two require_command_test cases that cited this bug reveals two separate, pre-existing issues (a missing ext-requirement warning message, and a RefCell re-entrancy panic in ConsoleIO::ask_question); their #[ignore] reasons are updated to describe the real current blocker instead of the now-fixed one. --- crates/shirabe/tests/command/require_command_test.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/tests/command') diff --git a/crates/shirabe/tests/command/require_command_test.rs b/crates/shirabe/tests/command/require_command_test.rs index b132eb43..bf742ea1 100644 --- a/crates/shirabe/tests/command/require_command_test.rs +++ b/crates/shirabe/tests/command/require_command_test.rs @@ -58,10 +58,10 @@ fn test_require_throws_if_none_matches() { #[test] #[serial] -#[ignore = "the prior RefCell re-entrancy panic is fixed; now fails on the pre-operations-exec \ - listener dispatch with \"Subscriber ?::? for event pre-operations-exec is not \ - callable\" (event_dispatcher.rs TODO(plugin): is_callable/invoke for non-string \ - callables is unimplemented)"] +#[ignore = "the pre-operations-exec listener bug is fixed; now fails with \"RefCell already \ + borrowed\" at console_io.rs:366 (ConsoleIO::ask_question, reached via \ + ask_confirmation from RequireCommand::update_requirements_after_resolution) — a \ + re-entrant IO RefCell borrow, unrelated to event dispatching"] fn test_require_warns_if_resolved_to_feature_branch() { let composer_json = serde_json::json!({ "repositories": { @@ -266,10 +266,11 @@ Using version 1.1.0 for required/pkg", #[test] #[serial] -#[ignore = "the prior RefCell re-entrancy panic is fixed; now fails on the pre-operations-exec \ - listener dispatch with \"Subscriber ?::? for event pre-operations-exec is not \ - callable\" (event_dispatcher.rs TODO(plugin): is_callable/invoke for non-string \ - callables is unimplemented)"] +#[ignore = "the pre-operations-exec listener bug is fixed; now fails on the first data-provider \ + case ('warn once for missing ext but a lower package matches') because the \ + \"Cannot use required/pkg's latest version 1.2.0 as it requires ext-foobar \ + ^1 which is missing from your platform.\" message is never emitted — a \ + distinct, unimplemented require_command warning path unrelated to event dispatching"] fn test_require() { for (label, composer_json, command, expected) in provide_require() { let _tear_down = init_temp_composer(Some(&composer_json), None, None, true); -- cgit v1.3.1