PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Number of replies: 27

Hi,

we run a 4.1.5 Moodle on Ubuntu 22.04 with Apache, PHP 7.4 and Mariadb 10.6.16.

I have updated alle plugins in 4.1. Then copied all files for 4.2 in a separate directory, copied all blocks, questions, plugins etc from 4.1 to 4.2.

Then i started Moodle and got:

Error: syntax error, unexpected ')', expecting variable (T_VARIABLE)

Nothing else - i cleared all browsercaches with no result.

Now i see that i minimally need PHP 8.0 - which is also installed on the server.

Questions:
Does anyone have experience with this error?
Do i have to purge the Moodle caches in 4.1 before the upgrade? Can it be done through the commandline? 

I will be gratefull for any hint.

Thanks,
Jan

評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
Moodle 4.1 LTS is PHP 8.0 capable and even PHP 8.1 capable since Moodle 4.1.2. See http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases. So one alternative would be to upgrade PHP to 8.0 or 8.1 first.

Caution: I don't know whether it is a good idea to upgrade PHP in a production server.

And also, I don't know why you go from 4.1 LTS to 4.2, which as a non-LTS has a shorter life span. See https://moodledev.io/general/releases.
評比平均分數:Useful (1)
In reply to Visvanath Ratnaweera

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Hi Visvanath,

I run PHP 5.6 up to 8.3 on the server (ondrey repository) and can choose which PHP-Version is used for each Website/Webapp.

The reason for 4.2 is that the user (Gerd) wishes to update to 4.4 and i have had a bad experience with skipping major versions.
So step 1 is from 4.1 to 4.2.

Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
In that case I would have gone to 4.3. It has corrected some overdone UX changes in Moodle 4 and after four minor releases very stable. Your bad experience with the long jump 4.1 LTS > 4.4 doesn't mean that long jumps generally go bad.
評比平均分數:Useful (1)
In reply to Visvanath Ratnaweera

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Thanks Visvanath,

my problems were with the moodle 3 series where i skipped a major release, after that i always made every update one by one from major release to major release.
What is your opinion on Ken's proposal to go to git for updates? I am open for anything but would always like to hear different opinions.

Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
A second opinion on Ken's opinion? Ha, ha, ha! It is like asking the general practitioner to endorse the specialist's opinion. But this particular question is an easy one: Git is the best, it is the work of Linus Torvalds - next to Linux, where we meet.

Seriously, I'm surprised that "an install where so many things are tried out" is not on Git.

About the other problem you had with a Moodle 3 upgrade, the rational way is to investigate what went (you did) wrong and learn from it, not to avoid double jumps. One could argue that the missing Git caused it. Either way, I am cautious, it looks like you work straight on the production Moodle, not on a trial instance. Again, may be, because you miss the correct tool?
'-)
評比平均分數:Useful (1)
In reply to Visvanath Ratnaweera

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Hi Visvanath,

i have 2 Testinstalls of which one is on my own server that is identical to that of Gerd.
Considering the speed with which Gerd changes "plans and plugins" and himself being the one that "runs the show" one can just accept it and make the best of it.
I have a long experience working as a systemadministrator and you know that there are users that simply do not test first.

Avoiding problems with a workflow that proved to be succesfull seems quite logical to me.


Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

"Avoiding problems with a workflow that proved to be succesfull seems quite logical to me."

'that proved' is past tense, is it not? 微笑

You have a test instance ... why not see for yourself if git is better than your current workflow on updates and upgrades.   I see one that is kinda obvious to me ... your current version of Moodle is 4.1.5 - the highest/most secure of that series is now 4.1.10+.   Why isn't the current site a 4.1.10+?

A site under git ... a bash shell script called 'up' ... executed with ./up [ENTER] sure does sound a lot quicker than old workflow.

up does the following:

runs a site backup

runs cron

puts site in maintenance mode

does a git pull - new code

runs the upgrade - takes web service out of the loop.

takes site out of the maintenance mode.

purges caches.

I have several instances on different networks and environments.   The other day I updated them all - with backups - in a matter of 3 hours.   The backups are what took the lions share of that time - no errors.

'SoS', Ken

評比平均分數:Useful (1)
In reply to Ken Task

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Hi Ken,

i like your humor, "paste tense"!

Yes i will try git on a test-install.

About Wordpress/woocommerce.

ISPConfig is like Plesk or CPanel - every install has its own directories, PHP-version, apache-directives and also htaccess.
In total the load on the sever is not extreme, i check that regularly.

The only point that is troublesome is a script to connect the calendar with the calendar of EGroupware.
I have to check whether EGroupware has now a way to communicate with external calendars, like moodle has.
They EGW told me that is was planned to be developed.

