[OS X] Fatal error in Step 2 of installation

cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Thu, 2005-03-10 05:52

I'm attempting to install the Gallery2 beta on the system summarized below. Each time I try to execute "Step 2" in the installation, I get the following message

"Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/gallery2/modules/core/classes/GalleryUtilities.class on line 50"

And that's as far as I get. It's entirely repeatable. Any suggestions on what to change or look for?

Thanks// Chris Freeborn

----

Webserver: Apache 2.0.52
Datatabase: MySQL 4.0.23
PHP: 5.0.3
Operating system: Mac OS X 10.3.8

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2005-03-10 19:12

hm, haven't seen this before.
please edit install/steps/SystemChecksStep.class and find "function CheckManifest"
just after the "$base = " line add this:
print "$base<br/>";
print dirname(dirname(dirname(__FILE__))) . "/<br/>";

and retry.. what values do you see?
Then remove the two lines you added and also remove the "require_once" line just below them and retry.. this may work.

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Fri, 2005-03-11 04:41

I made the changes you suggested and this was the result printed:

/Library/WebServer/Documents/gallery2/
/Library/WebServer/Documents/gallery2/

Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/gallery2/modules/core/classes/GalleryUtilities.class on line 50

When I removed the two print statements the same error fatal error repeats. Any other suggestions to debug?

//Chris Freeborn

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Fri, 2005-03-11 05:33

That is odd. But ok, we can figure this out. From mindless test it looks your __FILE__ directive works. Try removing his lines and then editing modules/core/classes/GalleryUtilities.class and adding this to the top of the file right below the <?php line:

printf("<pre>GalleryUtilities: %s</pre>", print_r(debug_backtrace(), 1)); 

That's a little macro I use to dump out the current location. We should see two stack traces, get printed out. Capture those and post 'em here and we'll have a chance of figuring out what's going wrong.

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Sat, 2005-03-12 00:11

I added the line and the following appears at the top of the first page of the installation:

GalleryUtilities: Array
(
    [0] => Array
        (
            [file] => /Library/Webserver/Documents/gallery2/install/index.php
            [line] => 44
            [function] => require_once
        )

)


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Library/Webserver/Documents/gallery2/modules/core/classes/GalleryUtilities.class:2) in /Library/Webserver/Documents/gallery2/install/index.php on line 74

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Library/Webserver/Documents/gallery2/modules/core/classes/GalleryUtilities.class:2) in /Library/Webserver/Documents/gallery2/install/index.php on line 74

And then when I get to the step after "Authentication" I see the following:

GalleryUtilities: Array
(
    [0] => Array
        (
            [file] => /Library/Webserver/Documents/gallery2/install/index.php
            [line] => 44
            [function] => require_once
        )

)


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Library/Webserver/Documents/gallery2/modules/core/classes/GalleryUtilities.class:2) in /Library/Webserver/Documents/gallery2/install/index.php on line 74

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Library/Webserver/Documents/gallery2/modules/core/classes/GalleryUtilities.class:2) in /Library/Webserver/Documents/gallery2/install/index.php on line 74

GalleryUtilities: Array
(
    [0] => Array
        (
            [file] => /Library/WebServer/Documents/gallery2/install/steps/SystemChecksStep.class
            [line] => 237
            [function] => require_once
        )

    [1] => Array
        (
            [file] => /Library/WebServer/Documents/gallery2/install/steps/SystemChecksStep.class
            [line] => 198
            [function] => CheckManifest
            [class] => SystemChecksStep
            [type] => ->
        )

    [2] => Array
        (
            [file] => /Library/Webserver/Documents/gallery2/install/index.php
            [line] => 168
            [function] => loadTemplateData
            [class] => SystemChecksStep
            [type] => ->
        )

)


Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/gallery2/modules/core/classes/GalleryUtilities.class on line 51

Hopefully this helps!

//Chris Freeborn

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2005-03-12 07:50

Ok, that is interesting. We are including the same file from two different places, but we use something called "require_once" which is supposed to guarantee that it doesn't load the same file twice. Apparently that is failing, which might be a bug in PHP. Let's see if we can figure out why.

in install/steps/SystemChecksStep.class on line 237 change:

        require_once($base . 'modules/core/classes/GalleryUtilities.class'); 

to:

        printf("[SystemChecksStep] %s", $base . 'modules/core/classes/GalleryUtilities.class');
        require_once($base . 'modules/core/classes/GalleryUtilities.class'); 

