Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

by David Mortimer -
Number of replies: 5

I'm installing Moodle on an Ubuntu server 20.04 instance on AWS, via EC2 Instance Connect, following the step-by-step Moodle installation guide on Ubuntu.

I install and update all necessary php packages, Apache2, MySQL, set up a root password, install all additional software, update and upgrade packages (including git), restart apache, obtain the most recent branch, copy the local repository to /var/www/html/, create the table within MySQL, and create my user ID attached to the table;

mid and late-March, I was able to do all of this and then access the public IP of the newly set up Apache2 server, from which I would then use ip.address.of.server/moodle to install Moodle; however, after trying to do the same thing after April 1st (we paused in the final few days of March because we'd gone over our free tier limit for testing), after performing the steps above, I now get the error when attempting to perform the install;

Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

After checking the php file, this is the line in question;

/**  * Magic __set_state method used for var_export  * @return string  */@return string  public funcstring  return $this->get_stri

The closest thing I've found to this on the forum is this thread that has a similar error, though using XAMPP; obviously I'm not using XAMPP, but is that error related to my own? I'm using Moodle 3.9.6+, MySQL Ver 8 and all php software is 7.4, in-line with the Ubuntu installation guide linked above.

I'm fairly new to Linux and Moodle (and AWS, not sure how much of an effect that will have on the installation process), so I'd appreciate the help, and will try to offer any additional information needed.

Average of ratings: -
In reply to David Mortimer

Re: Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The error from the other thread relates to the PHP version, it doesn't matter if it's XAMPP or otherwise. Your editor might be mangling that slightly, it should be:

Lines 10598 to 10605 of lib/moodlelib.php

Are you installing via the web interface (not the command line)? If you create a file called phpinfo.php in the Moodle source code folder containing:

<?php
phpinfo();

Then in your browser go to ip.address.of.server/phpinfo.php what version does it show at the top? Because all things being equal I would be certain you have PHP 8.0, not 7.4.

Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

by David Mortimer -
php8.0 confirmed I thinkAfter creating a new instance and entering "sudo apt install apache2 mysql-client mysql-server php libapache2-mod-php" as instructed by the tutorial, I checked the packages being listed for installation and you're right; they include 8.0. I'm assuming then (again, being a new user) that these are different to the php7.4-curl/aspell/etc. packages that are suggested further down in the guide? I hadn't realised that it would install php8.0 software during that phase--would you have any suggestions as to how I specifically install php7.4? Is it that simple, just adding "sudo apt install apache2 mysql-client mysql-server php7.4 libapache2-mod-php" instead of just 'php'?
In reply to David Mortimer

Re: Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

by Matt T -
Yes, specify php7.4.
Average of ratings: Useful (1)
In reply to David Mortimer

Re: Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Also: if this is going to be a public/production site remove that phpinfo.php file as it may reveal information about the server that could be useful to an attacker.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Fatal error: Method lang_string::__set_state() must take exactly 1 argument in /var/www/html/moodle/lib/moodlelib.php on line 10603

by David Mortimer -
That did it, thanks guys. I'm able to setup and install Moodle through the web browser once again. Help was much appreciated; you were correct in that it was because it was version 8.0 being used, and I know for future purposes. Much appreciated.