Install failed - realpath relative path issue?
ee
Joined: 2004-12-20
Posts: 7 |
Posted: Mon, 2004-12-20 23:54 |
When I get to step 2 in the install process, I receive the following warning and error: Quote:
Warning: checkmanifest(/modules/core/classes/GalleryUtilities.class): failed to open stream: No such file or directory in steps/SystemChecksStep.class on line 237 Figuring that there's a problem with the relative path calculation, I added code to echo dirname(__FILE__), realpath(dirname(__FILE_)) and a stack trace just before the calculation of $base on line 235. Here's the output Quote:
dirname(__FILE__)=steps Now I don't know much about php, but it looks like a problem calculating the relative path having something to do with the way that realpath works. I also know that on my host, gallery2 really is located either at Quote:
/home/www/eeaston/gallery2 or Quote:
/www/eeaston/gallery2 . When I log in I get a symlink from /home/eeaston/www to /www/eeaston. So in short I don't know what the real mount point for gallery2 is compared to what realpath is returning, but I suspect something odd here. I installed it just fine on a private freebsd box, so the build I grabbed is okay. It just doesn't seem to handle the path setup that my hosting provider is using (cihost). Any ideas? Evan Quote:
|
|
Posts: 3236
I think that almost all paths in gallery should be absolute, and from the output in your first error it looks like they are relative. I would try it with the two paths you pasted above and see what happens. Of course, maybe this error is popping up even though you are using the absolute path?
Posts: 8601
php docs say __FILE__ is
This is ambiguous what path info, if any, for an included file is returned.. to me it sounds like filename only but it appears you get a relative path and filename and I (and most php's, mine is 4.3.8 on freebsd) get an absolute path to the included file. try putting print __FILE__; in install/index.php and install/steps/SystemChecksStep.class .. what do you get for each? maybe you can get your install to proceed by changing $base to '../' instead of that realpath call... but you might get other problems later from this.
Posts: 7
For install/index.php
And for install/steps/SystemChecksStep.class
I'm able to get past the issue with the failure in the require_once call by hacking this code, but then all sorts of other things fail later.
Is my php built wrong? Is there a php.ini var I can set to tailor the behavior? Or does gallery2 need to be improved, to say derive the root dir from the top level php page instead of from __FILE__, in order to be more robust?
Evan
Posts: 8601
yeah, i expected as much.. we use dirname(__FILE__) a lot... it seems like your php is misbehaving, as i've not seen this before.. but as i mentioned before the php doc is a bit ambiguous so maybe we shouldn't be counting on a full path.. bharat, any insight on this one?
Posts: 7994
Oy. The check in the installer is supposed to detect this and let you know right away! Turns out that it wasn't sophisticated enough (I was looking for "steps/SystemChecksStep.class"). I've improved it so on the next nightly, it should give you a big warning right away.
This looks like PHP bug 13936. I don't know what causes it, and though they claim to have fixed it, it keeps popping back up again. That's why we put this check in the installer. Evan, can you add your info to that bug so that we can help them to narrow down and fix it?
Unfortunately, it's going to be really difficult for you to patch or work around this issue. We rely heavily on this at a very low level and even if you get by some of the initial issues with it, you're going to be hitting it everywhere. The problem with it is that __FILE__ is a magic token in PHP that can't be easily simulated or abstracted out (which is why our error handling code has it liberally sprinkled all over the place). There are 6500+ references to it in gallery2! So we can't replace it with a function .. the best we could do is to try to wrap it but even then we need to know the directory that we're currently in in order to figure out what to prepend to it. For example, in SystemChecksStep.class it gets back "steps/SystemChecksStep.class" so it has to know to prepend /home/www/eeaston/gallery2/install, which only the requiring/including file knows. If we could narrow this down to only includes or requires, you could probably do some magic to store the state in a global whenever you do a require (but even that will get hairy)...
Posts: 7
Yep. I'll update the bug with my information. I guess I'll have to bug my hosting provider to see if they can update the version of php. Maybe this is the impetus I need to seek out a new hosting provider and get onto newer OS and supporting tools. Thanks for the help.
Posts: 7
FYI, it seems that there is a pretty reliable way to change the gallery2 code to cope with this bug. But it would mean changing all include and require usages to look like:
include(dirname(__FILE__)."/includedfile");
If this were done everywhere, then the included files can get the realpath to __FILE__. This demonstrates the issue on my server http://www.eeaston.com/phpbug13936/ (excuse my php). And the interesting thing about it is that it intermittently reports
for the first of the three include calls instead of
I only mention this as I have little hope that
a) there will be anything remotely like a fix for the version of php installed on my host, and
b) my hosting provider is currently unwilling to do anything to try and help me work through the problem
So short of switching hosting providers, which I may just do, I'd love to see the gallery2 code fixed to cope with my crappy hosting provider ;-). Of course, ensuring that you can consistently use special galleryInclude and galleryRequire functions instead of what php provides would be troublesome at best and thus not really address my selfish wants.
Evan
Posts: 7994
Hmm. We use the include format that you suggest pretty much everywhere in the code already so if your theory is correct, then it should be working for you. (Grep around for uses of include and require and see if we missed any).
I fixed a couple of spots in the installer and upgrader where we didn't do this. But everywhere else I'm pretty sure that we do. We have to, otherwise embedding G2 won't work quite properly.
Posts: 7
So I bothered to mess around with it some more. In the file, install/index.php (using alpha 4) I changed the lines 70 and 163 from:
070: require("steps/$className.class");
163: include('templates/MainPage.html');
to:
070: require(dirname(__FILE__)."/steps/$className.class");
163: include(dirname(__FILE__).'/templates/MainPage.html');
and was indeed able to get through the install. So it does seem that if you did a complete search/replace everywhere my host would be happy and so would I.
I'll pull nightlies sometime and see if anything else is still broken for me.
Evan
Posts: 1
Hi,
what happened to this thread, is the suggested way a possible workaround? and if so, why is it not yet fixed everywhere in gallery?
cheers,
Florian
Posts: 32509
nothing happened.
if __FILE__ doesn't work in your php, it means your php is buggy. we can't do anything about it.