diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 1991c24..7e869c7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -389,7 +389,7 @@ function _node_extract_type($node) { /** * Returns a list of a site's known node types. - + * * Any node type added by hook_node_info() or node_type_save() that has not been * explicitly removed by node_type_delete() or direct database interaction will * appear in this list. The list can include types that are queued for addition @@ -500,7 +500,7 @@ function node_type_load($name) { /** * Saves a node type to the database. * - * Modules should not implement node types with this function, but should use + * Modules should not create node types with this function, but should use * hook_node_info() instead. * * @param $info @@ -515,13 +515,13 @@ function node_type_save($info) { $type = node_type_set_defaults($info); $map = array('%type' => $type->name); if (!$type->custom && $type->base == 'node_content') { - // A module provided node type whose 'base' key is 'node_content' will not - // be automatically disabled on disabling of it's parent module. - drupal_set_message(t('The content type %type will not be disabled with its parent module.', $map), 'warning'); + // If a module provides a node type with a 'base' key of 'node_content', the + // node type will not be automatically disabled when the module is disabled. + drupal_set_message(t('The content type %type will not be disabled.', $map), 'warning'); } elseif (!$type->custom && $type->module == '') { // The content types list is built by content_types.inc using node_hook(). - // But, when the module is disabled, the [base]_form vanishes if it was + // However, when the module is disabled, the [base]_form is hidden if it was // implemented by the same module. Under this condition, one can add content // of the disabled module, but cannot manage the content type. drupal_set_message(t("The content type %type must either have 'base' key set to 'node_content' or be defined via hook_node_info().", $map), 'error'); @@ -690,34 +690,33 @@ function node_type_update_nodes($old_type, $type) { * Gets a list of all node types that were not deleted by node_type_delete(). * * This function provides the {node_type} table state as it would appear after - * a rebuild, actually rebuilding the table when $rebuild is true. The returned - * node type's disabled property indicates if the node type's implementing - * module has been disabled, however, any node type with a base value of - * 'node_content' always remains non-disabled, making Node Content a - * bad name for a module. + * a rebuild. When the $rebuild parameter is set to TRUE, the table is also + * actually rebuilt. The returned node type's 'disabled' property indicates + * whether the module that defines it has been disabled. However, any node + * type with a value of 'node_content' for the base will never be disabled. * * @param $rebuild * TRUE to rebuild {node_type} table of the database. * @return * An object with two properties: - * - names: Associative array of the names corresponding to active or + * - names: An associative array of the names corresponding to active or * disabled node types, keyed by node type. This property does not * necessarily reflect the state of the {node_type} table unless - * $rebuild is equal to true. The property is a thin version of the 'types' + * $rebuild is equal to TRUE. The property is a thin version of the 'types' * property. See below for exactly what membership in this array means. - * - types: Associative array of node type objects, keyed by node type. + * - types: An associative array of node type objects, keyed by node type. * Like the 'names' array, this data structure does not necessarily reflect * the state of the {node_type} table. The node type objects contain * fresher data. * - disabled: If {node_type}.base is equal to 'node_content', then this - * property does not vary from FALSE. Otherwise, the $type->disabled flag - * takes a value of 0 for any type in the {node_type} table whose module - * is enabled, or it takes a value of TRUE if its module is disabled - * (or possibly uninstalled). + * property is always FALSE. Otherwise, the $type->disabled flag + * takes a value of FALSE for any type in the {node_type} table whose + * module is enabled, or it takes a value of TRUE if its module is + * disabled (or possibly uninstalled). * - is_new: The $type->is_new flag does not appear in the {node_type} * table. The property gets set to TRUE for node types implemented by - * hook_node_info() that did not appear in the {node_type} table at - * _node_types_build() entry. The property is left unset otherwise. + * hook_node_info() that do not yet appear in the {node_type} table. + * The property is left unset otherwise. */ function _node_types_build($rebuild = FALSE) { $cid = 'node_types:' . $GLOBALS['language_interface']->langcode; @@ -743,17 +742,15 @@ function _node_types_build($rebuild = FALSE) { $active_types->types[$type] = node_type_set_defaults($node_info); $active_types->types[$type]->module = $module; - // Overwrite the defaults of is_new and disabled for the new active type. + // Overwrite the defaults of 'is_new' and 'disabled' for the new active + // type. $active_types->types[$type]->is_new = TRUE; $active_types->types[$type]->disabled = FALSE; - // When rebuilding, mark this type as new, to ensure it overwrites any + // When rebuilding, mark this type as new to ensure it overwrites any // existing values in the database. if ($rebuild) { $active_types->types[$type]->new_state = TRUE; } - - // Copy data to the names array. - $active_types->names[$type] = $active_types->types[$type]->name; } } @@ -764,9 +761,9 @@ function _node_types_build($rebuild = FALSE) { ->fields('nt') ->orderBy('nt.type', 'ASC') ->execute(); - // Sync the {node_type} table against the enabled modules list. Any node type - // with a base other than 'node_content' inherits its disabled state from that - // of its module. + // Synchronize the {node_type} table against the enabled modules list. Any + // node type with a base other than 'node_content' inherits its disabled state + // from that of its module. $enabled_modules = module_list(); foreach ($db_types as $db_type) { // Remove any type information from hook_node_info() from the database @@ -799,12 +796,12 @@ function _node_types_build($rebuild = FALSE) { } } - // Don't litter the return data structure with internal data. + // Do not litter the return data structure with internal data. if ($rebuild) { $active_types->types[$db_type->type]->new_state = $new_state; } - // Copy data to names array. + // Copy data to the names array. $active_types->names[$db_type->type] = $active_types->types[$db_type->type]->name; } @@ -814,8 +811,8 @@ function _node_types_build($rebuild = FALSE) { foreach ($active_types->types as $type) { if (isset($type->is_new) || isset($type->new_state)) { node_type_save($type); - // Explicitly remove the new_state flag or someone will start depending - // on unspecified behavior. + // Explicitly remove the 'new_state' flag; it is for internal API use + // only. unset($type->new_state); } } @@ -3780,7 +3777,7 @@ function _node_access_rebuild_batch_finished($success, $results, $operations) { */ function node_content_form($node, $form_state) { // It is impossible to define a content type with a base that is not - // node_content without also implementing hook_form(). + // 'node_content' without also implementing hook_form(). // @todo: remove this requirement. $form = array(); $type = node_type_get_type($node); diff --git a/core/modules/node/node.test b/core/modules/node/node.test index e1141ae..871d9b7 100644 --- a/core/modules/node/node.test +++ b/core/modules/node/node.test @@ -1449,7 +1449,7 @@ class NodeTypeTestCase extends NodeWebTestCase { } /** - * Tests handling of node type types that are undefined. + * Tests the handling of node types that are undefined. */ public function testNodeTypeDisabled() { $test_type = new stdClass(); @@ -1464,13 +1464,13 @@ class NodeTypeTestCase extends NodeWebTestCase { ->execute(); $this->assertTrue(($updated == TRUE), 'Successfully disabled custom content type.'); $info = node_type_get_type($test_type->type); - $this->assertTrue($info !== FALSE, 'Return data from node_type_get_type is valid for a disabled content type with a base that is not node_content.'); + $this->assertTrue($info !== FALSE, 'Return data from node_type_get_type() is valid for a disabled content type with a base that is not node_content().'); $target_type = 'book'; module_enable(array($target_type), FALSE); module_disable(array($target_type)); $info = node_type_get_type($target_type); - $this->assertTrue($info !== FALSE, 'Return data from node_type_get_type is valid for a disabled content type with base of node_content.'); + $this->assertTrue($info !== FALSE, 'Return data from node_type_get_type() is valid for a disabled content type with base of node_content().'); } }