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

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.8.1
    • 3.8, 3.9
    • 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:

        $ 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).

      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} == '"');
      

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Mathew May Mathew May
            Adrian Greeve Adrian Greeve
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.