Skip to content

fix(updater): preserve Composer authentication during preflight - #2576

Merged
Seiger merged 1 commit into
evolution-cms:3.5.xfrom
MiddleSokilAI:sokil/updater-composer-auth
Nov 9, 2026
Merged

Seiger merged 1 commit into
evolution-cms:3.5.xfrom
MiddleSokilAI:sokil/updater-composer-auth

Conversation

@MiddleSokilAI

Copy link
Copy Markdown
Collaborator

Problem

php artisan make:site update 3.5.x can stop with HTTP 401 from a private Composer repository even when the site already has valid Composer credentials. The updater unconditionally selects core/composer as COMPOSER_HOME, hiding normal global authentication, and checks the extracted core without the installed site's core/auth.json.

Target branch

Prepared from evolution-cms/evolution:3.5.x (4dc56c87a). This fixes authentication in that update path. Related PR #2530 targets 3.6.x and preserves home selection; this change also makes project authentication available during the archive preflight.

Changes

  • Scope the complete update in ComposerEnvironment, keeping Composer's normal explicit, user/XDG or Windows home. Retain the site-local fallback for processes without a user home.
  • Merge existing credentials in this order: legacy core/composer/auth.json, normal global config/auth, core/auth.json, then COMPOSER_AUTH. Composer's own config merge replaces credentials per host and preserves the environment override.
  • Give the archive preflight and subsequent dependency restore the same authentication through the inherited process environment. No credential file is written into the archive and no credentials are added to shell arguments.
  • Restore the original process environment and distinct $_SERVER/$_ENV values on success, refusal or exception. Keep credential contents out of malformed-JSON diagnostics.
  • Load the helper even when an installed archive's authoritative Composer classmap predates it. Document the authentication policy in AGENTS.md.

Files

  • core/src/Console/SiteUpdateCommand.php
  • core/src/Services/ComposerEnvironment.php
  • core/tests/Unit/Services/ComposerEnvironmentTest.php
  • AGENTS.md

Validation

PHP 8.4.20, Pest 4.7.8: 135 tests passed, 467 assertions, covering SiteUpdateCommandTest, ComposerEnvironmentTest, UpdatePathConsistencyTest, CliInstallCustomPackagesTest and WebInstallCustomPackagesTest. Focused execution used a bootstrap defining EVO_CORE_PATH and EVO_BASE_PATH for the isolated checkout.

  • Native Composer against a loopback HTTP Basic repository: reproduced HTTP 401 without credentials; archive dry runs and installed-core package restores then passed independently with project, global, legacy and environment authentication. All fixtures use synthetic credentials and a metapackage; no private repository was contacted.
  • Tests cover native Composer configuration loading in both directories, source precedence, custom headers, implicit and explicit homes, no-home fallback, child-process inheritance, cleanup after refusal/exception, safe malformed-JSON errors and an authoritative classmap missing the helper.
  • composer analyze -- --no-progress --error-format=raw: PHPStan level 0, no errors.
  • PHP lint passes for all three changed PHP files; git diff --check passes.

Installing the existing development dependencies locally required --ignore-platform-req=php: the locked roave/security-advisories excludes the available PHP 8.4.20 patch release. This was only test bootstrap; no manifest, lock or vendor change is included.

Remaining scope

Production was not updated. Existing credentials must still authorize the requested repository; dependency compatibility checks and consent requirements remain in force. The loopback HTTP smoke was run as a local integration check, outside the implementation diff.

@MiddleSokilAI
MiddleSokilAI requested a review from Seiger November 9, 2026 11:21
@Seiger
Seiger merged commit b109b40 into evolution-cms:3.5.x Nov 9, 2026
@elcreator elcreator mentioned this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants