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

mb_substitute_character ValueError for PHP 8.0

    XMLWordPrintable

    Details

    • Story Points:
      1
    • Sprint:
      QA blitz 3

      Description

      As of PHP 8.0.0, a ValueError is thrown if the value of to_encoding or from_encoding is an invalid encoding. Prior to PHP 8.0.0, a E_WARNING was emitted instead.
       
      https://www.php.net/manual/en/function.mb-convert-encoding.php
       
      code: 
      $subst = mb_substitute_character();
      mb_substitute_character(''); // <=EXCEPTION
      $result = mb_convert_encoding($value, 'utf-8', 'utf-8');
      mb_substitute_character($subst);
       

      {"time":"2021-05-15 23:19:01","type":"error","errstr":"iconv(): Wrong encoding, conversion from \"UTF-8\" to \"UTF-8\/\/IGNORE\" is not allowed","errfile":"\/var\/www\/moodle\/lib\/moodlelib.php","errline":1281}

      !!! Exception - mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint !!!
      !!
      Error code: generalexceptionmessage !!
      !! Stack trace: * line 1287 of /lib/moodlelib.php: ValueError thrown

      • line 1287 of /lib/moodlelib.php: call to mb_substitute_character()
      • line 995 of /lib/moodlelib.php: call to fix_utf8()
      • line 1267 of /lib/filestorage/file_storage.php: call to clean_param()
      • line 51 of /mod/assign/feedback/editpdf/db/install.php: call to file_storage->create_file_from_pathname()
      • line 676 of /lib/upgradelib.php: call to xmldb_assignfeedback_editpdf_install()
      • line 1929 of /lib/upgradelib.php: call to upgrade_plugins()
      • line 489 of /lib/installlib.php: call to upgrade_noncore()
      • line 35 of /local/kos/cli/dev/fresh_install.php: call to install_cli_database()
        !!

      same for:

       

      {"time":"2021-05-16 00:13:07","type":"exception","message":"mb_substitute_character(): Argument #1 ($substitute_character) must be \"none\", \"long\", \"entity\" or a valid codepoint","file":"\/var\/www\/moodle\/lib\/configonlylib.php","line":107,"trace":"#0 \/var\/www\/moodle\/lib\/configonlylib.php(107): mb_substitute_character()\n#1 \/var\/www\/moodle\/lib\/configonlylib.php(67): min_fix_utf8()\n#2 \/var\/www\/moodle\/theme\/styles.php(49): min_clean_param()\n#3 \{main}

      "}

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              peterdias Peter Dias
              Reporter:
              janveselý1 Jan Veselý
              Peer reviewer:
              Mihail Geshoski Mihail Geshoski
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              CiBoT CiBoT
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Jul/21

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 1 minute
                  1h 1m