Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Christe McMenomy -
Number of replies: 12

We recently upgraded from 2.9 to 3.1.1. Our website uses a custom theme which was working prior to upgrade.

I practiced the upgrade by replicating my production site data on a Mac OS  (El Capitan) platform running PHP 5.5.36, MySQL 5.5.36, and Apache 2.4.18. The upgrade ran without error, and the interface with the custom theme works perfectly (all navigation arrows expand).


I then upgraded a test version of the system on our production server (LINUX GENTOO 4.4.6, PHP 5.6.24-pl0-gentoo, mySQL 5.6.31; this also ran without error.  I installed a copy of the working theme and am able to log in as administrator and user.  Navigation apparently worked (and are not greyed out!), but I did not expand all submenus exhaustively (I will know better next time).  I then upgraded the production site and discovered that many of the navigation submenus do not work: for the Admiistrator, none of the site administration menus between Users and Development will expand when clicked, although the cursor changes when hovering to indicate a link is present.  The Notifications, Registration, Advanced features, and Assignment Upgrade helper links all work.  When using a direct navigation URL (e.g., <site>/moodle/admin/settings.php?section=ajax), the submenu links will display and work, but any embedded submenus do not work.

I have tried all of the suggestions in the Blocks FAQ #13 [changing browsers (Safari, FireFox, Chrome) verifying timezone is set in php.ini, setting/unsetting YUI, changing themes, purging theme cache; turning javascript off did not help] exhaustively, purging caches between each change, and nothing has made any difference. The theme works perfectly on my MacOS, but not on the gentoo server.  Therefore I must assume that the issue is with the production server environment. 

I finally got Chrome to run with the javascript console turned on.  On my Mac, there is no issue.  On the LINUX gentoo server I get two error lines:

 Failed to load resource: the server responded with a status of 500" : http://www.myserver.org/moodle/lib/requireis.php?file=%2F-1%2F/core/first.js

Uncaught script error for: core/first: javascript.php?rev=-1&isfile=%2Flib%2Frequirejs%2Frequire.min.js:8

Any ideas on what needs to be added to my gentoo environment to make this work? (I do not own the server and do not have root access, so I will need to work with the system administrator for any php recompile configurations).

Average of ratings: -
In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

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

You need to find the entry for that 'Error 500' in your web server's error log to see what is really going on. If you haven't already, turn Debugging up full.

In reply to Howard Miller

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Christe McMenomy -
The apache log does not report an Error 500.  

I set the Moodle debugging to DEVELOPER and opened a page as the Admin.  The screenshot below shows the errors.

Since this process works perfectly on my MacOS, I am assuming that the issue is with differences in the environment on the LINUX gentoo production server.

Following up some suggestions for the errors shown, I made sure that no Sendmail values are set in the Apache http.conf file.  I can't find any other suggestions for why the code is misinterpreted in one environment while working in a different OS.


Attachment Report1.jpg
In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Ken Task -
Picture of Particularly helpful Moodlers

The screen shot is of web developer console not of debugging output. ;)    But in viewing the URL of the second error provided (at least to me) no useful info and think it was called because first.js couldn't find require.js

In moodle 3.1.1+ (Build: 20160714) code:

first.js is found in: moodlecode/lib/amd/src/first.js
require.js is found in: moodlecode/lib/requirejs/require.js

first.js has this comment:

 * This is an empty module, that is required before all other modules.
 * Because every module is returned from a request for any other module, this
 * forces the loading of all modules with a single request.
 *
 * This function also sets up the listeners for ajax requests so we can tell
 * if any requests are still in progress.

So in your Gentoo box logged on as root user and cd into /path/to/moodlecode/

issue:

find ./ -name first.js

to see if that file is found - will/should show the path above.

When you upgraded the code ... how did you upgrade the code?  FTP upload? (ugh!)

If one were to use a default theme ... like 'clean' via entry in config.php

$CFG->theme = 'clean';

does the issue go away? or does console still show the same error?   Can comment that theme line line out later or remove it all together.

Comment: testing an upgrade on a different OS there is always potential for issues.  Believe it's best to use the same OS and in a virtual apache on the production server in a **copy** of the site - like dev.blah.blah if at all possible.  Using the same environment then ... no doubt.

'spirit of sharing', Ken


In reply to Ken Task

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Christe McMenomy -

Yeah, I actually do know to test on the production server, I upgraded the code by moving the moodle.tar.gzip file via ftp from my debugging system (MacOS) to the LINUX genoo test site, which is a copy of my production site.  I ran the upgrade and tested access and flunctionality as a user — but the test did not include expanding every submenu, or modifying anything with the administration tools, and some of the submenu links do work, so I didn't realize there was a problem until after I had upgraded the production site, when I went to add classes for the fall, realized that I could not expand any of the Administration menus.


Changing themes does not fix the problem: in the "clean" theme, submenus still do not expand. (The reason I pointed out that I tested on a MacOS as well was to indicate that the theme does work there — so it would seem the problem is more likely to be in the environment than in the moodle code itself although some moodle settings may fix the problem if we can figure out what they should be).


I upgraded the code by moving the moodle.tar.gzip file downloaded from Moodle via ftp from my debugging system (MacOS) to the LINUX genoo test site, which is a copy of my production site.  I did the gunzip and tar -xpf on the genoo site.   I did not change any permissions, and everything (except this resource file load) appears to be working.


The directory path for moodle/amd/src is all executable and readable by the webserver.

first.js exists and is readable.


It contains the following content (I did not edit this file and it is timestamped for the release) after distribution comments:

**

 * This is an empty module, that is required before all other modules.

 * Because every module is returned from a request for any other module, this

 * forces the loading of all modules with a single request.

 *

 * This function also sets up the listeners for ajax requests so we can tell

 * if any requests are still in progress.

 *

 * @module     core/first

 * @package    core

 * @copyright  2015 Damyon Wiese <damyon@moodle.com>

 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

 * @since      2.9

 */

define(['jquery'], function($) {

    $(document).bind("ajaxStart", function(){

        M.util.js_pending('jq');

    }).bind("ajaxStop", function(){

        M.util.js_complete('jq');

    });

});


One possibility I can think of is that there may be URL length limit on the prod server that does not exist on my Mac's Apache2. Modifying the YUI slash argument setting (either through the admin php executable or by setting it in the config file) did not resolve the problem.  The moodle config file suggests that a RewriteRule may be necessary to work around path limitations, but does not say where this line belongs (just uncommenting it breaks the test Moodle).  If it needs to go into the Apache configuration, I will need help explaining to my Sys Admin what change is required, since I don't have root access to the system files for Apache.

In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Ken Task -
Picture of Particularly helpful Moodlers

Still kinda confused about the process using but ....

You don't have theme designer mode turned on by chance, do you?

Have you turned on or included lines in config.php related to the issue?

In the config-dist.php file of a functioning 3.1.1 site the following config lines could pertain:

// Prevent JS caching
// $CFG->cachejs = false; // NOT FOR PRODUCTION SERVERS!
//
// Restrict which YUI logging statements are shown in the browser console.
// For details see the upstream documentation:
//   http://yuilibrary.com/yui/docs/api/classes/config.html#property_logInclude
//   http://yuilibrary.com/yui/docs/api/classes/config.html#property_logExclude
// $CFG->yuiloginclude = array(
//     'moodle-core-dock-loader' => true,
//     'moodle-course-categoryexpander' => true,
// );
// $CFG->yuilogexclude = array(
//     'moodle-core-dock' => true,
//     'moodle-core-notification' => true,
// );

If you have, turn them off ... comment them out again.   Think we might be compounding an issue related to caching.

Have a functioning 3.1.1 not using any custom theme.   In the data directory for the site there is a localcache directory.   Contained therein is:

[root@sos localcache]# ls
htmlpurifier  js  mustache  requirejs  theme

Wonder if it's not a cache issue on your system.   You did say you purged the cache serveral times.

As a test, I hide the js and requirejs directories on a functioning 3.1.1 server.    Then purge all caches.   The js and requirejs directories in moodledata/localcache/ were rebuilt.   Am using the clean theme on this site and in the theme directory of localcache, there was a 1470603954 directory and contained therein a clean theme directory.  What is contained in your moodledata/localcache/theme/ directory?   Would think you'd see a directory by the name of your theme in that 'numbered' directory (which is an epoch time directory so is a good reference as to when that cache was rebuilt).

Another thing that sometimes bites Admin users ... the session file for the user in moodledata/sessions/

Suggest:

1. logout of the Moodle

2. using whatever you have to browse files, remove the moodledata/localcache/ js and requirejs directory - consider archiving the theme directory there since you are using custom.

3. remove any/all sess_ files in moodledata/sessions/ (that will force all users logged on to log back in again)

4. in whatever browser you are going to use ... suggest starting with FireFox ... remove cookies for the site.  Remove anything your browser has cached from that site.

Then try to hit the site and login.

Site should rebuild all that as one logs in and clicks around.

'spirit of sharing', Ken

In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Ken Task -
Picture of Particularly helpful Moodlers

As I re-read .... 'might be a URL length limit' ... do you mean 'AcceptPathInfo'?   That's what apache calls it ... Moodle calls it 'use slash arguments'.    That affects SCORM ... don't think it's related to the js stuff for menus.

Since your admin menu may not be working, one will have to go directory to locations.

For http stuff: http://yoursites/admin/settings.php?section=http

To find those paths you could use your own test system that works then use the URL's on production server to navigate.    Pain in the arse, but ....

There is one other thing possibly related ... how site uses YUI

http://site//admin/search.php?query=YUI

Use online YUI Libraries is off on a functioning site.  NOT checked and has this comment:

Instead of using local files, use online files available on Yahoo‘s servers. WARNING: This requires an internet connection, or no AJAX will work on your site. This setting is not compatible with sites using https.

YUI combo loading is set to yes.    The comment/info says

This options enables combined file loading optimisation for YUI libraries. This setting should be enabled on production sites for performance reasons.  Your console output showed a yui.combo.php reference just before the missing/required/messed up first.js error referenced.

One other area:

http://yoursite/admin/settings.php?section=ajax

I hope you are making notes on things you are changing ... might need to un-do or revert.

'spirit of sharing', Ken


In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

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

"The apache log does not report an Error 500. "

In which case you are looking in the wrong place. It's highly unlikely (tending towards impossible) that Apache issued a 500 error and did not log it. 

In reply to Howard Miller

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Christe McMenomy -

I agree that the error is not being generated by Apache.  The error reported in the browser, by the way, has changed slightly if you look at the screen capture. It no longer mentions anything about an "Error 500", it just says it can't load the resource.js file.

In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by A. Obeid -

Hi,

just get latest version.

https://tracker.moodle.org/browse/MDL-54977


In reply to A. Obeid

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Christe McMenomy -

Upgrading to a beta version not yet released for production, which also requires a PHP and mySQL db upgrade on a server, is not a solution for our production server issue.  


In reply to Christe McMenomy

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Ken Task -
Picture of Particularly helpful Moodlers

Think A. was referring to a higher build (latest) for 3.1.1 ... the tracker item does say:

Fixed Branches: MOODLE_31_STABLE

which should include your current 3.1.1

What's your build date?

Of course, that issue was reported for Windows WAMP.

Actually, this situation is a pretty good reason to use git for managing Moodle.

Guess you've not tried my lengthy suggestion. :\

'spirit of sharing', Ken


In reply to Ken Task

Re: Upgrading to 3.1.1: Admin navigation/user navigation fails to expand some entries

by Christe McMenomy -

OK, I'm all fixed.  My own stupid mistake....but reading through your emails really helped me figure out what I had messed up, especially when I started looking at the caches.

The Chrome report indicated that something was wrong with first.js:

javascript.php:34 GET http://www.scholarsonline.org/~sodeveloper/ScholarsOnline/moodle/lib/ requirejs.php?file=%2F-1%2F/core/first.js 

So I tried getting to the first.js file directly in the URL bar of chrome.


On MacOS (working), lib/src/ajax.js prints

On gentoo (not working), I get the error: JS file: /lib/amd/src/._mustache.js does not contain a javascript module in AMD format. "define()" not found.

There is NO lib/amd/src/._mustache.js file on the mac system.  


Then I read through Ken's lengthy suggestion again and went looking at the moodledata cache directories paying attention to the dates of files.

I realized that in moving the moodle release from my Mac to the genoo system, I had tarred my already installed moodle directory, not the original directory as downloaded from Moodle...and there was cached data from the Mac in that file system.

So I downloaded a fresh copy of Moodle 3.1.1 from Moodle to my test genoo system, moved the "bad" moodle directory out of the way, copied in my config.php file, and voila! all works.

Thank you all for your help; I would not have figured this out without your suggestions about where to poke.