Moving Drupal Modules To Contrib Causes Fatal Error

Author:
phil
Created:
Friday, August 31st, 2012
Last Updated:
Wednesday, October 02nd, 2019

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


Moving Drupal modules around, is usually a pretty painless thing as long as you disable the module first. Some folks say that you need to uninstall the module before moving it, but I have found that 90% of the modules out there, don't mind being moved around as long as they are disabled first.

With that being said, the remaining 10% of modules leverage a "require_once()" class that can cause all sorts of issues, regardless of whether or not you disable the module. The only "perceived" solution is to uninstall the module, move it to the contrib or new location, then re-install it.

However, there are a few things you might want to try before moving to that route.

Other's say they simply edit the database and move all /sites/all/modules to /sites/all/modules/contrib and it fixes the world...

I was not very lucky in my quest to move all of my modules to the /sites/all/modules/contrib folder, mainly when it came to both Rules and Ubercart.

That got me doing all sorts of crazy things to figure out why the heck I kept getting errors like:

Fatal error: Class 'uc_product_handler_field_price' not found when enabling Ubercart Order or similar errors when enabling rules.

Everything wanted to point back to the OLD location...

Not really knowing that much about how PHP works, I finally figured out that something other than Drupal was caching the "require_once" which got me thinking... What If I restarted PHP?? Now, I know you can't "restart PHP", but the next best thing is to restart the server that runs PHP, so I restarted Apache.

Volia! After a few browser reloads, my errors went away!

I'm using APC cache and after writing this article, think that might have something to do with it. Regardless, if you move any modules to a different location like the /contrib folder and you get a bunch of errors pointing to the OLD location, try restarting your web server.

The other thing I'll note is to use http://drupal.org/project/registry_rebuild which I'm finding is a must have for PHP errors.

In the end, I never was successful in getting Rules or Ubercart to migrate over... I'm sure there are other modules that require the same treatment. The ONLY time I've been successful in moving folders without any problems, is during a Major Drupal Upgrade. (ie D6 -> D7)

Post Comment