Closed (fixed)
Project:
Drush
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
15 May 2009 at 15:31 UTC
Updated:
2 Dec 2009 at 22:21 UTC
As described at http://sachachua.com/wp/2009/03/19/drupal-gotcha-watch-out-for-user-duri..., you really should be uid #1 or similarly priveleged account when running update.php. Consider that node_delete() does an access check internally (for example).
I'd like to add code like below to each update_main() function, after the full bootstrap. Any objections?
// Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D6.
if (!drush_get_context('DRUSH_USER')) {
drush_set_context('DRUSH_USER', 1);
_drush_bootstrap_drupal_login();
}
Comments
Comment #1
adrian commentedthat's cool. i never picked up any problems in the code i updated, because i always thought that it would just be like running with access_check disabled.
Comment #2
adrian commentedbtw. i think the correct way to handle this is :
instead of setting the context by hand
Comment #3
moshe weitzman commentedCommitted to all 3 branches using adrian's suggestion.
Comment #5
moshe weitzman commentedFor posterity - the above technique works great IFF you add a 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL (or less) in your command definition. Without that, drush logs in as uid=0 during its bootstrap and the bootstrap call in the command callback does nothing.