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

data_delete_instance() function breaks badly with big data contents

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Critical Critical
    • None
    • 1.9.9
    • None
    • MOODLE_19_STABLE
    • Moderate
    • Hide
      • Create a database activity
      • Allow posts to be rated and select a grade (I went with 100)
      • Create some fields (one should do)
      • Enter in some data using different students.
      • Grade their entries.
      • Check the gradebook.
      • Delete the database.
        [TEST] check that the database has been deleted (phpmyadmin or something like that).
        [TEST] check that the grades for the database activity have also been deleted.
      Show
      Create a database activity Allow posts to be rated and select a grade (I went with 100) Create some fields (one should do) Enter in some data using different students. Grade their entries. Check the gradebook. Delete the database. [TEST] check that the database has been deleted (phpmyadmin or something like that). [TEST] check that the grades for the database activity have also been deleted.

      Trying to delete one big database activity, breaks with memory exhausted problem.

      Looking at code, it seems that data_delete_instance() is highly inefficient:

      1) It uses one get_records() instead of get_recordset()
      2) It instantiated one object for each field and for each record.
      3) It uses the delete_content_files() but params doesn't match at all, so I guess it isn't deleting the files at all

      I would suggest to:

      • Take a look to the code in data_delete_instance() under 2.0.
      • For the DB part, backport it for 1.9. It's simple and quick
      • For the "potential" files, avoid the delete_content_files() completely and go and delete recursively the directory:
        • $CFG->dataroot.'/'.COURSEID.'/'.$CFG->moddata.'/data/'. DATAID

      That way there won't be more problems deleting one data instance completely, IMO.

            abgreeve Adrian Greeve
            stronk7 Eloy Lafuente (stronk7)
            Rajesh Taneja Rajesh Taneja
            Sam Hemelryk Sam Hemelryk
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.