Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Fatal error because of missing argument in local_o365\oauth2\systemtoken::instance #2332

Closed
wants to merge 1 commit into from

Conversation

AndreasSko
Copy link

We are using the o365 plugin version 4.1.2 with Moodle 4.1. We've recently upgraded our Moodle setup to PHP 8.1. Since then we noticed that some course pages failed to load completely. PHP is logging the following error message:

PHP Fatal error: Declaration of local_o365\oauth2\systemtoken::instance($userid, $tokenresource, local_o365\oauth2\clientdata $clientdata, $httpclient) must be compatible with local_o365\oauth2\token::instance($userid, $tokenresource, local_o365\oauth2\clientdata $clientdata , $httpclient, $forcecreate = false) in /www/local/o365/classes/oauth2/systemtoken.php on line 45

When debugging the issue we noticed that the following line appears to be missing the $forcecreate parameter:

public static function instance($userid, $tokenresource, \local_o365\oauth2\clientdata $clientdata, $httpclient) {

which the token class contains:

public static function instance($userid, $tokenresource, \local_o365\oauth2\clientdata $clientdata, $httpclient,
$forcecreate = false) {

By adding the argument to the method we were able to fix that issue. As this is a pretty small change I thought I would already prepare a PR 🙂

The `local_o365\oauth2\systemtoken::instance`
method, which extends `\local_o365\oauth2\token::instance`
was missing the `$forcecreate` argument. Since
upgrading to PHP 8.1 this resulted in the following
error message:

> PHP Fatal error:  Declaration of local_o365\oauth2\systemtoken::instance($userid, $tokenresource, local_o365\oauth2\clientdata $clientdata, $httpclient) must be compatible with local_o365\oauth2\token::instance($userid, $tokenresource, local_o365\oauth2\clientdata $clientdata , $httpclient, $forcecreate = false) in /www/local/o365/classes/oauth2/systemtoken.php on line 45

Adding the parameter now to fix the issue.
@AndreasSko AndreasSko changed the title Fix missing argument in local_o365\oauth2\systemtoken::instance Fix Fatal error because of missing argument in local_o365\oauth2\systemtoken::instance Jul 12, 2023
@weilai-irl weilai-irl self-assigned this Nov 6, 2023
@weilai-irl weilai-irl added this to the 2024-01 milestone Jan 8, 2024
@weilai-irl
Copy link
Collaborator

Hi @AndreasSko

The proposed changes have been included in the releases from today.

Thank you for your contribution.

Regards,
Lai

@weilai-irl weilai-irl closed this Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants