Notice after deleting aggregator feed
pwolanin - June 9, 2008 - 15:49
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | aggregator.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
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.
#1
so far I can't reproduce on 7.x, so this may be a 6.x bug.
#2
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.
#3
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.#4
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));
}
#5
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.
#6
I believe this should be fixed using block.module function
_block_rehash(). I working patch is attached.#7
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.
#8
Personally, I think pwolanin's approach is slightly cleaner (direct SQL query instead of calling an internal function).
#9
Re-roll of the patch from #5.
Does this need some tests?
#10
I think this one can go in without a test. I've committed this to CVS HEAD and DRUPAL-6. Thanks.
#11
Automatically closed -- issue fixed for two weeks with no activity.