Fatal Error: Constant X already defined...Cannot redeclare X

Fatal Error: Constant X already defined...Cannot redeclare X

by Ames Brown -
Number of replies: 5
I've been preparing launch of a site using 1.2B

Prep tested on a Linux server, Apache 1.3.26, PHP 4.3.4, MySQL 3.23.49
everything worked fine!

Installed production version on a Sun server, Apache 1.3.29, PHP 4.3.4, MySQL 3.23.49
errors appear every time try to post a resource, label, etc. to a course


extended error reporting shows following (subbed in [path] to make easier to read):

error when posting a Label
Notice: Constant LABEL_MAX_NAME_LENGTH already defined in [path]/mod/label/lib.php on line 6
Fatal error: Cannot redeclare label_add_instance() (previously declared in ../mod/label/lib.php:8) in [path]/mod/label/lib.php on line 8

leaves this message above post
Notice: Undefined index: 25 in .//lib.php on line 912

error when posting a Resource
Notice: Constant REFERENCE already defined in [path]/mod/resource/lib.php on line 3
Notice: Constant WEBPAGE already defined in [path]/mod/resource/lib.php on line 4
Notice: Constant UPLOADEDFILE already defined in [path]/mod/resource/lib.php on line 5
Notice: Constant PLAINTEXT already defined in [path]/mod/resource/lib.php on line 6
Notice: Constant WEBLINK already defined in [path]/mod/resource/lib.php on line 7
Notice: Constant HTML already defined in [path]/mod/resource/lib.php on line 8
Notice: Constant PROGRAM already defined in [path]/mod/resource/lib.php on line 9
Notice: Constant WIKITEXT already defined in [path]/mod/resource/lib.php on line 10
Fatal error: Cannot redeclare resource_add_instance() (previously declared in ../mod/resource/lib.php:57) in [path]/mod/resource/lib.php on line 57

leaves this message above post
Notice: Undefined index: 24 in .//lib.php on line 912


Trying to post any other module type gives errors in same format

I've used .htaccess to match everything on the Sun setup to the successful Linux setup.

At a loss...any ideas?


Average of ratings: -
In reply to Ames Brown

Re: Fatal Error: Constant X already defined...Cannot redeclare X

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
That's a wierd one, Ames, I've got no ideas ...
In reply to Martin Dougiamas

Re: Fatal Error: Constant X already defined...Cannot redeclare X

by Ames Brown -
Martin, I don't think it's an isolated problem. Here's another replication posted by Antti Immonen back in late Nov 2003:
http://moodle.org/mod/forum/discuss.php?d=3762&parent=16703

I don't know whether his server is also a Sun box, but from Antti's description it is obviously something which happened in 1.2 which didn't exist before.

I have no experience with earlier versions, as this initiative began a few months ago in search for a backend having a flexible pedagogic structure, a multi-tiered authoring permissions structure tied to content sections, & the differentiator in current CMS-type backends: IE&Gecko based cross-platform WYSIWYG smile. Moodle seemed perfect for what might rapidly become an international portal focused totally on ubiquitous computing in K12 education through an organization heading into its 3rd year of existence...if I can get the thing to run on the university Sun box designated for this purpose smile I've sunk some serious hours into theme design, en-lang file changes to give Moodle a portal-type flavor which 'hides' the course-orientation, and new colorful icons. Apple has been an annual funder of the organization so far and they might be prevailed upon to contribute a G5 box in the future...but I've got to get this thing functioning now on the Sun box...it's driving me nuts, as I have it functioning perfectly on a Linux box.

Perceptual characteristics of the behavior:
  • Can create categories and courses endelessly with no problems.
  • None of the mods smoothly function for completion of postings to courses or to the main menu block.
  • Any mod posting to a course, such as a forum, resource, label, or quiz will successfully post to the database despite error message, however only the correct icon next to the posting label will show with no label/link next to it, i.e. a user cannot select it. However, in edit mode, the posting can be brought up showing everything was captured whether an add or update instance.
So, the problem seems to occur in output back to screen of the mod label/link--capture of data works fine. Examination of the MySQL tables shows that whether an add or update, both name and content are correctly preserved, i.e. it only seems as though all was lost.

Of course, without display of the label/link for a posted forum, resource, link, choice, lesson, quiz, etc...there is no representation of the data safely stored thoughtful

What makes the process for outputing courses and course categories back to screen (which do work) different from outputing mod course resources back to screen (which do not work)?? Might there be a very simple change to make them function the same?


In reply to Ames Brown

Re: Fatal Error: Constant X already defined...Cannot redeclare X

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I've not personally seen Moodle on a Sun box before (though I used to sysadmin Sun boxes a long time ago).

Can you send me (privately) some access details?  I'd like to take a closer look at this one.  A Moodle admin account at minimum and ideally an ssh account.
In reply to Martin Dougiamas

Re: Fatal Error: Constant X already defined...Cannot redeclare X

by Ames Brown -
Martin, just sent you an email with acct access info for the Sun box  smile
In reply to Ames Brown

Re: Fatal Error: Constant X already defined...Cannot redeclare X

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
OK, great.  Problem is now fixed.

It seems to be something to do with the chroot going on there in that account ... for some reason there are problems when including a file using a relative path like ../mod/label/lib.php.   I changed it to use absolute names then rebuilt the modinfo cache and all is well now.

This fix will be in 1.2 too.  smile