Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While attempting to uninstall the mongodb_watchdog module I received the following error:
[Thu Jul 25 02:14:46 2013] [error] [client 174.84.232.114] PHP Fatal error: Call to undefined function mongodb_collection() in /var/www/vhosts/example.com/sites/all/modules/mongodb/mongodb_watchdog/mongodb_watchdog.install on line 30, referer: http://example.com/admin/modules/uninstall/confirm
Comments
Comment #1
sprice CreditAttribution: sprice commentedIt's an easy fix. Just drop
include_once dirname(__FILE__) . '/../mongodb.module';
into the mongodb_watchdog.install file.
Comment #2
fgmCannot reproduce the problem : when uninstalling, mongodb.module is always loaded when hook_uninstall() is triggered.
Can you detail your configuration and reproduce the problem on a blank install with just the mongodb and mongodb_watchdog modules, step by step, like this:
I also checked with the web UI instead of Drush. No such problem.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedI didn't try to replicate this on a clean system with only the mongodb and mongodb_watchdog modules, but I *can* confirm that I did have this problem, & that the solution in #1 worked for me.
Comment #4
ryumkin CreditAttribution: ryumkin commentedSame alert but on mongodb install. I've installed rc2, then receive message about deprecated functions, uninstall and delete it, downlad dev version, and tryied to enable basic mongodb module.
BTW mongodb() and mongodb_collection() functions where from? From Drupal module or PHP module?
Thank you.
Comment #5
fgm@rhclayto @ryumkin To help you I need a reproducible scenario starting from a fresh install (with the dev version), and just the mongodb and mongodb_watchdog modules : I have not been able to obtain this problem on my configurations.
@ryumkin : they are in mongodb.module.
Comment #6
ryumkin CreditAttribution: ryumkin commentedI don't think that the result of fresh install would be different. I did a small research and it seems like .module file don't load if the requirements not met. So this is a cycle hook_requirements required .module to execute, and .module needs hook_requirements to execute. I put
watchdog("include", json_encode(get_included_files()));
in your hook_requirements and there was no mongodb.module file. Also I found the following:https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...
https://www.drupal.org/node/1555220
https://www.drupal.org/node/2364737
Of course the best would be to trace drupal core code, hope I would find some time to proove it, meanwhile I would just include .module in .install as #1 recommends.
Comment #7
ryumkin CreditAttribution: ryumkin commentedBTW
include_once dirname(__FILE__) . '/../mongodb.module';
is not a good way to include the file, it depens on folders hierarchy, the following is better:
module_load_include('module', 'mongodb', 'mongodb');
Comment #8
fgm@ryumkin : module_load_include() is indeed needed when including files /not/ part of your package because you cannot know where the files are without asking core, but direct inclusions with dirname(__FILE__) or __DIR__ are the best way /within/ a given package, since as the package author you are in charge of the relative file layout below the package root, and this saves some function calls, and dependency on having drupal_get_path() be able to find the package, which is not a given in some circumstances.
To go further, I think the best way to proceed is to provide a failing Simpletest causing the error. Then we'll know the issue is fixed when the test passes.
Comment #9
fgmActually, I eventually managed to reproduce it : the key was to try to uninstall mongodb_watchdog after having disabled mongodb. This is now addressed as part of the patches for #2567211: WSOD on enabling mongodb and uninstalling mongodb_watchdog, so marking this one closed.
Comment #10
nehapandya55 CreditAttribution: nehapandya55 commentedHi,
I faced same problem but #1 did not work for me. But when i drop include_once dirname(__FILE__) . '/../mongodb.module'; from module mongodb_watchdog.module file and added module_load_include('module', 'mongodb', 'mongodb'); to mongodb_watchdog.install file under mongodb_watchdog_uninstall() function worked for me and successfully uninstalled mongodb module.