Permalink
Browse files

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

…first 250
  • Loading branch information...
tlevi authored and stronk7 committed Jan 6, 2012
1 parent f24a1a7 commit b6328863ada4100b73679694c5491f10183e1d98
Showing with 17 additions and 13 deletions.
  1. +17 −13 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 b632886

Please sign in to comment.