Skip to content
Browse files

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

…first 250
  • Loading branch information...
1 parent 5bbf3cb commit d0c94a1e84c7b452b0cc91da333982373fb06bb2 @tlevi tlevi committed with stronk7
Showing with 17 additions and 13 deletions.
  1. +17 −13 backup/util/ui/restore_ui_components.php
View
30 backup/util/ui/restore_ui_components.php
@@ -164,22 +164,26 @@ public function __construct(array $config=array()) {
$this->totalcount = 0;
$contextlevel = $this->get_itemcontextlevel();
list($sql, $params) = $this->get_searchsql();
- $resultset = $DB->get_recordset_sql($sql, $params, 0, 250);
- foreach ($resultset as $result) {
- context_instance_preload($result);
- $context = get_context_instance($contextlevel, $result->id);
- if (count($this->requiredcapabilities) > 0) {
- foreach ($this->requiredcapabilities as $cap) {
- if (!has_capability($cap['capability'], $context, $cap['user'])) {
- continue 2;
+ $blocksz = 5000;
+ $offs = 0;
+ while ($resultset = $DB->get_records_sql($sql, $params, $offs, $blocksz)){
+ foreach ($resultset as $result) {
+ context_instance_preload($result);
+ $context = get_context_instance($contextlevel, $result->id);
+ if (count($this->requiredcapabilities) > 0) {
+ foreach ($this->requiredcapabilities as $cap) {
+ if (!has_capability($cap['capability'], $context, $cap['user'])) {
+ continue 2;
+ }
}
}
+ $this->results[$result->id] = $result;
+ $this->totalcount++;
+ if ($this->totalcount >= self::$MAXRESULTS) {
+ break 2;
+ }
}
- $this->results[$result->id] = $result;
- $this->totalcount++;
- if ($this->totalcount >= self::$MAXRESULTS) {
- break;
- }
+ $offs += $blocksz;
}
return $this->totalcount;

0 comments on commit d0c94a1

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