What is the difference between first running updatecode and then updatedb compared to just running update?

I thought update was updatecode and then updatedb but I get an error if I run update but not if I run updatecode and then updatedb.

Running updatecode:

Refreshing update status information ...
Done.
Update information last refreshed: Wed, 2009-08-26 01:25

Update status information on all installed and enabled Drupal modules:
 Name    Installed version  Proposed version  Status     
 Drupal  6.13               6.13              Up to date 

No code updates available.                                           [ok]

Running updatedb:

No database updates required                                         [success]
Finished performing updates.                                         [ok]

Running update:

Refreshing update status information ...
Done.
Update information last refreshed: Wed, 2009-08-26 01:25

Update status information on all installed and enabled Drupal modules:
 Name    Installed version  Proposed version  Status     
 Drupal  6.13               6.13              Up to date 

No code updates available.                                           [ok]
Drush command could not be completed.                                [error]
[...] (Drupal HTML output)
An error occurred at function : drush_pm_post_update                 [error]

This applies both to All-Versions-2.0 and All-Versions-HEAD.

In my setup there was no modules that needed updates, I think read somewhere that there's an error in update if there is no updates availably, maybe that's the same error?

Comments

jonhattan’s picture

AdrianB: try it with --debug flag to see if we can get more info.
The difference when calling `update`is that `updatedb` is called through the backend (ie, in a separate process).

Perhaps the ommited (Drupal HTML output) is a backend dump and not drupal?

AdrianB’s picture

I if run update --debug I get this:

Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.029 sec]   [bootstrap]
Initialized Drupal 6.13 root directory at                               [notice]
/Users/adrian/Sites/drupaldev1/drupal [0.042 sec]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.044 sec]   [bootstrap]
Initialized Drupal site default at sites/default [0.046 sec]            [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration()      [bootstrap]
[0.047 sec]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.077    [bootstrap]
sec]
Successfully connected to the Drupal database. [0.077 sec]           [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.089 sec]   [bootstrap]
Including non-version specific file :                                   [notice]
/Users/adrian/Program/drush/commands/core/drupal/environment.inc
[0.498 sec]
Drush bootstrap phase : _drush_bootstrap_drupal_login() [0.536 sec]  [bootstrap]
Found command: update [0.539 sec]                                    [bootstrap]
Including /Users/adrian/Program/drush/commands/pm/updatecode.inc     [bootstrap]
[0.539 sec]
Including version specific file :                                       [notice]
/Users/adrian/Program/drush/commands/pm/update_info/drupal_6.inc
[0.541 sec]
Refreshing update status information ...
Done.
Update information last refreshed: Wed, 2009-08-26 14:51

Update status information on all installed and enabled Drupal modules:
 Name    Installed version  Proposed version  Status     
 Drupal  6.13               6.13              Up to date 

No code updates available. [1.566 sec]                               [ok]
Running: php /Users/adrian/Program/drush/drush.php                     [command]
--root='/Users/adrian/Sites/drupaldev1/drupal' --uri='http://default'
 'updatedb' --backend [1.773 sec]
