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

Download of large course or site log report results in out of memory error

    XMLWordPrintable

Details

    • Any
    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • mdl26_MDL-40094_allow_download_of_large_log_report
    • Hide

      Follow the step in "To reproduce this issue" in the issue Description.

      No out of memory error should be displayed, and the text or excel file should download successfully.

      Also test that it works when there are 0 log entries for the selected logging criteria; this should just download a file with column headers but no entries.

      Note that this fix does not necessarily fix large log downloads for the ODS format, because the ODS code collects all the data before writing it to a file. It tries to fix it by calling "raise_memory_limit(MEMORY_EXTRA);" if it's an ODS export. This should take care of the problem except if the data to be exported is especially huge. As a workaround if someone still experiences an error with ODS format ... you can download it in excel format, open it with Libre Office, and save in ODS format.

      Show
      Follow the step in "To reproduce this issue" in the issue Description. No out of memory error should be displayed, and the text or excel file should download successfully. Also test that it works when there are 0 log entries for the selected logging criteria; this should just download a file with column headers but no entries. Note that this fix does not necessarily fix large log downloads for the ODS format, because the ODS code collects all the data before writing it to a file. It tries to fix it by calling "raise_memory_limit(MEMORY_EXTRA);" if it's an ODS export. This should take care of the problem except if the data to be exported is especially huge. As a workaround if someone still experiences an error with ODS format ... you can download it in excel format, open it with Libre Office, and save in ODS format.

    Description

      To reproduce this issue:

      0. Configure your Moodle's PHP so that memory_limit <= 128M.
      1. Configure $CFG->debug to DEVELOPER, and $CFG->debugdisplay to yes.
      2. Generate a lot of log entries. To do this, find the id of an existing user and an existing course on your Moodle. Replace the '<insert ... here>' parts in the script below with these ids. Run the script to generate SQL statements and feed these SQL statements into your Moodle's database.

      <?php
       
      $courseid = <insert course id here>;
      $userid = <insert user id here>;
      $time = time();
      for ($i = 0; $i < 150000; $i++) {
          echo "insert into mdl_log (time, userid, ip, course, module, cmid, action, url, info) values ($time, $userid, '192.168.192.168', $courseid, 'course', 0, 'view', 'something/anything/view.php?id=$courseid', $courseid);\n";
      }
      

      3. go to "Site administration -> Reports -> Logs" .
      4. Select All Participants, All Days, All Activties, All Actions and "Download in Text Format" or "Download in Excel Format".
      5. click on 'Get these Logs' button.

      out of memory error occurs

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              brianking Brian King
              Dan Poltawski Dan Poltawski
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: