So I have created script that flushes drupal's cache and it's ran in CLI.

The problem is after first use, I can't use the script again, because some classes ('SelectQueryExtender' or 'DrupalDefaultEntityController') are missing. Clearing cache via drupal admin menu (admin_menu/flush-cache) fixes it and I can rerun.

Now the question is why clearing cache from via HTTP works and from CLI doesn't?

I'm running on Drupal 7 and code can be found below:

define('DRUPAL_ROOT', '/srv/www/'); // Drupal root folder.

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// Clear cache.

EDIT: when I clear cache via drupal_flush_all_caches and later make curl call for cache clearing through apc-status.php, then even website itself gives Fatal on above mentioned classes missing.

  • Your code has syntax errors, it won't run until you fix those
    – Clive
    Nov 19, 2015 at 10:25
  • Thanks, but that's not the case as DRUPAL_ROOT part was only line that was not copied.
    – R.P
    Nov 19, 2015 at 10:33
  • why are you not using drush ?
    – rémy
    Nov 19, 2015 at 13:21
  • I don't see a necessity of having one big tool for such a minor thing and also I would like, actually need to know the logic behind this behaviour.
    – R.P
    Nov 19, 2015 at 13:24
  • Okey, apperantly I had script starting on wrong folder thus breaking modules search. Basically for drupal_flush_all_caches() to work (or registry_rebuild to be more percise), script would need to be at same place where DRUPAL_ROOT is located or chdir(DRUPAL_ROOT); should be used after drupal_bootstrap. Next time I will add more code as this wasn't informative enough.
    – R.P
    Nov 19, 2015 at 13:45

1 Answer 1


Install Drush. It's your friend. Then you can issue

drush cc all

To clear caches.

You can also rebuild registries if needed to if you have that module installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.