diff options
author | David Rothstein <drothstein@gmail.com> | 2013-03-30 13:01:03 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-03-30 13:01:03 -0400 |
commit | 5177237f58d129f9348af723de886168f73f6a43 (patch) | |
tree | 5ed57d6f1b4639956e9bbf33c9c16aca38b3b60d | |
parent | 20a45b1117e28f4458fd72de81eb8ec0173d9b99 (diff) | |
download | brdo-5177237f58d129f9348af723de886168f73f6a43.tar.gz brdo-5177237f58d129f9348af723de886168f73f6a43.tar.bz2 |
Issue #1429442 by Jody Lynn, mathankumarc, gnuget, nrambeck, dcam | sun: Fixed Access denied page shown after submitting form that creates a unpublished node.
-rw-r--r-- | CHANGELOG.txt | 3 | ||||
-rw-r--r-- | modules/forum/forum.test | 1 | ||||
-rw-r--r-- | modules/node/node.pages.inc | 2 | ||||
-rw-r--r-- | modules/node/node.test | 19 |
4 files changed, 24 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 71dc76988..0f017bf6f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,9 @@ Drupal 7.22, xxxx-xx-xx (development version) ----------------------- +- Changed the default behavior after a user creates a node they do not have + access to view. The user will now be redirected to the front page rather than + an access denied page. - Fixed a bug which prevented empty HTTP headers (such as "0") from being set. (Minor behavior change: Callers of drupal_add_http_header() must now set FALSE explicitly to prevent a header from being sent at all; this was already diff --git a/modules/forum/forum.test b/modules/forum/forum.test index 6937c623d..a658377fe 100644 --- a/modules/forum/forum.test +++ b/modules/forum/forum.test @@ -677,6 +677,7 @@ class ForumIndexTestCase extends DrupalWebTestCase { 'status' => FALSE, ); $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save')); + $this->drupalGet("node/{$node->nid}"); $this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.'); // Verify that the node no longer appears on the index. diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index dee92e16c..75ed0ddb8 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -470,7 +470,7 @@ function node_form_submit($form, &$form_state) { if ($node->nid) { $form_state['values']['nid'] = $node->nid; $form_state['nid'] = $node->nid; - $form_state['redirect'] = 'node/' . $node->nid; + $form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '<front>'; } else { // In the unlikely case something went wrong on save, the node will be diff --git a/modules/node/node.test b/modules/node/node.test index 2180f5838..0256fecfd 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -573,6 +573,25 @@ class NodeCreationTestCase extends DrupalWebTestCase { $records = db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll(); $this->assertTrue(count($records) > 0, t('Rollback explanatory error logged to watchdog.')); } + + /** + * Create an unpublished node and confirm correct redirect behavior. + */ + function testUnpublishedNodeCreation() { + // Set "Basic page" content type to be unpublished by default. + variable_set('node_options_page', array()); + // Set the front page to the default "node" page. + variable_set('site_frontpage', 'node'); + + // Create a node. + $edit = array(); + $edit["title"] = $this->randomName(8); + $edit["body[" . LANGUAGE_NONE . "][0][value]"] = $this->randomName(16); + $this->drupalPost('node/add/page', $edit, t('Save')); + + // Check that the user was redirected to the home page. + $this->assertText(t('Welcome to Drupal'), t('The user is redirected to the home page.')); + } } /** |