Drush bootstrap phase : _drush_bootstrap_drush() [1.96 sec]          [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [1.96 sec]    [bootstrap]
Initialized Drupal 6.13 root directory at                               [notice]
/Users/adrian/Sites/drupaldev1/drupal [1.96 sec]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [1.96 sec]    [bootstrap]
Initialized Drupal site default at sites/default [1.96 sec]             [notice]
Found command: updatedb [1.96 sec]                                   [bootstrap]
Including version specific file :                                       [notice]
/Users/adrian/Program/drush/commands/core/drupal/update_6.inc [1.96
sec]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [1.96[bootstrap]
sec]
PDO support available, but the mysql driver has not been installed.  [bootstrap]
Assuming success. [1.961 sec]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [1.961    [bootstrap]
sec]
Successfully connected to the Drupal database. [1.961 sec]           [bootstrap]
Drush command could not be completed. [1.961 sec]                    [error]
[...] (Drupal HTML output)
An error occurred at function : drush_pm_post_update [1.961 sec]     [error]
Command dispatch complete [1.962 sec]                                   [notice]

The Drupal HTML output that i removed is this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
    <title>Site off-line | Drupal</title>
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/maintenance.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/style.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/minnelli/minnelli.css?0" />
<link type="text/css" rel="stylesheet" media="print" href="/themes/garland/print.css?0" />
        <!--[if lt IE 7]>
      <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/fix-ie.css" />    <![endif]-->
  </head>
  <body>

<!-- Layout -->
  <div id="header-region" class="clear-block"></div>

    <div id="wrapper">
    <div id="container" class="clear-block">

      <div id="header">
        <div id="logo-floater">
        <h1><a href="/" title="Drupal"><img src="/themes/garland/minnelli/logo.png" alt="Drupal" id="logo" /><span>Drupal</span></a></h1>        </div>

      </div> <!-- /header -->

      
      <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
          <h2>Site off-line</h2>                              <div class="clear-block">
            <p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p><hr /><p><small>If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the <a href="http://drupal.org/node/258">handbook</a>, or contact your hosting provider.</small></p>          </div>
          <div id="footer"></div>
      </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->

      
    </div> <!-- /container -->
  </div>
<!-- /layout -->

  </body>
</html>
jonhattan’s picture

Status: Active » Reviewed & tested by the community
jonhattan’s picture

Status: Reviewed & tested by the community » Active

ops, unintentionally I changed the status. Reverting to active.

AdrianB’s picture

Well, it's not a big issue, I'll just use updatecode + updatedb instead of update. I just wanted to report the issue.

markabur’s picture

just wanted to chime in and say that the same thing happens to me. i run drush on a variety of server configurations and for a bunch of different sites, and i've never seen update run without the drush_pm_post_update error. i always have to run updatedb separately. i've checked the php error log and the drupal log and don't see anything there.

markabur’s picture

ok, after a little digging i found the source of the problem for me. on line 329 of backend.inc,

  $cmd = sprintf(escapeshellcmd("php %s %s %s --backend"), escapeshellcmd($drush_path), $option_str, $command);

the "php" there is not the php i use to run drush -- rather, i'm using the php that's part of MAMP. the solution is to link the MAMP php to the system php as described here:

http://raincitystudios.com/blogs-and-pods/steve-krueger/how-use-drush-lo...

AdrianB’s picture

Aha, you found it markabur!

Line 329 has "php" hard coded and does not honor the php path that is used when I run drush.

My alias in .bash_login looks like this:
alias drush='/Applications/MAMP/bin/php5/bin/php ~/path/to/drush/drush.php'

This is what the drush README.txt suggest and it makes drush use this specific php installation. But when line 329 is run then the standard php is used instead.

To confirm this I change this part of line 329:

escapeshellcmd("php %s %s %s --backend")

to specifically use my MAMP php:

escapeshellcmd("/Applications/MAMP/bin/php5/bin/php %s %s %s --backend")

And voila! drush update is run with no errors.

Of course, this is bad solution. A better one is that to create a link like the one in the raincitystudios.com article:

$ sudo ln -f /Applications/MAMP/bin/php5/bin/php /usr/bin/php

This works (I assume, I haven't tested it myself), but then you're forcing every php request to use MAMP php and that may not be what you want.

An even better solution would be to make drush to use the same php as it was initialized with. I don't know how to do that, though.

markabur’s picture

Category: bug » feature

yep, and i realized that although i do run drush in non-mamp contexts, i only ever run the update command on my mac (the code updates are pushed to my servers via svn). so, the error only happens on my mac.

i too am curious if it's possible to make the php command on line 329 more robust by using the same php that drush was initialized with. changing from bug report to feature request..

jonhattan’s picture

USing the same php command is possible. There's already a function to find it available in drush. It should be moved off current place to a better location and the name be generalized.

http://drupalcontrib.org/api/function/drush_simpletest_find_php/6

AdrianB’s picture

jonhattan: Nice, that means that this problem is solvable within drush in a non-hacky way.

moshe weitzman’s picture

Status: Active » Fixed

Moved that function to environment.inc and using it here. Please reopen if this is not fixed. I wasn't able to test it easily.

markabur’s picture

moshe: works great, thanks.

AdrianB’s picture

I can confirm that this change (using All-Versions-HEAD from 2009-Sep-23) solves this issue. Thanks to markabur, jonhattan and moshe!

(I do get another warning using All-Versions-HEAD, array_merge(): Argument #2 is not an array but I don't think that's related at all.)

Status: Fixed » Closed (fixed)

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