Commit a334a69e authored by Aaron Wells's avatar Aaron Wells
Browse files

Bug 1595789: Make NULL urlsecret work during installation

It was failing because we'd set the default value on
param_alphanumext() to "null". But if the default passed
to that function evaluates to false (as null does), then
the function acts as if you've passed no default, and
hence it's a required function.

Further, the template form where we add the urlsecret
to the install button, in case of a null urlsecret,
would wind up adding "urlsecret=" to the end of the
URL. param_alphanumext() would see the presence of
the "urlsecret" query parameter, so it would evaluate
this to match its regex, which requires there to be
at least one character in the value. And then that
would throw a "ParameterException" when the check failed.

Change-Id: I1fb4ed7bcfe14155532e4ebb5d8c0dbdc33d1d36
behatnotneeded: Can't yet test in behat
parent 710108cf
......@@ -33,8 +33,8 @@ if (param_integer('finished', 0)) {
}
// Check if we have come via browser and have the right urlsecret
if (php_sapi_name() != 'cli') {
$urlsecret = param_alphanumext('urlsecret', null);
if (php_sapi_name() != 'cli' && get_config('urlsecret') !== null) {
$urlsecret = param_alphanumext('urlsecret', -1);
if ($urlsecret !== get_config('urlsecret')) {
die_info(get_string('accessdeniednourlsecret', 'error'));
}
......
......@@ -25,8 +25,8 @@ require_once(get_config('docroot') . 'webservice/lib.php');
// Check if we have come via browser and have the right urlsecret
// Note: if your crontab hits this file via curl/http thenyou will need
// to add the urlsecret there for the cron to work.
if (php_sapi_name() != 'cli') {
$urlsecret = param_alphanumext('urlsecret', null);
if (php_sapi_name() != 'cli' && get_config('urlsecret') !== null) {
$urlsecret = param_alphanumext('urlsecret', -1);
if ($urlsecret !== get_config('urlsecret')) {
die_info(get_string('accessdeniednourlsecret', 'error'));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment