Upgrading moodle from 3.10 to 4.3

Upgrading moodle from 3.10 to 4.3

by Pedro Carvalho -
Number of replies: 6
Hi,

I'm trying to update moodle from 3.10 to 4.3. I know that there is no direct update, so I need to first update the moodle to 4.0 as intermediate step. This is the procedure I did:
  • To test, I created a virtual machine and copied the 3.10 version of moodle to /var/www/http folder.
  • In the same folder I created two more versions, 4.0 and 4.3.
  • I created two mysql databases, one for the version 3.10 (this database is isolated because I want to have a backup), and the other for the upgrade, which will be used to upgrade the moodle from 3.10 to 4.0 and then 4.3.
  • The upgrade from 3.10 to 4.0 is done using apache2 + php7.4, while the upgrade from 4.0 to 4.3 is done using apache2 + php8.1.
  • All the custom plugins where copied first from 3.10 to 4.0 and then from 4.0 to 4.3
  • The upgrade from 3.10 to 4.0 worked "fine", just a few problems in the layout.
  • The upgrade from 4.0 to 4.3 worked just like the above, but when I try to open the webiste (http://ipaddress/moodle) it throws an error "Fatal error: Declaration of theme_adaptable\output\core\course_renderer::course_modchooser($modules, $course) must be compatible with core_course_renderer::course_modchooser() in /var/www/html/moodle-updated/theme/adaptable/classes/output/core/course_renderer.php".
I'm assuming this is an issue in the adaptable plugin. Probably, the plugin that is in 4.0 folder doesn't work with php 8.1.
Do you have any idea on why this is happening?

Thanks
Average of ratings: -
In reply to Pedro Carvalho

Re: Upgrading moodle from 3.10 to 4.3

by Ken Task -
Picture of Particularly helpful Moodlers
In /var/www/html/ how many 'moodle' directories do you have?

You didn't mention DB version, but think you need to read/compare version requirements:
https://moodledev.io/general/releases

One can avoid missing requirements by going to Admin -> Server -> Environment Check - update component.   Then choose higher versions of Moodle in the drop down pick list to see what your moodle server lacks.

That won't check add-on plugin compatibility - like the theme you mentioned.   Acquire a list of addons and search https://moodle.org/plugins/ for those plugins to see if there is a compat version for your destination version of core.

And, IMHO, there is a better way to install/update/upgrade a moodle (even do a march like you are doing) via Git versioning.
Please see:
https://docs.moodle.org/403/en/Git_for_Administrators

'SoS', Ken

In reply to Ken Task

Re: Upgrading moodle from 3.10 to 4.3

by Pedro Carvalho -
I have 3 moodle directories, 1 as backup (3.10) the other two (4.0 and 4.3) are to test the update flow. The idea is to simulate an upgrade that I will do to a real moodle site. The db is mysql 8.0.
Anyway, after some digging in the moodle forums, I decided to try one thing. I used the $CFG->theme = 'boost', just to enter in the moodle site. I was able to install the plugins to latest versions.
However for the recompletion plugin, I'm getting the following error:

Error writing to database

More information about this error
Debug info: Column 'courseid' cannot be null
INSERT INTO local_recompletion_ssv (attemptid, scoid, elementid, value, courseid, timemodified)
SELECT a.id as attemptid, t.scoid as scoid, e.id as elementid, t.value as value, s.course as courseid, t.timemodified
FROM local_recompletion_sst t
JOIN scorm_element e ON e.element = t.element
LEFT JOIN scorm s ON s.id = t.scormid
JOIN local_recompletion_sa a ON (t.userid = a.userid AND t.scormid = a.scormid AND a.attempt = t.attempt)
[array (
)]
Error code: dmlwriteexception
Stack trace:

line 497 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
line 1292 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
line 1057 of /local/recompletion/db/upgrade.php: call to mysqli_native_moodle_database->execute()
line 803 of /lib/upgradelib.php: call to xmldb_local_recompletion_upgrade()
line 1985 of /lib/upgradelib.php: call to upgrade_plugins()
line 726 of /admin/index.php: call to upgrade_noncore()

Thanks
In reply to Pedro Carvalho

Re: Upgrading moodle from 3.10 to 4.3

by Ken Task -
Picture of Particularly helpful Moodlers
You aren't reading the releases:
https://moodledev.io/general/releases/3.10
https://moodledev.io/general/releases/4.0
https://moodledev.io/general/releases/4.3

The last link above says:
Moodle upgrade: Moodle 3.11.8 or later.
So you could upgrade your 3.10 to 3.11.highest
and then hyper jump to 4.3 ... or so it says ...

But ... Catch 22's:
moodle is removing the old assignment 2.2 - recommended that be un-installed
prior to any upgrades.
Also removing examview.  You will also hit change in default editors:
atto -> TinyMCE (but not the full blown TinyMCE)
And, you've already discovered the issues with 3rd party themes during upgrades.
Setting default theme to boost throughout the march is wise.

'Devils are in the details'!

local_recompletion

https://moodle.org/plugins/local_recompletion/versions

I'll say it again ... the *best* way to march or update or upgrade a moodle is
to use Git.   See previous link.   If one marches a moodle via git, those little things that turn into big ones get taken are of during the march.

And there really isn't any reason to keep a 3.x any point release 'alive' and accessible
via web - even in your test environment.   Make a backup of it ... tar ball of code, tar ball of moodledata, and SQL dump of the db.

Me thinks you are so focused on your plan/process that you are ignoring the *best* way.
And as a result, having to work harder not smarter!    But that's my 2 cents, I guess.

'SoS', Ken

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

Re: Upgrading moodle from 3.10 to 4.3

by Pedro Carvalho -
Ok, so, I did the update through git and it seems easier. However, I found an issue when doing the upgrade from 3.10 to 4.00. It seems the adaptable theme doesn't work well with the custom css I had in the version 3.10. Is it normal that an upgrade from moodle 3.x to 4.x creates a different html for the landing page and login page?
In reply to Pedro Carvalho

Re: Upgrading moodle from 3.10 to 4.3

by Ken Task -
Picture of Particularly helpful Moodlers
+1 to Emma's response + 2 cents more.

Large change - 4.x touts revamp of UI/UX (theme).
It is also a good idea to force the theme to use one of the themes that come with core - boost/classic via config.php just prior to update/upgrading to avoid white screen of death when using 3rd party theme if you did not check for compat of the theme prior to update/upgrade.

$CFG->theme='boost';

'SoS', Ken

Average of ratings: Useful (1)
In reply to Pedro Carvalho

Re: Upgrading moodle from 3.10 to 4.3

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Well, did you upgrade Adaptable to match the new Moodle version - huge difference between 3.10 and 4.3 - 3.10 themes are not going to work with 4.xx versions...download the latest version..