Issues on upgrading to 3.1.2

Issues on upgrading to 3.1.2

by Davide Davide -
Number of replies: 11
I experienced some javascript errors after upgrading Moodle from 2.8 to 3.1.2.

The error occurs in every course/view.php pages, if I try to expand a tree in the left menus, the javascript associated to the event is triggered 2 times per click, causing the tree menu to opening and collapsing automatically:

"moodle-core-event: Event fired: block_content_updatedyui_combo.php:5828:21"

Error occurs also if "Cache Javascript" and/or YUI combo loading is enabled or disabled, developer debugging is off, and in empty and newly created courses too.

Everything working correctly in any other page, also works correctly on a clean installation.

I also tested using the 3.1.2 code base with a 2.8 DB, and access the course page without start the upgrading by calling a course url directly, and every menus worked fine.
Errors occuring only on upgrades of DB of previous installation.
In attachment, two screenshots of the issue, does anybody has encountered this issue already or just know a way to fix it?




Average of ratings: -
In reply to Davide Davide

Re: Issues on upgrading to 3.1.2

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I've a vague recollection that the 'globalEvents' stuff is to do with forms handling. 

Anyway, have you any custom/code plugins that may not be up to date or you can remove/disable just to see if the problem goes away. If weird stuff happens always back up to core Moodle code (and a core theme) and add stuff back until you work out what it is. 

In reply to Howard Miller

Re: Issues on upgrading to 3.1.2

by Davide Davide -
Hi Howard, thanks for your response.

I tried again, by using clear 3.1.2 Moodle sources with the 2.8 database, without any customizations added.
Skipping the upgrade and getting to a course page, the problem is still there.

The only custom component that I added, was a custom user profile field, that I needed for login, also by removing and uninstalling it, I can't still expand the menues...
In developer tools console, I saw the event is triggered 3 times.

I ran the database migration upgrade, and test it again, same problem.


In reply to Davide Davide

Re: Issues on upgrading to 3.1.2

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

No additional plugins?  

In reply to Emma Richardson

Re: Issues on upgrading to 3.1.2

by Davide Davide -

Nothing.
I used the old DB with a clean 3.1.2 moodle source code base, without any extra plugins, modules or custom scripts, no additional html or something else, only vanilla code.

In reply to Davide Davide

Re: Issues on upgrading to 3.1.2

by Ken Task -
Picture of Particularly helpful Moodlers

Strange.   Suggest creating a tar ball backup of the moodledata/localcache directory then manually removing the contents of moodledata/localcache/.   That directory doesn't contain the following:

htmlpurifier
js
mustache
requirejs
theme

which kinda sounds related to the issue.

Reason for the tar ball backup is just in case it makes things worse ... then you might need to look at apache error logs as there might be networking issues with YUI combo loading.

'spirit of sharing', Ken


In reply to Ken Task

Re: Issues on upgrading to 3.1.2

by Davide Davide -
Hi Ken,
thanks for your reply, I tried to empty the moodledata/localcache/ directory, but nothing change, the problem is still there...

I wonder why this problem occurs only in /course/view.php and not in any other page...
I think there's something that is being called by this page that interferes with the page contents (javascripts and maybe other dom elements), but I can't understand what...
I haven't encountered this problem in any other page, only course/view.php...
In reply to Davide Davide

Re: Issues on upgrading to 3.1.2

by Ken Task -
Picture of Particularly helpful Moodlers

Well, that's really strange ... lots of caching going on in Moodle.

Have any content delivery network in front of the Moodle?

Wonder if purging cache on server, clearing any all cookies/cache in browser(s) might help.

Have you another workstation you've not used where you could login as another admin level user to see if behavior still there?

Assumes that the script involved is good .... what's the byte size of view.php in moodlecode/course/

Working site ... git updated ... ie no issues has:

-r--r--r-- 1 apache apache 12162 Oct  2 08:41 view.php

'spirit of sharing', Ken


In reply to Davide Davide

Re: Issues on upgrading to 3.1.2

by Ken Task -
Picture of Particularly helpful Moodlers

Debugging shows nothing?

We (I) might be 'barking up the wrong tree' here ... looked at the code of view.php and it requires the usage of:

    require_once('../config.php');
    require_once('lib.php');
    require_once($CFG->libdir.'/completionlib.php');

It also has a line that indicates that it should not be cached!

    // Prevent caching of this page to stop confusion when changing page after  making AJAX changes
    $PAGE->set_cacheable(false);

So might need to be looking into AJAX settings.

Let's backup a second ... this comment:

"Everything working correctly in any other page, also works correctly on a clean installation."

So how did you upgrade the troubled  site?
What theme are you using?

'spirit of sharing', Ken


In reply to Ken Task

Re: Issues on upgrading to 3.1.2

by Davide Davide -
Hi ken,

the size of view.php is 12162, the same of yours.

I'm using a local Linux OS as development environment, and for the upgrade, I made a new folder under my /var/www/ and putted inside the new moodle sources, also make a new apache vhost correctly pointing to the directory and assign it a local address (mapped to my /etc/hosts), like "test31.local".

I created  a copy of the old database and added a new config.php, with db configuration pointing to the new one.

No problems in this, since it's the same procedure I use since moodle 2.0.

By purging the cache and calling test31.local, the database migration procedure started, and everything works correctly until end.

That's all.
In reply to Davide Davide

Re: Issues on upgrading to 3.1.2

by Luis de Vasconcelos -

A wild guess here... What happens when you switch to a different theme?

In reply to Luis de Vasconcelos

Re: Issues on upgrading to 3.1.2

by Davide Davide -

Hi Luis, same results with every theme.

Try inspecting the javascript, I noticed that the problem is in /blocks/settings/amd/src/settingsblock.js, maybe relative to the issue MDL 54722.

Everytime I try to expand the tree menu, this script is called and functions adminTree.finishExpandingGroup and adminTree.collapseGroup, are called consecutively.

Like in the possible patch attached in the issue, I omitted the call to Y.use('moodle-core-event') in settingsblock.js and menu are exapanding/collapsing correctly, but a javascript errors occurs everytime "TypeError: M.core.globalEvents is undefined  first.js:10044:21"
Every other sources, seems to be aligned correctly...

I saw a lot of bugs in the Moodle Tracker about this kind of issue, and I thinks mine it's not an isolate case.
What kind of problems can being encountered with this simple fix that I applied?