Don't use module API in hook_update_N()

killes@www.drop.org - September 14, 2009 - 11:50
Project:FeedAPI
Version:6.x-1.x-dev
Component:Code feedapi (core module)
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

feedapi_enabled_type is called in the .install file, but defined in the .module.

#1

Aron Novak - September 14, 2009 - 12:43
Status:active» needs review

Patch is attached. However i'm not glad about querying serialized data from variables table. Any better way?

This is a regression of #455688: Make refresh rate of feeds configurable

AttachmentSize
576848_update_get_types.patch 1.58 KB

#2

alex_b - September 17, 2009 - 20:01
Priority:critical» normal
Status:needs review» postponed (maintainer needs more info)

Calling feedapi_enabled_type() should be fine in hook_update_N() - killes, can you describe better the problem that has occurred?

#3

jbrauer - September 27, 2009 - 20:51
Status:postponed (maintainer needs more info)» needs review

The error reported is:

Fatal error: Call to undefined function feedapi_enabled_type() in /drupalroot/sites/all/modules/feedapi/feedapi.install on line 250

This patch seems to address that error but then it comes back in update 6107 which calls the same undefined function.

#4

jbrauer - September 27, 2009 - 21:39
Status:needs review» active

Looking at this further it seems to happen only on sites that have FeedAPI disabled, but haven't had FeedAPI uninstalled. At least on several sites in a multi-site install I've been working with. The modules directory is the same for all sites to the same code is present but only a problem on updating those sites have disabled feedapi

#5

alex_b - September 29, 2009 - 14:57
Title:feedapi_update_6106 failes with undefined function error» Don't use module API in hook_update_N()

#4: Just learned something new. I see now that the update system tries to update all modules that are available and have a schema record in system, not just enabled modules.

This means we can't use any module API functions in our updates.

Needs fixing.

#6

adrian - September 29, 2009 - 15:00

you can use module_list() and it's force list parameter to add it if need be.

outside of modifying core, it's pretty much your only real option.

#7

fago - September 29, 2009 - 15:00

What about using drupal_load() to load your module? ;)

#8

DamienMcKenna - September 29, 2009 - 15:04

Is that an intended behavior? Should it be running updates on modules that are not enabled?

#9

Wim Leers - September 29, 2009 - 15:11

You may never ever call your module functions or APIs anyway, because they may change over time, thereby breaking the upgrade path.

#10

alex_b - September 29, 2009 - 15:32
Status:active» needs work

#9: that's a good point.

I just tested using drupal_load() on systems where feedapi is present but not enabled. It works. Attaching the patch as a stop gap.

Otherwise I agree with Wim that we shouldn't use the module's APIs so as to not break upgrade paths when if it changes.

AttachmentSize
576848-10_drupal_load.patch 1013 bytes

#11

budda - October 10, 2009 - 22:31

I can get this error when using drush to update the feedapi module, and then calling drush 'updatedb'.

Fatal error: Call to undefined function feedapi_enabled_type() in /var/www/html/drupal-6-sites/all/modules/feedapi/feedapi.install on line 237

 
 

Drupal is a registered trademark of Dries Buytaert.