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

detach completely objects inside moodle_database calls so never get modified

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      As commented by chat, perhaps it would be interesting to, always, detach the object passed to moodle_database methods (insert/update...), so it never gets changed by internals.

      The most noticeable case right now is insert_record() that unsets the "id" of the outer object, while, under some circumpstances you can be interested into retaining it (I've found myself having to store it into variable before insert in a lot of place in restore code).

      But I think it's a good general rule/principle: "moodle_database methods won't modify the outer object ever"

      Ciao

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            stronk7 Eloy Lafuente (stronk7)
            Tester:
            Nobody
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Nov/10