diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-28 23:08:34 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-04-28 23:08:34 -0700 |
commit | 060eb35f0ae4cde353a0048a6da0818b2fd5fb35 (patch) | |
tree | c10e675df649e6023019056bdaf26a88083bfe2c /modules/aggregator | |
parent | e03e94f41e51f043be44daeadb090df3b92de929 (diff) | |
download | brdo-060eb35f0ae4cde353a0048a6da0818b2fd5fb35.tar.gz brdo-060eb35f0ae4cde353a0048a6da0818b2fd5fb35.tar.bz2 |
Issue #1058754 by Yaron Tal, kathyh, naxoc, xjm, tim.plunkett: Fixed Attempt to loop through undefined result set in aggregator.
Diffstat (limited to 'modules/aggregator')
-rw-r--r-- | modules/aggregator/aggregator.module | 8 | ||||
-rw-r--r-- | modules/aggregator/aggregator.test | 10 |
2 files changed, 16 insertions, 2 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index d320328ef..686f4248a 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -397,6 +397,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()) { @@ -414,9 +415,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. diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index 5609d68ae..77b60cb93 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -848,6 +848,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.'); } /** |