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

Creation of dynamic property is deprecated with PHP 8.2+ #2547

Closed
opitz opened this issue Apr 15, 2024 · 4 comments · Fixed by #2592 or #2593
Closed

Creation of dynamic property is deprecated with PHP 8.2+ #2547

opitz opened this issue Apr 15, 2024 · 4 comments · Fixed by #2592 or #2593
Assignees
Labels
Issue type - enhancement request New feature being requested outside of original scope. Plugin - local_o365 Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release.
Milestone

Comments

@opitz
Copy link

opitz commented Apr 15, 2024

To see the issue run a Moodle instance on PHP 8.2 with local_o356 installed.
Log in as admin, set debugging to developer and (try to) open to the plugin overview page.

You will see an error:
Creation of dynamic property local_o365\adminsetting\tabs::$component is deprecated
A similar issue appears with ...\tabs::$theme.

This can be fixed by explicitly declaring $component and $theme in the constructor method.

@weilai-irl weilai-irl self-assigned this Jun 10, 2024
@weilai-irl weilai-irl added Issue type - enhancement request New feature being requested outside of original scope. Plugin - local_o365 Status - queued / not yet started The request is clear, but the work has yet to be scheduled. labels Jun 10, 2024
@weilai-irl
Copy link
Collaborator

Hi @opitz

Could you paste the full stack trace of the error/warning please? I can't seem to find where the errors would be triggered.

Regards,
Lai

@opitz
Copy link
Author

opitz commented Jun 28, 2024

Hi @weilai-irl ,
sorry for the delayed response, only spotted this today...

1st: the issue only appears with PHP 8.2+.
To see the issue you need to set debugging to DEVELOPER and allow showing errors on screen (or dig through the log).

Then click "Site administration" from the main menu to open this page: http://moodle_root_here/admin/search.php.
On top of the page you should see:

Deprecated: Creation of dynamic property local_o365\adminsetting\tabs::$theme is deprecated in /var/www/html/local/o365/classes/adminsetting/tabs.php on line 68

Deprecated: Creation of dynamic property local_o365\adminsetting\tabs::$component is deprecated in /var/www/html/local/o365/classes/adminsetting/tabs.php on line 67

Deprecated: Creation of dynamic property local_o365\adminsetting\tabs::$theme is deprecated in /var/www/html/local/o365/classes/adminsetting/tabs.php on line 68

To resolve this you will need to declare the properties before you use them. For this simply add

/**
 * @var mixed the component.
 */
protected $component;

/**
 * @var string the theme.
 */
protected $theme;

to the 'tabs' class after line 50 of local/o365/classes/adminsetting/tabs.php.

Best,
m!

@weilai-irl
Copy link
Collaborator

@opitz

Thank you for the updates and providing the solution.

I have created PR for Moodle 4.2 and 4.3, and they will be included in the next release. Moodle 4.1 doesn't support PHP 8.2, so the fix doesn't apply there.

Regards,
Lai

@weilai-irl weilai-irl added Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release. and removed Status - queued / not yet started The request is clear, but the work has yet to be scheduled. labels Jun 28, 2024
@weilai-irl
Copy link
Collaborator

Hi @opitz

The fix to this issue has been included in release 4.1.7, 4.2.6 and 4.3.4 on 2nd of July 2024.

Thank you again for reporting the issue and providing the solution.

Regards,
Lai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue type - enhancement request New feature being requested outside of original scope. Plugin - local_o365 Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release.
Projects
None yet
2 participants