Forcing WordPress To Run Minor Updates (In Version Control)

I manage all my WordPress development with git. It’s a pretty standard workflow for small teams; We have a staging server and a live server. We make development changes on our local machines, do a push to staging, then a push to live. (PHP solution below)

The Issue With Minor Updates

When WordPress rolls out minor updates (3.9.x, 4.2.x, etc…), these are important to have automatically installed because they may contain urgent security patches. By default, WordPress is setup to install these. The problem with this and version control is that these changes will be automatic on your live server, but not on your staging server, or local system. So if your main repo has an older minor version, then your live server will auto-update every time you push changes live. Why does WordPress not update minor version automatically in your development environment? Because if WordPress detects a .git, .svn, .gh, or .bzr in your WordPress directory, it won’t run minor version updates! Here is the comment written next to this check:

The underlying assumption is that if you are using version control *anywhere*, then you should be making decisions for how things get updated.

The Solution

I like this paradigm of running updates, personally, but we still need a way to get minor updates into our latest commits. Here’s what I do:

  • Create a file in your main directory called “force-update.php”
  • Put this code in that file:

  • Add this file to your .gitignore (I recommend not keeping this file tracked)
  • Run force-update.php

You can run git status to verify core files have been changed. Also at this point you can commit and push your changes up.