summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/node/node.admin.inc5
-rw-r--r--modules/node/node.test6
2 files changed, 9 insertions, 2 deletions
diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc
index fe8636dc9..18e3312f6 100644
--- a/modules/node/node.admin.inc
+++ b/modules/node/node.admin.inc
@@ -439,6 +439,7 @@ function node_admin_nodes() {
'#type' => 'submit',
'#value' => t('Update'),
'#submit' => array('node_admin_nodes_submit'),
+ '#validate' => array('node_admin_nodes_validate'),
);
$languages = language_list();
@@ -475,8 +476,8 @@ function node_admin_nodes() {
* 'Update option' on.
*/
function node_admin_nodes_validate($form, &$form_state) {
- $nodes = array_filter($form_state['values']['nodes']);
- if (count($nodes) == 0) {
+ // Error if there are no items to select.
+ if (!is_array($form_state['values']['nodes']) || !count(array_filter($form_state['values']['nodes']))) {
form_set_error('', t('No items selected.'));
}
}
diff --git a/modules/node/node.test b/modules/node/node.test
index 71a39801c..016ce5619 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -967,6 +967,9 @@ class NodeAdminTestCase extends DrupalWebTestCase {
* Create 3 nodes and test if they are listed on the node admistration page.
*/
function testNodeAdmin() {
+ $this->drupalPost('admin/content', array(), t('Update'));
+ $this->assertText(t('No items selected.'), t('Clicking update with no nodes displays error message on the node administration listing.'));
+
$node1 = $this->drupalCreateNode(array('type' => 'article', 'status' => 1));
$node2 = $this->drupalCreateNode(array('type' => 'article', 'status' => 0));
$node3 = $this->drupalCreateNode(array('type' => 'page'));
@@ -974,6 +977,9 @@ class NodeAdminTestCase extends DrupalWebTestCase {
$this->drupalGet('admin/content');
$this->assertText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], t('Node appears on the node administration listing.'));
+ $this->drupalPost('admin/content', array(), t('Update'));
+ $this->assertText(t('No items selected.'), t('Clicking update with no selected nodes displays error message on the node administration listing.'));
+
// Filter the node listing by status.
$edit = array(
'filter' => 'status',