Core image module not found Some how it seems like the core image module is missing from the module list.

Here is the screenshot of the module list:



Also I tried fetching the list using drush.

$ drush pml | grep image
 Image                                Image Attach (image_attach)                                                          Module  Not installed  7.x-1.x-dev          
 Image                                Image Gallery (image_gallery)                                                        Module  Not installed  7.x-1.x-dev          
 Image                                Image Import (image_import)                                                          Module  Not installed  7.x-1.x-dev          
 Image                                Image legacy (image_legacy)                                                          Module  Not installed  7.x-1.x-dev          
 Image                                ImageMagick Advanced Options (image_im_advanced)                                     Module  Not installed  7.x-1.x-dev          
 ImageAPI                             ImageAPI (imageapi)                                                                  Module  Enabled        7.x-1.x-dev          
 ImageAPI                             ImageAPI GD2 (imageapi_gd)                                                           Module  Enabled        7.x-1.x-dev          
 ImageAPI                             ImageAPI ImageMagick (imageapi_imagemagick)                                          Module  Enabled        7.x-1.x-dev          
 Other                                Image crop (imagefield_crop)                                                         Module  Not installed  7.x-1.1              
 Spam control                         Image CAPTCHA (image_captcha)                                                        Module  Enabled        7.x-1.0-beta2        


But the list shows up on the database system table. All the images on my site are not showing up because of this.

I fixed this issue by manual enabling the module from the database and also had to set bootstrap = 1 for it work properly, without it won't work.

so for image row I have to make this changes on system table.

status = 1 and bootstrap = 1

This is bit weird but some how the image module gets disable after some time ( days ). Not sure what is causing it. Every time I have this issue, I have to go to database and make the same changes as above. Can some one guide me what might be causing this issue or how do I debug this. 

Note: this is multi site installation. 


  Update: Rregistry rebuild using drush rr also fixes the issue, but
  doesn't seem to be permanent.
Missing Image module from the list suggest that it disappeared somehow from the system table which have the list of all modules.

To confirm that, double check that directly using the query, e.g.:

drush sqlq "SELECT * FROM system WHERE name='image'"  


It's difficult to answer what causing that without actually debugging it. It depends what kind of modules you've installed, custom code and the environment it-self (e.g. caching).

To track the problem, you can try:


temporary disable external caches (memcached/redis),
temporary disable PHP caches (OPCache/APC/XCache/eAccelerator) or its settings which could interfere with Drupal internals,
disable any automated QA testing (such as Simpletests or Selenium) for affected environment,
disable useless non-stable modules,
temporary disable further modules which you can,
check if this is specific to environment (dev, stage, live),
if happens on all, could be some bug in the code, so follow the section below.


Debugging

This could be a tricky part to find out, so you probably need some tricky tools to debug it.

Here are my ideas:


watch the module lists and check when it's missing:

watch 'drush pml | grep -w image || echo Missing'


for example by sending your-self e-mail with the recent logs:

watch 'drush pml | grep -w image || { drush watchdog-show | mail -s missing-image drupal@niepodam.pl &amp;&amp; killall watch; } '

run debuggers attached to MySQL which monitor everything to do withsystem table or image entry (note: it could be overwhelming for the system):

sudo strace -e recvfrom -s999 -fp $(pgrep mysqld) | grep -w image &gt;&gt; sql.log

run debuggers attached to PHP:

sudo strace -e sendto -s999 -fp $(pgrep -fn php) 2&gt;&amp;1 | egrep "system|image" &gt;&gt; php.log


Or simply enable log queries in MySQL configuration file.

Above is more useful if you've Devel installed, so there is an option to prepend a function name before the query (so you know exactly which function caused it).
install XDebug and enable tracing for the part which you suspect the most by adding xdebug_start_trace(); and xdebug_stop_trace(); in appropriate places (see sample ini config), suggested places would be:


system_list()
system_list_reset()


then analyse the trace files.