Commit b3cf0681 authored by catch's avatar catch
Browse files

Issue #375397 by sun, Xano, Rob Loach: Make Node module optional.

parent 25043d96
...@@ -7367,7 +7367,11 @@ function drupal_flush_all_caches() { ...@@ -7367,7 +7367,11 @@ function drupal_flush_all_caches() {
system_rebuild_theme_data(); system_rebuild_theme_data();
drupal_theme_rebuild(); drupal_theme_rebuild();
node_types_rebuild(); // @todo D8: Split cache flushing from rebuilding.
// @see http://drupal.org/node/996236
if (module_exists('node')) {
node_types_rebuild();
}
// node_menu() defines menu items based on node types so it needs to come // node_menu() defines menu items based on node types so it needs to come
// after node types are rebuilt. // after node types are rebuilt.
menu_rebuild(); menu_rebuild();
......
...@@ -520,11 +520,6 @@ function module_disable($module_list, $disable_dependents = TRUE) { ...@@ -520,11 +520,6 @@ function module_disable($module_list, $disable_dependents = TRUE) {
foreach ($module_list as $module) { foreach ($module_list as $module) {
if (module_exists($module)) { if (module_exists($module)) {
// Check if node_access table needs rebuilding.
if (!node_access_needs_rebuild() && module_hook($module, 'node_grants')) {
node_access_needs_rebuild(TRUE);
}
module_load_install($module); module_load_install($module);
module_invoke($module, 'disable'); module_invoke($module, 'disable');
db_update('system') db_update('system')
...@@ -549,12 +544,6 @@ function module_disable($module_list, $disable_dependents = TRUE) { ...@@ -549,12 +544,6 @@ function module_disable($module_list, $disable_dependents = TRUE) {
registry_update(); registry_update();
_system_update_bootstrap_status(); _system_update_bootstrap_status();
} }
// If there remains no more node_access module, rebuilding will be
// straightforward, we can do it right now.
if (node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) {
node_access_rebuild();
}
} }
/** /**
......
...@@ -16,7 +16,7 @@ function drupal_path_initialize() { ...@@ -16,7 +16,7 @@ function drupal_path_initialize() {
// Ensure $_GET['q'] is set before calling drupal_normal_path(), to support // Ensure $_GET['q'] is set before calling drupal_normal_path(), to support
// path caching with hook_url_inbound_alter(). // path caching with hook_url_inbound_alter().
if (empty($_GET['q'])) { if (empty($_GET['q'])) {
$_GET['q'] = variable_get('site_frontpage', 'node'); $_GET['q'] = variable_get('site_frontpage', 'user');
} }
$_GET['q'] = drupal_get_normal_path($_GET['q']); $_GET['q'] = drupal_get_normal_path($_GET['q']);
} }
...@@ -292,7 +292,7 @@ function drupal_is_front_page() { ...@@ -292,7 +292,7 @@ function drupal_is_front_page() {
if (!isset($is_front_page)) { if (!isset($is_front_page)) {
// As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path, // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
// we can check it against the 'site_frontpage' variable. // we can check it against the 'site_frontpage' variable.
$is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'node')); $is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'user'));
} }
return $is_front_page; return $is_front_page;
...@@ -323,7 +323,7 @@ function drupal_match_path($path, $patterns) { ...@@ -323,7 +323,7 @@ function drupal_match_path($path, $patterns) {
$replacements = array( $replacements = array(
'|', '|',
'.*', '.*',
'\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2' '\1' . preg_quote(variable_get('site_frontpage', 'user'), '/') . '\2'
); );
$patterns_quoted = preg_quote($patterns, '/'); $patterns_quoted = preg_quote($patterns, '/');
$regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/'; $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
......
...@@ -3,6 +3,7 @@ description = Allows users to create and organize related content in an outline. ...@@ -3,6 +3,7 @@ description = Allows users to create and organize related content in an outline.
package = Core package = Core
version = VERSION version = VERSION
core = 8.x core = 8.x
dependencies[] = node
files[] = book.test files[] = book.test
configure = admin/content/book/settings configure = admin/content/book/settings
stylesheets[all][] = book.theme.css stylesheets[all][] = book.theme.css
...@@ -3,6 +3,7 @@ description = Allows users to comment on and discuss published content. ...@@ -3,6 +3,7 @@ description = Allows users to comment on and discuss published content.
package = Core package = Core
version = VERSION version = VERSION
core = 8.x core = 8.x
dependencies[] = node
dependencies[] = text dependencies[] = text
dependencies[] = entity dependencies[] = entity
files[] = comment.entity.inc files[] = comment.entity.inc
......
...@@ -18,6 +18,7 @@ class FieldUITestCase extends DrupalWebTestCase { ...@@ -18,6 +18,7 @@ class FieldUITestCase extends DrupalWebTestCase {
if (isset($modules[0]) && is_array($modules[0])) { if (isset($modules[0]) && is_array($modules[0])) {
$modules = $modules[0]; $modules = $modules[0];
} }
$modules[] = 'node';
$modules[] = 'field_ui'; $modules[] = 'field_ui';
$modules[] = 'field_test'; $modules[] = 'field_test';
$modules[] = 'taxonomy'; $modules[] = 'taxonomy';
......
name = Forum name = Forum
description = Provides discussion forums. description = Provides discussion forums.
dependencies[] = node
dependencies[] = taxonomy dependencies[] = taxonomy
dependencies[] = comment dependencies[] = comment
package = Core package = Core
......
...@@ -43,7 +43,10 @@ function help_help($path, $arg) { ...@@ -43,7 +43,10 @@ function help_help($path, $arg) {
$output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/config'))) . '</li>'; $output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/config'))) . '</li>';
$output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/modules'), '@download_modules' => 'http://drupal.org/project/modules')) . '</li>'; $output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/modules'), '@download_modules' => 'http://drupal.org/project/modules')) . '</li>';
$output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/appearance'), '@download_themes' => 'http://drupal.org/project/themes')) . '</li>'; $output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/appearance'), '@download_themes' => 'http://drupal.org/project/themes')) . '</li>';
$output .= '<li>' . t('<strong>Start posting content</strong> Finally, you can <a href="@content">add new content</a> for your website.', array('@content' => url('node/add'))) . '</li>'; // Display a link to the create content page if Node module is enabled.
if (module_exists('node')) {
$output .= '<li>' . t('<strong>Start posting content</strong> Finally, you can <a href="@content">add new content</a> for your website.', array('@content' => url('node/add'))) . '</li>';
}
$output .= '</ol>'; $output .= '</ol>';
$output .= '<p>' . t('For more information, refer to the specific topics listed in the next section or to the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a> or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/handbooks', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) . '</p>'; $output .= '<p>' . t('For more information, refer to the specific topics listed in the next section or to the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a> or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/handbooks', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) . '</p>';
return $output; return $output;
......
...@@ -73,9 +73,11 @@ function locale_uninstall() { ...@@ -73,9 +73,11 @@ function locale_uninstall() {
variable_del("locale_language_providers_weight_$type"); variable_del("locale_language_providers_weight_$type");
} }
foreach (node_type_get_types() as $type => $content_type) { // Remove all node type language variables. Node module might have been
$setting = variable_del("language_content_type_$type"); // enabled, but may be disabled, so use a wildcard delete.
} db_delete('variable')
->condition('name', db_like('language_content_type_') . '%', 'LIKE')
->execute();
} }
/** /**
......
...@@ -5,7 +5,6 @@ version = VERSION ...@@ -5,7 +5,6 @@ version = VERSION
core = 8.x core = 8.x
files[] = node.module files[] = node.module
files[] = node.test files[] = node.test
required = TRUE
dependencies[] = entity dependencies[] = entity
configure = admin/structure/types configure = admin/structure/types
stylesheets[all][] = node.css stylesheets[all][] = node.css
...@@ -443,6 +443,38 @@ function node_install() { ...@@ -443,6 +443,38 @@ function node_install() {
->execute(); ->execute();
} }
/**
* Implements hook_uninstall().
*/
function node_uninstall() {
// Delete node type variables.
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
db_delete('variable')
->condition(db_or()
->condition('name', 'node_preview_' . $type)
->condition('name', 'node_options_' . $type)
->condition('name', 'node_submitted_' . $type)
->condition('name', 'node_permissions_' . $type)
)
->execute();
}
// Delete node search ranking variables.
// @see node_ranking(), _node_rankings()
variable_del('node_rank_relevance');
variable_del('node_rank_sticky');
variable_del('node_rank_promote');
variable_del('node_rank_recent');
// Delete remaining general module variables.
variable_del('node_access_needs_rebuild');
variable_del('node_admin_theme');
variable_del('node_cron_last');
variable_del('node_recent_block_count');
variable_del('default_nodes_main');
}
/** /**
* Fetches node types directly from the database. * Fetches node types directly from the database.
* *
...@@ -469,3 +501,30 @@ function _update_7000_node_get_types() { ...@@ -469,3 +501,30 @@ function _update_7000_node_get_types() {
} }
return $node_types; return $node_types;
} }
/**
* @addtogroup updates-7.x-to-8.x
* @{
*/
/**
* Set 'node' as front page path if it implicitly was before.
*
* Node module became optional. The default front page path was changed to
* 'user'. Since 'node' was the implicit default front page path previously and
* may not have been explicitly configured as such, this update ensures that the
* old implicit default is still the default.
*
* @see http://drupal.org/node/375397
*/
function node_update_8000() {
$front_page = variable_get('site_frontpage');
if (!isset($front_page)) {
variable_set('site_frontpage', 'node');
}
}
/**
* @} End of "addtogroup updates-7.x-to-8.x"
* The next series of updates should start at 9000.
*/
...@@ -2895,6 +2895,31 @@ function node_search_validate($form, &$form_state) { ...@@ -2895,6 +2895,31 @@ function node_search_validate($form, &$form_state) {
} }
} }
/**
* Implements hook_form_FORM_ID_alter().
*
* Alters the theme form to use the admin theme on node editing.
*
* @see node_form_system_themes_admin_form_submit()
*/
function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id) {
$form['admin_theme']['node_admin_theme'] = array(
'#type' => 'checkbox',
'#title' => t('Use the administration theme when editing or creating content'),
'#default_value' => variable_get('node_admin_theme', '0'),
);
$form['#submit'][] = 'node_form_system_themes_admin_form_submit';
}
/**
* Form submission handler for system_themes_admin_form().
*
* @see node_form_system_themes_admin_form_alter()
*/
function node_form_system_themes_admin_form_submit($form, &$form_state) {
variable_set('node_admin_theme', $form_state['values']['node_admin_theme']);
}
/** /**
* @defgroup node_access Node access rights * @defgroup node_access Node access rights
* @{ * @{
...@@ -4080,6 +4105,28 @@ function node_modules_enabled($modules) { ...@@ -4080,6 +4105,28 @@ function node_modules_enabled($modules) {
} }
} }
/**
* Implements hook_modules_disabled().
*/
function node_modules_disabled($modules) {
// Check whether any of the disabled modules implemented hook_node_grants(),
// in which case the node access table needs to be rebuilt.
foreach ($modules as $module) {
// At this point, the module is already disabled, but its code is still
// loaded in memory. Module functions must no longer be called. We only
// check whether a hook implementation function exists and do not invoke it.
if (!node_access_needs_rebuild() && module_hook($module, 'node_grants')) {
node_access_needs_rebuild(TRUE);
}
}
// If there remains no more node_access module, rebuilding will be
// straightforward, we can do it right now.
if (node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) {
node_access_rebuild();
}
}
/** /**
* Controller class for nodes. * Controller class for nodes.
* *
......
...@@ -635,7 +635,7 @@ function overlay_overlay_parent_initialize() { ...@@ -635,7 +635,7 @@ function overlay_overlay_parent_initialize() {
// Let the client side know which paths are administrative. // Let the client side know which paths are administrative.
$paths = path_get_admin_paths(); $paths = path_get_admin_paths();
foreach ($paths as &$type) { foreach ($paths as &$type) {
$type = str_replace('<front>', variable_get('site_frontpage', 'node'), $type); $type = str_replace('<front>', variable_get('site_frontpage', 'user'), $type);
} }
drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting'); drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting');
// Pass along the Ajax callback for rerendering sections of the parent window. // Pass along the Ajax callback for rerendering sections of the parent window.
......
...@@ -3,5 +3,6 @@ description = Allows your site to capture votes on different topics in the form ...@@ -3,5 +3,6 @@ description = Allows your site to capture votes on different topics in the form
package = Core package = Core
version = VERSION version = VERSION
core = 8.x core = 8.x
dependencies[] = node
files[] = poll.test files[] = poll.test
stylesheets[all][] = poll.css stylesheets[all][] = poll.css
...@@ -4,3 +4,4 @@ package = Testing ...@@ -4,3 +4,4 @@ package = Testing
version = VERSION version = VERSION
core = 8.x core = 8.x
hidden = TRUE hidden = TRUE
dependencies[] = rdf
...@@ -13,18 +13,19 @@ function shortcut_install() { ...@@ -13,18 +13,19 @@ function shortcut_install() {
// Create an initial default shortcut set. // Create an initial default shortcut set.
$shortcut_set = new stdClass(); $shortcut_set = new stdClass();
$shortcut_set->title = $t('Default'); $shortcut_set->title = $t('Default');
$shortcut_set->links = array( $shortcut_set->links = array();
array( if (module_exists('node')) {
$shortcut_set->links[] = array(
'link_path' => 'node/add', 'link_path' => 'node/add',
'link_title' => $t('Add content'), 'link_title' => $t('Add content'),
'weight' => -20, 'weight' => -20,
), );
array( $shortcut_set->links[] = array(
'link_path' => 'admin/content', 'link_path' => 'admin/content',
'link_title' => $t('Find content'), 'link_title' => $t('Find content'),
'weight' => -19, 'weight' => -19,
), );
); }
// If Drupal is being installed, rebuild the menu before saving the shortcut // If Drupal is being installed, rebuild the menu before saving the shortcut
// set, to make sure the links defined above can be correctly saved. (During // set, to make sure the links defined above can be correctly saved. (During
// installation, the menu might not have been built at all yet, or it might // installation, the menu might not have been built at all yet, or it might
......
...@@ -19,7 +19,12 @@ class DatabaseTestCase extends DrupalWebTestCase { ...@@ -19,7 +19,12 @@ class DatabaseTestCase extends DrupalWebTestCase {
protected $profile = 'testing'; protected $profile = 'testing';
function setUp() { function setUp() {
parent::setUp('database_test'); $modules = func_get_args();
if (isset($modules[0]) && is_array($modules[0])) {
$modules = $modules[0];
}
$modules[] = 'database_test';
parent::setUp($modules);
$schema['test'] = drupal_get_schema('test'); $schema['test'] = drupal_get_schema('test');
$schema['test_people'] = drupal_get_schema('test_people'); $schema['test_people'] = drupal_get_schema('test_people');
...@@ -377,10 +382,6 @@ class DatabaseFetch2TestCase extends DatabaseTestCase { ...@@ -377,10 +382,6 @@ class DatabaseFetch2TestCase extends DatabaseTestCase {
); );
} }
function setUp() {
parent::setUp();
}
// Confirm that we can fetch a record into an indexed array explicitly. // Confirm that we can fetch a record into an indexed array explicitly.
function testQueryFetchNum() { function testQueryFetchNum() {
$records = array(); $records = array();
...@@ -2218,24 +2219,14 @@ class DatabaseSelectComplexTestCase2 extends DatabaseTestCase { ...@@ -2218,24 +2219,14 @@ class DatabaseSelectComplexTestCase2 extends DatabaseTestCase {
} }
function setUp() { function setUp() {
DrupalWebTestCase::setUp('database_test', 'node_access_test'); parent::setUp(array('node_access_test'));
$schema['test'] = drupal_get_schema('test');
$schema['test_people'] = drupal_get_schema('test_people');
$schema['test_one_blob'] = drupal_get_schema('test_one_blob');
$schema['test_two_blobs'] = drupal_get_schema('test_two_blobs');
$schema['test_task'] = drupal_get_schema('test_task');
$this->installTables($schema);
$this->addSampleData();
} }
/** /**
* Test that we can join on a query. * Test that we can join on a query.
*/ */
function testJoinSubquery() { function testJoinSubquery() {
$acct = $this->drupalCreateUser(array('access content')); $acct = $this->drupalCreateUser();
$this->drupalLogin($acct); $this->drupalLogin($acct);
$query = db_select('test_task', 'tt', array('target' => 'slave')); $query = db_select('test_task', 'tt', array('target' => 'slave'));
...@@ -2754,6 +2745,10 @@ class DatabaseRegressionTestCase extends DatabaseTestCase { ...@@ -2754,6 +2745,10 @@ class DatabaseRegressionTestCase extends DatabaseTestCase {
); );
} }
function setUp() {
parent::setUp(array('node'));
}
/** /**
* Regression test for #310447. * Regression test for #310447.
* *
...@@ -3045,10 +3040,6 @@ class DatabaseBasicSyntaxTestCase extends DatabaseTestCase { ...@@ -3045,10 +3040,6 @@ class DatabaseBasicSyntaxTestCase extends DatabaseTestCase {
); );
} }
function setUp() {
parent::setUp('database_test');
}
/** /**
* Test for string concatenation. * Test for string concatenation.
*/ */
...@@ -3146,10 +3137,6 @@ class DatabaseInvalidDataTestCase extends DatabaseTestCase { ...@@ -3146,10 +3137,6 @@ class DatabaseInvalidDataTestCase extends DatabaseTestCase {
); );
} }
function setUp() {
parent::setUp('database_test');
}
/** /**
* Traditional SQL database systems abort inserts when invalid data is encountered. * Traditional SQL database systems abort inserts when invalid data is encountered.
*/ */
...@@ -3219,10 +3206,6 @@ class DatabaseQueryTestCase extends DatabaseTestCase { ...@@ -3219,10 +3206,6 @@ class DatabaseQueryTestCase extends DatabaseTestCase {
); );
} }
function setUp() {
parent::setUp('database_test');
}
/** /**
* Test that we can specify an array of values in the query by simply passing in an array. * Test that we can specify an array of values in the query by simply passing in an array.
*/ */
......
...@@ -66,7 +66,8 @@ class ThemeUnitTest extends DrupalWebTestCase { ...@@ -66,7 +66,8 @@ class ThemeUnitTest extends DrupalWebTestCase {
$q = $_GET['q']; $q = $_GET['q'];
// Set $_GET['q'] to node because theme_get_suggestions() will query it to // Set $_GET['q'] to node because theme_get_suggestions() will query it to
// see if we are on the front page. // see if we are on the front page.
$_GET['q'] = variable_get('site_frontpage', 'node'); variable_set('site_frontpage', 'node');
$_GET['q'] = 'node';
$suggestions = theme_get_suggestions(explode('/', $_GET['q']), 'page'); $suggestions = theme_get_suggestions(explode('/', $_GET['q']), 'page');
// Set it back to not annoy the batch runner. // Set it back to not annoy the batch runner.
$_GET['q'] = $q; $_GET['q'] = $q;
...@@ -264,7 +265,7 @@ class ThemeFunctionsTestCase extends DrupalWebTestCase { ...@@ -264,7 +265,7 @@ class ThemeFunctionsTestCase extends DrupalWebTestCase {
// Required to verify the "active" class in expected links below, and // Required to verify the "active" class in expected links below, and
// because the current path is different when running tests manually via // because the current path is different when running tests manually via
// simpletest.module ('batch') and via the testing framework (''). // simpletest.module ('batch') and via the testing framework ('').
$_GET['q'] = variable_get('site_frontpage', 'node'); $_GET['q'] = variable_get('site_frontpage', 'user');
// Verify that a list of links is properly rendered. // Verify that a list of links is properly rendered.
$variables = array(); $variables = array();
......
...@@ -26,14 +26,14 @@ function theme_test_menu() { ...@@ -26,14 +26,14 @@ function theme_test_menu() {
$items['theme-test/suggestion'] = array( $items['theme-test/suggestion'] = array(
'title' => 'Suggestion', 'title' => 'Suggestion',
'page callback' => '_theme_test_suggestion', 'page callback' => '_theme_test_suggestion',
'access arguments' => array('access content'), 'access callback' => TRUE,
'theme callback' => '_theme_custom_theme', 'theme callback' => '_theme_custom_theme',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
); );
$items['theme-test/alter'] = array( $items['theme-test/alter'] = array(
'title' => 'Suggestion', 'title' => 'Suggestion',
'page callback' => '_theme_test_alter', 'page callback' => '_theme_test_alter',
'access arguments' => array('access content'), 'access callback' => TRUE,
'theme callback' => '_theme_custom_theme', 'theme callback' => '_theme_custom_theme',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
); );
......
<