Upgrade to 4.2 Fails

Upgrade to 4.2 Fails

by Dennis Fulton -
Number of replies: 32
Running Moodle 4.1.2 on Ubuntu VPS

After installing the 4.2 Moodle I am receiving the following errors:

 
Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)
Exception - Call to undefined method cache_disabled::check_lock_state()

Any ideas?
Average of ratings: -
In reply to Dennis Fulton

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
Did you purge caches (all of them) right after upgrading?
What's your version of PHP?  Min is now 8.0.
'SoS', Ken
In reply to Ken Task

Re: Upgrade to 4.2 Fails

by joe cool -
Also I had the same error. I could not clear caches in the web gui, since the error prevented my doing anything there. 

So I cleared caches from the command line with 

$ php admin/cli/purge_caches.php

I am running php 8:

$ php -v

PHP 8.1.18 (cli) (built: Apr 14 2023 04:39:24) (NTS)

Copyright (c) The PHP Group

Zend Engine v4.1.18, Copyright (c) Zend Technologies

    with Zend OPcache v8.1.18, Copyright (c), by Zend Technologies

I was already running MOODLE_401_STABLE, which I had installed with git

Upgrading was done via command line, which is shown below:

$ git branch --track MOODLE_402_STABLE origin/MOODLE_402_STABLE

$ git checkout MOODLE_402_STABLE 

In reply to joe cool

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
There is a checks.php script in code/admin/cli/
which is like the GUI environment check but brief.   Will tell you if you are missing supports for the code you are attempting to install.

Also, add the following lines to your config.php (these are taken from SECTION 7 of config-dist.php):

// Force a debugging mode regardless the settings in the site administration
@error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
@ini_set('display_errors', '1');    // NOT FOR PRODUCTION SERVERS!
$CFG->debug = (E_ALL | E_STRICT);   // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
$CFG->debugdisplay = 1;             // NOT FOR PRODUCTION SERVERS!

As well as checking servers error logs.

'SoS', Ken

In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Dennis Fulton -
The checks.php script give the following:

cli$ php -f checks.php
!!! Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE) !!
In reply to Dennis Fulton

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
@Dennis
4.2 requires version 8.0 of PHP minimum.
'SoS', Ken

In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Madhu Avasarala -
Hi Ken,
I too am facing this exact error. However, usually, server requirements should be caught at the environment check level and get flagged but not at the level right after code install. Should this not be the case, and if so, perhaps a bug/enhancement request should be filed?
In reply to Madhu Avasarala

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
@Madhu

Server Admin (ie, you) must do the prelim's to any upgrade ...
One is: Server -> Admin -> Environment check - update component.   Then set to desired moodle version in drop down pick list.
Then you know.
What you are suggesting is a 'dry run' ... and that doesn't exist ... probably will never exist!

The other - checks of addon plugins - of which a third party theme is included.

Yes, it does environment check as first step in process of an upgrade in attempt to stop an admin from a train wreck!   Would be nice if moodle had AI or 'Vulcan Mind Meld' with Admin user before upgrading, but that's not possible! smile

I don't work for any Moodle Partner ... nor Moodle HQ ... just a user.

As it has been recommended in these forums, best to have a dev clone of production server to test anything/everything!

'SoS', Ken

In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Alan Cherwinski -
I am 10 months later encountering the same error going from 4.1.8 to 4.2.5  I my PHP  (8.1) and SQL (8.0.36) versions meet the 4.2 requirements. I had removed the assignment (2.2) modules.   I cleared the server cache. I can revert back  4.1.8, but don't know how to get around this issue going forward?

There must be a large number of users in the last 10 months with exactly the same issue.

Thanks for any help you can provide.
In reply to Alan Cherwinski

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
@Alan ... mind giving a few more details to your situation?   'Me too' posting doesn't give much to go on. :|
Got ssh into server?   I have found performing the upgrade via command line better than GUI.

'SoS', Ken

In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
This is the catch-all thread for all "Upgrade to 4.2 Fails https://moodle.org/mod/forum/discuss.php?d=446147#p1802737. Expect more "Me too" here. Ha, ha, ha!
In reply to Visvanath Ratnaweera

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
This 'catch all' thing is confusing.

