From b5d6d91054b9ceef95aef0819bb5c4ef7db1abdd Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Aug 2026 08:42:55 +0900 Subject: fix(repository): run lazy initialization in count/has_package PHP's ArrayRepository::count()/hasPackage() call $this->initialize(), which late-binds to the concrete repository class and lazily loads its packages. The Rust pass-throughs skipped that: they ran ArrayRepository's stub initialize instead, returning 0/false and marking the repository initialized with an empty package list, which made ensure_initialized() skip the real initialization forever after. Take &mut self in RepositoryInterface::count/has_package so the lazy repositories (Filesystem, Platform, Composer) can guard with their real initialize, and return Result from has_package since that initialization can fail (PHP propagates the exception). InstallerInterface::is_installed and InstallationManager::is_package_installed/mark_alias_installed propagate the same way, which also resolves the TODO(phase-d) markers on Package/Path/Artifact/Vcs repositories about initialization errors being swallowed. Co-Authored-By: Claude Fable 5 --- crates/shirabe/tests/installer/metapackage_installer_test.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/tests/installer/metapackage_installer_test.rs') diff --git a/crates/shirabe/tests/installer/metapackage_installer_test.rs b/crates/shirabe/tests/installer/metapackage_installer_test.rs index 86013871..b87fdebd 100644 --- a/crates/shirabe/tests/installer/metapackage_installer_test.rs +++ b/crates/shirabe/tests/installer/metapackage_installer_test.rs @@ -30,7 +30,7 @@ fn test_install() { )) .unwrap(); - assert!(repository.has_package(package)); + assert!(repository.has_package(package).unwrap()); } #[test] @@ -50,8 +50,8 @@ fn test_update() { )) .unwrap(); - assert!(!repository.has_package(initial.clone())); - assert!(repository.has_package(target.clone())); + assert!(!repository.has_package(initial.clone()).unwrap()); + assert!(repository.has_package(target.clone()).unwrap()); // Updating again, with the initial package no longer installed, fails. assert!( @@ -81,7 +81,7 @@ fn test_uninstall() { )) .unwrap(); - assert!(!repository.has_package(package.clone())); + assert!(!repository.has_package(package.clone()).unwrap()); // Uninstalling again, with the package no longer installed, fails. assert!( -- cgit v1.3.1