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/src/repository/composite_repository.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/repository/composite_repository.rs') diff --git a/crates/shirabe/src/repository/composite_repository.rs b/crates/shirabe/src/repository/composite_repository.rs index 9e5c9757..a9c55a0f 100644 --- a/crates/shirabe/src/repository/composite_repository.rs +++ b/crates/shirabe/src/repository/composite_repository.rs @@ -60,7 +60,7 @@ impl CompositeRepository { } impl RepositoryInterface for CompositeRepository { - fn count(&self) -> anyhow::Result { + fn count(&mut self) -> anyhow::Result { let mut total = 0; for repository in &self.repositories { total += repository.count()?; @@ -78,13 +78,13 @@ impl RepositoryInterface for CompositeRepository { format!("composite repo ({})", names.join(", ")) } - fn has_package(&self, package: PackageInterfaceHandle) -> bool { + fn has_package(&mut self, package: PackageInterfaceHandle) -> anyhow::Result { for repository in &self.repositories { - if repository.has_package(package.clone()) { - return true; + if repository.has_package(package.clone())? { + return Ok(true); } } - false + Ok(false) } fn find_package( -- cgit v1.3.1