8

I created a module through Drupal Console, unfortunately it wasn't placed in a folder of its own, rather straight into /modules/custom. Before I noticed where it had gone, I enabled the module.

In Drupal 6/7, this was easy to fix - I could literally just put the files into the correct path, clear the cache (maybe rebuild the registry, it wasn't an exact science), and all was well.

The same isn't true for Drupal 8; I moved the files into a subfolder, rebuilt cache, and all requests tell me that Drupal is failing to include a required file. The particular file is a block class, and the path Drupal is trying to find it is where it used to be, not where I've moved it to.

The bit of code objecting is in Symfony's ApcClassLoader, so I guess I need to clear something that's slightly above Drupal's head to get this path reference updated.

How can I do that?

Uninstalling and re-installing the module does work, but once there's important data stored that's not going to be an option.

I was wrong, uninstalling and re-installing is not a viable option. After uninstalling and reinstalling, Drupal can no longer pick up the custom blocks the module defines. I'm guessing that reference is cached somewhere that isn't cleared when the module is uninstalled. Just need to find out where that is and how to clear it...

  • So, if you create first.module and a second.module with Drupal Console, do you find both those file in /modules/custom? I will never create a module with that, then. – kiamlaluno Jan 27 '16 at 15:45
  • I had an old version @kiamlaluno, upgraded now and that problem isn't there. The problem in the question most definitely is though, it's actually getting worse. I've just added a brand new module, with a brand new block, and Drupal now won't pick up that block for the admin page. Something's got really screwed up inside its config but I don't know where to look :/ – Clive Jan 27 '16 at 15:51
  • Is ApcClassLoader::findFile() getting the wrong path from apc_fetch(), or is the decorated class loader returning the wrong path? – gapple Jan 27 '16 at 17:59
11

Just restart apache. The APC cache will be rebuild then.

You can also try to hit rebuild.php or run drush cr. Those all attempt to explicitly clear the APC cache.

  • Yeah I did the same things (nginx+fpm but restarted both several times), plus running apc_flush_cache directly and even switching between php5 and 7 so totally different stores, still saw the problem but I'm guessing it's something with my setup specifically, logic says one of those methods would fix it. will have a closer look tomorrow – Clive Jan 27 '16 at 19:32
  • Night time seems to have fixed it so I'm going to put a pin in this for now... – Clive Jan 28 '16 at 16:55
  • rebuild.php (open in browser) helped, restarting apache and clearing cache did not help. – drupalfan Aug 18 '17 at 10:20
  • I did cache clear, run rebuild.php, apache restart. Still not working getting same error. Blocks refering old module path. – ARUN Feb 22 '18 at 9:47
-1

You should clear drupal cache. That's how to do it with drush:

drush cr
  • We are talking here about Drupal 8, this above works for drupal 7. – Marko Blazekovic May 3 at 9:18
  • Thanks Marko, have updated my answer for drupal 8 solution. – Somerussian May 4 at 17:41
0

Another solution is put in your settings.php:

 /**
 * Class Loader.
 *
 * If the APC extension is detected, the Symfony APC class loader is used for
 * performance reasons. Detection can be prevented by setting
 * class_loader_auto_detect to false, as in the example below.
 */
$settings['class_loader_auto_detect'] = FALSE;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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