How to rebuild context paths
Sometimes, if something has gone wrong in your database, you will get an error like:
[Thu Jan 15 16:20:59 2009] [error] [client 184.108.40.206] PHP Notice: Context id 113 does not have valid path, please use build_context_path()
- line 375 of lib\\accesslib.php: call to debugging()
- line 125 of mod\\forum\\index.php: call to has_capability()
- in \\lib\\weblib.php on line 6923, referer: mod/forum/index.php?id=2
This page explains how to follow the instruction to "please use build_context_path". You will need to create a simple PHP script to do this, then run it.
Before you start
This error should never happen, so the fact that it has may be a symptom of something more serious being wrong. If you are paranoid, you may wish to check your database for corruption before running the repair script below.
On the other hand, sometimes these things happens, so you could just run the script below then forget about it.
Step 1: create the script
On your server, create a file in the admin folder called rebuildcontextpaths.php with contents:
<?php require_once(dirname(__FILE__) . '/../config.php'); require_login(); require_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM)); print_header();
Rebuilding context paths ...
(You can either create this file on your own computer using a text editor like Notepad, then upload it to Moodle's admin folder. Or you can edit the file directly on the server. It does not matter how you do it, just that you end up with the file there, with those contents.)
Step 2: run the script
Go to the URL .../admin/rebuildcontextpaths.php in your web browser (for example, if your Moodle site is at http://example.com/moodle/, then go to the URL http://example.com/moodle/admin/rebuildcontextpaths.php. You need to log in as an administrator. The script will run, and immediately print 'Rebuilding context paths ...'. Some time later (depending on how big your Moodle site is) it will print 'Done'.