- Patch #821290 by marcingy, aspilicious, scor, catch, ronald_istos: unexpected error after disabling - unistalling - re-enabling forum module.
parent
2d3af8fe80
commit
27df25f60f
|
@ -24,6 +24,10 @@ function forum_install() {
|
|||
* Implements hook_enable().
|
||||
*/
|
||||
function forum_enable() {
|
||||
// If we enable forum at the same time as taxonomy we need to call
|
||||
// field_associate_fields() as otherwise the field won't be enabled until
|
||||
// hook modules_enabled is called which takes place after hook_enable events.
|
||||
field_associate_fields('taxonomy');
|
||||
// Create the forum vocabulary if it does not exist.
|
||||
$vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0));
|
||||
if (!$vocabulary) {
|
||||
|
@ -56,28 +60,6 @@ function forum_enable() {
|
|||
);
|
||||
field_create_field($field);
|
||||
|
||||
$instance = array(
|
||||
'field_name' => 'taxonomy_' . $vocabulary->machine_name,
|
||||
'entity_type' => 'node',
|
||||
'label' => $vocabulary->name,
|
||||
'bundle' => 'forum',
|
||||
'required' => TRUE,
|
||||
'widget' => array(
|
||||
'type' => 'options_select',
|
||||
),
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'type' => 'taxonomy_term_reference_link',
|
||||
'weight' => 10,
|
||||
),
|
||||
'teaser' => array(
|
||||
'type' => 'taxonomy_term_reference_link',
|
||||
'weight' => 10,
|
||||
),
|
||||
),
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
||||
variable_set('forum_nav_vocabulary', $vocabulary->vid);
|
||||
|
||||
// Create a default forum so forum posts can be created.
|
||||
|
@ -90,6 +72,30 @@ function forum_enable() {
|
|||
$term = (object) $edit;
|
||||
taxonomy_term_save($term);
|
||||
}
|
||||
|
||||
// Create the instance on the bundle.
|
||||
$instance = array(
|
||||
'field_name' => 'taxonomy_' . $vocabulary->machine_name,
|
||||
'entity_type' => 'node',
|
||||
'label' => $vocabulary->name,
|
||||
'bundle' => 'forum',
|
||||
'required' => TRUE,
|
||||
'widget' => array(
|
||||
'type' => 'options_select',
|
||||
),
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'type' => 'taxonomy_term_reference_link',
|
||||
'weight' => 10,
|
||||
),
|
||||
'teaser' => array(
|
||||
'type' => 'taxonomy_term_reference_link',
|
||||
'weight' => 10,
|
||||
),
|
||||
),
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
||||
// Ensure the forum node type is available.
|
||||
node_types_rebuild();
|
||||
$types = node_type_get_types();
|
||||
|
|
|
@ -218,7 +218,7 @@ class ModuleDependencyTestCase extends ModuleTestCase {
|
|||
$edit = array();
|
||||
$edit['modules[Core][translation][enable]'] = 'translation';
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertText(t('Some required modules must be enabled'), t('Dependecy required.'));
|
||||
$this->assertText(t('Some required modules must be enabled'), t('Dependency required.'));
|
||||
|
||||
$this->assertModules(array('translation', 'locale'), FALSE);
|
||||
|
||||
|
@ -285,6 +285,39 @@ class ModuleDependencyTestCase extends ModuleTestCase {
|
|||
$this->assertModules(array('comment'), TRUE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests re-enabling forum with taxonomy disabled.
|
||||
*/
|
||||
function testEnableForumTaxonomyFieldDependency() {
|
||||
// Enable the forum module.
|
||||
$edit = array();
|
||||
$edit['modules[Core][forum][enable]'] = 'forum';
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertModules(array('forum'), TRUE);
|
||||
|
||||
// Disable the forum module.
|
||||
$edit = array();
|
||||
$edit['modules[Core][forum][enable]'] = FALSE;
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertModules(array('forum'), FALSE);
|
||||
|
||||
// Disable the taxonomy module.
|
||||
$edit = array();
|
||||
$edit['modules[Core][taxonomy][enable]'] = FALSE;
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertModules(array('taxonomy'), FALSE);
|
||||
|
||||
// Attempt to re-enable the forum module with taxonomy disabled and ensure
|
||||
// forum does not try to recreate the taxonomy_forums field.
|
||||
$edit = array();
|
||||
$edit['modules[Core][forum][enable]'] = 'forum';
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertText(t('Some required modules must be enabled'), t('Dependency required.'));
|
||||
$this->drupalPost(NULL, NULL, t('Continue'));
|
||||
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
||||
$this->assertModules(array('taxonomy', 'forum'), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue