Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-67114

Fix known uses of null, bool, int, float or resource as array

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.8, 3.9
    • Fix Version/s: 3.8.1
    • Component/s: General, Libraries
    • Labels:
    • Testing Instructions:
      Hide

      Not much to test here, because all the fixed cases have been detected via phpunit/behat/server logs. So, basically, verify that nothing is broken:

      1) travis is passing for php 7.1 & 7.3

      2) CI jobs also pass.

      3) Can run php 7.4 tests (locally or @ CI) and then look for "Trying to access array offset on value" remaining problems. But that has been already done (see the comment below were this was sent to peer-review).

      Ciao

      Show
      Not much to test here, because all the fixed cases have been detected via phpunit/behat/server logs. So, basically, verify that nothing is broken: 1) travis is passing for php 7.1 & 7.3 2) CI jobs also pass. 3) Can run php 7.4 tests (locally or @ CI) and then look for "Trying to access array offset on value" remaining problems. But that has been already done (see the comment below were this was sent to peer-review). Ciao
    • Affected Branches:
      MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull 3.8 Branch:
    • Pull Master Branch:

      Description

      . Trying to use values of type null, bool, int, float or resource as an
      array (such as $null["key"]) will now generate a notice. This does not
      affect array accesses performed by list().
      RFC: https://wiki.php.net/rfc/notice-for-non-valid-array-container

      This issue is about to detect as many uses of this type as possible and add the missing checks to avoid the notices. Note that, apart from the notice, the outcome remains BC, evaluating as null, so no change in the result is expected.

      We'll be using unit, acceptance and web server logs to detect wrong uses. It's not possible to detect them with regex/semantic searches, so some uses may remain hidden until detected in practice.

      WIP on this happening @ https://github.com/stronk7/moodle/compare/master...MDL-67114

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 2 hours, 51 minutes
                  1d 2h 51m