Skip to content

Commit

Permalink
MDL-71159 output: Do not run content prefetch during install
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Mar 22, 2021
1 parent 15f3ddd commit 76c6d2f
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/outputrequirementslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,26 @@ protected function get_amd_footercode() {
}

// First include must be to a module with no dependencies, this prevents multiple requests.
$prefix = 'M.util.js_pending("core/first");';
$prefix .= "require(['core/first'], function() {\n";
$prefix .= "require(['core/prefetch']);\n";
$suffix = 'M.util.js_complete("core/first");';
$suffix .= "\n});";
$output .= html_writer::script($prefix . implode(";\n", $this->amdjscode) . $suffix);
$prefix = <<<EOF
M.util.js_pending("core/first");
require(['core/first'], function() {
EOF;

if (during_initial_install()) {
// Do not run a prefetch during initial install as the DB is not available to service WS calls.
$prefetch = '';
} else {
$prefetch = "require(['core/prefetch'])\n";
}

$suffix = <<<EOF
M.util.js_complete("core/first");
});
EOF;

$output .= html_writer::script($prefix . $prefetch . implode(";\n", $this->amdjscode) . $suffix);
return $output;
}

Expand Down

0 comments on commit 76c6d2f

Please sign in to comment.