Then on line 44 of index.php, change:

require_once(dirname(dirname(__FILE__)) . "/modules/core/classes/GalleryUtilities.class"); 

to:

printf("index.php %s", dirname(dirname(__FILE__)) . "/modules/core/classes/GalleryUtilities.class");
require_once(dirname(dirname(__FILE__)) . "/modules/core/classes/GalleryUtilities.class"); 

You can comment out or delete the lines you added before. This will generate some additional output when you try the installer. Post that here and we'll see if we can figure out what's going on.

My guess thus far is that this is a bug in PHP5, which has some known issues especially on less commonly used server platforms (like the Mac). If you don't want to go through the pain of dealing with unstable software, you might downgrade to PHP 4.3.10. But then again, you're installing G2 Beta so my guess is that you're willing to try bleeding edge stuff :-)

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-03-12 07:59

bharat, we can also remove that require_once since GalleryUtilities now gets included in index.php

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2005-03-12 08:15

Duh! Good idea. I've removed that. So this should make this problem go away for cbfreeborn, but I bet he'll have other similar ones.

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Sat, 2005-03-12 18:06

I made the changes suggested and here's the result at Step 2:

index.php /Library/Webserver/Documents/gallery2/modules/core/classes/GalleryUtilities.class
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /Library/Webserver/Documents/gallery2/install/index.php:45) in /Library/Webserver/Documents/gallery2/install/index.php on line 76

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Library/Webserver/Documents/gallery2/install/index.php:45) in /Library/Webserver/Documents/gallery2/install/index.php on line 76
[SystemChecksStep] /Library/WebServer/Documents/gallery2/modules/core/classes/GalleryUtilities.class
Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/gallery2/modules/core/classes/GalleryUtilities.class on line 51

Appreciate your patience and help!

//Chris Freeborn

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-03-12 18:38

this is what i posted in my first reply.. not clear you ever tried it:

mindless wrote:
Then remove the two lines you added and also remove the "require_once" line just below them and retry.. this may work.

also remove any debug output you added in index.php

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Sat, 2005-03-12 19:15

I forgot to delete the lines as you suggested. When I did delete them, I was able to successfully get through Step 2 and all the way to Step 7. At this point I get the following fatal error message:

Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/gallery2/modules/core/classes/GalleryUtilities.class on line 51

Progress!!

Thanks// Chris Freeborn

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2005-03-12 22:32

I think this has something to do with filename case insensitivity on the Mac. I think that even if you get through the installer there are going to be more issues that we'll need to resolve. I've been unable to reproduce this problem on my Mac, though. Would it be possible for me to ssh to your box and check it out directly? Thanks.

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Sun, 2005-03-13 00:02

Well, at the moment I'm in development mode and all of my systems -- including the Mac OS X are behind a router/NAT and not directly exposed. Perhaps you could send me a pm and give me some insight as to options for enabling ssh access.

Appreciate your ongoing help.

//Chris Freeborn

 
alindeman
alindeman's picture

Joined: 2002-10-06
Posts: 8194
Posted: Sun, 2005-03-13 03:02

bharat: joan has experienced this problem too. You may want to talk to her, as she can probably either (1) help resolve it or (2) give you access to poke around.

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2005-03-13 08:22

Yup, I had this problem. It's a strange bug in php/os x. If you want to see it in action, create files called j.php

<?php
echo __FILE__."<br>";
include "jj.php";
?>

and jj.php

<?php
echo __FILE__."<br>";
?>

Then view j.php in your browser. What I saw was this:

/Users/jem/Sites/g2/j.php

/Users/jem/Sites/G2/jj.php

The fix for me was to rename the gallery directory from g2 to G2 and use that in the browser. So try renaming your directory to GALLERY to see if that fixes it.

joan

- first posting in 10 months!!

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Sun, 2005-03-13 17:58

I changed the name of the gallery2 directory to GALLERY2 and the g2data directory to G2DATA and reran the installation. It failed again at Step 7 with the same fatal error:

Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/GALLERY2/modules/core/classes/GalleryUtilities.class on line 51

Is the suspected upper/lower case (in)sensitivity causing a problem at an even lower level?

//Chris Freeborn

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2005-03-13 19:49

This is weird. I tried to pin it down to a small test file, but I couldn't reproduce the problem. Then I thought I'd reproduce it by doing the install again. Despite my doing "everything the same as the first time", the installation went through fine.

