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.
I keep getting this, and I have no idea what it is, or how it happens. It's very annoying. I'd be grateful if anyone could shed light.
blah@vps1:~/public_html/sites/all/modules$ drush dl unfuddle_api
Fatal error: Call to undefined function module_implements() in /home/aarlive/domains/blah.com/public_html/includes/bootstrap.inc on line 844
Drush command could not be completed. [error]
blah@vps1:~/public_html/sites/all/modules$
I've got 2.1 or the latest HEAD, I forget which. This is on debian, under apache2. I really don't know how else to diagnose this! It happens randomly. Sometimes I log out and back in and it stops, others not. Really annoying cos it basically breaks most of drush for me :(
Comments
Comment #1
NikLP CreditAttribution: NikLP commentedSometimes seems to be alleviated when I su to root...? :/
Edit: of course, that fscks all the ownership... *grr*
Comment #2
omega8cc CreditAttribution: omega8cc commentedUse http://ftp.drupal.org/files/projects/drush-All-Versions-HEAD.tar.gz
It works.
Comment #3
NikLP CreditAttribution: NikLP commentedDebug output
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedput a print_r(debug_backtrace()) at top of module_implements(). i think some module is misbehaving.
Comment #5
NikLP CreditAttribution: NikLP commentedOk ... and then do what, sorry? :)
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedgo home and cry?
rerun drush command and view an array that gets printed. the top of the array tells you which file and line in the file called module_implements() too early.
then post back in this issue and give it a meaningful title while you are at it :)
Comment #7
NikLP CreditAttribution: NikLP commentedUm. Hmm. Took me ages to get to a situation where I was able to "replicate" this. It's unpredictable...
"put a print_r(debug_backtrace()) at top of module_implements()." Well I can do that for sure, but... it doesn't get executed, because it "doesn't exist" according to drush, so that leaves me with no more information, I'm afraid :/Ok so I moved the backtrace into bootstrap, and got this:
I assume this is the problem? :( Something to do with my shell user not having the same permissions as apache does...?
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedRight. You can't write to /tmp which is odd. Note that it is cacherouter that is trying to write this file. Usuallly watchdog is saved to the DB, not filesystem. Perhaps you can change cacherouter config avoid the error. Further, phpinfo() advertises a tmp directory that cacherouter may or may not be using. If it is using right dir, then your php is misrepresenting your permissons.
Comment #9
NikLP CreditAttribution: NikLP commentedI honestly think that the problem is related to file ownership in the cacherouter directory, but I can't be sure. The shell user is not in the same group as apache, so the file is inherently unwritable by that shell user, AFAICT. I don't actually know how to remedy that tho...
Comment #10
andypostas pointed in #9 file-engine should check for OS-type and access permissions both for web and cli users
Comment #11
andypostCaused by new locking system, so duplicate #588820: Creating severe load on system by logging thousands of unlink errors in DB log
Comment #12
dparkmit CreditAttribution: dparkmit commentedHi All,
Just ran into this problem myself today. I figured out the reason for this problem and 2 different fixes for it. Here they are:
Reason for Problem: You don't have the proper permissions to write to the CacheRouter file directories when running drush.
Most Linux servers run web servers under a separate user - for example, Ubuntu uses the www-data account, which also belongs to a group called www-data, to run web servers. CacheRouter's file-based caching sets permissions for the cache-related directories to be 755 and cache-related files to be 644. And so, only the www-data account or accounts that belong to www-data group can use the file-based cache.
But when you run drush from the command line, you're running drush with your own user account, which is different from the web server's account. And so CacheRouter can't successfully write files needed for the file-based cache. CacheRouter then attempts to call Watchdog. And this makes drush crash because module_implements hasn't been defined yet.
Solution #1 - Add your user to the web server user group
If you have root access to your box, you can just add your user to the web server user group by using the usermod command. Here is the command that I used on our box:
Once you add your account to the web server's user group, you should be able to run drush successfully because your account now has write privileges for all the file-based caches.
Solution #2 - Modify CacheRouter code so that it grants write privileges to all accounts
If you don't have root access to your box, then you need to modify the CacheRouter code. You should open engines/file.php. There are 2 lines that set file permission. One of them has the permission "664", and the other has the permission "775". You need to change those permissions to "666" and "777". After you make these changes be sure to clear all caches so that all the current sub-directories and files in your cache directory are deleted.
Comment #13
NikLP CreditAttribution: NikLP commentedThis information would be well worth having in the documentation...
Comment #14
bcobin CreditAttribution: bcobin commentedWow - I know it's months later, but thanks for tracking this down and for the detailed post- I was going crazy. This should be added to Drush documentation as well...
Comment #15
webdevbyjoss CreditAttribution: webdevbyjoss commentedI've found this issue too
This should be definitely documented somewhere
because its not a good practice to crash with fatal error without any messages due to simply permission issues.
Comment #16
moshe weitzman CreditAttribution: moshe weitzman commentedThis isn't going into the drush docs because it is really cacherouter making poor assumption that all drupal requests are done by a web server user.
Comment #17
andypostAdded link to #12 from project page