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

Fix known cases of creating objects from empty value

    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
    • Labels:
    • Testing Instructions:
      Hide
      1. Confirm that php71 and php73 unit tests are passing with this patch (travis tells you). Nothing to do here - travis is passing.
      2. Confirm that a php74 phpunit and behat runs does not return any* "creating default object from empty value". Can use a DEV job to verify that, php74-rc is available there. Otherwise, do a full run of phpunit on 7.4, passing the output to a file which you can search afterwards.
      • Note: there is one exception to this, and it's MDL-66259 that is being handled separately. With that issue still not integrated it's possible to find the "creating default object from empty value" happening for some qtypes (multianswer). If those are the unique cases, that's ok for this issue.
      • Note2: under php74 there are still lots of errors. Ignore them 100%. Here we are only interested about the "creating default object from empty value" ones.
      Show
      Confirm that php71 and php73 unit tests are passing with this patch (travis tells you). Nothing to do here - travis is passing. Confirm that a php74 phpunit and behat runs does not return any* "creating default object from empty value". Can use a DEV job to verify that, php74-rc is available there. Otherwise, do a full run of phpunit on 7.4, passing the output to a file which you can search afterwards. Note: there is one exception to this, and it's MDL-66259 that is being handled separately. With that issue still not integrated it's possible to find the "creating default object from empty value" happening for some qtypes (multianswer). If those are the unique cases, that's ok for this issue. Note2: under php74 there are still lots of errors. Ignore them 100%. Here we are only interested about the "creating default object from empty value" ones.
    • Affected Branches:
      MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:

      Description

      From PHP 7.4 upgrading info:

      The "creating default object from empty value" warning is now consistently
      thrown if a falsy value is promoted into an stdClass object. Previously some
      cases like `$null->prop[0] = $val` missed this warning.

      Main problem with this issue is that it's impossible to detect all cases programmatically and we only can fix them while they happen (right now, with phpunit and behat executions).

      So, hoping that coverage will unveil the majority of them and knowing that this change doesn't lead to any fatal error (but "just" warnings) that's the approach we are going to follow:

      • Impossible to detect in advance.
      • Fix all uses found via automated testing.
      • Remaining cases will be fixed when discovered (if any).

        Attachments

          Activity

            People

            Assignee:
            stronk7 Eloy Lafuente (stronk7)
            Reporter:
            stronk7 Eloy Lafuente (stronk7)
            Peer reviewer:
            Sara Arjona (@sarjona)
            Integrator:
            Jake Dallimore
            Tester:
            Gladys Basiana
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            4 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 - 2 hours, 55 minutes
                2h 55m