When running update.php for 6102 during a migration from Drupal 5 to Drupal 6, the following error occurs:

Fatal error: Call to undefined function forum_access_query_moderator_rid() in /sman/app/mwkefre6_1/httpsdocs/sites/all/modules/forum_access/forum_access.install on line <i>181</i>

As a result, the update process is aborted.

Comments

salvis’s picture

Category: bug » support
Status: Active » Closed (cannot reproduce)

The forum_access_query_moderator_rid() function is in forum_access.module. It cannot be 'undefined' unless you messed up something, e.g. failed to remove all copies of FA under the Drupal root directory but the 6.x-1.5 that you intend to use.

In fact, if you were really using FA 6.x-1.5, then the call to forum_access_query_moderator_rid() would be at line 206 (not 181!), as you can see in http://drupalcode.org/viewvc/drupal/contributions/modules/forum_access/f... — you must be doing something weird and I can't help you.

jpl-2’s picture

Version: 6.x-1.5 » 6.x-1.4

I stand corrected, the version with which this problem occurs is 6.x-1.4.

Perhaps the reason why the function was undefined is because the module was disabled when update.php was run? If having the module in enabled state is required for the upgrade, then there should be an appropriate message displayed about it like in Views and CCK modules.

jpl-2’s picture

Indeed enabling the module before re-running update.php eliminates the undefined function error. Now I "only" get these two errors:

    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3 query: UPDATE forum_access SET grant_view = 0, grant_update = 0, grant_delete = 0 WHERE rid IN () in .../sites/all/modules/forum_access/forum_access.install on line 224.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3 query: DELETE FROM node_access WHERE realm = 'forum_access' AND gid IN () in .../sites/all/modules/forum_access/forum_access.install on line 229.
salvis’s picture

Category: support » bug
Status: Closed (cannot reproduce) » Fixed

Drupal is offering to update a disabled module??? Is that really what you're seeing?

Why would it do that? That would be a core bug, IMO. According to steps 10 to 12 in D6's UPGRADE.txt, contribs are not updated until you enable them.

If FA is not enabled, then I'm not surprised that forum_access.module is not loaded. But I don't understand how you can run the update of a module that's not enabled. Again, it seems that you're doing something weird...

 

If you're upgrading from D5 to D6, why would you want to go to the obsolete version 6.x-1.4 of FA? More weirdness? Actually, I'd recommend going to the -dev version, because it has some additional enhancements and bug fixes.

 

The code in forum_access_update_6104() assumes that there is at least one role with the 'administer nodes' permission. I've just committed a fix to the -dev version to execute those queries only if such a role exists. (Give it up to 12h to be repackaged.)

You can safely ignore the two warnings in #3.

jpl-2’s picture

Thanks for the additional information.

To clarify, I was following the upgrade guide which says to disable all optional core and contributed modules at the beginning of the migration process, then run update.php. It doesn't urge you to enable the modules before running update.php, and in fact updating most of the disabled modules works just fine. It makes sense that a module should stay disabled before its database schema is brought up to date (to prevent errors or worse data corruption). The few modules that *do* in fact require being enabled warn you about it when you try running update.php on them. I suggest for usability reasons that you also implement this same warning in your module.

update.php doesn't care whether a module is enabled or disabled - it offers all modules for upgrade, so I'm not doing anything especially weird there. However, what I did was select the 6000 (or equivalent first 6xxx) update for each module myself and then run update.php for just this single module. The reason for this cumbersome step-by-step procedure was the experience gathered from my first upgrade attempt. When I went the supposedly "smooth and easy" path of running update.php over everything offered at once (42 modules), I ended up with tons of error messages that were difficult to associate with each module. I got significantly fewer errors during my second try - I suppose it worked better because update.php doesn't properly respect module dependencies and I was able to upgrade in a more intelligent order.

Finally, the reason why I used 6.x-1.4 as target (rather than 6.x-1.5) is that the whole process began some two months ago and at that time 6.x-1.4 was the most recent version. Also, I don't use dev versions as a matter of policy (it's easier to track changes against officially numbered versions, if changes are needed).

salvis’s picture

Thank you for the explanation, I see clearly now. You have my full sympathy — I'm a paranoid type myself and tend to get into trouble because of it.

D6's UPGRADE.txt says:

10. Run update.php by visiting http://www.example.com/update.php (replace
www.example.com with your Drupal installation's domain name and path). This
step will update the core database tables to the new Drupal installation.

Note: if you are unable to access update.php do the following:

- Open your settings.php with a text editor.

- There is a line that says $update_free_access = FALSE;
Change it to $update_free_access = TRUE;

- Once update.php is done, you must change the settings.php file
back to its original form with $update_free_access = FALSE;

11. Ensure that the versions of all custom and contributed modules match the
new Drupal version to which you have updated. For a major update, such as
from 5.x to 6.x, modules from previous versions will not be compatible
and updated versions will be required.

- For contributed modules, check http://drupal.org/project/modules
for the version of a module matching your version of Drupal.

- For custom modules, review http://drupal.org/update/modules to
ensure that a custom module is compatible with the current version.

12. Re-enable custom and contributed modules and re-run update.php
to update custom and contributed database tables.

#12 is pretty clear about enabling modules before trying to update them. I doubt that any module maintainer tests whether his modules can be upgraded in disabled state. If that works for you, then you've been lucky, but definitely not within the specs.

It makes perfect sense to not enable all contribs at once, but just because some module maintainers have been sufficiently annoyed by support issues from admins trying to update their modules in disabled state to actually implement a check, does not mean that any of the other modules would support that.

update.php doesn't properly respect module dependencies

No, that's not update.php's job. Those are enforced when you enable the modules.

jpl-2’s picture

Thanks for pointing this out. I concur that UPGRADE.txt is a good place to look for specification of the official behavior. Yet I still consider a check in update script a best practice from the usability and perhaps even safety viewpoint. Firstly, the user might simply forget to re-enable the module, in which case it's nicer to tell her about it rather than throw strange errors at her. Secondly, I can imagine cases where enabling too many modules prematurely might have bad side effects. Are all modules coded so that they can operate in a safe degraded state before their schema updates have been run? And what if your module's update script depends on another module, which has not been updated yet, but which is already enabled? Given that your update might be chosen by update.php to run first, you might end up using a half-baked helper module that either generates errors or (worse) does something silly which corrupts data.

That's what I meant with update.php not respecting dependencies - it's clear that it cannot be entirely solved through dependency checking while enabling out-of-date modules. Granted, this broader issue and worst-case-scenarios do not really have much to do with this particular bug report. The sum of the story is, I was unaware and mistaken trying to update disabled modules, yet it would have been nice if forum_access could have protected me against that mistake. I also suspect that what I did might not be truly "unsupported" after all, otherwise update.php should have categorically guard against it (also: other modules' authors such as CCK/Views would be rallyng for core to implement this protection in update.php instead of doing the work themselves). FYI, I also submitted a similar request with a patch to forum.module at http://drupal.org/node/569872, but haven't got a response from the maintainer yet.

salvis’s picture

I think the single most effective thing you can do to stay out of update.php trouble is to never play with the update version combos. They are there for exceptional cases, but they should never be used unless you're absolutely sure you know what you're doing. BTW, they are gone in D7.

Please post a patch for FA to provide the protection that you'd like to see.

jpl-2’s picture

"Never play with version combos" is good advice in normal circumstances and will certainly save the novice user from messing up their db, but it is sometimes not possible to follow in practice:

  • some update scripts are buggy, so sometimes you actually do have to re-run an update after having seen, understood and corrected an underlying cause for an error; unfortunately, the error handling is poor, so an update scripts may not abort when an error is encountered, especially true for SQL errors;
  • displaying errors is poorly implemented (and possibly difficult to implement better), so it is hard to associate errors with modules and individual update functions when you run a bunch of updates all at once, which is especially true during major version migration.

I hope that while removing the combos in D7 the devs thought about these issues!

Status: Fixed » Closed (fixed)

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