Commit f6ca0153 authored by webchick's avatar webchick
Browse files

#986296 by blup, tstoeckler, Damien Tournoud, carlos8f: Fixed...

#986296 by blup, tstoeckler, Damien Tournoud, carlos8f: Fixed _node_types_build() accidentally marks node types as disabled
parent f735aa35
......@@ -711,10 +711,10 @@ function _node_types_build($rebuild = FALSE) {
// Types defined by the node module in the database (rather than by a separate
// module using hook_node_info) have a base value of 'node_content'. The isset()
// check prevents errors on old (pre-Drupal 7) databases.
if (isset($type_object->base) && $type_object->base != 'node_content' && empty($info_array[$type_db])) {
if (isset($type_object->base) && $type_object->base != 'node_content' && empty($_node_types->types[$type_db])) {
$type_object->disabled = TRUE;
}
if (isset($info_array[$type_db])) {
if (isset($_node_types->types[$type_db])) {
$type_object->disabled = FALSE;
}
if (!isset($_node_types->types[$type_db]) || $type_object->modified) {
......
......@@ -1220,6 +1220,54 @@ class NodeTypeTestCase extends DrupalWebTestCase {
$this->drupalGet('node/add/bar');
$this->assertNoRaw('Body', t('Body field was not found.'));
}
/**
* Test that node_types_rebuild() correctly handles the 'disabled' flag.
*/
function testNodeTypeStatus() {
// Enable all core node modules, and all types should be active.
module_enable(array('blog', 'book', 'poll'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
foreach (array('blog', 'book', 'poll', 'article', 'page') as $type) {
$this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type)));
}
// Disable poll module and the respective type should be marked as disabled.
module_disable(array('poll'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
$this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type disabled."));
$this->assertTrue(isset($types['blog']) && empty($types['blog']->disabled), t("Blog module's node type still active."));
// Disable blog module and the respective type should be marked as disabled.
module_disable(array('blog'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
$this->assertTrue(!empty($types['blog']->disabled), t("Blog module's node type disabled."));
$this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type still disabled."));
// Disable book module and the respective type should still be active, since
// it is not provided by hook_node_info().
module_disable(array('book'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
$this->assertTrue(isset($types['book']) && empty($types['book']->disabled), t("Book module's node type still active."));
$this->assertTrue(!empty($types['blog']->disabled), t("Blog module's node type still disabled."));
$this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type still disabled."));
$this->assertTrue(isset($types['article']) && empty($types['article']->disabled), t("Article node type still active."));
$this->assertTrue(isset($types['page']) && empty($types['page']->disabled), t("Basic page node type still active."));
// Re-enable the modules and verify that the types are active again.
module_enable(array('blog', 'book', 'poll'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
foreach (array('blog', 'book', 'poll', 'article', 'page') as $type) {
$this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type)));
}
}
}
/**
......
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