0

I have a home-grown plugin that's a library of various classes/methods. Let's call it my_autoload. In WP single-site I've been using spl autoload to require() the classes as I have other plugins that use what's offered in the library. No problems**.

I've tried to use my_autoload and a second plugin that uses the library in a WP multisite install. Let's call the second plugin uses_my_autoload. If the plugins are used as single site plugins, again no problems. However, if I tried to use the plugins (my_autoload + uses_my_autoload) as network plugins I get a white screen of death.

I log when then the spl autoload does the require($file) and that seems fine. Again, this works fine in WP single site, or a single site within a MS network. However when uses_my_autoload tried to instantiate a class (spl autoloaded by) my_autoload I get:

"PHP Fatal error: Class 'someClassFromMyAutoload' not found in /srv/www/comcastlmd.com/public_html/wp-content/plugins/pov-videos/pov-videos.php on line ###"

It's as if in WP MS one plugin is "sandboxed" from the other. That the require() doesn't carry from on plugin to the next.

What am I missing? What can I try? What might WP MS do (differently from single-site) that could effect spl autoload??

** Note: I do account for plugin loading order and adjust (single site) option 'active_plugins' and (multisite) option 'active_sitewide_plugins'. So as far as I know it's no a loading order issue. That is, something else that uses the library runs before the library. The library plugin is set up to also be move to the top of the option(s) array and also be first.

  • Set up your library logic like this, so dependent plugins cannot run earlier than the library. – fuxia May 26 '13 at 19:33
  • 1
    You say you account for order, but still this seems precisely like order loading issue. Try to double check that order of things is correct (review the code, log how it loads, etc). – Rarst May 26 '13 at 19:59
  • Thx guys. However...I dump both of the options values for active plugins to a log. NP there. I write the $file in the autoload require($file) to a log. NP there. The require doesn't error. So NP there. (I do a file_exists prior as well). I can see the files / classes being required by the autoload (in my log). And then when that's all done and WP goes to run the uses_my_autoload plugin - because it's further down in the plugin order - it blows up. Exactly! Crazy, right? What do ya think? – Chief Alchemist May 26 '13 at 22:37

Your Answer

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

Browse other questions tagged or ask your own question.