Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-66319 Remove curly brace syntax for accessing array elements and string offsets
  3. MDL-67029

Required changes to make bennu lib PHP 7.4 compliant (curly braces)

    XMLWordPrintable

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.8, 3.9
    • 3.8.1
    • Calendar, Libraries
    • MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_38_STABLE
    • Hide
      1. run the following command (requires ag, although advanced grep versions should be able to run it, after all, it's just a regular expression:
        N.b. If you have ack, you should be able to replace ag with ack in the command below. (sudo apt-get install ack)

        $ ag '(\$[0-9a-zA-Z_]+|\))(\[[\w$]+\])?{[^\n=}]+}'  lib/bennu --php
        

      2. Verify that you only get TWO matches and both correspond to regular expressions, so they are ok and don't need any change.
      3. Using moodle-docker (or any >= PHP7.4 RC4 installation) install phpunit (init.php).
      4. Verify that there isn't any PHP notice/warning related with lib/bennu stuff. (Be warned that there may be lots of notices/warnings/errors, here we are only interested in the lib/bennu ones).
      5. Run phpunit (with that PHP7.4 version).
      6. Verify that there isn't any PHP notice/warning related with lib/bennu. (Be warned that there are lots of notices/warning/errors and failures, here we are only interested in the lib/bennu ones
      7. Verify that travis is passing for php71 and php73 (specifically core_calendar_lib_testcase).
      Show
      run the following command (requires ag , although advanced grep versions should be able to run it, after all, it's just a regular expression: N.b. If you have ack, you should be able to replace ag with ack in the command below. (sudo apt-get install ack) $ ag '(\$[0-9a-zA-Z_]+|\))(\[[\w$]+\])?{[^\n=}]+}' lib/bennu --php Verify that you only get TWO matches and both correspond to regular expressions, so they are ok and don't need any change. Using moodle-docker (or any >= PHP7.4 RC4 installation) install phpunit (init.php). Verify that there isn't any PHP notice/warning related with lib/bennu stuff. (Be warned that there may be lots of notices/warnings/errors, here we are only interested in the lib/bennu ones). Run phpunit (with that PHP7.4 version). Verify that there isn't any PHP notice/warning related with lib/bennu. (Be warned that there are lots of notices/warning/errors and failures, here we are only interested in the lib/bennu ones Verify that travis is passing for php71 and php73 (specifically core_calendar_lib_testcase).

    Description

      The Bennu library that we are using since 2005 is not php74 compliant.

      Our one is based in really old version 0.1 and heavily customized since then. So there isn't any library upgrade to perform but straight fixes (documented).

      Here we are looking for all the curly brackets being used for array/string indexes (there maybe other changes to perform).

      $ ag '(\$[0-9a-zA-Z_]+|\))(\[[\w$]+\])?{[^\n=}]+}' --php | sort | uniq
      iCalendar_properties.php:1282:            if($value{$i} == ';' && !$escch) {
      iCalendar_properties.php:1288:            $escch = ($value{$i} == '\\');
      iCalendar_properties.php:1309:        if($parts[0]{0} < '1' || $parts[0]{0} > '4') {
      iCalendar_properties.php:1316:        if($len > 5 || $parts[0]{$len - 1} == '.') {
      iCalendar_properties.php:1321:            if(($i & 1) == 1 && $parts[0]{$i} != '.') {
      iCalendar_properties.php:1325:            else if(($i & 1) == 0 && ($parts[0]{$i} < '0' || $parts[0]{$i} > '9')) {
      iCalendar_properties.php:1349:                $thischar = $parts[$i]{$j};
      iCalendar_properties.php:1350:                $nextchar = $parts[$i]{$j + 1};
      iCalendar_properties.php:740:        return ($value{0} != '-');
      iCalendar_properties.php:764:        if($value{$pos - 1} != 'Z') {
      iCalendar_properties.php:768:        if($value{$pos + 1} != 'P' && substr($value, -1) != 'Z') {
      iCalendar_rfc2445.php:144:                $regexp = '#^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$#';
      iCalendar_rfc2445.php:147:                $regexp = '#^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$#';
      iCalendar_rfc2445.php:165:                $ch = $value{$i};
      iCalendar_rfc2445.php:214:            return($value{8} == 'T' && 
      iCalendar_rfc2445.php:231:            if($value{0} == '+' || $value{0} == '-') {
      iCalendar_rfc2445.php:236:            if($value{0} != 'P') {
      iCalendar_rfc2445.php:245:                $ch = $value{$i};
      iCalendar_rfc2445.php:312:                switch($value{$i}) {
      iCalendar_rfc2445.php:352:            if($value{0} == '+' || $value{0} == '-') {
      iCalendar_rfc2445.php:387:                return ($parts[1]{0} != '-');
      iCalendar_rfc2445.php:755:            if($value{0} != '+' && $value{0} != '-') {
      

      Attachments

        Activity

          People

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Mathew May Mathew May
            Jake Dallimore Jake Dallimore
            Gladys Basiana Gladys Basiana
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              13/Jan/20

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 30 minutes
                2h 30m