Question: is update.php invoked when running "drush pm update module"?
If so, would it be possible to include the update # as an optional parameter?
If not, could we have a "drush pm updatephp module update #"
This feature could be useful for managing multiple domains.

#10 194107.patch3.8 KBroychri
Members fund testing for the Drupal project. Drupal Association Learn more


moshe weitzman’s picture

Title: Drush and update.php » Drush command for running update.php
Category: support » feature

no, it isn't. thats an interesting idea though.

agentrickard’s picture


skizzo's question comes from some Domain Access testing that he's doing.

For background, see:


The module Domain Prefix provides a user interface for enabling select database table prefixing for use with subdomains. We're trying to figure out how to update those tables when running update.php.

moshe weitzman’s picture

As far as I can tell, update.php uses a workhorse function called update_data() which calls module_invoke($module, 'update_'. $number); So, I think drush could pretty easily perform specified updates just with module_invoke($module, 'update_'. $number); i don't have time to implement this, but i would review any patch submitted here.

in general, drush should offer to perform all pending updates. specifying an extremely rare use case IMO.

moshe weitzman’s picture

nice example code at

dlhubler’s picture

Title: Drush command for running update.php » posh running update.php

I wrote a script for running updates from posh (plain old shell)
(some folks in IRC sug. i post here, but they probably didn't realize I wasn't using drush)

dlhubler’s picture

Title: posh running update.php » Drush command for running update.php

revert change to issue title

greggles’s picture

And yet another separate post about this

If sacha doesn't find a round tuit to create a patch then I've got it on my calendar ;)

batje’s picture


gunzip’s picture


roychri’s picture

Status: Active » Needs review
3.8 KB

Here is a patch from sacha's code.
I added some extra code that will print anything that was set using drupal_set_message() in order to catch errors and notices that we would not otherwise be able to see.
I also modified the drush_pm to mention that an alternative to update.php is drush update.

To run this code you simply do:

  php sites/all/modules/contrib/drush/drush.php update

It will show you which version needs to be updated and ask you to confirm.
If you want to update without having to confirm (blind update) then you can pass "force" like this:

  php sites/all/modules/contrib/drush/drush.php update force

If there is nothing to update, it will show you the current version and exit.

Here is what it can show you:

statistics                      1000
system                          1022
content                         1008
number                             5
optionwidgets                      1
text                               5
date                            5104
fckeditor                          3
lightbox2                          3
link                               1
messaging                          2
nodequeue                       5204
notifications                      6
taxonomy_redirect                  2
token                              1
views                             16
devel                              3 ->     5 (4, 5)

This example tells you that your previous devel version was 3 but the current version is now 5 and the update 4 and 5 needs to be ran.

roychri’s picture

Version: 5.x-1.0-beta4 » 5.x-1.4
lomz’s picture

Will this update all sites in a multisite-setup or just one site?

greggles’s picture

@lomz - I expect it to follow the normal drush style which is that it will respect the -l switch.

moshe weitzman’s picture

folks - we need to get this into d7 and d6 which means supporting batch API syntax for updates.

lomz’s picture

@greggles - could you explain a little further?

greggles’s picture

Will this update all sites in a multisite-setup or just one site?

I don't know of any drush commands that run the command on all multisites. When we call drush we have to tell it "-l" to get it to work on a particular site. I expect this to work the same: that it executes for one site within a multisite.

moshe weitzman’s picture

moshe weitzman’s picture

Status: Needs review » Needs work

has to handle batch api style updates.

roychri’s picture

@moshe: The batch API is in D6 and/or D7, right? Maybe the version of this issue should be changed to D7?

adrian’s picture

I have code in provision HEAD for installs and updates for d5/d6/d7.

I have them built as conditional includes, which depend on the VERSION you have bootstrapped. This might not gel with how drush is handling the version specific code (as a separate extras project).

The commands also use the logging, error handling and _invoke api, but ideally I would like to see them move into drush.

The system is built so that commands can either be re-used in the same thread (ie: the pm commands could just call the command internally, or they could choose to execute drush.php update and integrate the output into their own).

adrian’s picture

Version: 5.x-1.4 »

I think this should be for 2.x, as that's where the main development is going on, and one of the PRIMARY requirements for this to work properly, is that the commands need to be able to run without needing to bootstrap.

There's also a case to be made for moving this to drush_extras. The code needed to update each version of drupal is wildly different.
In provision however, I felt it served me better to not have to manage multiple branches, so I separated all of this code into their own .inc files :

Drupal 5 :

Drupal 6 :

Drupal 7 :

Now that the logging and error handling code is in Drush, and the drush_invoke getting close, the code I wrote should be very portable.

I also wrote a helper function that conditionally includes these files, based on the active drupal version. It should be noted that 'install' and 'update' commands need to have a 'bootstrap' => -1 property set, as the commands themselves need to manage the bootstrap level.

function drush_platform_include(&$data, $path, $command, $version = null, $platform = 'drupal') {
  $version = ($version) ? $version : drush_drupal_major_version();
  $options[] = sprintf("%s_%s_%s", $platform, $version, $command);
  $options[] = sprintf("%s_%s", $platform, $command);
  $options[] = sprintf("%s", $command);

  $match = false;
  foreach ($options as $option) {
    $file = sprintf("%s/", $path, $option);
    if (file_exists($file)) {
      $match = $file;

  if ($match) {
    drush_log(dt('Including platform specific file : @file', array('@file' => $match)));

So at a later point where I wanted to have the code execute, I could just do :

  provision_platform_include($data, dirname(__FILE__), 'update');

This is pretty unlike the way Drush currently does the version specific code (ie: a separate project), so to do it the drush way, and not the provision way, would involve requiring the download of drush extras for that version, and having the update command running in there.

moshe weitzman’s picture

I think putting this in drush_extras makes perfect sense.

anarcat’s picture

Note that I submitted a patch for D7 that would ease the implementation of such things, see #233091: Move code from update.php into includes/ Please review and comment. The idea is to get rid of our code in provision and make Drupal offer a proper upgrade API.

bjaspan’s picture


adrian’s picture

Assigned: Unassigned » adrian

We have decided to move the provision install and update code upstream into drush, which means that drush will get full site install and update functionality , with full support for install profiles and locales, from Drupal 5 through Drupal 7.

adrian’s picture

I have created a new Issue for the porting process, because I felt it would be better to keep everything about the task at hand in the same place:

frankcarey’s picture


adrian’s picture

Status: Needs work » Fixed

committed the provision update commands.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.