The update is the technical part that was postponed because some organisational problems had to be cleared considering "some coordination".

Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Hi,
i have deleted the "assigment plugin" all together, as the site on versions, mentioned before, tells that 4.1.5 could function on PHP 8.0 i tried that.
The effect is
Errorr: Undefined constant "define"

Nothing else - under 7.4 the site is still working.
The only red flag considering the update to 4.2 is the PHP-version.

I decided that i will try to install 4.1.10+ first to see if PHP 8.0 will work then.

Regards,
Jan
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

If you have debugging turned on and set to max, you should see some more useful information.

http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases
row for 4.1
Columns for PHP min 7.4.0 max 8.1[6]
the (6) footnote
PHP 8.1 since Moodle 4.1.2.

I have several 4.1.10+ sites (git installed and maintained - with some addon plugins) running under 8.1.28 of PHP

What's your contributed plugin list?

And I asked about where moodle code was in relationship to the wordpress.

Reason: .htaccess

'SoS', Ken

In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

Sounds like you don't have an upgrade check list.
Error: syntax error, unexpected ')', expecting variable (T_VARIABLE)
is an indication that a plugin (themes are plugins - contributed) or any customizations
to core code is not compatible with the required version of PHP + extensions.

You are not using git .. too bad .. as the first step I would perform is an 
update to the 4.1 to get it to the highest available for that version which is 4.1.10+
That would acquire not only fixes but security updates.
If that failed for some reason, you're not gonna be able to do a 4.2 upgrade.
A site under git versioning means no moving parts prior to any update or upgrade.
Code directory stays where it is ... no copy back etc.
Git wlll also show customizations/hacked core code.

Gerd?  What the heck is that?

Login as admin, Server, Environment check.
Update component.
Set drop down pick list for next highest version of Moodle.
Any Reds or Yellows?
Address those before going anything more.

Next, check plugins from moodle.org plugins.
(you said you did this)

There is a command line only script in admin/cli/ called 'uninstall_plugins.php'.
It has an option to list all contributed plugins.   There is your list to check
moodle.org plugins.

It will also show custom code that it does not recognize ... RED FLAG.
Can't help ya there ... but is definitely an area for investigation prior to upgrade.

Other things one might want to do ...
From admin/cli/ run check_database_schema.php
One might be surprised as to what has changed DB wise - crept in but didn't cause
moodle to whoopee!

Can an upgrade be done via command line?
Sure can ... much preferred as it takes web service out of the loop and it's
just your php taking to your DB.

Then there are php settings ... max_input_vars, time for a script to run, memory
a script can consume.

'SoS', Ken

評比平均分數:Useful (2)
In reply to Ken Task

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Hi Ken,

thank you very much for these hints, i will start working on it and notify.

As far as GIT is concerned, i have doubts if in an install where so many things are tried out "in production" this is a good idea.

BTW Gerd is the user, the owner of the driving school.

Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

In config.php set theme to be forced to boost:
$CFG->theme='boost';
and leave it there until after successful upgrade and theme updates.

Moodle has a new doc:
https://docs.moodle.org/404/en/Administration_via_command_line

22 and 22.1 Managing Plugins via command line and List and Uninstall Moodle plugins

Think the version you are staring with 4.1.x was the version that recommended
using the GUI interface to remove the old assignment 2.2 which has been hidden
for a very long time and shouldn't be used.

The script to remove:
php admin/cli/uninstall_plugins.php --plugins=assignment to see
Then to attempt to remove:
php admin/cli/uninstall_plugins.php --plugins=assignment --run

Discovered that command removed the tables, but not the code.
Had to manually erase mod/assignment

On the same page ... See Also at bottom
Don't forget the Swiss Army Knife for Mooodle - Moosh.

Once you get the plugins cleaned up, I'd still do a 'gitify' on core code.
And a finger wag to Gerd for going Plugin Happy ... 'if you don't use it, lose it!"

In the last year or two, I've taken on quite a few 'projects from HELL' ... able to fix via command line.   Those sites are on git now. 微笑

'SoS', Ken

評比平均分數:Useful (1)
In reply to Ken Task

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Thank you Ken for all the useful help.
2 "reds"
I will have to read that carefully and as i already started, i must put PHP 8.0 in charge for Moodle to run the update.
I will also have to get rid of Assignment 2.2 subplugins

Although there is no red, we had the googletranslate plugin with a connection to Googlecloud (imho an absolute catastrophy) it must be removed first.
We even combined that with Readspeaker, after the Readspeaker-plugin was removed the translations were inconsistent, i corrected the translations where i found errors, there may be some more i did not find.

As Gerd is the owner and i am "just" the systemadministrator for the server, the controlpanel (ispconfig) and all the Software on the server including 8 CMS-installs, Nextcloud and up to 8 other webapps, Gerd decides what he wants installed (with an other expert that has no experience with any of the software installed). . . so i am herding cats here and being nostalgic about the VMS-Cluster i used to manage in the old days.

The preparation i will do tomorrow, it is 23:15 now here so i will better sleep first.

Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

"8 CMS-installs" - really!!! 8?!!!!

Any of those WordPress?   And are they up to date as well?

Important ... where is the moodle code directory in relation to the rest of the stuff?

So you are the moodle person and there is another 'expert' for other stuff?

Wow!  Can see an wreck looking to happen there unless there is some coordination! :|

So might I suggest making a site backup of the moodle first?

'SoS', Ken

In reply to Ken Task

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Hi Ken,

I am not just for Moodle, also the other software and the server.
The CMS is a lightweight but nice system and no Wordpress, we have only 1 Wordpress (with woocommerce) on the server that brings more work than the other CMSses together.

I have build up everthing and coordinate it too. "Just" the courses, videos and the daily use of Moodle is made by Gerd.
He is the one doing the content.

And yes we make backups.

Regards,
Jan
評比平均分數:Useful (1)
In reply to Jan van Leeuwen

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

Ya missed one ... where is the moodle code in relationship to the WordPress woocommerce CMS site?

Reason I ask ... WP/woocommerce uses .htaccess files ... .htaccess files are heirarchial - top level .htaccess file affects all files/folders beneath.   Those have been known to affect Moodle adversely.

'SoS', Ken

評比平均分數:Useful (1)
In reply to Ken Task

Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於

Hi Ken,

first of all thanks for all the help.

I did coordinated this server with all software, moodle 4x, cms made simple 8x, nextcloud and about 6 other small webapps, all running under the foss controlpanel called ispconfig. Gerd has 2 other server, 1 with BigBlueButton that i installed and 1 with nextcloud, all coordinated and serviced by me.

All Webapps inclusive Moodle have there own Webspace on the server with there own PHP-Version (ondrej-repo) so tehet cannot beconfusion with .htaccess-files.

Considering this thread, there will be no more progress for i stopped working for Gerd.

I cannot keep control when another "expert" with no experience in any of the software that i listed here is changing and breaking things on the server,
and a drivingschool-owner that thinks he can judge it-professionalty and is too stubborn to see he cannot.

So i will be busy with other software and moodle is for now a thing of the past.

Kind regards,

Jan

In reply to Jan van Leeuwen

[CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

A case of 'Too many Chiefs and not enough Indians?"  I too have had 'customers' that would argue and wanna do things not advised.  Nice thing about being an independent, I don't have to work for/with anyone!  All the 'finger wagging' is for naught.  Best to part ways!

So we can consider this thread 'CLOSED'!

'SoS', Ken

In reply to Ken Task

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
Thanks for the confirmation and yes this thread can be closed!

Regards,
Jan
In reply to Jan van Leeuwen

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於
One last answer.
If you run ISPConfig as a control panel for the server, then using git is a bad idea for it ruins the workflow of ISPconfig.
The time you gain with using git will be lost with all adjustments needed to keep the ispconfig-part working.
Jan
In reply to Jan van Leeuwen

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Ken Task發表於
Particularly helpful Moodlers的相片

It's been years and years since I looked at ISPConfig!   In doing a quick google ... yep, can see where git seems to give ISPConfig a lot of extra's to do.   Too bad. 傷心

But thanks for sharing back that bit of info ... might save time for someone else using ISPConfig.

'SoS', Ken

In reply to Ken Task

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
"Years since"? I've never heard of ISPconfig. My answer is the same as elsewhere, with (secure) shell access you don't need any of those!
In reply to Visvanath Ratnaweera

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於

I guess your car does not need powersteering as well . . . 

In reply to Jan van Leeuwen

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
Not joking. I drove cars for decades, non of them had power steering. The last two had something "power assisted", but only when the car was rolling.

Same thing with the manual gear box.

May be I'm the type who prefers steering in one's own hands.
微笑

In reply to Ken Task

Re: [CLOSED] Re: PHP-error after preparing for upgrade fron 4.1.5 to latest 4.2

Jan van Leeuwen發表於

Last Answer,

it is possible to run Git and ISPConfig.

You need to search the ISPConfig-forum to figure out how.
I would refrain from that.

Regards,

Jan