Moodle
  1. Moodle
  2. MDL-26938

No matching courses when importing due to max courses limit

    Details

    • Database:
      MySQL
    • Testing Instructions:
      Hide

      This needs a Moodle DB with a large number of courses (say, 1000 approx).

      • Create two additional courses, "source" and "target".
      • Create a user "U" and enrol the user as Teacher into both of these courses.
      • Log in as "U" and navigate to "target".
      • Click "Import".

      Verify that the list displayed contains the course "source", and in aprticualr is not empty.

      Show
      This needs a Moodle DB with a large number of courses (say, 1000 approx). Create two additional courses, "source" and "target". Create a user "U" and enrol the user as Teacher into both of these courses. Log in as "U" and navigate to "target". Click "Import". Verify that the list displayed contains the course "source", and in aprticualr is not empty.
    • Affected Branches:
      MOODLE_20_STABLE
    • Pull Master Branch:
    • Rank:
      16567

      Description

      In backup/util/ui/restore_ui_components.php function search(), get_recordset_sql is limited to 250 rows. The import utility in courses generates a search query like this one:

      SELECT c.id,c.fullname,c.shortname,c.visible,c.sortorder , ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, ctx.instanceid AS ctxinstance FROM mdl_course c LEFT JOIN mdl_context ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = 50) WHERE (LOWER(c.fullname) LIKE LOWER('%%') COLLATE utf8_bin ESCAPE '
      ' OR LOWER(c.shortname) LIKE LOWER('%%') COLLATE utf8_bin ESCAPE '
      ') AND c.id <> 1 ORDER BY c.sortorder;

      Which returns all courses in the site. So if you happen to have more than 250 courses, teachers won't get a single one in the first 250, therefore an empty array will be returned, and a message saying "No matching courses".

      This is beacuse the context is checked after creating the search. I modified the code to get 2500 and 5500 (more than the 4870 we have), and worked, but it was REALLY slow.

        Issue Links

          Activity

          Hide
          Tamara Snyder added a comment -

          Jorge - thanks for the suggested workaround. We have that same issue (we are using Moodle 2.0) and increasing 250 to exceed our number of courses worked.

          Show
          Tamara Snyder added a comment - Jorge - thanks for the suggested workaround. We have that same issue (we are using Moodle 2.0) and increasing 250 to exceed our number of courses worked.
          Hide
          Tamara Snyder added a comment -

          Jorge - thanks for the suggested workaround. We have that same issue (we are using Moodle 2.0) and increasing 250 to exceed our number of courses worked.

          Show
          Tamara Snyder added a comment - Jorge - thanks for the suggested workaround. We have that same issue (we are using Moodle 2.0) and increasing 250 to exceed our number of courses worked.
          Hide
          Jorge Villalon added a comment -

          Hi Tamara. I'm happy it helped, and thanks for voting. Hopefully more people vote for it because I have not seen any activity around this bug...

          Show
          Jorge Villalon added a comment - Hi Tamara. I'm happy it helped, and thanks for voting. Hopefully more people vote for it because I have not seen any activity around this bug...
          Hide
          Robert Puffer added a comment -

          I'd call this a blocker.

          Show
          Robert Puffer added a comment - I'd call this a blocker.
          Hide
          Kevin Wiliarty added a comment -

          We're not that big a school, but we will exceed this limit in a single semester. We'd definitely appreciate a core solution.

          Show
          Kevin Wiliarty added a comment - We're not that big a school, but we will exceed this limit in a single semester. We'd definitely appreciate a core solution.
          Hide
          Henning Bostelmann added a comment -

          I'm submitting a fix for review that just removes the 250 courses limit. This may not give great performance, but at least it removes the unexpected functional limit for the moment. On an installation with 1000 courses, it worked fine.

          Also adding a missing $resultset->close().

          Will backport the fix once agreed.

          Show
          Henning Bostelmann added a comment - I'm submitting a fix for review that just removes the 250 courses limit. This may not give great performance, but at least it removes the unexpected functional limit for the moment. On an installation with 1000 courses, it worked fine. Also adding a missing $resultset->close(). Will backport the fix once agreed.
          Hide
          Troy Williams added a comment -

          Fix worked for us, thanks

          Show
          Troy Williams added a comment - Fix worked for us, thanks
          Hide
          Jan Gilevich added a comment -

          Worked for us too. Thank you very much!

          Show
          Jan Gilevich added a comment - Worked for us too. Thank you very much!
          Hide
          Steve Massicotte added a comment -

          Also, work for us too.

          Show
          Steve Massicotte added a comment - Also, work for us too.
          Hide
          Justin Litalien added a comment -

          It sounds like this fix is working for folks. Any chance of it being added to a new release sometime soon?

          Show
          Justin Litalien added a comment - It sounds like this fix is working for folks. Any chance of it being added to a new release sometime soon?
          Hide
          omer added a comment -

          fix worked for me too..

          Show
          omer added a comment - fix worked for me too..
          Hide
          James Rudd added a comment -

          Fix also worked for me. Teachers were unable to import last years classes until I applied this fix. Now it works fine.

          Show
          James Rudd added a comment - Fix also worked for me. Teachers were unable to import last years classes until I applied this fix. Now it works fine.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Henning (et all),

          many thanks for the patch, comments, and testing... I'm closing this as duplicate of MDL-26037, where a more advanced (complex) fix is being checked and, hopefully will land upstream in 1-2 weeks.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Henning (et all), many thanks for the patch, comments, and testing... I'm closing this as duplicate of MDL-26037 , where a more advanced (complex) fix is being checked and, hopefully will land upstream in 1-2 weeks. Ciao

            People

            • Votes:
              52 Vote for this issue
              Watchers:
              28 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: