Moodle 4.2

Moodle 4.2

از Paul Raper در
Number of replies: 20
I just took a quick look to upgrade my Moodle 4.1 to 4.2 but was not able to find the channel.

git branch --track MOODLE_402_STABLE origin/MOODLE_402_STABLE does not seem to exist.

Can anyone shed some light please?

میانگین امتیازات:  -
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
In your 4.1 code directory, what does:

git branch -a

show?

Did you install the 4.1 using ...
git clone -b MOODLE_401_STABLE blah?
IF so, doesn't that restrict git to only the 401 branch ... and 402 wouldn't be known then?

'SoS', Ken

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
Hi Ken,

Great to hear from you.

I did that. The result is that it shows that I have 4.1 installed. It then shows me a list of possible versions, but 4.2 did not appear on the list.

Yes, I installed 3.11 from GIT, then upgraded via GIT to 4.1.

I'll try again later.

Best,
Paul
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
just tested a git pull on a test 4.1 code directory

git pull
remote: Enumerating objects: 2925, done.
remote: Counting objects: 100% (1650/1650), done.
remote: Total 2925 (delta 1650), reused 1650 (delta 1650), pack-reused 1275
Receiving objects: 100% (2925/2925), 824.80 KiB | 1.77 MiB/s, done.
Resolving deltas: 100% (2197/2197), completed with 590 local objects.
From git://git.moodle.org/moodle
   017a3274fe8..090baf556eb  MOODLE_401_STABLE -> origin/MOODLE_401_STABLE
   63555942ce9..9dbb082f04e  MOODLE_311_STABLE -> origin/MOODLE_311_STABLE
   2fa4da9aa47..31f6d9ccc5b  MOODLE_39_STABLE  -> origin/MOODLE_39_STABLE
   0ec98042d63..abb8647b620  MOODLE_400_STABLE -> origin/MOODLE_400_STABLE
   f9edf5c1be8..6b8884e13bc  MOODLE_402_STABLE -> origin/MOODLE_402_STABLE
   063ffc8073c..4ed782dd03a  master            -> origin/master
Updating 017a3274fe8..090baf556eb

also ... git branch -a does show the 4.2

  remotes/origin/MOODLE_402_STABLE

HIckup? ناراحت

'SoS', Ken

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
So ok, tried Git pull, it did all sorts of things before finally aborting. When I re-ran git branch -a, same result.

Really something weird. Some how sort of stuck here on this one.
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
What did "it did all sorts of things" look like?

Guess you could side load version desired thus getting the hidden .git directories and files, then copy them to the code directory that's having issues to see if you can't straighten this out.

So code is in /var/www/html/
In /var/www/
git clone git://git.moodle.org/moodle.git gitsideload
cd gitsideload
git branch --track MOODLE_401_STABLE origin/MOODLE_401_STABLE
git checkout MOODLE_401_STABLE
Check version
fgrep '$release' version.php

Then copy from gitsideload directory
cp -p .gitattributes ../html/
cp -p .gitignore ../html/
cp -pr .git ../html/
cp -pr .github ../html/

Then change into html cd ../html/
run git branch -a check
See if 402 is listed there.

Now issue git commands to set banch to 402 and checkout the 402 code.

check:
fgrep '$release' version.php

Pull the trigger! لبخند

'SoS', Ken

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
Hi Ken,

Awesome, you are a true genius sir. Just one small thing, when I try to checkout, I now get the following message:
Attachment 2023-06-01 10_34_39-Window.png
In reply to Paul Raper

Re: Moodle 4.2

از Paul Raper در
So I moved it, the script runs but then aborts. ناراحت
In reply to Paul Raper

Re: Moodle 4.2

از Paul Raper در
Ok, I think I know why this didn't work. The directory permissions were set to 755, which if I am not mistaken means that the directory and sub-directories are write protected, so I have now set about modifying the permission to 777 and will reset back to 755 when I am done. I'll keep you posted with progress.
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
Did you modify any core code?

Git tracks every file/folder in the code.   If a file has been modified git will complain and actually halt the process.

Also, concerning ownerships/permissions on files ... I know that folks would say don't do it, but I use root account to do the update/upgrades from a bash shell script - no issues - last few lines of my bash shell scripts resets all files folders to web service user and takes away some write access.

'SoS', Ken

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
Hi Ken, That's the weird thing, this site has always been clean with the exception of adding the odd plugin, but apart from that I have made absolutely no changes to any of the code at all.

