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

NikLP’s picture

Sometimes seems to be alleviated when I su to root...? :/

Edit: of course, that fscks all the ownership... *grr*

omega8cc’s picture

NikLP’s picture

Debug output

bluh@vps1:~/public_html/sites/all/modules$ drush -d update
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.03 sec]    [bootstrap]
Initialized Drupal 6.14 root directory at /home/bluh/public_html     [notice]
[0.038 sec]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.041 sec]   [bootstrap]
Initialized Drupal site default at sites/default [0.077 sec]            [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.08[bootstrap]
sec]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.087    [bootstrap]
sec]
Successfully connected to the Drupal database. [0.088 sec]           [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.094 sec]   [bootstrap]
session_start(): Cannot send session cookie - headers already sent by[warning]
(output started at /usr/bin/drushbin/includes/drush.inc:483) [0.095
sec]
session_start(): Cannot send session cache limiter - headers already [warning]
sent (output started at /usr/bin/drushbin/includes/drush.inc:483)
[0.095 sec]

Fatal error: Call to undefined function module_implements() in /home/aarlive/domains/bluh.com/public_html/includes/bootstrap.inc on line 844
Drush command could not be completed. [0.103 sec]                    [error]
bluh@vps1:~/public_html/sites/all/modules$
moshe weitzman’s picture

Status: Active » Postponed (maintainer needs more info)

put a print_r(debug_backtrace()) at top of module_implements(). i think some module is misbehaving.

NikLP’s picture

Ok ... and then do what, sorry? :)

moshe weitzman’s picture

go 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 :)

NikLP’s picture

Title: Solution for Drush integration problem » Weird thing. Keeps happening.
Project: Cache Router » Drush
Version: 6.x-1.x-dev » All-Versions-2.1
Status: Closed (duplicate) » Postponed (maintainer needs more info)

Um. 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:

[0] => Array
(
[file] => /home/aarlive/domains/mysite.com/public_html/sites/all/modules/cacherouter/engines/file.php
[line] => 107
[function] => watchdog
[args] => Array
(
[0] => cache
[1] => Cache write error, failed to open file "/tmp/filecache/aarlive/cache/8/87cd8b8808600624d8c590cfc2e6e94b--variables"
[2] => 3
)

)

I assume this is the problem? :( Something to do with my shell user not having the same permissions as apache does...?

moshe weitzman’s picture

Project: Drush » Cache Router
Version: All-Versions-2.1 » 6.x-1.x-dev

Right. 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.

NikLP’s picture

I 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...

andypost’s picture

Title: Weird thing. Keeps happening. » Drush integration, filesystem permissions
Status: Postponed (maintainer needs more info) » Active

as pointed in #9 file-engine should check for OS-type and access permissions both for web and cli users

andypost’s picture

Status: Active » Closed (duplicate)
dparkmit’s picture

Title: Drush integration, filesystem permissions » Solution for Drush integration problem

Hi 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:

sudo usermod -a -G www-data dpark

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.

NikLP’s picture

This information would be well worth having in the documentation...

bcobin’s picture

Wow - 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...

webdevbyjoss’s picture

I'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.

moshe weitzman’s picture

This 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.

andypost’s picture

Added link to #12 from project page

Status: Postponed (maintainer needs more info) » Closed (duplicate)