Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-53701

Regression MDL-52978: Uncaught exception in dateselector-min.js depending used language

    XMLWordPrintable

    Details

    • Database:
      MySQL
    • Testing Instructions:
      Hide
      Test 1: Repeat testing instructions of MDL-52978 (test on linux and windows)
      1. Go to 'Site administration' > 'Location' > 'Location settings' and set timezone to 'Australia/Perth'.
      2. Go to your profile settings and set the timezone to 'Europe/London'
      3. Go to add a new course.
      4. Select the date picker next to 'Course start date' and go through the years 1986 (http://www.timeanddate.com/calendar/?year=1986&country=29) and 2016 (http://www.timeanddate.com/calendar/?year=2016&country=29) and ensure that the 1st for each month is listed as the correct day.
      Test 2:
      1. On windows moodle install, get French language pack
      2. Go to create new course
      3. Ensure there is no JS error and you can edit "course start date" using date picker
      Test 3: (Stolen from MDL-53975)

      1. Go to Site administration >> Language >> Language settings
      2. set Sitewide locale: fi_FI
      3. Open a Quiz
      4. Select Edit settings
      5. Ensure the page loads as expected
      Alternatively you can create new Quiz

      Show
      Test 1: Repeat testing instructions of MDL-52978 (test on linux and windows) Go to 'Site administration' > 'Location' > 'Location settings' and set timezone to 'Australia/Perth'. Go to your profile settings and set the timezone to 'Europe/London' Go to add a new course. Select the date picker next to 'Course start date' and go through the years 1986 ( http://www.timeanddate.com/calendar/?year=1986&country=29 ) and 2016 ( http://www.timeanddate.com/calendar/?year=2016&country=29 ) and ensure that the 1st for each month is listed as the correct day. Test 2: On windows moodle install, get French language pack Go to create new course Ensure there is no JS error and you can edit "course start date" using date picker Test 3: (Stolen from MDL-53975 ) 1. Go to Site administration >> Language >> Language settings 2. set Sitewide locale: fi_FI 3. Open a Quiz 4. Select Edit settings 5. Ensure the page loads as expected Alternatively you can create new Quiz
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE
    • Pull Master Branch:
      wip-mdl-53701

      Description

      Pre-Requisites :
      1. Log in as admin .
      2. Navigate to any course->Edit settings
      2.2. Change language of the page to DE or FR or RU or AR or ES or ES_ES
      3. Verify that call to M.form.dateselector.init_date_selectors() have something in parameters (and then don't throw the uncaught exception : Cannot read property 'firstdayofweek' of undefined.

      Problem localized:
      In the PHP file \moodle\lib\formslib.php line 76, there is function form_init_date_js()
      Comparing the source code with a working one, I've pointed a difference in the way $config is populated:

      No bug (Moodle 3.0):
      'mon' => date_format_string(strtotime("Monday"), '%a', 99),

      With bug (Moodle 2.9 build 20160324):
      'mon' => strftime('%a', strtotime("Monday")),

      The bug was solved by taking the 3.0 source code and put it instead 2.9 source code.
      It's a regression introduced by the last commit on this file for (MDL-52978): https://github.com/moodle/moodle/commit/197f99a80863182cfac2bfab7e109774af23b1d5

      Hi,

      We have two Moodle sites (2.9.5+) running automated update every week (wed. morning).
      One is in build: 20160324, the other is in build 20160331.

      Both have the same javascript uncaught error at least since the update to the build 20160324, but maybe sooner.
      I'm not 100% sure if this bug is a regression introduced by a build or is only related to our configuration somehow. I doubt because it's curious that it hasn't be reported yet but I see nothing we've done that can break YUI?

      Here is the error and how it happened:
      Which pages: the edition page of any course (ex: /course/edit.php?id=36).
      EDIT: also in the edition of modules parameters like: /course/modedit.php?update=91342&return=1

      Which JS error: Uncaught TypeError: Cannot read property 'firstdayofweek' of undefined

      Which JS file: dateselector-min.js, line 84

      What happens: The error is triggered when an allowed user opens the edition page of a course with some particular languages settings (FR, ES,...). The file uploader in the Description section loops on "loading" and the collapse/uncollapse arrows of sections below do not appears because of the uncatched error (see the screenshot attached).

      What I do: First, I replaced dateselector-min.js with dateselector-debug.js.
      The error is localized in function init_date_selectors, where config is null and shouldn't be. config is supposed to be the only argument of the function:

      init_date_selectors: function(config) {
      ...

      I looked after the call of the function in the HTML page: I found this:
      Y.use("moodle-form-dateselector",function()

      {M.form.dateselector.init_date_selectors();}

      );

      Looks like config is missing as an argument of init_date_selectors() ?

      As a quick and dirty fix, I've add a return; in the begginning of the function init_date_selectors if config is null but I guess it should trigger errors somewhere else. I cannot look deeper in the code as I don't know a thing about YUI.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/May/16