Commit build artifacts, or repeat WordPress core’s mistake

If you look after a lot of client sites, the failure that wrecks your week is usually dull: a file that exists on your machine and not on the server, or a bug you can’t bisect because the file was never in version control. WordPress core hit both at once during the 7.0 cycle, then spent nearly three months restoring what it lost. Dennis Snell wrote the full post-mortem on Make WordPress Core, and it maps almost line for line onto why I still commit build artifacts on repositories that other people have to deploy from.

The short version is that a set of PHP files live in both the gutenberg repository and wordpress/wordpress-develop, generated upstream and synced into core. A build change tracked in Trac ticket #64393 and committed as [61438] removed those files from version control and put them in .gitignore, so Gutenberg would be the single source of truth and a script would materialize the files in your working copy. The intent was sensible. Nobody had fully mapped everything that assumed those files exist.

What broke in the 7.0 cycle

WordPress calls require directly on those files during its boot sequence, so anything that checked out the code without running the build got a fatal error instead of a site. The distributed hosting tests were among the first to notice. Files that the build used to minify stopped being minified. Anything that steps through commits one at a time now needed a full build per step, and even after optimizations, walking the 800-plus commits between 6.8.5 and 6.9.0 cost over nine hours of runtime. The files’ history was cut off, so it looked like they had never been in the repository at all, and the only way back in was through git commands your IDE and GitHub’s UI will not give you.

Two of the failures sit close to home for agency work. Because the removed files were ignored, accidental edits to them became invisible: git, the IDE, and the linters all reported a clean tree while the change sat there waiting to break the next person’s checkout. And the build server, which had been carrying those files for years, never cleaned them up, so files that were supposed to be gone kept shipping into the beta and RC builds. Ticket #65418 tracks the leftovers. That’s a works-on-my-machine bug, and it happened in the most watched repository in WordPress.

The subtler problem was the source of truth itself. Before the change, two copies of each file existed and the one in SVN won for releases, which was clunky but unambiguous. After the change the only copy lived in Gutenberg, and because wordpress-develop started pinning a commit hash, the file served to WordPress and the file shipped in the plugin could genuinely differ. That left one source of truth on paper and two in practice. A build change sold as cleanup can open that kind of gap.

Why I commit build artifacts on client sites

There are only two ways to handle generated files, and the 7.0 cycle stress-tested one of them. You can commit the build output: the minified CSS and JS, the compiled PHP, whatever npm run build produces. Or you can ignore all of it and generate it at deploy time, with only sources in the repository. Everything else is a hybrid of those two.

Committing the output costs you noisy diffs and the occasional merge conflict in a file nobody wants to read. What it buys is a repository that ships as-is. Any host can serve a checkout, and any colleague can clone and run it without a Node toolchain. git blame and git bisect work on the exact bytes that ran in production, and nothing can hide from your editor. When a regression shows up, the question of which commit changed this file has an answer, and being able to answer it is most of what good debugging is.

Building at deploy time keeps the repository clean and removes the manual sync between two copies of the same file, which is the friction core wanted gone. The cost is that everything downstream of the build has to run the build: hosts, CI jobs, integration tests, every other developer. Miss one and you ship a fatal error, which is what the hosting tests ran into. Version history for the generated file is gone by design, so bisecting means rebuilding at every step. Core’s extra complication was that the sync spanned two repositories moving at two tempos, Gutenberg daily and core periodically, so the pins for when a defect arrived only existed on the core side.

Which side I pick depends on who consumes the repository, not on which approach is more elegant in the abstract. On client sites and WooCommerce stores spread across mixed hosting, some of them managed through panels rather than pipelines, I commit build artifacts. For projects where I control the pipeline and the deploy target, generating at deploy time is the better default and I use it without guilt. If your deploy has no CI at all, that is the first gap to close, and it does not need to be elaborate: a basic CI setup that builds and tests on every push makes either strategy safe.

(I’m not sure where plugins in the wordpress.org directory fall, since the directory’s build flow and the plugin’s own repository can both end up shipping the same files.)

Three checks I run before a deploy

The checks below are small enough to run on anything, and together they cover the failure modes core just spent a quarter cleaning up.

#!/usr/bin/env bash
# Run before rsync or any file-based deploy.
set -euo pipefail

required=(
  "assets/css/theme.min.css"
  "assets/js/theme.min.js"
  "build/blocks-generated.php"
)

for path in "${required[@]}"; do
  if [ ! -s "$path" ]; then
    echo "deploy: missing or empty: $path"
    exit 1
  fi
  if ! git ls-files --error-unmatch "$path"; then
    echo "deploy: exists only on this machine, not tracked: $path"
    exit 1
  fi
done

The first check is existence: every file your theme or plugin cannot boot without is present and non-empty. The second is tracking: git ls-files --error-unmatch fails when a file exists only on the machine in front of you, which catches the file-exists-locally bug before it ships instead of after. The third is deletion, and it’s the one I see skipped most often. Preview what a clean build removes with git clean -n -fdx, run git clean -fdx between builds in CI, and make the server side remove files with rsync --delete or by deploying a release artifact instead of copying over an old tree. The core build server shipped stale files into the beta and RC builds because nothing removed them. WordPress itself keeps the $_old_files array in wp-admin/includes/update-core.php for the same reason: the updater cannot assume an old file is gone.

If your repository sits somewhere in between, half committed and half generated, close that gap before a release finds it for you. I’m glad to look at how a store builds and deploys and say which side I’d land on for that setup, and the script above is a small piece of that work.

Reading the restored history in svn and git

The fix is worth reading slowly. A plain revert would have restored the files but reintroduced them as new files with the same names, so everything before January 5 would have stayed orphaned. Instead, a branch was cut from the revision just before [61438], the files were restored across a sequence of commits matching each Gutenberg sync, and the branch was merged back into trunk so contents and history reconnect. The whole thing was prototyped in git, mirrored into a test copy of the Subversion repository, and rehearsed fifteen times before anyone touched production.

When you debug core, git represents commits from merged branches automatically, so git log on the wordpress-develop mirror shows the restored history with no ceremony. Subversion does not. A plain svn log on trunk hides the branch’s sync commits entirely, and you need svn -g log, the merge-history flag, to see them, which means every svn-based tool defaults to the blind view. The repository documentation in the core handbook is worth a skim if you bounce between the two. One caveat from the restore itself: the recovered commits all carry March 26 timestamps even though each corresponds to a change made between January 5 and March 26, because rewriting svn metadata afterwards risked breaking the git-svn sync. When you narrow down a regression in that window, the upstream commit each restore commit points at is the reliable part; the date on it is an artifact of the merge.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.

Leave a Comment