It seems Moodle is not able to record the
URL (including full
parameters) it came from when you are sent to the login page. It
remembers the URL, but not the parameters (the '?d=7#23' in your
example above). So after login, you are redirected to the right page,
but with missing parameters that are mandatory. That's why you get the
error.
Now the question is, why isn't Moodle able to record the parameters in
your installation? The $FULLME global variable should contain the full
URL+parameter data. That variable is set in lib/setup.php and used
(among other places) in require_login(), where you are sent after
trying to access something that requires you are logged in.
$FULLME is setup using a function called qualified_me() in weblib.php,
which in turns calls a function called me() in that same file to get
the 'URI' part of the URL.
So I guess we need to 'debug' qualified_me() and me() to see why they
are not recording the parameters in the URI.
You can add the following lines (the ones in blue) in function
qualified_me() to see what you get in $FULLME when you are sent to the
login page:
if (isset($_SERVER['HTTPS'])) {
$protocol = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
} else if (isset($_SERVER['SERVER_PORT'])) { # Apache2 does not export $_SERVER['HTTPS']
$protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';
} else {
$protocol = 'http://';
}
$url_prefix = $protocol.$hostname;
$uri = me();
echo "<!-- url_prefix = $url_prefix , uri = $uri -->\n";
return $url_prefix . me();
And the following lines in function me():
function me() {
if (!empty($_SERVER['REQUEST_URI'])) {
echo "<!-- path 1 -->\n";
return $_SERVER['REQUEST_URI'];
} else if (!empty($_SERVER['PHP_SELF'])) {
if (!empty($_SERVER['QUERY_STRING'])) {
echo "<!-- path 2 -->\n";
return $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
}
echo "<!-- path 3 -->\n";
return $_SERVER['PHP_SELF'];
} else if (!empty($_SERVER['SCRIPT_NAME'])) {
if (!empty($_SERVER['QUERY_STRING'])) {
echo "<!-- path 4 -->\n";
return $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING'];
}
echo "<!-- path 5 -->\n";
return $_SERVER['SCRIPT_NAME'];
} else if (!empty($_SERVER['URL'])) { // May help IIS (not well tested)
if (!empty($_SERVER['QUERY_STRING'])) {
echo "<!-- path 6 -->\n";
return $_SERVER['URL'] .'?'. $_SERVER['QUERY_STRING'];
}
echo "<!-- path 7 -->\n";
return $_SERVER['URL'];
} else {
notify('Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL');
return false;
}
}
You'll get the values as HTMLs comment, so they won't be displayed in the browser, but you can see them if you look at the page source.
Saludos. Iñaki.