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

Persistent method 'get' does not return the correct type

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_311_STABLE
    • Fixed Branches:
      MOODLE_400_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-72329-master
    • Testing Instructions:
      Hide

      Covered by unit tests:

      vendor/bin/phpunit --filter core_persistent_testcase
      

       

      We removed the custom getter from ReportBuilder and these tests should pass too:

      vendor/bin/phpunit --filter system_report_exporter_testcase
      

       

       

      Show
      Covered by unit tests: vendor/bin/phpunit --filter core_persistent_testcase   We removed the custom getter from ReportBuilder and these tests should pass too: vendor/bin/phpunit --filter system_report_exporter_testcase    

      Description

      The 'get' method in persistents does not return the property with the correct type, even if it has been defined in the persistent definition. If for example we have property 'id' and we set it as int, persistent should cast the property to int before return it.

      We encountered this problem in Workplace plugins and recently in Reportbuilder component. Here is an example of what we need to do to solve this issue:

      https://github.com/moodle/moodle/blob/0d0e66d37c6271657d76f948db9eeb10c139e7ae/reportbuilder/classes/local/models/report.php#L84-L91

        Attachments

          Activity

            People

            Assignee:
            davidmatamoros David Matamoros
            Reporter:
            davidmatamoros David Matamoros
            Peer reviewer:
            Paul Holden Paul Holden
            Integrator:
            Andrew Lyons Andrew Lyons
            Tester:
            CiBoT CiBoT
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 10 minutes
                1d 10m