WordPress staging environments are never identical to production after the first week. Someone updates a plugin on staging only, an editor saves an option on production, a migration runs on one but not the other. By the time you promote staging to production, six things have diverged — and one of them is going to be the production-only bug you hit at noon.
What’s happening
Drift accumulates across four dimensions: code (plugin and theme files), data (database content and options), schema (table definitions, especially custom plugin tables), and configuration (wp-config.php, environment variables, .htaccess). Most teams version-control the code via Git, which catches one dimension. The other three are mostly invisible until something breaks.
The painful drift cases: a plugin updated on production via the admin UI never made it into the staging git checkout, a custom option added by an editor on production isn’t on staging, a custom table created by a plugin update exists on one and not the other, or a WP_CACHE = true constant on production isn’t mirrored on staging so the bug doesn’t reproduce.
How to verify
# Plugin version drift:
diff <(wp --path=/var/www/staging plugin list --format=csv --fields=name,version) \
<(wp --path=/var/www/production plugin list --format=csv --fields=name,version)
# Option drift (for a known set):
for opt in siteurl home blog_charset active_plugins; do
echo "=== $opt ==="
wp --path=/var/www/staging option get $opt
wp --path=/var/www/production option get $opt
done
# Schema drift:
diff <(mysqldump --no-data -u root staging_db | sort) \
<(mysqldump --no-data -u root prod_db | sort)
# File diff:
diff -r /var/www/staging/wp-content /var/www/production/wp-content
The fix
- Compare plugin and theme versions. The diff above catches version skew. If staging is on a newer version than production, you need to test the upgrade path on staging first.
- Use schema-only mysqldump for table drift.
mysqldump --no-datagives you just the CREATE TABLE statements. Sort and diff. New tables, dropped tables, changed columns — all show up. - Use
wp config listfor constant drift.wp config list --format=csvon both environments, diff the output. A differentDB_HOSTorWP_CACHEis expected; a differentWP_DEBUGbetween staging and production is fine; a differentWP_CONTENT_DIRis a real bug. - Snapshot the options table. A weekly cron exports
wp_optionsto a known location:wp db export --tables=wp_options wp_options_$(date +%Y%m%d).sql. Diff against the previous week to catch silent option changes. - Use git on
mu-plugins. Drop-in files inmu-pluginsare easy to forget. Version-control the directory. - Run a smoke test post-promotion. A 30-line script that hits the homepage, a category page, a logged-in admin page, and the REST endpoint catches 80% of drift-caused regressions.
For teams running staging-to-production promotions multiple times per week, Stack Harbor wires drift detection into enterprise WordPress support CI. To set up automated drift checks, book a consult.