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

There are many "json_encode(): Invalid UTF-8 sequence in argument" errors in Apache's error_log file

XMLWordPrintable

    • Any
    • MOODLE_21_STABLE, MOODLE_24_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • w49_MDL-29442_m25_entityutf8
    • Hide

      Use some Chinese character in the course title, then visit these course from navigation menu, apache error_log will show this error.

      You need PHP < 5.4.0

      Show
      Use some Chinese character in the course title, then visit these course from navigation menu, apache error_log will show this error. You need PHP < 5.4.0

      If you visit other course from navigation menu, apache's error_log file will record something like "json_encode(): Invalid UTF-8 sequence in argument". It seems json_encode() function received none utf8 character. Navigation menu can't work sometimes. I found some problematic code in lib/navigationlib.php line 4000:

      lib/navigationlib.php line 4000

      if ($child->forcetitle || $child->title !== $child->text) {
          $attributes['title'] = htmlentities($child->title);
      }

      htmlentities use ISO-8859-1 character set as default, but my course title has Chinese character, after called htmlentities, these Chinese character will not be recognizable any more. I think the code should be changed like this:

      if ($child->forcetitle || $child->title !== $child->text) {
          $attributes['title'] = htmlentities($child->title,null,'UTF-8');
      }

      I found moodle called htmlentities in many places, if these callings use ISO-8859-1 as default charset, the Asia user of moodle will suffer inconvenience. I hope all these callings will be checked carefully.

            skodak Petr Skoda
            luyanfei Yanfei Lu
            Sam Hemelryk Sam Hemelryk
            Sam Hemelryk Sam Hemelryk
            Adrian Greeve Adrian Greeve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.