3 ob_start(); //for whitespace test
4 require_once('../config.php');
6 // extra whitespace test - intentionally breaks cookieless mode
8 while (ob_get_level()) {
9 $extraws .= ob_get_contents();
13 require_once($CFG->libdir
.'/adminlib.php');
15 admin_externalpage_setup('healthcenter');
17 define('SEVERITY_NOTICE', 'notice');
18 define('SEVERITY_ANNOYANCE', 'annoyance');
19 define('SEVERITY_SIGNIFICANT', 'significant');
20 define('SEVERITY_CRITICAL', 'critical');
22 $solution = optional_param('solution', 0, PARAM_SAFEDIR
); //in fact it is class name alhanumeric and _
25 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM
));
29 echo $OUTPUT->header();
32 <style type="text/css">
33 div#healthnoproblemsfound {
37 border: 1px black solid;
38 -moz-border-radius: 6px;
44 dl.critical dt, dl.critical dd {
45 background-color: #a71501;
47 dl.significant dt, dl.significant dd {
48 background-color: #d36707;
50 dl.annoyance dt, dl.annoyance dd {
51 background-color: #dba707;
53 dl.notice dt, dl.notice dd {
54 background-color: #e5db36;
56 dt.solution, dd.solution, div#healthnoproblemsfound {
57 background-color: #5BB83E !important;
59 dl.healthissues dt, dl.healthissues dd {
62 border: 1px black solid;
67 padding-bottom: 0.5em;
74 dl.healthissues dd form {
78 form#healthformreturn {
93 if(strpos($solution, 'problem_') === 0 && class_exists($solution)) {
94 health_print_solution($solution);
97 health_find_problems();
101 echo $OUTPUT->footer();
104 function health_find_problems() {
107 echo $OUTPUT->heading(get_string('healthcenter'));
110 SEVERITY_CRITICAL
=> array(),
111 SEVERITY_SIGNIFICANT
=> array(),
112 SEVERITY_ANNOYANCE
=> array(),
113 SEVERITY_NOTICE
=> array(),
117 for($i = 1; $i < 1000000; ++
$i) {
118 $classname = sprintf('problem_%06d', $i);
119 if(!class_exists($classname)) {
122 $problem = new $classname;
123 if($problem->exists()) {
124 $severity = $problem->severity();
125 $issues[$severity][$classname] = array(
126 'severity' => $severity,
127 'description' => $problem->description(),
128 'title' => $problem->title()
136 echo '<div id="healthnoproblemsfound">';
137 echo get_string('healthnoproblemsfound');
141 echo $OUTPUT->heading(get_string('healthproblemsdetected'));
142 $severities = array(SEVERITY_CRITICAL
, SEVERITY_SIGNIFICANT
, SEVERITY_ANNOYANCE
, SEVERITY_NOTICE
);
143 foreach($severities as $severity) {
144 if(!empty($issues[$severity])) {
145 echo '<dl class="healthissues '.$severity.'">';
146 foreach($issues[$severity] as $classname => $data) {
147 echo '<dt id="'.$classname.'">'.$data['title'].'</dt>';
148 echo '<dd>'.$data['description'];
149 echo '<form action="health.php#solution" method="get">';
150 echo '<input type="hidden" name="solution" value="'.$classname.'" /><input type="submit" value="'.get_string('viewsolution').'" />';
159 function health_print_solution($classname) {
161 $problem = new $classname;
163 'title' => $problem->title(),
164 'severity' => $problem->severity(),
165 'description' => $problem->description(),
166 'solution' => $problem->solution()
169 echo $OUTPUT->heading(get_string('healthcenter'));
170 echo $OUTPUT->heading(get_string('healthproblemsolution'));
171 echo '<dl class="healthissues '.$data['severity'].'">';
172 echo '<dt>'.$data['title'].'</dt>';
173 echo '<dd>'.$data['description'].'</dd>';
174 echo '<dt id="solution" class="solution">'.get_string('healthsolution').'</dt>';
175 echo '<dd class="solution">'.$data['solution'].'</dd></dl>';
176 echo '<form id="healthformreturn" action="health.php#'.$classname.'" method="get">';
177 echo '<input type="submit" value="'.get_string('healthreturntomain').'" />';
188 function severity() {
189 return SEVERITY_NOTICE
;
191 function description() {
194 function solution() {
199 class problem_000002
extends problem_base
{
201 return 'Extra characters at the end of config.php or other library function';
206 if($extraws === '') {
211 function severity() {
212 return SEVERITY_SIGNIFICANT
;
214 function description() {
215 return 'Your Moodle configuration file config.php or another library file, contains some characters after the closing PHP tag (?>). This causes Moodle to exhibit several kinds of problems (such as broken downloaded files) and must be fixed.';
217 function solution() {
219 return 'You need to edit <strong>'.$CFG->dirroot
.'/config.php</strong> and remove all characters (including spaces and returns) after the ending ?> tag. These two characters should be the very last in that file. The extra trailing whitespace may be also present in other PHP files that are included from lib/setup.php.';
223 class problem_000003
extends problem_base
{
225 return '$CFG->dataroot does not exist or does not have write permissions';
229 if(!is_dir($CFG->dataroot
) ||
!is_writable($CFG->dataroot
)) {
234 function severity() {
235 return SEVERITY_SIGNIFICANT
;
237 function description() {
239 return 'Your <strong>config.php</strong> says that your "data root" directory is <strong>'.$CFG->dataroot
.'</strong>. However, this directory either does not exist or cannot be written to by Moodle. This means that a variety of problems will be present, such as users not being able to log in and not being able to upload any files. It is imperative that you address this problem for Moodle to work correctly.';
241 function solution() {
243 return 'First of all, make sure that the directory <strong>'.$CFG->dataroot
.'</strong> exists. If the directory does exist, then you must make sure that Moodle is able to write to it. Contact your web server administrator and request that he gives write permissions for that directory to the user that the web server process is running as.';
247 class problem_000004
extends problem_base
{
249 return 'cron.php is not set up to run automatically';
253 $lastcron = $DB->get_field_sql('SELECT max(lastcron) FROM {modules}');
254 return (time() - $lastcron > 3600 * 24);
256 function severity() {
257 return SEVERITY_SIGNIFICANT
;
259 function description() {
260 return 'The cron.php mainenance script has not been run in the past 24 hours. This probably means that your server is not configured to automatically run this script in regular time intervals. If this is the case, then Moodle will mostly work as it should but some operations (notably sending email to users) will not be carried out at all.';
262 function solution() {
264 return 'For detailed instructions on how to enable cron, see <a href="'.$CFG->wwwroot
.'/doc/?file=install.html#cron">this section</a> of the installation manual.';
268 class problem_000005
extends problem_base
{
270 return 'PHP: session.auto_start is enabled';
273 return ini_get_bool('session.auto_start');
275 function severity() {
276 return SEVERITY_CRITICAL
;
278 function description() {
279 return 'Your PHP configuration includes an enabled setting, session.auto_start, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include fatal errors and/or blank pages when trying to log in.';
281 function solution() {
283 return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>session.auto_start = 1</pre> and change it to <pre>session.auto_start = 0</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot
.'/.htaccess</strong> to contain this line: <pre>php_value session.auto_start "0"</pre></li></ol>';
287 class problem_000006
extends problem_base
{
289 return 'PHP: magic_quotes_runtime is enabled';
292 return (ini_get_bool('magic_quotes_runtime'));
294 function severity() {
295 return SEVERITY_SIGNIFICANT
;
297 function description() {
298 return 'Your PHP configuration includes an enabled setting, magic_quotes_runtime, that <strong>must be disabled</strong> in order for Moodle to work correctly. Notable symptoms arising from this misconfiguration include strange display errors whenever a text field that includes single or double quotes is processed.';
300 function solution() {
302 return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>magic_quotes_runtime = On</pre> and change it to <pre>magic_quotes_runtime = Off</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot
.'/.htaccess</strong> to contain this line: <pre>php_value magic_quotes_runtime "Off"</pre></li></ol>';
306 class problem_000007
extends problem_base
{
308 return 'PHP: file_uploads is disabled';
311 return !ini_get_bool('file_uploads');
313 function severity() {
314 return SEVERITY_SIGNIFICANT
;
316 function description() {
317 return 'Your PHP configuration includes a disabled setting, file_uploads, that <strong>must be enabled</strong> to let Moodle offer its full functionality. Until this setting is enabled, it will not be possible to upload any files into Moodle. This includes, for example, course content and user pictures.';
319 function solution() {
321 return '<p>There are two ways you can solve this problem:</p><ol><li>If you have access to your main <strong>php.ini</strong> file, then find the line that looks like this: <pre>file_uploads = Off</pre> and change it to <pre>file_uploads = On</pre> and then restart your web server. Be warned that this, as any other PHP setting change, might affect other web applications running on the server.</li><li>Finally, you may be able to change this setting just for your site by creating or editing the file <strong>'.$CFG->dirroot
.'/.htaccess</strong> to contain this line: <pre>php_value file_uploads "On"</pre></li></ol>';
325 class problem_000008
extends problem_base
{
327 return 'PHP: memory_limit cannot be controlled by Moodle';
332 $oldmemlimit = @ini_get
('memory_limit');
333 if (empty($oldmemlimit)) {
334 // PHP not compiled with memory limits, this means that it's
335 // probably limited to 8M or in case of Windows not at all.
336 // We can ignore it for now - there is not much to test anyway
337 // TODO: add manual test that fills memory??
340 $oldmemlimit = get_real_size($oldmemlimit);
341 //now lets change the memory limit to something higher
342 $newmemlimit = ($oldmemlimit +
1024*1024*5);
343 raise_memory_limit($newmemlimit);
344 $testmemlimit = get_real_size(@ini_get
('memory_limit'));
345 //verify the change had any effect at all
346 if ($oldmemlimit == $testmemlimit) {
347 //memory limit can not be changed - is it big enough then?
348 if ($oldmemlimit < get_real_size('128M')) {
354 reduce_memory_limit($oldmemlimit);
357 function severity() {
358 return SEVERITY_NOTICE
;
360 function description() {
361 return 'The settings for PHP on your server do not allow a script to request more memory during its execution. '.
362 'This means that there is a hard limit of '.@ini_get
('memory_limit').' for each script. '.
363 'It is possible that certain operations within Moodle will require more than this amount in order '.
364 'to complete successfully, especially if there are lots of data to be processed.';
366 function solution() {
367 return 'It is recommended that you contact your web server administrator to address this issue.';
371 class problem_000009
extends problem_base
{
373 return 'SQL: using account without password';
377 return empty($CFG->dbpass
);
379 function severity() {
380 return SEVERITY_CRITICAL
;
382 function description() {
384 return 'The user account your are connecting to the database server with is set up without a password. This is a very big security risk and is only somewhat lessened if your database is configured to not accept connections from any hosts other than the server Moodle is running on. Unless you use a strong password to connect to the database, you risk unauthorized access to and manipulation of your data.'.($CFG->dbuser
!= 'root'?
'':' <strong>This is especially alarming because such access to the database would be as the superuser (root)!</strong>');
386 function solution() {
388 return 'You should change the password of the user <strong>'.$CFG->dbuser
.'</strong> both in your database and in your Moodle <strong>config.php</strong> immediately!'.($CFG->dbuser
!= 'root'?
'':' It would also be a good idea to change the user account from root to something else, because this would lessen the impact in the event that your database is compromised anyway.');
391 /* // not implemented in 2.0 yet
392 class problem_000010 extends problem_base {
394 return 'Uploaded files: slasharguments disabled or not working';
397 if (!$this->is_enabled()) {
400 if ($this->status() < 1) {
405 function severity() {
406 if ($this->is_enabled() and $this->status() == 0) {
407 return SEVERITY_SIGNIFICANT;
409 return SEVERITY_ANNOYANCE;
412 function description() {
414 $desc = 'Slasharguments are needed for relative linking in uploaded resources:<ul>';
415 if (!$this->is_enabled()) {
416 $desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
418 $desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
420 if ($this->status() == -1) {
421 $desc .= '<li>can not run automatic test, you can verify it <a href="'.$CFG->wwwroot.'/file.php/testslasharguments" target="_blank">here</a> manually</li>';
422 } else if ($this->status() == 0) {
423 $desc .= '<li>slashargument test <strong>failed</strong>, please check server configuration</li>';
425 $desc .= '<li>slashargument test passed</li>';
430 function solution() {
432 $enabled = $this->is_enabled();
433 $status = $this->status();
435 if ($enabled and ($status == 0)) {
436 $solution .= 'Slasharguments are enabled, but the test failed. Please disable slasharguments in Moodle configuration or fix the server configuration.<hr />';
437 } else if ((!$enabled) and ($status == 0)) {
438 $solution .= 'Slasharguments are disabled and the test failed. You may try to fix the server configuration.<hr />';
439 } else if ($enabled and ($status == -1)) {
440 $solution .= 'Slasharguments are enabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
441 } else if ((!$enabled) and ($status == -1)) {
442 $solution .= 'Slasharguments are disabled, <a href="'.$CFG->wwwroot.'/file.php/testslasharguments">automatic testing</a> not possible.<hr />';
443 } else if ((!$enabled) and ($status > 0)) {
444 $solution .= 'Slasharguments are disabled though the iternal test is OK. You should enable slasharguments in Moodle configuration.';
445 } else if ($enabled and ($status > 0)) {
446 $solution .= 'Congratulations - everything seems OK now :-D';
449 $solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>';
450 $solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
451 $solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
455 function is_enabled() {
457 return !empty($CFG->slasharguments);
461 $handle = @fopen($CFG->wwwroot.'/file.php?file=/testslasharguments', "r");
462 $contents = @trim(fread($handle, 10));
464 if ($contents != 'test -1') {
467 $handle = @fopen($CFG->wwwroot.'/file.php/testslasharguments', "r");
468 $contents = trim(@fread($handle, 10));
471 case 'test 1': return 1;
472 case 'test 2': return 2;
478 class problem_000012
extends problem_base
{
480 return 'Random questions data consistency';
484 return $DB->record_exists_select('question', "qtype = 'random' AND parent <> id", array());
486 function severity() {
487 return SEVERITY_ANNOYANCE
;
489 function description() {
490 return '<p>For random questions, question.parent should equal question.id. ' .
491 'There are some questions in your database for which this is not true. ' .
492 'One way that this could have happened is for random questions restored from backup before ' .
493 '<a href="http://tracker.moodle.org/browse/MDL-5482">MDL-5482</a> was fixed.</p>';
495 function solution() {
497 return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the SQL</p>' .
498 '<pre>UPDATE ' . $CFG->prefix
. 'question SET parent = id WHERE qtype = \'random\' and parent <> id;</pre>';
502 class problem_000013
extends problem_base
{
504 return 'Multi-answer questions data consistency';
508 $positionexpr = $DB->sql_position($DB->sql_concat("','", "q.id", "','"),
509 $DB->sql_concat("','", "qma.sequence", "','"));
510 return $DB->record_exists_sql("
511 SELECT * FROM {question} q
512 JOIN {question_multianswer} qma ON $positionexpr > 0
513 WHERE qma.question <> q.parent") ||
514 $DB->record_exists_sql("
515 SELECT * FROM {question} q
516 JOIN {question} parent_q ON parent_q.id = q.parent
517 WHERE q.category <> parent_q.category");
519 function severity() {
520 return SEVERITY_ANNOYANCE
;
522 function description() {
523 return '<p>For each sub-question whose id is listed in ' .
524 'question_multianswer.sequence, its question.parent field should equal ' .
525 'question_multianswer.question; and each sub-question should be in the same ' .
526 'category as its parent. There are questions in your database for ' .
527 'which this is not the case. One way that this could have happened is ' .
528 'for multi-answer questions restored from backup before ' .
529 '<a href="http://tracker.moodle.org/browse/MDL-14750">MDL-14750</a> was fixed.</p>';
531 function solution() {
532 return '<p>Upgrade to Moodle 1.9.1 or later, or manually execute the ' .
533 'code in question_multianswer_fix_subquestion_parents_and_categories in ' .
534 '<a href="http://cvs.moodle.org/moodle/question/type/multianswer/db/upgrade.php?revision=1.1.10.2&view=markup">/question/type/multianswer/db/upgrade.php' .
535 'from the 1.9 stable branch</a>.</p>';
539 class problem_000014
extends problem_base
{
541 return 'Only multianswer and random questions should be the parent of another question';
545 return $DB->record_exists_sql("
546 SELECT * FROM {question} q
547 JOIN {question} parent_q ON parent_q.id = q.parent
548 WHERE parent_q.qtype NOT IN ('random', 'multianswer')");
550 function severity() {
551 return SEVERITY_ANNOYANCE
;
553 function description() {
554 return '<p>You have questions that violate this in your databse. ' .
555 'You will need to investigate to determine how this happened.</p>';
557 function solution() {
558 return '<p>It is impossible to give a solution without knowing more about ' .
559 ' how the problem was caused. You may be able to get help from the ' .
560 '<a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a>.</p>';
564 class problem_000015
extends problem_base
{
566 return 'Question categories should belong to a valid context';
570 return $DB->record_exists_sql("
571 SELECT qc.*, (SELECT COUNT(1) FROM {question} q WHERE q.category = qc.id) AS numquestions
572 FROM {question_categories} qc
573 LEFT JOIN {context} con ON qc.contextid = con.id
574 WHERE con.id IS NULL");
576 function severity() {
577 return SEVERITY_ANNOYANCE
;
579 function description() {
581 $problemcategories = $DB->get_records_sql("
582 SELECT qc.id, qc.name, qc.contextid, (SELECT COUNT(1) FROM {question} q WHERE q.category = qc.id) AS numquestions
583 FROM {question_categories} qc
584 LEFT JOIN {context} con ON qc.contextid = con.id
586 ORDER BY numquestions DESC, qc.name");
587 $table = '<table><thead><tr><th>Cat id</th><th>Category name</th>' .
588 "<th>Context id</th><th>Num Questions</th></tr></thead><tbody>\n";
589 foreach ($problemcategories as $cat) {
590 $table .= "<tr><td>$cat->id</td><td>" . s($cat->name
) . "</td><td>" .
591 $cat->contextid
."</td><td>$cat->numquestions</td></tr>\n";
593 $table .= '</tbody></table>';
594 return '<p>All question categories are linked to a context id, and, ' .
595 'the context they are linked to must exist. The following categories ' .
596 'belong to a non-existant category:</p>' . $table . '<p>Any of these ' .
597 'categories that contain no questions can just be deleted form the database. ' .
598 'Other categories will require more thought.</p>';
600 function solution() {
602 return '<p>You can delete the empty categories by executing the following SQL:</p><pre>
603 DELETE FROM ' . $CFG->prefix
. 'question_categories
605 NOT EXISTS (SELECT * FROM ' . $CFG->prefix
. 'question q WHERE q.category = ' . $CFG->prefix
. 'question_categories.id)
606 AND NOT EXISTS (SELECT * FROM ' . $CFG->prefix
. 'context con WHERE contextid = con.id)
607 </pre><p>Any remaining categories that contain questions will require more thought. ' .
608 'People in the <a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a> may be able to help.</p>';
612 class problem_000016
extends problem_base
{
614 return 'Question categories should belong to the same context as their parent';
618 return $DB->record_exists_sql("
619 SELECT parent_qc.id AS parent, child_qc.id AS child, child_qc.contextid
620 FROM {question_categories} child_qc
621 JOIN {question_categories} parent_qc ON child_qc.parent = parent_qc.id
622 WHERE child_qc.contextid <> parent_qc.contextid");
624 function severity() {
625 return SEVERITY_ANNOYANCE
;
627 function description() {
629 $problemcategories = $DB->get_records_sql("
631 parent_qc.id AS parentid, parent_qc.name AS parentname, parent_qc.contextid AS parentcon,
632 child_qc.id AS childid, child_qc.name AS childname, child_qc.contextid AS childcon
633 FROM {question_categories} child_qc
634 JOIN {question_categories} parent_qc ON child_qc.parent = parent_qc.id
635 WHERE child_qc.contextid <> parent_qc.contextid");
636 $table = '<table><thead><tr><th colspan="3">Child category</th><th colspan="3">Parent category</th></tr><tr>' .
637 '<th>Id</th><th>Name</th><th>Context id</th>' .
638 '<th>Id</th><th>Name</th><th>Context id</th>' .
639 "</tr></thead><tbody>\n";
640 foreach ($problemcategories as $cat) {
641 $table .= "<tr><td>$cat->childid</td><td>" . s($cat->childname
) .
642 "</td><td>$cat->childcon</td><td>$cat->parentid</td><td>" . s($cat->parentname
) .
643 "</td><td>$cat->parentcon</td></tr>\n";
645 $table .= '</tbody></table>';
646 return '<p>When one question category is the parent of another, then they ' .
647 'should both belong to the same context. This is not true for the following categories:</p>' .
650 function solution() {
651 return '<p>An automated solution is difficult. It depends whether the ' .
652 'parent or child category is in the wrong pace.' .
653 'People in the <a href="http://moodle.org/mod/forum/view.php?f=121">Quiz forum</a> may be able to help.</p>';
657 class problem_000017
extends problem_base
{
659 return 'Question categories tree structure';
661 function find_problems() {
663 static $answer = null;
665 if (is_null($answer)) {
666 $categories = $DB->get_records('question_categories', array(), 'id');
668 // Look for missing parents.
669 $missingparent = array();
670 foreach ($categories as $category) {
671 if ($category->parent
!= 0 && !array_key_exists($category->parent
, $categories)) {
672 $missingparent[$category->id
] = $category;
678 while (!empty($categories)) {
679 $current = array_pop($categories);
680 $thisloop = array($current->id
=> $current);
682 if (isset($thisloop[$current->parent
])) {
684 $loops[$current->id
] = $thisloop;
686 } else if (!isset($categories[$current->parent
])) {
687 // Got to the top level, or a category we already know is OK.
690 // Continue following the path.
691 $current = $categories[$current->parent
];
692 $thisloop[$current->id
] = $current;
693 unset($categories[$current->id
]);
698 $answer = array($missingparent, $loops);
704 list($missingparent, $loops) = $this->find_problems();
705 return !empty($missingparent) ||
!empty($loops);
707 function severity() {
708 return SEVERITY_ANNOYANCE
;
710 function description() {
711 list($missingparent, $loops) = $this->find_problems();
713 $description = '<p>The question categories should be arranged into tree ' .
714 ' structures by the question_categories.parent field. Sometimes ' .
715 ' this tree structure gets messed up.</p>';
717 if (!empty($missingparent)) {
718 $description .= '<p>The following categories are missing their parents:</p><ul>';
719 foreach ($missingparent as $cat) {
720 $description .= "<li>Category $cat->id: " . s($cat->name
) . "</li>\n";
722 $description .= "</ul>\n";
725 if (!empty($loops)) {
726 $description .= '<p>The following categories form a loop of parents:</p><ul>';
727 foreach ($loops as $loop) {
728 $description .= "<li><ul>\n";
729 foreach ($loop as $cat) {
730 $description .= "<li>Category $cat->id: " . s($cat->name
) . " has parent $cat->parent</li>\n";
732 $description .= "</ul></li>\n";
734 $description .= "</ul>\n";
739 function solution() {
741 list($missingparent, $loops) = $this->find_problems();
743 $solution = '<p>Consider executing the following SQL queries. These fix ' .
744 'the problem by moving some categories to the top level.</p>';
746 if (!empty($missingparent)) {
747 $solution .= "<pre>UPDATE " . $CFG->prefix
. "question_categories\n" .
748 " SET parent = 0\n" .
749 " WHERE id IN (" . implode(',', array_keys($missingparent)) . ");</pre>\n";
752 if (!empty($loops)) {
753 $solution .= "<pre>UPDATE " . $CFG->prefix
. "question_categories\n" .
754 " SET parent = 0\n" .
755 " WHERE id IN (" . implode(',', array_keys($loops)) . ");</pre>\n";
762 class problem_00000x
extends problem_base
{
769 function severity() {
770 return SEVERITY_SIGNIFICANT
;
772 function description() {
775 function solution() {
785 session.save_path -- it doesn't really matter because we are already IN a session, right?
786 detect unsupported characters in $CFG->wwwroot - see bug Bug #6091 - relative vs absolute path during backup/restore process