CLI-1853: Force-add docroot/autoload_runtime.php to push:artifact scaffold files#2021
CLI-1853: Force-add docroot/autoload_runtime.php to push:artifact scaffold files#2021amangrover90 wants to merge 1 commit into
Conversation
Drupal 11.4 introduced docroot/autoload_runtime.php as a Symfony Runtime bootstrap entry point, generated by core-composer-scaffold. Because this file is typically gitignored, `git add -A` alone does not include it in push:artifact builds, causing 500 errors on deployed sites. Add docroot/autoload_runtime.php to the scaffoldFiles list alongside docroot/autoload.php, but only when the file actually exists in the artifact directory. The file_exists guard ensures backwards compatibility with Drupal < 11.4 repos where the file is not generated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2021 +/- ##
=========================================
Coverage 92.49% 92.49%
- Complexity 1991 1992 +1
=========================================
Files 123 123
Lines 7232 7234 +2
=========================================
+ Hits 6689 6691 +2
Misses 543 543 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2021/acli.phar |
There was a problem hiding this comment.
Pull request overview
Ensures push:artifact artifacts include Drupal 11.4’s docroot/autoload_runtime.php (Symfony Runtime bootstrap) even when it’s gitignored, preventing missing-bootstrap deploy failures.
Changes:
- Conditionally include
docroot/autoload_runtime.phpin the force-add scaffold list when the file exists. - Extend
PushArtifactCommandTestscaffolding/mocks to optionally create/expect the runtime file. - Add a new test intended to cover the Drupal
< 11.4(runtime file absent) scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Command/Push/PushArtifactCommand.php | Adds conditional inclusion of docroot/autoload_runtime.php to the scaffold force-add list. |
| tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php | Updates mocks to simulate presence/absence of autoload_runtime.php and adds a new test case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| // Simulate Drupal < 11.4 where autoload_runtime.php is absent. | ||
| @unlink($runtimeFile); | ||
| } |
| $runtimeFile = Path::join($artifactDir, 'docroot', 'autoload_runtime.php'); | ||
| if ($hasAutoloadRuntime) { | ||
| // Simulate Drupal 11.4+ where autoload_runtime.php is generated. | ||
| @mkdir(Path::join($artifactDir, 'docroot'), 0777, true); |
There was a problem hiding this comment.
I think we should do this
| $this->mockRequest('getApplicationByUuid', $applications[0]->uuid); | ||
| $environments = $this->mockRequest('getApplicationEnvironments', $applications[0]->uuid); | ||
| $localMachineHelper = $this->mockLocalMachineHelper(); | ||
| $this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, false, true, false); |
There was a problem hiding this comment.
The setUpPushArtifact() call in the new test has 9 positional args, 5 of them booleans. It's unreadable:
can we do it this way
$this->setUpPushArtifact(
localMachineHelper: $localMachineHelper,
vcsPath: $environments[0]->vcs->path,
vcsUrls: [$environments[0]->vcs->url],
destGitRef: 'master:master',
push: false,
hasAutoloadRuntime: false,
);
| // autoload_runtime.php was introduced in Drupal 11.4 as the Symfony | ||
| // Runtime bootstrap entry point. It is not in core's file-mapping so | ||
| // it must be force-added like autoload.php, but only when present — | ||
| // Drupal < 11.4 does not generate this file. | ||
| if (file_exists(Path::join($artifactDir, 'docroot', 'autoload_runtime.php'))) { |
|
Would it be better to read The contents of that gitignore mostly duplicate what's already in That way when some other critical file gets added in Drupal 12, we don't have to go through this exercise again. |
It could be, but I think it'll be problematic in scenarios where someone would have added so in that case, Also even if was, someone might have added few things to docroot that they wouldn't want to be added to the artifact. e.g. So these are few edge cases where things can get wrongly added to or missed from the deployed artifact. |
Summary
Drupal 11.4 introduced
docroot/autoload_runtime.phpas a Symfony Runtime bootstrap entry point, generated bydrupal/core-composer-scaffold. Because this file is typically listed indocroot/.gitignore,git add -Adoes not pick it up duringpush:artifactbuilds. This causes HTTP 500 errors on deployed sites because the bootstrap file is missing from the artifact.Changes:
docroot/autoload_runtime.phpto thescaffoldFiles()hardcoded list alongsidedocroot/autoload.php, using afile_existsguard so it is only force-added when present (backwards compatible with Drupal < 11.4).mockGitAddCommit()inPushArtifactCommandTestto accept a$hasAutoloadRuntimeflag that creates the file on disk (triggering thefile_existscheck) and adds the corresponding mock expectation.testPushArtifactWithoutAutoloadRuntimeto cover the Drupal < 11.4 case (file absent,git add -fnot called).Root cause
scaffoldFiles()atPushArtifactCommand.phpexplicitly force-addsdocroot/autoload.php(and other core scaffold files) becausegit add -Arespects.gitignore. The same pattern is needed forautoload_runtime.php, which Drupal 11.4 added as a new scaffold file that is gitignored by default.Test plan
php vendor/bin/phpunit tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php— all 10 tests passacli push:artifactagainst a Drupal 11.4 site — verifyautoload_runtime.phpis committed to the artifact branchFixes: CLI-1853
🤖 Generated with Claude Code