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

Date Selector causes a json_encode error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      Test pre-requisites

      • To be tested on a Windows server
      • Install the Japanese language pack

      Test 1

      1. Go to your home page and switch to English language pack
      2. Go to the calendar, and add a new event
      3. Make sure that the pop-up date selector correctly displays each month
        • Month and days are correctly translated (February is not March, check that you'll never have two similar names while going from one month to another)
        • No errors are displayed during the process

      Test 2

      1. Go to your home page and switch to Japanese
      2. Go to the calendar, and add a new event
      3. Make sure that the pop-up date selector correctly displays each month
        • Month and days are correctly translated
        • No errors are displayed during the process
      Show
      Test pre-requisites To be tested on a Windows server Install the Japanese language pack Test 1 Go to your home page and switch to English language pack Go to the calendar, and add a new event Make sure that the pop-up date selector correctly displays each month Month and days are correctly translated (February is not March, check that you'll never have two similar names while going from one month to another) No errors are displayed during the process Test 2 Go to your home page and switch to Japanese Go to the calendar, and add a new event Make sure that the pop-up date selector correctly displays each month Month and days are correctly translated No errors are displayed during the process
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-35412-master

      Description

      Opening this issue to investigate and fix the following reported by Yamashita Kōichi on MDL-35171.

      Since Moodle 2.3.2, "json_encode(): Invalid UTF-8 sequence in argument" occurs when editing quizzes etc., on Windows servers with some locales (e.g. Japanese). Changing the code in formslib like below fixes that.

      'mon' => userdate(strtotime("Monday"), '%a'), // 5th Jan 1970 at 12pm
      'january' => userdate(strtotime("January"), '%B'), // 1st Jan 1970 at 12pm

      My environment is: Moodle 2.3.2, Windows 7, IIS 7.5, PHP 5.3.14 Zend Server, debug is set to DEVELOPER.

      I get errors when editing a quiz (date selector is used for Timing > Open/Close the quiz), in some locales (en is OK but ja, fr, de all have errors).
      strftime can return results only in multibyte encoding on Windows so we need to convert back to UTF-8 for use in moodle. (userdate() in moodlelib.php does that.)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fred Frédéric Massart
              Reporter:
              k-yama Koichi Yamashita
              Peer reviewer:
              Jason Fowler
              Integrator:
              Sam Hemelryk
              Tester:
              Michael de Raadt
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Nov/12