I've tried a couple more times, and I can't reproduce it.

But anyway, are you typing GALLERY2 in the browser?

joan - 2nd posting in 10 months!

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Sun, 2005-03-13 21:10

I went back and made sure I used upper-case in the browser access (both Safari and Firefox) and ran into the same fatal error at Step 7.

BTW, after this fatal error occurs at Step 7, I get the following error message if I try to access Gallery2 again from the browser:

------------

Error (ERROR_STORAGE_FAILURE) :

* in modules/core/classes/GalleryStorage/DatabaseStorage.class at line 1136 (MySqlDatabaseStorage::error)
* in modules/core/classes/GalleryStorage.class at line 220 (MySqlDatabaseStorage::search)
* in modules/core/classes/Gallery.class at line 189 (GalleryStorage::search)
* in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 256 (Gallery::search)
* in modules/core/classes/helpers/GalleryPluginHelper_simple.class at line 197 (Gallery::fetchAllParameters)
* in modules/core/classes/GalleryCoreApi.class at line 203 (Gallery::getParameter)
* in modules/core/classes/Gallery.class at line 507 (Gallery::getPluginParameter)
* in modules/core/classes/Gallery.class at line 479 (Gallery::getActiveLanguageCode)
* in init.php at line 140 (Gallery::initTranslator)
* in main.php at line 32

-------------------------

I have to go in and delete config.php in order to be able to restart the installation. This scenario might be something that should be accounted for more gracefully in the production version.

Thanks// Chris

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Mon, 2005-03-14 00:56

There's no way that we're going to be able to gracefully handle this; as far as I can tell something is seriously wrong with PHP and if PHP is lying to us we can't really cope.

I can't reproduce this on my Mac so I can't really debug it. It sounds like Joan can no longer reproduce it either. I need to reproduce it to fix it, I think. Chris, do you have a local sysadmin you can talk to who can help you configure your NAT properly so that we can get external access? Or can somebody here walk him through the process? thanks.

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Mon, 2005-03-14 01:18

I'm the sysadmin (as well as chief cook and bottle washer etc etc) so you can walk me personally through what needs to be done.

Thanks for your patience// Chris

 
Gurami

Joined: 2005-03-14
Posts: 1
Posted: Mon, 2005-03-14 07:07

I can reproduce both of the problems mentioned on this thread on my mac:

Webserver: Apache 1.3.33
Datatabase: MySQL 4.0.22
PHP: 4.3.10
Operating system: Mac OS X 10.3.8

I run into the __FILE__ directive complaint, as well as the error at step 7 mentioned above. I've done a little hacking about and it appears that the problem with the file directive involves the following:

inside of SystemCheckStep.class, the magic constant __FILE__ returns a relative path (which looks sth like "./steps/SystemCheckStep.class"), which most certainly makes SystemCheckStep::CheckFileDirective() barf.

Curious thing is though, that at a higher level, such as /install/index.php, __FILE__ returns a fully qualified path. I'm stumped. This code works just fine on my OpenBSD box.

So, when I just brute force it to pass step 2, i get all the way to step 7, and I hit this problem, but for me it says:
--------------------
Fatal error: Cannot redeclare class galleryutilities in ./steps/../../modules/core/classes/GalleryUtilities.class on line 50
--------------------.

Any Ideas?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Mon, 2005-03-14 07:34

Gurami, any chance that I can ssh to your box and inspect this directly? I can't reproduce it on my Mac and it's really hard to figure out how to resolve it if I can't seet it first hand and try tinkering with the code.

My guess from what I've heard is that there's not much that G2 is going to be able to do about this. We depend heavily on the __FILE__ directive and it's gotta work properly. If it's busted then we're dead in the water (which is why we check for it as soon as we can and tell you).

However, I will be happy to log onto your box and try to isolate it into a small script that we can use to file a bug on bugs.php.net and get them to fix it! But I need access...

 
cbfreeborn

Joined: 2005-03-10
Posts: 10
Posted: Mon, 2005-03-21 22:25

Bharat -

Has there been any further troubleshooting or testing re this problem? I'm willing to offer you access to my system if we can work out the logistics.

Thanks// Chris Freeborn

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2005-03-22 10:55

Sadly, I'm baffled. Gurami gave me access to his box where he was having the problem, and when I tried to install -- I had no problems! So I still can't reproduce this :-( :-(

 
littlejo

Joined: 2005-03-23
Posts: 1
Posted: Wed, 2005-03-23 06:16

I am experiencing the same issue that is being discussed here. If you would like, I can offer another test envionment...

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Wed, 2005-03-30 03:50

littlejo, I'd love to test it out in your environment. Please send me your ssh details via private message and I'll try it out. Thanks.

 
chadmriden

Joined: 2005-09-22
Posts: 4
Posted: Thu, 2005-09-22 20:26

I have the same problem with Gallery 2.0 as I click on "Continue to step 3" -

Fatal error: Cannot redeclare class galleryutilities in /Volumes/binky/WebServer/Documents/tools/gallery2/modules/core/classes/GalleryUtilities.class on line 50

OS X Server 10.3.9
Apache 1.3.33
php 4.3.11
MySQL 4.0.24

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-22 21:20

chadmriden, please PM (write to author) bharat. he may not have that much time (right now), but if you can give him SSH access such that he can debug your issue, maybe he can find the time, since it seems to be an important issue.

 
bcbrock

Joined: 2005-09-25
Posts: 2
Posted: Sun, 2005-09-25 21:29

Has a solution been found for this thread yet? I tried to install G2 today and got the same error message during step 3.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-09-25 21:41

there are a couple of issues in this thread. do you mean "cannot redeclare" or the __FILE__ issue?
__FILE__ -> your php is bugged, g2 won't work with it.
cannot redeclare -> your php doesn't work correctly, it's very weird.

 
bcbrock

Joined: 2005-09-25
Posts: 2
Posted: Mon, 2005-09-26 03:08

Sorry... mine is the 'cannot redeclare' weird issue. If needed, I can set up a user on my OSX Box for ssh access.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-26 05:37

please read my last answer for chadmriden, the same applies to you.

 
chadmriden

Joined: 2005-09-22
Posts: 4
Posted: Mon, 2005-09-26 13:00

I can't get a test account with ssh access to that box, but I'm working on setting up a mirror that we can put test accounts on..

 
masi

Joined: 2005-05-02
Posts: 6
Posted: Tue, 2005-11-22 19:54

I've the same problem. I'm running Mac OS X 10.4.3 with Apache/1.3.33 (Darwin) PHP/4.3.11
Though, when I run g2 form my home directory ~/Sites/ it works fine. When running from /Library/WebServer/Documents/ I get the __FILE__ directive problem.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-11-22 19:59

from #gallery (irc)

Quote:
20:23 masi Hi, i got the __FILE__ directive error on OS X. on the forums valiant says my php is bugged and g2 won't work. though it works from my home directories public directory...
20:24 masi link: http://gallery.menalto.com/node/27427
<- itcheg has disconnected ("bye")
20:26 <- bon has disconnected ("leaving")
valiant i guess valiant is right :)
20:27 bharat masi: I've tried debugging that issue several times to no avail
valiant nothing we can do about it. g2 doesn't change the behavior of __FILE__ . you can't change __FILE__, it's a PHP directive. as long as it doesn't work for you....recompile the whole friggin computer
20:28 -> Away_j has joined gallery
20:29 -> itcheg has joined gallery
valiant i've seen a user that has __FILE__ returning an absolute path in one dir and a relative in another. probably a weird php error that isn't yet fixed on all platforms or for old libs...

 
airboy808

Joined: 2006-07-28
Posts: 4
Posted: Fri, 2006-07-28 05:53

any updates on to get this to work?

 
chadmriden

Joined: 2005-09-22
Posts: 4
Posted: Fri, 2006-07-28 12:23

I upgraded php to 5.1.x & it worked just fine. That broke some of the functionality of the default os x server version of SquirrelMail, but if you upgrade that to the latest-greatest, it works ok too.

 
airboy808

Joined: 2006-07-28
Posts: 4
Posted: Fri, 2006-07-28 15:14

we got php 5.1.4 installed but still get:

Fatal error: Cannot redeclare class galleryutilities in /Library/WebServer/Documents/gallery/modules/core/classes/GalleryUtilities.class on line 50

I have not tried all the code mods from above. Is that what you did chadmriden?

thanks

 
chadmriden

Joined: 2005-09-22
Posts: 4
Posted: Fri, 2006-07-28 15:52

I didn't modify Gallery at all.

Now that I think of it, I may have upgraded to server 10.4.x before re-attempting the Gallery2 install.. so if you're on 10.3.x there might be more fundamental issues.