Me thinks much of this is un-fortunate ... but could also be a very specific bug ... which makes it difficult to file with tracker as one has to give details on how to replicate. :|

So far:
php version upgraded before upgrading moodle
or vice versa
upgrade to moodle attempted and needed to upgrade php prior to attempt.
Removal of mod_assignment - easiest - removal of mod_assignment in versions below 4.2 via the GUI - that gets tables related with a check to see if the /mod/assignment/ directory has also been removed ... and if not manually remove.
There is also OP's past practice of manually removing a directory and then depending upon moodle GUI to upgrade the DB - ie, remove related tables.
Found that executing the admin/cli/uninstall_plugins.php for mod_assignment did remove the tables, but not the code directory.

Room for improvement for sure ... checks.php doesn't do plugins.   Maybe a plugins_check.php script needs to be added - right now it's an option switch in uninstall_plugins.php - and folks wouldn't be looking there to find out.

Just in observation ... which isn't very scientific at all ... I'd say uprading to 4.2 or 4.3 has been an unpleasant experience for those that:
use old method of acquiring moodle core code
missed out on checking environment and/or plugin compatibility - kinda out of site out of mind ... a proposal for adding links to Check Environment, Check Plugins, and Backup docs in notification screen might help.
didn't happen to see the recommendation to remove mod_assignment prior to
and if they are at a point where they have to use PHPMyAdmin they are in trouble - I too, hate having to mess with DB tables!

Anyhoo ... maybe ... this thread will hold a future lesson for OP's/Admins as well as Moodle HQ in communicating what needs to be done prior to upgrades.

Too bad there is not a 'support plugin' to moodle for admin remote assistance ... gives support person access to CLI via web terminal cause tools needed to fix many things are there already (if Linux) - for a fee of course! smile

My 2 cents!
'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Alan Cherwinski -
Hello Ken - Thanks for your reaching out and offering help. I decided to start over with a clean server and OS. I went with MariaDB and installed a the latest Moodle version. The production server had been updated for more than 15 years. So far it is working well and I have not noticed any significant issues with the courses restored from the backup.
In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Jumping in here - also trying to upgrade to 4.2. I have php8.1 and upgraded mariadb - environment check all green - switch to 402 branch and it blank screens instantly...switch back to 4.1.4 and all good...
In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
@Emma ... mind sharing just how you 'switch to 402 branch' ... am assuming git and as what user (root?).

And mariadb upgraded to what version?  Upgrades of mariadb and mysql might require making sure the DB server is 'secure'/localhost only.

Other places to check for errors:  some apache setups log errors in the directory where error occurs.   So as root from command line and in the moodle code directory, check with a command:
find ./ -name error_log
That should spit out /paths/to/error_log files
View with cat.  Example ... an error_log file in install subdirectory of moodle code is found by find ...
cat ./install/error_log ... or whereever the error_log file is found.

DB server error logs also ... confess I don't know where mariadb would log those but a ps -aux |grep mariadb might give you a clue.

Also, not normally done, but copy and paste the debugging lines from config-dist.php into config.php of moodle code - with git updates/upgrades that file isn't touched and that might spit out more info for ya! smile

'SoS', Ken

Comment: appears quite a few folks are having issues with upgrades to 4.2. sad

In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Have already done most of this - debugging in config file gave me nothing - makes me think it is php related but apache error logs don't give much info - just get a totally blank screen. Used git as root. Switching back to 4.1 version though works just fine so that is baffling. Upgraded to Maria 10.6.14 and PHP 8.1. Just noticed a message about deleting assignment folder - wonder if that is it...
In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
"Just noticed a message about deleting assignment folder - wonder if that is it..."

You might have found the issue!

In 4.1 there remained the old assignment (2.2) but hidden and really couldn't activate it any longer.  mod/assignment.

In 4.2, 'assignment' is being deleted and only the newer/upgraded way back in version 2.2 of Moodle 'assign' remains.

Wonder if the fix involves doing something out of the ordinary and while at 4.1 un-installling - either by GUI admin or manually removing 'mod/assignment/ - would get by this!

'SoS', Ken

