Prebuild and download checksums not matching#355
Conversation
…if prebuild_zipball and include_archive_checksum enabled)
|
Reproduced on Worth flagging the impact is wider than the title suggests. With On any deployment behind a CDN with a sub-100s edge timeout (Cloudflare's default is 100s), the downstream Meanwhile, the lazy build runs synchronously in php-fpm and holds a worker for its full duration, so deployments with small fpm pools also see concurrent requests queue behind it. The one-line fix here resolves it. Please consider merging. |
Problem
When
prebuild_zipballandinclude_archive_checksumare enabled, the shasum stored in the Composer metadata (/p2/vendor/package.json) never matched the actual downloaded archive file. This causes Composer to fail checksum verification duringcomposer install/composer update.Root Cause
A version string mismatch between the prebuild and the download path when constructing archive filenames.
Updater::updateArchive()) passed$data->getVersion()toDistManager::buildAndWriteArchive(). For a ComposerPackageInterface, getVersion()returns the normalized version — e.g. 2.1.2.0 (four-part).DistManager::getDist()) builds the cache key from$version->getVersion()on theVersionentity. That method returns$this->version, which is the pretty version stored in the version column — e.g. 2.1.2 (three-part).So for a tag like 2.1.2:
<basedir>/<vendor>/<package>/2.1.2.0-<ref>.zip→ shasum stored in metadata.<basedir>/<vendor>/<package>/2.1.2-<ref>.zip→ cache miss → rebuilt a fresh archive → different (non-deterministic) SHA1 than what the metadata said.Both files ended up coexisting on disk with different contents, and the mismatch was guaranteed on every download. Dev branches (e.g.
dev-release/2.1.2) were unaffected, because their pretty and normalized versions are identical — only tags triggered the bug.Fix
Use the pretty version also for
Updater::updateArchive(). This aligns the prebuild withDistManagerand theVersionentity, which already consistently use the pretty version for cache keys.