Note that this article applies primarily to Drupal 6. When developing features or other modules, I often find myself making changes to the module dependencies or other aspects after my module has first been moved to the staging site. I use hook_update_N() for that. Here's how.
Features normally don't do anything to the database, so typically we won't have an implementation of hook_install(), but we can still do stuff like add URL aliases using the install hook.
The title of this post is a
The title of this post is a bit of a misnomer since you are changing things in the database, but you are using API functions rather than direct queries.
Secondly you are making this a bit more complicated than it needs to be, your dependency example can be reduced to:
<?php
function myfeature_update_6001() {
$return = array();
$modules = array('module_x', 'module_y'); // you must also put these modules in your .info file as dependencies.
drupal_install_modules($modules); // note that this is for Drupal 6
foreach ($modules as $module) {
$return[] = array(
'success' => module_exists($module),
'query' => $module . ' installed.',
);
}
// Clear whatever caches are necessary here.
cache_clear_all('*', 'cache', TRUE);
return $return;
}
?>
Of course you are right about
Of course you are right about the database. Maybe a better way to put it is "operations that don't modify the database schema".
Also: thanks for the more concise way of writing this.
Cheers,
Albert.
Exactly what I was looking
Exactly what I was looking for. Thanks.