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

PHP 8.2 compatibility fix #1553

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

forsdahl
Copy link
Contributor

Currently silverstripe-admin in version 4 triggers a lot of deprecation errors, because of setting dynamic class properties. This can be easily fixed by declaring these properties on the classes, and should have no impact on the code otherwise.

The reason for fixing this is to be able to fix deprecation errors with PHP 8.2 in other Silverstripe modules without these errors getting buried in all the deprecation errors from silverstripe-admin, not to have version 4 of silverstripe-admin officially support PHP 8.2.

@GuySartorelli
Copy link
Member

You said there are a lot of deprecation warnings (note, they're not errors) and the description of the pr makes it sound like there are multiple changes required - but there's only one. Can you please clarify if this pr is complete?

@forsdahl
Copy link
Contributor Author

Sorry, meant deprecation notices. I meant that silverstripe-admin causes deprecation notices on all requests to /admin, hence my wording of a lot of notices. The PR is complete though, with this change (which has no impact otherwise) we can get rid of these notices, so that we can fix deprecation notices in other modules.

I see that there is a linting error from this change though, should the property perhaps be declared private in this case, since it is not used by any other code?

@GuySartorelli
Copy link
Member

It should be public, because the dynamic property was public implicitly. But in any case, the linting error is because of the underscore more than because of the visibility I think. You may need to add a phpdoc comment to disable the linting rule for that property.

@GuySartorelli
Copy link
Member

@forsdahl
Copy link
Contributor Author

Changed the property to public, and disabled linting for that line

code/LeftAndMain.php Outdated Show resolved Hide resolved
code/LeftAndMain.php Outdated Show resolved Hide resolved
@forsdahl
Copy link
Contributor Author

I'll go ahead and change this PR to use the AllowDynamicProperties annotation instead of declaring the property public, as per silverstripe/silverstripe-framework#10921

annotation on classes that set dynamic properties
@GuySartorelli GuySartorelli merged commit 2a30bf4 into silverstripe:1.13 Aug 29, 2023
12 checks passed
@GuySartorelli
Copy link
Member

This will be automatically tagged when GitHub Actions has finished running on the branch.
I've manually reverted it in the merge-up to 2.0

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.

3 participants