Any tips on workaround for MDL-11061?

Any tips on workaround for MDL-11061?

by John Watson -
Number of replies: 5
Hi,

We are experiencing the Quiz view problem discribed by MDL-11061 .
Can anyone give me some pointers on how to edit the qualified_me function so that $CFG->wwwroot matches $_SERVER?

Thanks,
John

We are running 1.7.1+
Apache/2.2.4 (Unix) PHP/5.2.3
mysql 5.0.41
SSL
Average of ratings: -
In reply to John Watson

Re: Any tips on workaround for MDL-11061?

by Pierre Pichet -
The comments on line 270 of lib/weblib.php in 1.9
// TODO, this does not work in the situation described in MDL-11061, but
// I don't know how to fix it. Possibly believe $CFG->wwwroot ahead of what
// the server reports.
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;
return $url_prefix . me();
are related to the same code (without the TODO lines) line 250 in 1.7 , if this can help you.

Pierre

In reply to Pierre Pichet

Re: Any tips on workaround for MDL-11061?

by John Watson -
Hi Pierre,

Thanks for your reply but it still doesn't point me in the right direction.
The code in 1.7 is exactly the same as in 1.9 and it's the '// I don't know how to fix it.' that worries me wink

Tim suggests in MDL-11061:
In this case, probably the best place to fix moodle is in the qualified_me function from lib/weblib.php, so that $ME,
does always start with lib/weblib.php. However, I am not sure of the best way to do this.

Thats what prompted me to ask the user community, but seeing that even Tim doesn't know how to fix I think my chances of resolving this are slim ;-(

I'm by no standards a PHP programmer. The occasional workaround tweak sums up my PHP skills wink
In reply to John Watson

Re: Any tips on workaround for MDL-11061?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I only meant that I do not know how to fix that function so it gives the right result on every possible web server and reverse proxy set-up, just from the information provided in the the Moodle configuration files and the $_SERVER variable (which each type of web server seems to set up differently).

If you just need to make it work correctly for your own set-up, it should be a lot easier. You can probably just do a crude hack at the end of
qualified_me, for example change the last line to:
if ($CFG->wwwroot == 'http://my.server/moodle/') {
 return 'http://my.server/moodle/' . me();
} else {
 return $url_prefix . me();
}
Obviously that is not a general solution, but with a bit of experimentation you should be able to get it working for you.

This is probably not the best forum for discussion a problem like this. The 'General Problems' forum may be better.
In reply to Tim Hunt

Re: Any tips on workaround for MDL-11061?

by John Watson -
Hi Tim,

You're a star! Your suggestion worked like a charm. Maybe you could add it as a comment to the function in weblib.php?

Regards and thanks again,
John


In reply to John Watson

Re: Any tips on workaround for MDL-11061?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Probably better for you to add it to the bug report. The comment in weblib references that.