Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Richard Webb -
Number of replies: 16
Today was supposed to be a day of triumph. The IS director finally gave his consent to upgrade from Moodle 1.8.2 to Moodle 1.9.2. I have done the upgrade process numerous times on my Mac and PC's at home, so I figured this would be a cake walk. WRONG!

After installing the software (replacing old Moodle folder with new folder and copying config.php over) we went to the WWW browser to initiate the conversion and got a blank screen. A little searching here and we pasted in code to make it display errors. Tried again and this is what we got:

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION
 or T_FUNCTION or T_VAR or '}' in /var/www/html/moodle/lib/adminlib.php
 on line 3517
The line being referenced in the error message is the bold line below:
/**
 * Enrolment manage page
 */
class admin_enrolment_page extends admin_externalpage {
 public function admin_enrolment_page() { 
global $CFG; parent::admin_externalpage('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php'); }
which doesn't look so bad to me. I did a search here and found multiple entries reporting the same parse error in different situations and the solution is generally to upgrade the version of PHP, which I requested in May when I requested upgrading to Moodle 1.9. If I had control, I would do the PHP upgrade before coming here, but as you can surmise, I do not have any control.

After running into this problem, I went back to Site Administration-->Server-->Environment and noticed that there is an option to update component. I did that and it threw me some hints, but not enough for me to know what is going on. Here are the two hints it gave me:

php_extension xmlrpc docs.gifis recommended to be installed/enabled

xmlrpcrecommended

Check
Other checks

docs.gifError reading environment data (13) Error

We have fixed the "Other checks" error following the instructions posted here and are checking on the possibility of adding the recommended xmlrpc extension (it is not part of our installation of PHP). However, it does not appear that a missing recommended extension should be responsible for this problem.

The following are the important environment details:

Redhat Linux 2.6.9-55.0.2.ELsmp
PHP Version 4.3.9
Apache/2.0.52
MySQL 4.1.20

Any and all help would be appreciated in getting these problems solved!

Thank you,

Richard
Average of ratings: -
In reply to Richard Webb

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm going to take a wild stab in the dark here... you got Moodle from CVS?

It's not Moodle 1.9.x you have there (or at least that file isn't). That's from the Moodle 2.0 development branch. Get rid of that version of Moodle and start again.
In reply to Howard Miller

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Richard Webb -
Nope, not CVS. It's the Moodle 1.9.2+ that was built yesterday.
In reply to Richard Webb

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Mmm.... MDL-15890
In reply to Howard Miller

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Richard Webb -
Sweet outcome! Petr already fixed it (in CVS) by removing the word public. We have now successfully passed that hurdle and are in the database conversion business. Thank you for jumping on this for me Howard and Petr!

Richard
In reply to Howard Miller

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Kam Vento -
I also tried an update, usually goes very well from current version of 1.92+ to weekly patches. Backed-up all original Moodle files, including "Moodledata" to a "save" folder. Also saved a sql dump of the database.

I got the same error you did, updating from Moodle 1.92+ to todays Moodle-weekly.

Trying to roll-back the install. Have copied the original files back to the Moodle directories and I think uploaded the sql database backup before the install.

Blocks on main screen are scrambled and have "skip" next to them. Also unable to login as admin. http://www.lassenonline.org

Fatal error: Call to undefined function: profile_user_record() in /usr/local/4admin/apache/vhosts/lassenonline.org/httpdocs/moodle/lib/moodlelib.php on line 3308

I'm hoping someone has an idea, because I'm broken. I'm wondering if I should try 1.92 release, I believe it's newer than my last 1.92+

Another note: I don't see a version file in the moodle root.

Thanks
Kam
In reply to Kam Vento

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Did you take a database backup before you started the upgrade? If you didn't, you have just learned something the hard way (but read on). If you did I would try and roll back to where you where.

The other option is to grab the *latest* 1.9 CVS (see the CVS for Administrators docs but substitute MOODLE_19_STABLE for MOODLE_19_WEEKLY) this will be the newest and have Petr's fix. This has the best chance of getting you out of trouble.
In reply to Kam Vento

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Richard Enison -
KV,

If you don't have a version.php file in the main folder, that is a major problem. Offhand, my recollection is that Moodle will shut down if it doesn't find that file. Looks like you have at least one missing file, which means either the extraction from the download file or the download itself was incomplete. Hopefully this will be taken care of when you either roll back or go to CVS.

RLE
In reply to Kam Vento

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Richard Enison -
KV and all good little Moodler boys and girls everywhere,

Just for the record: I just noticed that the undefined function in your error msg., profile_user_record, is defined in user/profile/lib.php, which is included (if it hasn't already been) by the line just before the one that got the error (line 3307 in lib/moodlelib.php). Which means that the only way that error could occur is if that lib.php file, like version.php, is also missing in the buggy download file of 1.9.2+; or else that file is incomplete.

RLE

EDIT: P.S. In the code listing at http://xref.moodle.org/nav.html?index.html, where I discovered this, if you look at the summary screen for user/profile/lib.php, it looks like all the functions defined in that file are really methods of a class (profile_field_base), which would mean that the function really is undefined. However, if you examine the code (and the comments) in the file carefully, you will find that the last eight functions defined are not part of the class. So the summary page is inaccurate.
In reply to Howard Miller

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Kam Vento -
Try the latest official release 1.92 11 July 2008. It fixed my problem! Looks like current weekly 1.92+ has a glitch.
In reply to Kam Vento

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It certainly does.... that's what we've been talking about big grin
In reply to Richard Webb

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Kam Vento -
Richard I installed 1.92 instead of 1.92+ and ignored the xmlrpc message. My site is working great!
v
In reply to Richard Webb

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Zbysiu Rodak -
Tried to update a test site with 1.9 weekly today and got different errors, so tried twice to do a clean install and failed both times. Just done a fresh install of 1.9 stable successfully.
In reply to Zbysiu Rodak

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Alex Büchner -
What exactly is the Update Component in Site Administration-->Server-->Environment supposed to do? Surely, it cannot install missing php_extensions?
In reply to Alex Büchner

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Ian Wild -
Picture of Plugin developers
Hi Alex smile!

I don't know if you've already got an answer to this one, but if memory serves it tries to download an XML file containing a list of the different php extension requirements for the different versions of Moodle. I guess if you want to find out what the latest requirements are you can download the latest file? Not sure thoughtful.

Cheers,

Ian.
In reply to Ian Wild

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Richard Enison -
IW (& AB),

You're on the right track. What it does, in both 1.8.3 and 1.9, which is hopefully close to what it is supposed to do, is to download http://download.moodle.org/environment/environment.zip to the data folder (directory) and unzip it there. That zip file, which I just downloaded to see what is in it, contains only a folder called environment, which contains only a file called (guess what? That's right!) environment.xml.

And yes, that xml file contains a list of the php extension requirements for each major version of Moodle (starting with 1.5). But it contains more than that. It also contains, for each version of Moodle, which types of databases can be used and what version of each; whether the database needs to be Unicode-compliant; what version of PHP is required; and other requirements.

I'm still a bit fuzzy on what this has to do with the subject of this thread.

RLE
In reply to Richard Enison

Re: Installation failure: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}

by Ian Wild -
Picture of Plugin developers
RLE,

Thanks for your post. I suppose I should have just clicked on the link to see what happened blush.

Cheers,

Ian.