-
Bug
-
Resolution: Fixed
-
Minor
-
3.2.2, 3.3
-
MOODLE_32_STABLE, MOODLE_33_STABLE
-
MOODLE_31_STABLE, MOODLE_32_STABLE
-
mdl-58489
-
There is an if condition in oauth2_client that is likely an error: https://github.com/moodle/moodle/blob/bf919ddf021cacb6711bd00fa3b3b97019ad450a/lib/oauthlib.php#L507
if (!$this->info['http_code'] === 200) { |
throw new moodle_exception('Could not upgrade oauth token'); |
I assume that something along the lines of "HTTP code is not equal to 200" was intended. However, PHP interprets this statement as
if ((!$this->info['http_code']) === 200) { |
...i.e. "!" negates $this->info['http_code'] instead of the entire expression. Since $this->info['http_code'] is usually (always?) truthy, !$this->info['http_code'] is false which is definitely never identical to 200. Therefore, the exception-throwing part is never reached.
This would solve it:
if (!$this->info['http_code'] !== 200) { |
I am going to prepare a patch.