Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-26037: restore/import: check through all courses instead of only …

…first 250
  • Loading branch information...
commit b6328863ada4100b73679694c5491f10183e1d98 1 parent f24a1a7
Tony Levi tlevi authored stronk7 committed

Showing 1 changed file with 17 additions and 13 deletions. Show diff stats Hide diff stats

  1. +17 13 backup/util/ui/restore_ui_components.php
30 backup/util/ui/restore_ui_components.php
@@ -164,22 +164,26 @@ public function __construct(array $config=array()) {
164 164 $this->totalcount = 0;
165 165 $contextlevel = $this->get_itemcontextlevel();
166 166 list($sql, $params) = $this->get_searchsql();
167   - $resultset = $DB->get_recordset_sql($sql, $params, 0, 250);
168   - foreach ($resultset as $result) {
169   - context_instance_preload($result);
170   - $context = get_context_instance($contextlevel, $result->id);
171   - if (count($this->requiredcapabilities) > 0) {
172   - foreach ($this->requiredcapabilities as $cap) {
173   - if (!has_capability($cap['capability'], $context, $cap['user'])) {
174   - continue 2;
  167 + $blocksz = 5000;
  168 + $offs = 0;
  169 + while ($resultset = $DB->get_records_sql($sql, $params, $offs, $blocksz)){
  170 + foreach ($resultset as $result) {
  171 + context_instance_preload($result);
  172 + $context = get_context_instance($contextlevel, $result->id);
  173 + if (count($this->requiredcapabilities) > 0) {
  174 + foreach ($this->requiredcapabilities as $cap) {
  175 + if (!has_capability($cap['capability'], $context, $cap['user'])) {
  176 + continue 2;
  177 + }
175 178 }
176 179 }
  180 + $this->results[$result->id] = $result;
  181 + $this->totalcount++;
  182 + if ($this->totalcount >= self::$MAXRESULTS) {
  183 + break 2;
  184 + }
177 185 }
178   - $this->results[$result->id] = $result;
179   - $this->totalcount++;
180   - if ($this->totalcount >= self::$MAXRESULTS) {
181   - break;
182   - }
  186 + $offs += $blocksz;
183 187 }
184 188
185 189 return $this->totalcount;

0 comments on commit b632886

Please sign in to comment.
Something went wrong with that request. Please try again.