Moodle
  1. Moodle
  2. MDL-17497

Course import runs out of memory when a category has a lot of courses

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.3
    • Fix Version/s: 1.9.4
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      When trying to import resources to a course that is in a large category, PHP runs out of memory. Increasing the memory_limit is the workaround, but Moodle code could be improved also:

      /course/import/activities/mod.php is reading category course information with
      $cat_courses = get_courses($course->category);
      This loads all of the course data for all of the category courses, but then the script only uses the course id and the course full name, as fas as I understand. So it takes a lot more memory than necessary. Default PHP limit of 128M can hold around 1200 courses, we ran out of mem when a category had 1278 courses.

      Could /course/import/activities/mod.php only read the course information that it really needs?

      To reproduce: have a category with a lot of courses (hundreds or thousands) with descrriptions and moddata in them. Reduce the memory_limit of PHP to something like 8M or 16M. Go to a course in a large category and click Import from the admin block. A semi-blank page appears. PHP ran out of memory.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Samuli Karevaara added a comment -

            Not ported to HEAD yet...

            Show
            Samuli Karevaara added a comment - Not ported to HEAD yet...
            Hide
            Samuli Karevaara added a comment -

            The rather trivial fix now merged to HEAD also...

            Show
            Samuli Karevaara added a comment - The rather trivial fix now merged to HEAD also...
            Hide
            Petr Skoda added a comment -

            next time please do not "Close", instead "Resolve" the issue only

            Rosolve - means developer fixed the problem usually by committing into cvs
            Close - means somebody else not involved yet in the bugfixing of this issue verified the solution of the problem

            Person "Closing" issue should add himself/herself to QA Assignee field.

            in any case thanks for the report and patch!

            Show
            Petr Skoda added a comment - next time please do not "Close", instead "Resolve" the issue only Rosolve - means developer fixed the problem usually by committing into cvs Close - means somebody else not involved yet in the bugfixing of this issue verified the solution of the problem Person "Closing" issue should add himself/herself to QA Assignee field. in any case thanks for the report and patch!
            Hide
            Samuli Karevaara added a comment -

            Petr, you are of course right! That was quite sloppy on my part, sorry!

            Show
            Samuli Karevaara added a comment - Petr, you are of course right! That was quite sloppy on my part, sorry!
            Hide
            Petr Skoda added a comment -

            no problem, just wanted to make sure you know the new rules

            Show
            Petr Skoda added a comment - no problem, just wanted to make sure you know the new rules
            Hide
            Luke Tucker added a comment -

            Just wondering if this issue was actually fixed?

            I noticed that course/import/activities/mod.php in the latest version of Moodle 1.9 still selects all course fields and is still causes our moodles to run out of memory unless we patch this file to only select id and name as Samuli suggests.

            Apologies if this already been resolved - the duplicate ticket (19880) attached to this can also probably be deleted.

            Thanks,
            Luke

            Show
            Luke Tucker added a comment - Just wondering if this issue was actually fixed? I noticed that course/import/activities/mod.php in the latest version of Moodle 1.9 still selects all course fields and is still causes our moodles to run out of memory unless we patch this file to only select id and name as Samuli suggests. Apologies if this already been resolved - the duplicate ticket (19880) attached to this can also probably be deleted. Thanks, Luke
            Hide
            Luke Tucker added a comment -

            Please disregard my previous comment - there is actually another query a few lines above the query fixed here that also causes moodle to run out of memory.

            I will add some comments to the ticket I originally created for this.

            Luke

            Show
            Luke Tucker added a comment - Please disregard my previous comment - there is actually another query a few lines above the query fixed here that also causes moodle to run out of memory. I will add some comments to the ticket I originally created for this. Luke

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: