Moodle
  1. Moodle
  2. MDL-32629

Environment checks should require preg unicode support

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: Future Dev
    • Fix Version/s: None
    • Component/s: Installation
    • Labels:
      None
    • Rank:
      39558

      Description

      Code such as this test script:

      <?php
      ini_set('display_errors', 1);
      error_reporting(E_ALL);
      $silly = preg_replace('~a~u', 'b', 'abc');
      print htmlspecialchars(print_r($silly, true));
      

      can fail on some servers with an error such as 'Warning: preg_replace() [function.preg-replace]: Compilation failed: unknown option bit(s) set at offset -1' because PHP is using a version of the PCRE library that doesn't support Unicode. I have had this reported on CentOS 5.5. This link suggests that the only solution on those platforms is to use a custom-built PHP package: http://stackoverflow.com/questions/7456939/what-is-the-preg-match-all-u-flag-dependent-on

      If possible it would be nice to add this to the environment checks for Moodle 2.4. Otherwise we need to make sure that we don't use the 'u' regex modifier (in core or contrib code) without specifically checking for the error. (Note: I think it returns null in this case.)

      I'm looking for opinions on as to whether this is a good idea, before doing anything

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: