summaryrefslogtreecommitdiff
path: root/modules/block
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2011-08-26 10:09:12 +0100
committerDries Buytaert <dries@buytaert.net>2011-08-26 10:09:12 +0100
commitd70426b221c517b86e25d993853fca447ab789e5 (patch)
tree2abbe1a1fb6dcb7f5214ef3451742283f7341938 /modules/block
parent8009b45f19e22405168c1e65c3df91e61b0f746c (diff)
downloadbrdo-d70426b221c517b86e25d993853fca447ab789e5.tar.gz
brdo-d70426b221c517b86e25d993853fca447ab789e5.tar.bz2
- Patch #1078176 by franz, agentrickard: block module renders blocks that are set to display on no pages.
Diffstat (limited to 'modules/block')
-rw-r--r--modules/block/block.module6
-rw-r--r--modules/block/block.test43
2 files changed, 49 insertions, 0 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index b2a3f0522..4f498d3c6 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -761,6 +761,12 @@ function block_block_list_alter(&$blocks) {
else {
$enabled = TRUE;
}
+
+ // Limited visibility blocks must list at least one page.
+ if ($block->visibility == BLOCK_VISIBILITY_LISTED && empty($block->pages)) {
+ $enabled = FALSE;
+ }
+
if (!$enabled) {
unset($blocks[$key]);
continue;
diff --git a/modules/block/block.test b/modules/block/block.test
index 022bf3830..03f3048b4 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -193,6 +193,49 @@ class BlockTestCase extends DrupalWebTestCase {
}
/**
+ * Test block visibility when using "pages" restriction but leaving
+ * "pages" textarea empty
+ */
+ function testBlockVisibilityListedEmpty() {
+ $block = array();
+
+ // Create a random title for the block
+ $title = $this->randomName(8);
+
+ // Create the custom block
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $title;
+ $custom_block['body[value]'] = $this->randomName(32);
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $block['module'] = 'block';
+ $block['delta'] = $bid;
+ $block['title'] = $title;
+
+ // Move block to the first sidebar.
+ $this->moveBlockToRegion($block, $this->regions[1]);
+
+ // Set the block to be hidden on any user path, and to be shown only to
+ // authenticated users.
+ $edit = array();
+ $edit['visibility'] = BLOCK_VISIBILITY_LISTED;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ $this->drupalGet('');
+ $this->assertNoText($title, t('Block was not displayed according to block visibility rules.'));
+
+ $this->drupalGet('user');
+ $this->assertNoText($title, t('Block was not displayed according to block visibility rules regardless of path case.'));
+
+ // Confirm that the block is not displayed to anonymous users.
+ $this->drupalLogout();
+ $this->drupalGet('');
+ $this->assertNoText($title, t('Block was not displayed to anonymous users.'));
+ }
+
+ /**
* Test user customization of block visibility.
*/
function testBlockVisibilityPerUser() {