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 Check if blank method passed #10417

Merged

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Jul 21, 2022

Issue silverstripe/silverstripe-cms#2750

Checking for emtpy($method) protects against null being passed in for $method and later on triggering a deprecation warning in PHP 8.1 on strtolower($method);

Note: docblock params and return types are wrong because null is being passed in at least one instance (so not limited to string) and this function already returns null, so array return type is also incorrect. There's a much wider issue with the docblock params and return type accuracy so not going to fix here.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the specific cause of the listed issue is graphql is passing in a null when it arguable should be a string:
https://github.com/silverstripe/silverstripe-graphql/blob/2aa13a52bd74c632ce87e591ca74b1dd565f119b/src/Schema/DataObject/Plugin/DBFieldArgs/DBDateArgs.php#L53-L66

But as noted in the PR description, phpdoc types can't really be trusted in silverstripe at the moment anyway, and this fix will protect against other situations where a null is passed in as a method to check.

Works well locally. MOG.

@emteknetnz emteknetnz merged commit dd210e0 into silverstripe:4.11 Jul 21, 2022
@emteknetnz emteknetnz deleted the pulls/4.11/emtpy-method branch July 21, 2022 03:49
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