require_once bug on some server (plesk) [fix proposal]

Posts: 17
Joined: 08/16/2007
Internationalizationizer

Got some problem making Ubercart work on server with plesk, found the problem with require_once you add on some modules (payment, cart, taxes ...).

It would be better to use drupal_get_path() function, to make it work on every server (almost plesk !):
for uc_cart :

require_once(drupal_get_path('module','uc_cart').'/uc_cart_checkout_pane.inc');
require_once(drupal_get_path('module','uc_cart').'/uc_cart_workflow.inc');

regards.
Mog.

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I don't know much about plesk, but I'm curious why it wouldn't be taking these paths as relative to the module file... Puzzled

Have you tested your solution to confirm that drupal_get_path() has already been bootstrapped by this point? (I imagine it is, just want to make sure.)

Posts: 17
Joined: 08/16/2007
Internationalizationizer

Yes, i test with drupal_get_path() and it works fine,
with plesk, when i try absolute path it works, but relative not, perhaps it's a bad configuration of my plesk but i try with 2 plesk on different server and i got the same problem. I let you see if this justify to use drupal_get_path().

regards
Mog

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I confirmed other modules like Views do this and have updated all our modules accordingly.

Posts: 1314
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Interesting, but is this a plesk issue or something more to do with Apache? Seems like it'd be some kind of a conf issue, but I don't know much about that. Just since I'm a curious fellow, can you guys point me to a link with more info? (Or care to provide your own..) Thanks!

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I have no clue why it doesn't work... I'm just a lemming following the Views module here. Evil

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Well... found out today that this "fix" breaks page caching altogether. Sticking out tongue

So... gotta figure something else out methinks. Perhaps there is some other server configuration that should be addressed. The problem is drupal_get_path() doesn't get included in the bootstrap until after the modules are included for cached pages... meaning we get a function not found error on every cached page view.

Posts: 1314
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

I am still doubting that Plesk has anything to do with it. Plesk is an interface and a tool for setting up a server, right? (It's what we use on our dedicated box). It's the underlying software that's the problem - whether it's an Apache config issue or a Linux rpm that needs to get installed.

If the underlying issue seems to go away when changing paths in require_once(), it makes it sound like a PHP bug. Mog, do you know what versions of PHP and Apache you are using on your server? Is this a shared or a dedicated setup? Sorry if I missed this info elsewhere.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 1314
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Something changed in our Apache / PHP setup, and now I'm receiving errors such as this:

require_once() [<a href='function.require-once'>function.require-once</a>]: open_basedir restriction in effect. File(/usr/share/php/uc_payment_checkout_pane.inc) is not within the allowed path(s) in /.../sites/all/modules/ubercart/payment/uc_payment/uc_payment.module on line 16.

I checked uc_payment.module and, indeed, the require_once lines do not use the function drupal_get_path(). Is this something that has changed? It looks to be a PHP config issue but I have racked my brain and check everything, and I can't seem to find a fix. What's strange is that this didn't happen until we made a change to our open_basedir settings.

Also, a question: is this the standard way for using require() and include() in Drupal modules? I seem to recall reading somewhere, maybe in this forum, that using drupal_get_path for every require and include might start to add up. I know that it's not just Ubercart that does things this way, since I am also getting this error for the FCKEditor module, and others.

EDIT: I re-read your post, Ryan, about it breaking caching. That sucks. The site still works, which is good, but I'm getting a dozen or so errors every time someone loads a page. If I find a solution I'll post it here.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 1314
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

It looks like commenting out the open_basedir configuration in httpd.include does the trick. But this makes it possible for people to run PHP scripts from any folder (if they are granted permission).

Do you guys see any major issue with doing this in a Drupal environment? I want to avoid making everything available to the apache user, but at the same time, we've had this config in the past and never had any trouble. Any opinions?

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

That moves into the realm of the unknown to me. Shocked Sorry I'm not much help, but I'm glad you found a solution.