Enabling New Modules Via Update.php

Enabling New Modules Via Update.php


Add Comment
Source
Tutorials
Bookmark/Search this post with:
Delicious Delicious
Digg Digg
StumbleUpon StumbleUpon
Facebook Facebook
Google Google
Yahoo Yahoo
Technorati Technorati
16
Wednesday, January 16, 2008
By admin
UPDATE: There’s a better way.

I work with 3 other developers, all of whom have their own local sandbox of our site. Since we’re constantly adding new modules, I found a simple way to enable a new module via another module’s .install file. That way, all we have to do is run update.php when we update our source tree.

Here’s a simple example update function:

<?php

function some_enabled_module_update_1() {
  $ret = array();
  switch ($GLOBALS[‘db_type’]) {
    case ‘mysqli’:
    case ‘mysql’:
      //this function tells drupal to update its file directories, and insert records for any new modules it sees.
      module_rebuild_cache();
      $ret[] = update_sql(“UPDATE {system} SET status = 1 WHERE name = ‘some_completely_new_module'”);
      break;
  }
  return $ret;
}
;
?>
The major limitation of this method is that it doesn’t run the new modules install file. I can live with that. It beats always bugging other developers to see if the build needs a new module enabled. I’m sure there’s a workaround for that anyhow.

read more

Leave a Reply

Your email address will not be published. Required fields are marked *