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

[8.x Compatibility] Doctrine_Validator::validateLength - Deprecation #105

Closed
wants to merge 1 commit into from
Closed

[8.x Compatibility] Doctrine_Validator::validateLength - Deprecation #105

wants to merge 1 commit into from

Conversation

iricketson
Copy link

If a model definition contains a column of type decimal that allows nullable values, Doctrine_Table attempts to validate the length of the null value, which calls Doctrine_Validator::validateLength and ultimately throws a deprecation notice when it tries to call abs() on the null value.

PHP message: PHP Deprecated: abs(): Passing null to parameter #1 ($num) of type int|float is deprecated in /path/to/friendsofsymfony1/doctrine1/lib/Doctrine/Validator.php on line 100

This PR simply returns true early if the $value is null, which is what it would return anyway.

@iricketson iricketson changed the title Return early when value is null [8.x Compatibility] Doctrine_Validator::validateLength - Deprecation Dec 28, 2023
@iricketson iricketson mentioned this pull request Dec 28, 2023
Copy link

@alquerci alquerci left a comment

Choose a reason for hiding this comment

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

The patch looks good.

I invite you to add a test case for that.
You can find an example on tests/Ticket/1385TestCase.php.


To execute tests on your computer, you need this patch.

@iricketson iricketson closed this by deleting the head repository Jan 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.

3 participants