Commit 029c48c6 authored by Dries's avatar Dries
Browse files

- Patch #306151 by agentrickard, David_Rothstein, Dave Reid, dbabbage, moshe...

- Patch #306151 by agentrickard, David_Rothstein, Dave Reid, dbabbage, moshe weitzman: automatically install/uninstall schema.
parent 82b51dff
......@@ -4798,9 +4798,10 @@ function drupal_get_schema_unprocessed($module, $table = NULL) {
if (!is_null($table) && isset($schema[$table])) {
return $schema[$table];
}
else {
else if (!empty($schema)) {
return $schema;
}
return array();
}
/**
......
......@@ -2130,7 +2130,9 @@ function db_close(array $options = array()) {
* A Schema API table definition array.
*/
function db_create_table(&$ret, $name, $table) {
return Database::getConnection()->schema()->createTable($ret, $name, $table);
if (!db_table_exists($name)) {
return Database::getConnection()->schema()->createTable($ret, $name, $table);
}
}
/**
......
......@@ -586,8 +586,9 @@ function drupal_install_modules($module_list = array(), $disable_modules_install
*/
function _drupal_install_module($module) {
if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
module_load_install($module);
drupal_load('module', $module);
drupal_install_schema($module);
// Now allow the module to perform install tasks.
module_invoke($module, 'install');
$versions = drupal_get_schema_versions($module);
drupal_set_installed_schema_version($module, $versions ? max($versions) : SCHEMA_INSTALLED);
......@@ -663,6 +664,8 @@ function drupal_uninstall_modules($module_list = array()) {
// Uninstall the module.
module_load_install($module);
module_invoke($module, 'uninstall');
drupal_uninstall_schema($module);
watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO);
// Now remove the menu links for all paths declared by this module.
......
......@@ -6,21 +6,10 @@
* Install, update and uninstall functions for the aggregator module.
*/
/**
* Implement hook_install().
*/
function aggregator_install() {
// Create tables.
drupal_install_schema('aggregator');
}
/**
* Implement hook_uninstall().
*/
function aggregator_uninstall() {
// Remove tables.
drupal_uninstall_schema('aggregator');
variable_del('aggregator_allowed_html_tags');
variable_del('aggregator_summary_items');
variable_del('aggregator_clear');
......
......@@ -205,7 +205,6 @@ function block_schema() {
* Implement hook_install().
*/
function block_install() {
drupal_install_schema('block');
// Block should go first so that other modules can alter its output
// during hook_page_alter(). Almost everything on the page is a block,
......@@ -216,13 +215,6 @@ function block_install() {
->execute();
}
/**
* Implement hook_uninstall().
*/
function block_uninstall() {
drupal_uninstall_schema('block');
}
/**
* Set system.weight to a low value for block module.
*
......
......@@ -10,8 +10,6 @@
* Implement hook_install().
*/
function book_install() {
// Create tables.
drupal_install_schema('book');
// Add the node type.
_book_install_type_create();
}
......@@ -23,8 +21,6 @@ function book_uninstall() {
// Delete menu links.
db_query("DELETE FROM {menu_links} WHERE module = 'book'");
menu_cache_clear_all();
// Remove tables.
drupal_uninstall_schema('book');
}
function _book_install_type_create() {
......
......@@ -6,21 +6,10 @@
* Install, update and uninstall functions for the comment module.
*/
/**
* Implement hook_install().
*/
function comment_install() {
// Create tables.
drupal_install_schema('comment');
}
/**
* Implement hook_uninstall().
*/
function comment_uninstall() {
// Remove tables.
drupal_uninstall_schema('comment');
// Remove variables.
variable_del('comment_block_count');
$node_types = array_keys(node_type_get_types());
......
......@@ -6,21 +6,10 @@
* Install, update and uninstall functions for the contact module.
*/
/**
* Implement hook_install().
*/
function contact_install() {
// Create tables.
drupal_install_schema('contact');
}
/**
* Implement hook_uninstall().
*/
function contact_uninstall() {
// Remove tables.
drupal_uninstall_schema('contact');
variable_del('contact_default_status');
variable_del('contact_form_information');
variable_del('contact_hourly_threshold');
......
......@@ -6,22 +6,6 @@
* Install, update and uninstall functions for the dblog module.
*/
/**
* Implement hook_install().
*/
function dblog_install() {
// Create tables.
drupal_install_schema('dblog');
}
/**
* Implement hook_uninstall().
*/
function dblog_uninstall() {
// Remove tables.
drupal_uninstall_schema('dblog');
}
/**
* Implement hook_schema().
*/
......
......@@ -6,13 +6,6 @@
* Install, update and uninstall functions for the field module.
*/
/**
* Implement hook_install().
*/
function field_install() {
drupal_install_schema('field');
}
/**
* Implement hook_schema.
*/
......
......@@ -6,20 +6,6 @@
* Install, update and uninstall functions for the field_sql_storage module.
*/
/**
* Implement hook_install().
*/
function field_sql_storage_install() {
drupal_install_schema('field_sql_storage');
}
/**
* Implement hook_uninstall().
*/
function field_sql_storage_uninstall() {
drupal_uninstall_schema('field_sql_storage');
}
/**
* Implement hook_schema().
*/
......
......@@ -10,8 +10,6 @@
* Implement hook_install().
*/
function forum_install() {
// Create tables.
drupal_install_schema('forum');
// Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
db_update('system')
->fields(array('weight' => 1))
......@@ -61,7 +59,6 @@ function forum_uninstall() {
$vid = variable_get('forum_nav_vocabulary', 0);
taxonomy_vocabulary_delete($vid);
drupal_uninstall_schema('forum');
variable_del('forum_containers');
variable_del('forum_nav_vocabulary');
variable_del('forum_hot_topic');
......
......@@ -10,8 +10,6 @@
* Implement hook_install().
*/
function image_install() {
drupal_install_schema('image');
// Create the styles directory and ensure it's writable.
$path = file_directory_path() . '/styles';
file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
......@@ -21,8 +19,6 @@ function image_install() {
* Implement hook_uninstall().
*/
function image_uninstall() {
drupal_uninstall_schema('image');
// Remove the styles directory and generated images.
$path = file_directory_path() . '/styles';
file_unmanaged_delete_recursive($path);
......
......@@ -14,9 +14,6 @@ function locale_install() {
// fields; non-MySQL database servers need to ensure the field type is text
// and that LIKE produces a case-sensitive comparison.
// Create tables.
drupal_install_schema('locale');
db_insert('languages')
->fields(array(
'language' => 'en',
......@@ -83,8 +80,6 @@ function locale_uninstall() {
// try to query the unexisting {locales_source} and {locales_target} tables.
drupal_language_initialize();
// Remove tables.
drupal_uninstall_schema('locale');
}
/**
......
......@@ -10,8 +10,6 @@
* Implement hook_install().
*/
function menu_install() {
// Create tables.
drupal_install_schema('menu');
$system_menus = menu_list_system_menus();
$descriptions = array(
'navigation' => 'The <em>Navigation</em> menu contains links such as Recent posts (if the Tracker module is enabled). Non-administrative links are added to this menu by default by modules.',
......@@ -31,8 +29,6 @@ function menu_install() {
* Implement hook_uninstall().
*/
function menu_uninstall() {
// Remove tables.
drupal_uninstall_schema('menu');
menu_rebuild();
}
......
......@@ -6,22 +6,6 @@
* Install, update and uninstall functions for the openid module.
*/
/**
* Implement hook_install().
*/
function openid_install() {
// Create table.
drupal_install_schema('openid');
}
/**
* Implement hook_uninstall().
*/
function openid_uninstall() {
// Remove table.
drupal_uninstall_schema('openid');
}
/**
* Implement hook_schema().
*/
......
......@@ -6,22 +6,6 @@
* Install, update and uninstall functions for the poll module.
*/
/**
* Implement hook_install().
*/
function poll_install() {
// Create tables.
drupal_install_schema('poll');
}
/**
* Implement hook_uninstall().
*/
function poll_uninstall() {
// Remove tables.
drupal_uninstall_schema('poll');
}
/**
* Implement hook_schema().
*/
......
......@@ -6,21 +6,10 @@
* Install, update and uninstall functions for the profile module.
*/
/**
* Implement hook_install().
*/
function profile_install() {
// Create tables.
drupal_install_schema('profile');
}
/**
* Implement hook_uninstall().
*/
function profile_uninstall() {
// Remove tables
drupal_uninstall_schema('profile');
variable_del('profile_block_author_fields');
}
......
......@@ -6,21 +6,10 @@
* Install, update and uninstall functions for the search module.
*/
/**
* Implement hook_install().
*/
function search_install() {
// Create tables.
drupal_install_schema('search');
}
/**
* Implement hook_uninstall().
*/
function search_uninstall() {
// Remove tables.
drupal_uninstall_schema('search');
variable_del('minimum_word_size');
variable_del('overlap_cjk');
variable_del('search_cron_limit');
......
......@@ -10,7 +10,6 @@
* Implement hook_install().
*/
function simpletest_install() {
drupal_install_schema('simpletest');
// Check for files directory.
$path = 'public://simpletest';
if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
......@@ -110,9 +109,6 @@ function simpletest_uninstall() {
variable_del('simpletest_clear_results');
variable_del('simpletest_verbose');
// Uninstall schema.
drupal_uninstall_schema('simpletest');
// Remove generated files.
$path = file_directory_path() . '/simpletest';
$files = file_scan_directory($path, '/.*/');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment