summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-02-26 18:31:29 +0000
committerDries Buytaert <dries@buytaert.net>2010-02-26 18:31:29 +0000
commitf6b166ff23faa3ab8a2f643394842710dbecfd3d (patch)
tree871c742fb8e120901ec941b9062109df36d9c593 /modules
parentbc70eaeb8ddd78022ea6831ccb2e49b9cb653069 (diff)
downloadbrdo-f6b166ff23faa3ab8a2f643394842710dbecfd3d.tar.gz
brdo-f6b166ff23faa3ab8a2f643394842710dbecfd3d.tar.bz2
- Patch #620298 by David_Rothstein: schema not available in hook_install().
Diffstat (limited to 'modules')
-rw-r--r--modules/node/node.module11
-rw-r--r--modules/rdf/rdf.install5
-rw-r--r--modules/shortcut/shortcut.install9
-rw-r--r--modules/simpletest/tests/module.test40
-rw-r--r--modules/simpletest/tests/module_test.install43
-rw-r--r--modules/system/system.module2
6 files changed, 100 insertions, 10 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index 9e6b76045..36cc76dcd 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -3536,6 +3536,17 @@ function node_requirements($phase) {
}
/**
+ * Implements hook_modules_enabled().
+ */
+function node_modules_enabled($modules) {
+ // Check if any of the newly enabled modules require the node_access table to
+ // be rebuilt.
+ if (!node_access_needs_rebuild() && array_intersect($modules, module_implements('node_grants'))) {
+ node_access_needs_rebuild(TRUE);
+ }
+}
+
+/**
* Controller class for nodes.
*
* This extends the DrupalDefaultEntityController class, adding required
diff --git a/modules/rdf/rdf.install b/modules/rdf/rdf.install
index ec553fcda..905c24771 100644
--- a/modules/rdf/rdf.install
+++ b/modules/rdf/rdf.install
@@ -43,8 +43,9 @@ function rdf_schema() {
* Implements hook_install().
*/
function rdf_install() {
- // The installer does not trigger hook_modules_installed(), so it needs to be
- // triggered manually for modules defining RDF mappings.
+ // Collect any RDF mappings that were declared by modules installed before
+ // this one.
$modules = module_implements('rdf_mapping');
rdf_modules_installed($modules);
}
+
diff --git a/modules/shortcut/shortcut.install b/modules/shortcut/shortcut.install
index 634ee51fb..5c49322ee 100644
--- a/modules/shortcut/shortcut.install
+++ b/modules/shortcut/shortcut.install
@@ -7,14 +7,9 @@
*/
/**
- * Implements hook_enable().
+ * Implements hook_install().
*/
-function shortcut_enable() {
- if (shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME)) {
- // Quit out; this module has already been installed before.
- return;
- }
-
+function shortcut_install() {
$t = get_t();
// Create an initial default shortcut set.
$shortcut_set = new StdClass();
diff --git a/modules/simpletest/tests/module.test b/modules/simpletest/tests/module.test
index 242910c7f..31c0bb028 100644
--- a/modules/simpletest/tests/module.test
+++ b/modules/simpletest/tests/module.test
@@ -126,13 +126,50 @@ class ModuleUnitTest extends DrupalWebTestCase {
}
/**
+ * Unit tests for module installation.
+ */
+class ModuleInstallTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Module installation',
+ 'description' => 'Tests the installation of modules.',
+ 'group' => 'Module',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('module_test');
+ }
+
+ /**
+ * Test that calls to drupal_write_record() work during module installation.
+ *
+ * This is a useful function to test because modules often use it to insert
+ * initial data in their database tables when they are being installed or
+ * enabled. Furthermore, drupal_write_record() relies on the module schema
+ * information being available, so this also checks that the data from one of
+ * the module's hook implementations, in particular hook_schema(), is
+ * properly available during this time. Therefore, this test helps ensure
+ * that modules are fully functional while Drupal is installing and enabling
+ * them.
+ */
+ function testDrupalWriteRecord() {
+ // Check for data that was inserted using drupal_write_record() while the
+ // 'module_test' module was being installed and enabled.
+ $data = db_query("SELECT data FROM {module_test}")->fetchCol();
+ $this->assertTrue(in_array('Data inserted in hook_install()', $data), t('Data inserted using drupal_write_record() in hook_install() is correctly saved.'));
+ $this->assertTrue(in_array('Data inserted in hook_enable()', $data), t('Data inserted using drupal_write_record() in hook_enable() is correctly saved.'));
+ }
+}
+
+/**
* Unit tests for module uninstallation and related hooks.
*/
class ModuleUninstallTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Module uninstallation',
- 'description' => 'Checks module uninstallation',
+ 'description' => 'Tests the uninstallation of modules.',
'group' => 'Module',
);
}
@@ -147,6 +184,7 @@ class ModuleUninstallTestCase extends DrupalWebTestCase {
function testUserPermsUninstalled() {
// Uninstalls the module_test module, so hook_modules_uninstalled()
// is executed.
+ module_disable(array('module_test'));
drupal_uninstall_modules(array('module_test'));
// Are the perms defined by module_test removed from {role_permission}.
diff --git a/modules/simpletest/tests/module_test.install b/modules/simpletest/tests/module_test.install
new file mode 100644
index 000000000..5f8e76b70
--- /dev/null
+++ b/modules/simpletest/tests/module_test.install
@@ -0,0 +1,43 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Install, update and uninstall functions for the module_test module.
+ */
+
+/**
+ * Implements hook_schema().
+ */
+function module_test_schema() {
+ $schema['module_test'] = array(
+ 'description' => 'Dummy table to test the behavior of hook_schema() during module installation.',
+ 'fields' => array(
+ 'data' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'An example data column for the module.',
+ ),
+ ),
+ );
+ return $schema;
+}
+
+/**
+ * Implements hook_install().
+ */
+function module_test_install() {
+ $record = array('data' => 'Data inserted in hook_install()');
+ drupal_write_record('module_test', $record);
+}
+
+/**
+ * Implements hook_enable().
+ */
+function module_test_enable() {
+ $record = array('data' => 'Data inserted in hook_enable()');
+ drupal_write_record('module_test', $record);
+}
+
diff --git a/modules/system/system.module b/modules/system/system.module
index 18ada5af7..f598fc590 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2226,6 +2226,8 @@ function _system_update_bootstrap_status() {
$query->condition('name', $bootstrap_modules, 'NOT IN');
}
$query->execute();
+ // Reset the cached list of bootstrap modules.
+ system_list_reset();
}
/**