Skip to content

Instantly share code, notes, and snippets.

@jameswilson
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameswilson/c1d5b4b6acd6278668a0 to your computer and use it in GitHub Desktop.
Save jameswilson/c1d5b4b6acd6278668a0 to your computer and use it in GitHub Desktop.
Update module locations in Drupal 7 from sites/all/modules/contrib to profiles/distroname/modules/contrib
#!/usr/bin/php
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
db_query("UPDATE {system} SET filename = replace(filename, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');")->execute();
db_query("UPDATE {system} SET filename = replace(filename, 'sites/all/themes/contrib', 'profiles/distroname/themes/contrib');")->execute();
db_query("UPDATE {registry} SET filename = replace(filename, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');")->execute();
db_query("UPDATE {registry_file} SET filename = replace(filename, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');")->execute();
db_query("UPDATE {variable} SET value = replace(value, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');")->execute();
db_query("UPDATE {menu_router} SET include_file = replace(include_file, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');")->execute();
db_query("TRUNCATE {cache};")->execute();
db_query("TRUNCATE {cache_block};")->execute();
db_query("TRUNCATE {cache_bootstrap};")->execute();
db_query("TRUNCATE {cache_field};")->execute();
db_query("TRUNCATE {cache_filter};")->execute();
db_query("TRUNCATE {cache_form};")->execute();
db_query("TRUNCATE {cache_image};")->execute();
db_query("TRUNCATE {cache_l10n_update};")->execute();
db_query("TRUNCATE {cache_libraries};")->execute();
db_query("TRUNCATE {cache_menu};")->execute();
db_query("TRUNCATE {cache_page};")->execute();
db_query("TRUNCATE {cache_panels};")->execute();
db_query("TRUNCATE {cache_path};")->execute();
db_query("TRUNCATE {cache_proxy};")->execute();
db_query("TRUNCATE {cache_token};")->execute();
db_query("TRUNCATE {cache_update};")->execute();
db_query("TRUNCATE {cache_variable};")->execute();
db_query("TRUNCATE {cache_views};")->execute();
db_query("TRUNCATE {cache_views_data};")->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment