Commit e8b9f3b4 authored by catch's avatar catch
Browse files

Issue #1058754 by Yaron Tal, kathyh, naxoc, xjm: Fixed attempt to loop through...

Issue #1058754 by Yaron Tal, kathyh, naxoc, xjm: Fixed attempt to loop through undefined result set in aggregator.
parent 32c1b1e6
......@@ -396,6 +396,7 @@ function aggregator_block_view($delta = '') {
if (user_access('access news feeds')) {
$block = array();
list($type, $id) = explode('-', $delta);
$result = FALSE;
switch ($type) {
case 'feed':
if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) {
......@@ -413,9 +414,12 @@ function aggregator_block_view($delta = '') {
}
break;
}
$items = array();
foreach ($result as $item) {
$items[] = theme('aggregator_block_item', array('item' => $item));
if (!empty($result)) {
foreach ($result as $item) {
$items[] = theme('aggregator_block_item', array('item' => $item));
}
}
// Only display the block if there are items to show.
......
......@@ -887,6 +887,16 @@ class AggregatorRenderingTestCase extends AggregatorTestCase {
$this->drupalGet($href);
$correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->title));
$this->assertFalse(empty($correct_titles), t('Aggregator feed page is available and has the correct title.'));
// Set the number of news items to 0 to test that the block does not show
// up.
$feed->block = 0;
aggregator_save_feed((array) $feed);
// It is nescessary to flush the cache after saving the number of items.
drupal_flush_all_caches();
// Check that the block is no longer displayed.
$this->drupalGet('node');
$this->assertNoText(t($block['title']), 'Feed block is not displayed on the page when number of items is set to 0.');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment