Skip to content

Commit 73d6043

Browse files
committed
MDL-71062 core: Step 1 deprecation of print_error function
1 parent a23f0bf commit 73d6043

File tree

506 files changed

+1511
-1488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

506 files changed

+1511
-1488
lines changed

admin/auth.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929

3030
if (!empty($auth) and !exists_auth_plugin($auth)) {
31-
print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
31+
throw new \moodle_exception('pluginnotinstalled', 'auth', $returnurl, $auth);
3232
}
3333

3434
////////////////////////////////////////////////////////////////////////////////
@@ -55,7 +55,7 @@
5555
$key = array_search($auth, $authsenabled);
5656
// check auth plugin is valid
5757
if ($key === false) {
58-
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
58+
throw new \moodle_exception('pluginnotenabled', 'auth', $returnurl, $auth);
5959
}
6060
// move down the list
6161
if ($key < (count($authsenabled) - 1)) {
@@ -72,7 +72,7 @@
7272
$key = array_search($auth, $authsenabled);
7373
// check auth is valid
7474
if ($key === false) {
75-
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
75+
throw new \moodle_exception('pluginnotenabled', 'auth', $returnurl, $auth);
7676
}
7777
// move up the list
7878
if ($key >= 1) {

admin/blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
/// Get and sort the existing blocks
7676

7777
if (!$blocks = $DB->get_records('block', array(), 'name ASC')) {
78-
print_error('noblocks', 'error'); // Should never happen
78+
throw new \moodle_exception('noblocks', 'error'); // Should never happen.
7979
}
8080

8181
$incompatible = array();

admin/category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
$settingspage = $adminroot->locate($category, true);
4242

4343
if (empty($settingspage) or !($settingspage instanceof admin_category)) {
44-
print_error('categoryerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
44+
throw new \moodle_exception('categoryerror', 'error', "$CFG->wwwroot/$CFG->admin/");
4545
}
4646

4747
if (!($settingspage->check_access())) {
48-
print_error('accessdenied', 'admin');
48+
throw new \moodle_exception('accessdenied', 'admin');
4949
}
5050

5151
$hassiteconfig = has_capability('moodle/site:config', $PAGE->context);

admin/cli/restore_backup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@
6969
}
7070

7171
if (!$admin = get_admin()) {
72-
print_error('noadmins');
72+
throw new \moodle_exception('noadmins');
7373
}
7474

7575
if (!file_exists($options['file'])) {
76-
print_error('filenotfound');
76+
throw new \moodle_exception('filenotfound');
7777
}
7878

7979
if (!$category = $DB->get_record('course_categories', ['id' => $options['categoryid']], 'id')) {
80-
print_error('invalidcategoryid');
80+
throw new \moodle_exception('invalidcategoryid');
8181
}
8282

8383
$backupdir = "restore_" . uniqid();
@@ -102,7 +102,7 @@
102102
} catch (Exception $e) {
103103
cli_heading(get_string('cleaningtempdata'));
104104
fulldelete($path);
105-
print_error('generalexceptionmessage', 'error', '', $e->getMessage());
105+
throw new \moodle_exception('generalexceptionmessage', 'error', '', $e->getMessage());
106106
}
107107

108108
cli_heading(get_string('restoredcourseid', 'backup', $courseid));

admin/contentbank.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$sortorder = array_flip(array_keys($plugins));
4343

4444
if (!isset($plugins[$name])) {
45-
print_error('contenttypenotfound', 'error', $return, $name);
45+
throw new \moodle_exception('contenttypenotfound', 'error', $return, $name);
4646
}
4747

4848
switch ($action) {

admin/courseformats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
$sortorder = array_flip(array_keys($formatplugins));
4242

4343
if (!isset($formatplugins[$formatname])) {
44-
print_error('courseformatnotfound', 'error', $return, $formatname);
44+
throw new \moodle_exception('courseformatnotfound', 'error', $return, $formatname);
4545
}
4646

4747
switch ($action) {

admin/cron.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@
5858
// check if execution allowed
5959
if (!empty($CFG->cronclionly)) {
6060
// This script can only be run via the cli.
61-
print_error('cronerrorclionly', 'admin');
61+
throw new \moodle_exception('cronerrorclionly', 'admin');
6262
exit;
6363
}
6464
// This script is being called via the web, so check the password if there is one.
6565
if (!empty($CFG->cronremotepassword)) {
6666
$pass = optional_param('password', '', PARAM_RAW);
6767
if ($pass != $CFG->cronremotepassword) {
6868
// wrong password.
69-
print_error('cronerrorpassword', 'admin');
69+
throw new \moodle_exception('cronerrorpassword', 'admin');
7070
exit;
7171
}
7272
}

admin/customfields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
$sortorder = array_flip(array_keys($customfieldplugins));
4242

4343
if (!isset($customfieldplugins[$customfieldname])) {
44-
print_error('customfieldnotfound', 'error', $return, $customfieldname);
44+
throw new \moodle_exception('customfieldnotfound', 'error', $return, $customfieldname);
4545
}
4646

4747
switch ($action) {

admin/dataformats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$sortorder = array_flip(array_keys($plugins));
4343

4444
if (!isset($plugins[$name])) {
45-
print_error('courseformatnotfound', 'error', $return, $name);
45+
throw new \moodle_exception('courseformatnotfound', 'error', $return, $name);
4646
}
4747

4848
switch ($action) {

admin/environment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
$a = new stdClass();
5656
$a->url = 'https://download.moodle.org/environment/environment.zip';
5757
$a->dest = $CFG->dataroot . '/';
58-
print_error($cd->get_error(), 'error', $PAGE->url, $a);
58+
throw new \moodle_exception($cd->get_error(), 'error', $PAGE->url, $a);
5959
die();
6060

6161
} else {
62-
print_error($cd->get_error(), 'error', $PAGE->url);
62+
throw new \moodle_exception($cd->get_error(), 'error', $PAGE->url);
6363
die();
6464
}
6565

0 commit comments

Comments
 (0)