Enabled Aggregator module. I added a couple feeds and then deleted one. After this I see the message on every page:

notice: Undefined variable: result in modules/aggregator/aggregator.module on line 353.

Comments

pwolanin’s picture

Version: 7.x-dev » 6.x-dev

so far I can't reproduce on 7.x, so this may be a 6.x bug.

pwolanin’s picture

Version: 6.x-dev » 7.x-dev

Now can reproduce - an extra step is needed:

Before deleting the feed enable the block specific to that feed.

Once the feed is deleted this notice appears but then the block does not appear in the blocks UI at admin/build/block, but the notice appears on every page.

The error is in function aggregator_block() - the cause may be that the block corresponding to that feed is not deleted from the {blocks} table.

If you visit the admin/build/block page then the blocks are rebuilt and the notice goes away.

pwolanin’s picture

Basically the same thing happens if you delete a category which has an enabled block:

notice: Undefined variable: result in modules/aggregator/aggregator.module on line 337.
pwolanin’s picture

The code from hook_block shows how the block deltas are built:

      $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
      while ($category = db_fetch_object($result)) {
        $block['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
      }
      $result = db_query('SELECT fid, title FROM {aggregator_feed} ORDER BY fid');
      while ($feed = db_fetch_object($result)) {
        $block['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
      }
pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

Patch attached for 7.x. Initial tests suggests that it resolves the bug. The 6.x backport should be simple- just change the spacing of the concat.

mustafau’s picture

Title: notice after deleting aggregator feed » Notice after deleting aggregator feed
StatusFileSize
new1.19 KB

I believe this should be fixed using block.module function _block_rehash(). I working patch is attached.

pwolanin’s picture

by convention the "_" means that this is not really a public function. Basically block module is broken is as much as it does not offer a readily available public function for this purpose. We can use it for D6, but perhaps we should reform block module a little for D7.

dries’s picture

Personally, I think pwolanin's approach is slightly cleaner (direct SQL query instead of calling an internal function).

mustafau’s picture

StatusFileSize
new1.29 KB

Re-roll of the patch from #5.

Does this need some tests?

dries’s picture

Status: Needs review » Fixed

I think this one can go in without a test. I've committed this to CVS HEAD and DRUPAL-6. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.