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

Magic methods (some) must be public

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.11, 4.0
    • Fix Version/s: 3.11
    • Component/s: General
    • Labels:

      Description

      Really not all need to, for example __construct() or, in fact, __clone()
      but wakeup seems to need this or you get this error with php80.:

      Warning: The magic method file_system::__wakeup() must have public visibility
      in lib/filestorage/file_system.php on line 47

      I keep this commit separate because I think those methods aren't
      preventing clone or unserialize operations to happen, they are just
      preventing any spesialization when cloning or unserialising to happen
      so it's not clear why they couldn't, simply, be removed.

      Detected using this regexp, all the remaining cases in core are:

      • __clone()
      • __construct()
      • other methods not being magic.

      ag 'function __' --php | grep -v __construct | grep -P '(protected|private)'

        Attachments

          Activity

            People

            Assignee:
            stronk7 Eloy Lafuente (stronk7)
            Reporter:
            stronk7 Eloy Lafuente (stronk7)
            Peer reviewer:
            Marina Glancy Marina Glancy
            Integrator:
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Tester:
            CiBoT CiBoT
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              17/May/21

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 45 minutes
                45m