I suppose the only thing I can do here is to create a new directory with the code in it, install Moodle 4.2 in to that, and then change my config.php file to reflect the new code location. This really is a pain. And someone once said that using GIT was easier that downloading the zip file and installing from that. لبخند
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
"And someone once said that using GIT was easier that downloading the zip file and installing from that."

That's been me!   And that has been my experience.    Forums are full of folks that update/upgrade not using git that have issues.   Not many report issues with git.

If initially installed via git I've really had no such issue.   Difference might be that I run as root user of the system most of the time and change ownerships/permissions after git acquires/changes files/folders updates/upgrades.

Did notice a change in behavior in assisting someone else recently ... doing a sideload, first run in true code directory, prompted that git hadn't originally installed moodle in that directory and asked if I should trust it.   Said yes, of course.

So 'git fetch' (thanks for that tip, Mark!) didn't show something like:

remote: Enumerating objects: 1093, done.
remote: Counting objects: 100% (1093/1093), done.
remote: Compressing objects: 100% (284/284), done.
remote: Total 1093 (delta 793), reused 1093 (delta 793), pack-reused 0
Receiving objects: 100% (1093/1093), 1.03 MiB | 1.76 MiB/s, done.
Resolving deltas: 100% (793/793), completed with 247 local objects.
From git://git.moodle.org/moodle
   6b8884e13bc..20302d4f864  MOODLE_402_STABLE -> origin/MOODLE_402_STABLE
   9dbb082f04e..5291b32c638  MOODLE_311_STABLE -> origin/MOODLE_311_STABLE
   31f6d9ccc5b..d0d7d578c5a  MOODLE_39_STABLE  -> origin/MOODLE_39_STABLE
   abb8647b620..52a4f2d030f  MOODLE_400_STABLE -> origin/MOODLE_400_STABLE
   090baf556eb..03b605f2eb3  MOODLE_401_STABLE -> origin/MOODLE_401_STABLE
   4ed782dd03a..84bb5725f8a  master            -> origin/master

What version of git do you have:

git --version

I noticed recently an update to git via package manager.

May 31 03:54:58 Updated: git.x86_64 1.8.3.1-25.el7_9

Also noticed that running 'git fetch' prior to actual pull in updating or upgrading does make file/folder acquisition appear to be faster in the actual git pull.

Dunno what to tell ya! :|

'SoS', Ken

In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
File mentioned in the error:
/lib/classes/task/question_stats_cleanup_task.php

ls -l ./moodle4?/lib/classes/task/question_stats_cleanup_task.php
-rw-r--r--  1 kentask  staff  2157 Nov 18  2021 ./moodle40/lib/classes/task/question_stats_cleanup_task.php
-rw-r--r--  1 kentask  staff  1942 May 22 17:00 ./moodle42/lib/classes/task/question_stats_cleanup_task.php

Both directories of code, git acquired.
As you can see, the file: question_stats_cleanup_task.php is larger in a moodle40
than in a moodle42.

Wonder what would happen if you moved that file out of the way as it suggested and tried it again?   Would git re-acquire that file?

Looked at that file and in the header:
 * Task to cleanup old question statistics cache.
 *
 * This task is no longer required. It has been kept on stable branches for backwards-compatibility,
 * and will be removed completely in Moodle 4.3.

So looks like one might be able to remove it cause it's slated for demise in 4.3! لبخند

'SoS', Ken

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
Hi Ken,
I fixed it using a slightly modified of your sideload approach.
I created a director called html-new
I ran:
git clone git://git.moodle.org/moodle.git html-new
cd html-new
git branch --track MOODLE_402_STABLE origin/MOODLE_402_STABLE
git checkout MOODLE_402_STABLE
Check version
fgrep '$release' version.php
I now had the latest version
I updated posgres to version 15 and php to the latest version too.

I then copied over my config.php file and then ran the update.
After moving over the missing plugins and reloading the preview, all was good and the update ran a dream.

Thanks everyone for your input.
لبخند
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
Good to hear!

Side load is a combo of git and old way (copying config.php/plugins etc) into new git acquired directory.

That's the last time you have to do that! لبخند

From here on out (until you decide to upgrade to 4.3) you'll only be doing git pull in your update script.

'SoS', Ken

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
Absolutely. But the great thing was that I didn't copy any files over, I used the same location as the sideload files were in, that way it was rather like a completely new install.
In reply to Paul Raper

Re: Moodle 4.2

از Paul Raper در
By the way: two sites that were really great, one for updating postgresql, the other for PHP:

1. PHP - https://computingforgeeks.com/how-to-install-php-on-ubuntu-linux-system/
2. Postgresql - https://gorails.com/guides/upgrading-postgresql-version-on-ubuntu-server

This third site was actually useful for removing the redundant php 7.4: https://stackoverflow.com/questions/39754099/how-to-uninstall-php-7-completely-kali-linux-debian

Overall I am delighted at the outcome and will watch out to see whether or not git works when I come to perform the next update.

Once again: thank you everyone for the awesome input here.
In reply to Paul Raper

Re: Moodle 4.2

از Ken Task در
عکس Particularly helpful Moodlers
Welcome.  Congrats!  And thanks for sharing the links that helped you.

'watch out ...'

One of the things I learned in using git was that my memory for commands to be issued when wasn't so good so I made a bash shell script that I called 'up' - updates moodle core code only ... doesn't upgrade.  I combined site backup with update ...

A shared 'up' script that would need changing per your system.

echo '4.1.3+ (Build: 20230427)'
tar -cvf /path/to/backup/moodle-code-413+-$(date +%Y%m%d%-H%M%S).tar ../moodle;
tar -cvf /path/to/backup/moodle-data-min-413+-$(date +%Y%m%d%-H%M%S).tar /var/www/moodledata/filedir;
mysqldump -u root -p moodle > /path/to/backup/moodle413+-db-$(date +%Y%m%d%-H%M%S).sql;
ls -l /path/to/backup/;
echo 'Paused ...';
read $keypress;
git branch -a
php admin/cli/cron.php;
php admin/cli/maintenance.php --enable;
git pull;
php admin/cli/upgrade.php --non-interactive;
php admin/cli/maintenance.php --disable;
php admin/cli/purge_caches.php;
php admin/cli/cron.php;
chown apache:apache * -R;
chown root:root up bu upgrade .git .github -R;
fgrep '$release' version.php

One could add the execution of the checks.php script before the git parts with a pause just in case something isn't compat.

Think you will enjoy using git! لبخند
'SoS', Ken

In reply to Paul Raper

Re: Moodle 4.2

از Mark Johnson در
عکس Core developers عکس Particularly helpful Moodlers عکس Peer reviewers عکس Plugin developers

Try doing a git fetch, which will just update your remote branches without trying to merge any updates into your local branches. If that works you should have origin/MOODLE_402_STABLE available and you can check out a local branch from there.

In reply to Ken Task

Re: Moodle 4.2

از Paul Raper در
So Ken,

When I run git branch -a I get:
MOODLE_400_STABLE
* MOODLE_401_STABLE
master
remotes/origin/HEAD -> origin/master
remotes/origin/MOODLE_13_STABLE
remotes/origin/MOODLE_14_STABLE
remotes/origin/MOODLE_15_STABLE
remotes/origin/MOODLE_16_STABLE
remotes/origin/MOODLE_17_STABLE
remotes/origin/MOODLE_18_STABLE
remotes/origin/MOODLE_19_STABLE
remotes/origin/MOODLE_20_STABLE
remotes/origin/MOODLE_21_STABLE
remotes/origin/MOODLE_22_STABLE
remotes/origin/MOODLE_23_STABLE
remotes/origin/MOODLE_24_STABLE
remotes/origin/MOODLE_25_STABLE
remotes/origin/MOODLE_26_STABLE
remotes/origin/MOODLE_27_STABLE
remotes/origin/MOODLE_28_STABLE
remotes/origin/MOODLE_29_STABLE
remotes/origin/MOODLE_30_STABLE
remotes/origin/MOODLE_310_STABLE
remotes/origin/MOODLE_311_STABLE
remotes/origin/MOODLE_31_STABLE
remotes/origin/MOODLE_32_STABLE
remotes/origin/MOODLE_33_STABLE
remotes/origin/MOODLE_34_STABLE
remotes/origin/MOODLE_35_STABLE
remotes/origin/MOODLE_36_STABLE
remotes/origin/MOODLE_37_STABLE
remotes/origin/MOODLE_38_STABLE
remotes/origin/MOODLE_39_STABLE
remotes/origin/MOODLE_400_STABLE
remotes/origin/MOODLE_401_STABLE
remotes/origin/master

But I shall take a look at your suggestion above: so do bear with me.