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

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

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.8, 3.9
    • Fix Version/s: 3.8.1
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      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/typo3 --php
        

      2. Verify that you only get ZERO matches.
      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/typo3 stuff. (Be warned that there may be lots of notices/warnings/errors, here we are only interested in the lib/typo3 ones).
      5. Run phpunit (with that PHP7.4 version).
      6. Verify that there isn't any PHP notice/warning related with lib/typo3. (Be warned that there are lots of notices/warning/errors and failures, here we are only interested in the lib/typo3 ones
      7. Verify that travis is passing for php71 and php73 (specifically core_text_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: $ ag '(\$[0-9a-zA-Z_]+|\))(\[[\w$]+\])?{[^\n=}]+}' lib/typo3 --php Verify that you only get ZERO matches. 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/typo3 stuff. (Be warned that there may be lots of notices/warnings/errors, here we are only interested in the lib/typo3 ones). Run phpunit (with that PHP7.4 version). Verify that there isn't any PHP notice/warning related with lib/typo3. (Be warned that there are lots of notices/warning/errors and failures, here we are only interested in the lib/typo3 ones Verify that travis is passing for php71 and php73 (specifically core_text_testcase).
    • Affected Branches:
      MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:

      Description

      The Typo3 library that we are using since 2014 is not php74 compliant (neither it was php73 compliant - see MDL-63967.

      And, given that maybe will be able to remove it for Moodle 3.9 (because surely we are going to start requiring mbstring - see MDL-65809) and to update the whole lib at this point can be a real pain, we are just going to make it php74 compliant "by hand".

      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
      class.t3lib_cs.php:1167:			switch ($cat{0}) {
      class.t3lib_cs.php:1227:					if ($line{0} != '#' && trim($line) != '') {
      class.t3lib_cs.php:1230:						if ($cond == '' || $cond{0} == '#') {
      class.t3lib_cs.php:1267:					if ($line{0} != '#' && trim($line) != '') {
      class.t3lib_cs.php:1612:				if (strlen($string{$i})) {
      class.t3lib_cs.php:1617:				if (strlen($string{$i - 1})) {
      class.t3lib_cs.php:1838:		for ($i = 0; strlen($str{$i}); $i++) {
      class.t3lib_cs.php:1839:			$c = $str{$i};
      class.t3lib_cs.php:1911:		for ($i = 0; strlen($str{$i}); $i++) {
      class.t3lib_cs.php:1912:			$c = ord($str{$i});
      class.t3lib_cs.php:1936:		if (ord($str{$i}) & 0x80) { // part of a multibyte sequence
      class.t3lib_cs.php:1937:			for (; $i > 0 && !(ord($str{$i}) & 0x40); $i--) {
      class.t3lib_cs.php:1944:			for ($bc = 0, $mbs = ord($str{$i}); $mbs & 0x80; $mbs = $mbs << 1) {
      class.t3lib_cs.php:2031:		for (; strlen($str{$i}) && $n < $p; $i += $d) {
      class.t3lib_cs.php:2032:			$c = (int) ord($str{$i});
      class.t3lib_cs.php:2042:		if (!strlen($str{$i})) {
      class.t3lib_cs.php:2048:			while ((ord($str{$i}) & 0x80) && !(ord($str{$i}) & 0x40)) {
      class.t3lib_cs.php:2071:			$c = (int) ord($str{$i});
      class.t3lib_cs.php:2081:		if (!strlen($str{$i})) {
      class.t3lib_cs.php:2116:		for ($i = 0; strlen($str{$i}); $i++) {
      class.t3lib_cs.php:2117:			$c = ord($str{$i});
      class.t3lib_cs.php:2120:				$mbc = $str{$i};
      class.t3lib_cs.php:2165:		for ($i = 0; strlen($str{$i}) && $i < $len; $i++) {
      class.t3lib_cs.php:2166:			$c = ord($str{$i});
      class.t3lib_cs.php:2178:		if (!strlen($str{$i})) {
      class.t3lib_cs.php:2235:		for ($i = 0; strlen($str{$i}); $i++) {
      class.t3lib_cs.php:2236:			$c = ord($str{$i});
      class.t3lib_cs.php:2276:		for (; strlen($str{$i}) && $n < $p; $i += $d) {
      class.t3lib_cs.php:2277:			$c = ord($str{$i});
      class.t3lib_cs.php:2291:		if (!strlen($str{$i})) {
      class.t3lib_cs.php:2334:		for ($i = 0; strlen($str{$i}); $i++) {
      class.t3lib_cs.php:2335:			$mbc = $str{$i};
      class.t3lib_cs.php:682:					$ord2 = ord($str{$a + 1});
      class.t3lib_div.php:1366:		if (!isset($bytes{$bytesToReturn - 1})) {
      class.t3lib_div.php:1375:				if (!isset($bytes{$bytesToReturn - 1})) {
      class.t3lib_div.php:1380:				if (!isset($bytes{$bytesToReturn - 1})) {
      class.t3lib_div.php:1386:			if (!isset($bytes{$bytesToReturn - 1})) {
      class.t3lib_div.php:1456:		while (!isset($bytes{$bytesToReturn - 1})) {
      class.t3lib_div.php:5321:			$partWasQuoted = ($part{0} == '"');
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stronk7 Eloy Lafuente (stronk7)
                Reporter:
                stronk7 Eloy Lafuente (stronk7)
                Peer reviewer:
                Mathew May
                Integrator:
                Adrian Greeve
                Tester:
                Gladys Basiana
                Participants:
                Component watchers:
                Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/Jan/20

                  Time Tracking

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