Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 3.2.2, 3.3
-
Component/s: Authentication, Repositories
-
Testing Instructions:
-
Affected Branches:MOODLE_32_STABLE, MOODLE_33_STABLE
-
Fixed Branches:MOODLE_31_STABLE, MOODLE_32_STABLE
-
Pull from Repository:
-
Pull Master Branch:mdl-58489
Description
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.