In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
A follow up about deleting mod assignment (2.2) in 4.1 of moodle.

Can un-install Assignment 2.2 (disabled) via Admin GUI
It also removes the following tables:
assignment_offline
Success
assignment_online
Success
assignment_upload
Success
assignment_uploadsingle
Success
assignment
Success

No issues/errors in deleting ... now I just need to migrate the instance to a server that can do 4.2 and see.   Sigh ... but don't have time right now! :|

'SoS', Ken


Average of ratings: Useful (1)
In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
@Emma ... got moosh 1.1 installed on that server having issues with 4.2 upgrade - and has mod_assignment (the old 2.2 that is to be deleted)?

On an mtest 3.10.11 instance - am guessing it works with a 4.2 ... don't know why it wouldn't! smile

Issuing:

moosh -n plugin-uninstall mod_assignment

Uninstalling Assignment 2.2 (Disabled) plugin.
Uninstalling plugins...
-->assignment_offline
++ Success ++
-->assignment_online
++ Success ++
-->assignment_upload
++ Success ++
-->assignment_uploadsingle
++ Success ++
-->assignment
++ Success ++

Deleting folder: /var/www/html/mtest/mod/assignment (if exists)
Upgrade noncore.

Default exception handler: The plugin mod_assignment is defective or outdated; sorry you cannot continue. Debug: Missing version.php

Error code: detectedbrokenplugin
* line 755 of /lib/upgradelib.php: plugin_defective_exception thrown
* line 570 of /lib/upgradelib.php: call to upgrade_plugins_modules()
* line 1922 of /lib/upgradelib.php: call to upgrade_plugins()
* line 132 of /root/moosh/Moosh/Command/Generic/Plugin/PluginUnInstall.php: call to upgrade_noncore()
* line 365 of /root/moosh/moosh.php: call to Moosh\Command\Generic\Plugin\PluginUnInstall->execute()

!!! The plugin mod_assignment is defective or outdated; sorry you cannot continue. !!!
!! Missing version.php
Error code: detectedbrokenplugin !!
!! Stack trace: * line 755 of /lib/upgradelib.php: plugin_defective_exception thrown
* line 570 of /lib/upgradelib.php: call to upgrade_plugins_modules()
* line 1922 of /lib/upgradelib.php: call to upgrade_plugins()
* line 132 of /root/moosh/Moosh/Command/Generic/Plugin/PluginUnInstall.php: call to upgrade_noncore()
* line 365 of /root/moosh/moosh.php: call to Moosh\Command\Generic\Plugin\PluginUnInstall->execute()
 !!

While moosh reports errors ... mod/assignment is gone and so are its tables.
 
So if you still have that failed 4.2 with white screen of death, above should remove mod_assignment successfully.   And thus test your 'wonderment'! smile

'SoS', Ken

In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
So this is weird - ran php check.php and it told me there was an issue with the php mysqli extension but my 4.1 site is working just fine so it really can't be bad...
I did find out I have two versions of php on the server 8.1 and 8.1 is the active one and again it is working just fine with 4.1...will try again tomorrow morning after deleting the assignment folder and see if that helps any
In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
So this is the place where all failed upgrades to 4.2 come to rest?
wink

More seriously, that message about delete assignments, could you post it verbatim?
In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Dennis Fulton -
PHP 7.4.3-4ubuntu2.18 (cli) (built: Feb 23 2023 12:43:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3-4ubuntu2.18, Copyright (c), by Zend Technologies
In reply to Dennis Fulton

Re: Upgrade to 4.2 Fails

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
You are not running the correct PHP version...
In reply to Emma Richardson

Re: Upgrade to 4.2 Fails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
In reply to Visvanath Ratnaweera

Re: Upgrade to 4.2 Fails

by Manfred Roer -
Hello, as far as I understand the previous forum posts about the "screen of death" when upgrading from Moodle 4.1.5+ to 4.2 via git, there is no solution yet. I checked the installation requirements on my Ubuntu 18.04 LTS server for the upgrade, it says: 
(1) php 8.0 is required 
(2) Assignment 2.2. subplugins may exist. The mod/assignment folder and all its subplugins must be removed before the upgrade. 

After I met these conditions, the described white screen problem occurred after the update. In debug mode I got the following long error message: """Trouble. blank page, Moodle site won't start. Warning: require_once(/var/www/html/moodle/cache/lib.php): Failed to open stream: No such file or directory in /var/www/html/moodle/lib/setup.php on line 644

Fatal error: Uncaught error: Class "cache" not found in /var/www/html/moodle/lib/classes/string_manager_standard.php:83 Stack trace: #0 /var/www/html/moodle/lib/moodlelib.php(7286): core_string_manager_standard->__construct() #1 /var/www/html/moodle/lib/setuplib. php(520): get_string_manager() #2 /var/www/html/moodle/lib/setuplib. php(363): get_exception_info() #3 [internal function]: default_exception_handler() #4 {main} thrown in /var/www/html/moodle/lib/classes/string_manager_standard.php on line 83"""

After hours of trying different solutions, I gave up and went back to Moodle 4.1.5. I am not an expert and hope there is a simple solution for the upgrade. Thanks in advance and my best regards   Manfred
In reply to Manfred Roer

Re: Upgrade to 4.2 Fails

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
I have been meaning to try again but I did the same thing you did - returned to 4.1 - however I am on a different server now as I thought I might still have a php conflict on the first server...next week, I might try again...I don't remember this much trouble with an upgrade but definitely thought that demanding a php and a database upgrade in one version was a little much...
In reply to Manfred Roer

Re: Upgrade to 4.2 Fails

by Ken Task -
Picture of Particularly helpful Moodlers
4.1.5+ is now out.

"(2) Assignment 2.2. subplugins may exist. The mod/assignment folder and all its subplugins must be removed before the upgrade."

Think this is the first time ever when doing an upgrade it checks for and if found attempts to remove a core plugin .... that's been around since 2.2 but never removed.

Are you sure that 'assignment' directory is NOT present in code directory?
Are you sure that no mdl_assignment tables exist in DB?

At one point in time recently, environment check flagged presence of assignment 2.2 and said it should be removed *before* attempting upgrade.

Maybe 4.1.5+ has resolved.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Upgrade to 4.2 Fails

by Manfred Roer -
In fact, I tried upgrading from Moodle 4.1.5+ and removed the mod/assigment folder beforehand. I don't know if mdl_assignment tables exist in the DB. I am a bit cautious to experiment with the database as there are still 200 students registered on my server who will continue their classes in September. Furthermore, I'm content to update from 4.1.3+ to Moodle 4.1.5+ and rather wait until the semester ends in February 2024 and then do a complete reinstallation. I hope I have not caused any unnecessary headaches by my post. So long and best thanks to all.
In reply to Manfred Roer

Re: Upgrade to 4.2 Fails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
May be a not very helpful check: What is the urgent need to upgrade to 4.2? FYI, Moodle rel. 4.1 LTS will get security updates one full year, 14 months to be exact, after the end-of-life of 4.2. Source https://moodledev.io/general/releases.

Talking of fundamental questions: I'm referring to Manfred's issue, the sub-thread starting here https://moodle.org/mod/forum/discuss.php?d=446147#p1808050 and not to Emma's issue, the sub-thread started at https://moodle.org/mod/forum/discuss.php?d=446147#p1802694. The original thread by Dennis https://moodle.org/mod/forum/discuss.php?d=446147#p1793017 is SOLVED, I believe https://moodle.org/mod/forum/discuss.php?d=446147#p1793135. And Madhu hasn't come back: https://moodle.org/mod/forum/discuss.php?d=446147#p1793199.
In reply to Visvanath Ratnaweera

Re: Upgrade to 4.2 Fails

by Manfred Roer -
Hello Visnavath, thank you for your feedback. I usually only update twice a year during the semester break. It's not urgent, so I'm happy with the small update from 4.1.3 to 4.1.5. But I don't think it's a bad idea to try the latest version while you're updating. Since I know that you speak perfect German,  nochmals vielen Dank für deine Beiträge, die ich immer mit Interesse verfolge.  I think we can also close my question as the problem will surely solve itself with the upcoming updates. Best regards to all