Drupal Updater Script

From WolfTech
Revision as of 13:02, 9 December 2008 by Abstein2 (talk | contribs)
Jump to navigation Jump to search

The Drupal Updater Script is a PHP command line script used for keeping multiple Drupal installs current and updated based on another Drupal install you are running. This install (which we'll call the Source Drupal) should but the most recent, updated version Drupal that has had any necessary file modifications performed.

The script performs the following actions:

  • Reads the Source Drupal install and determines the current version of Drupal that is installed
  • Begins processing, one by one, through the list of user-defined Drupal installs (which we'll call Patch Drupals), detecting versions and connecting to database
    • If the version number is less than or equal to the Source Drupal Version, the update continues.
    • If the version number is greater than the Source Drupal Version, the update stops
  • Creates a tarball containing the Patch Drupal currently being examined that contains all the files in the Patch Drupal's defined path
  • Dumps contents of database to an SQL file which is then added to the tarball.
  • Replaces any .htaccess with a customized .htaccess that only allows our cron server access; effectively taking the site down temporarily
  • Finds and deactivates all non-core Drupal modules
  • Updates the database to set the Patch Drupal into "Maintenance Mode"
  • Clears internal Drupal cache
  • Copies all files (excluding /sites/default) from the Source Drupal path to the Path Drupal path
    • Checks for any module conflits:
      • Any modules in the /sites/all/modules folder of the Source Drupal will also be copied to the Path Drupal's /sites/all/modules folder. This is meant as a method to push approved modules to our other Drupal installs and make sure that all other Drupals are also using the updated, working modules.
      • The following happens if a Drupal modules exists in the Patch Drupal's /sites/all/modules and /sites/default/modules folders:
  • The /sites/all and /sites/default modules both have their versions checked. If the module version in /sites/all is greater than the version in /sites/default, the version in /sites/default is deleted and all database entries pointing to its path and changed to the /sites/all version. Any updates that actually need to be run in order to upgrade versions will be handled in a bit.
  • Re-activate all non-core Drupal modules
  • Take site out of "Maintenance Mode"
  • Clears internal cache again
  • Detects all settings.php files in your /sites folder (generally just /sites/default/settings.php) and edits the $update_free_access variable to TRUE. This is necessary for the script to run the update.php file manually. This script updates the Patch Drupal to recognize the new files we copied from the Source Drupal, run any database updates that are necessary, and also run any module updates.
  • Performs any automatic module installs and activations we requested in the Patch Drupal definition.
  • Changes any settings.php files that the script previously modified the value of $update_free_access back to $update_free_access = FALSE.
  • If it exists, restore the original .htaccess file into position
  • Your updated Patch Drupal should now be up and running.