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

Privacy tests override or report invalid data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3.5, 3.4.2
    • Fix Version/s: 3.3.6, 3.4.3
    • Component/s: Privacy, Unit tests
    • Labels:

      Description

      Here is a test.

          /**
           * Test export and recover with children.
           */
          public function test_get_data_with_children() {
              $writer = $this->get_writer_instance();
              $context = \context_system::instance();
       
              $writer->set_context($context)
                  ->export_data(['a'], (object) ['parent' => true])
                  ->export_data(['a', 'b'], (object) ['parent' => false]);
       
              $this->assertTrue($writer->get_data(['a'])->parent);
              $this->assertFalse($writer->get_data(['a', 'b'])->parent);
              $this->assertSame([], $writer->get_data(['a', 'b', 'c']));
          }
      

      I identified two issues:

      1. Writing a sub context overrides the parent
      2. Getting a sub context that does not exist returns the parent

      Andrew mentioned that this will likely affect other `get_*` methods.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dobedobedoh Andrew Nicols
              Reporter:
              fred Frédéric Massart
              Peer reviewer:
              Adrian Greeve
              Integrator:
              Jun Pataleta
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

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