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

Remove curly brace syntax for accessing array elements in H5P component

    XMLWordPrintable

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.8
    • 3.8.1
    • H5P
    • MOODLE_38_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:

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

      2. Verify that you get THREE matches, all them are false-positives corresponding to regular expressions.

        lib/h5p/h5p.classes.php
        1135:        if (preg_match('/^(-?[a-z]+){1,7}\.json$/i', $languageFile) === 0) {
        2083:    $this->relativePathRegExp = '/^((\.\.\/){1,2})(.*content\/)?(\d+|editor)\/(.+)$/';
        2780:         !preg_match('/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i', $_SERVER['REMOTE_ADDR']))) {
        

      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 h5p stuff. (Be warned that there may be lots of notices/warnings/errors, here we are only interested in the h5p ones).
      5. Run phpunit (with that PHP7.4 version).
      6. Verify that there isn't any PHP notice/warning related with h5p and curly braces. (Be warned that there are lots of notices/warning/errors and failures, here we are only interested in the h5p ones).
      7. Verify that travis is passing for php71 and php73 (specifically h5p ones).
      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: $ ag '(\$[0-9a-zA-Z_]+|\))(\[['\''"\w$]+\])?{[^\n=}]+}' \ lib/h5p h5p --php Verify that you get THREE matches, all them are false-positives corresponding to regular expressions. lib/h5p/h5p.classes.php 1135: if (preg_match('/^(-?[a-z]+){1,7}\.json$/i', $languageFile) === 0) { 2083: $this->relativePathRegExp = '/^((\.\.\/){1,2})(.*content\/)?(\d+|editor)\/(.+)$/'; 2780: !preg_match('/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i', $_SERVER['REMOTE_ADDR']))) { Using moodle-docker (or any >= PHP7.4 RC4 installation) install phpunit (init.php). Verify that there isn't any PHP notice/warning related with h5p stuff. (Be warned that there may be lots of notices/warnings/errors, here we are only interested in the h5p ones). Run phpunit (with that PHP7.4 version). Verify that there isn't any PHP notice/warning related with h5p and curly braces. (Be warned that there are lots of notices/warning/errors and failures, here we are only interested in the h5p ones). Verify that travis is passing for php71 and php73 (specifically h5p ones).

    Description

      We have to solve an issue raised in php74 regarding the deprecation of the curly braces in php74.
      Link: https://ci.moodle.org/view/Testing/job/DEV.74%20-%20PHPUnit%207.4%20-%20MDL-66260/8/

      Array and string offset access syntax with curly braces is deprecated

      /var/www/html/lib/h5p/h5p.classes.php:2760
      /var/www/html/h5p/classes/autoloader.php:56
      /var/www/html/h5p/classes/autoloader.php:56
      /var/www/html/h5p/classes/framework.php:36
      /var/www/html/lib/classes/component.php:118
      /var/www/html/h5p/classes/factory.php:76
      /var/www/html/h5p/tests/framework_test.php:48
      /var/www/html/lib/phpunit/classes/advanced_testcase.php:80
      

      More details: https://tracker.moodle.org/browse/MDL-66609?focusedCommentId=707888&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-707888

      Attachments

        Issue Links

          Activity

            People

              stronk7 Eloy Lafuente (stronk7)
              cescobedo Carlos Escobedo
              Mathew May Mathew May
              Jun Pataleta Jun Pataleta
              Jun Pataleta Jun Pataleta
              Amaia Anabitarte, Carlos Escobedo, Laurent David, Sabina Abellan, Sara Arjona (@sarjona)
              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, 26 minutes
                  2h 26m