Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Apr 2024 at 09:41 UTC
Updated:
25 Feb 2025 at 15:09 UTC
Jump to comment: Most recent
Comments
Comment #5
sandeep sanwale commentedHere i have added the check which validates that if $string contains malformed string then it throws an exception .
Comment #7
sandeep sanwale commentedComment #8
smustgrave commentedComment #10
vidorado commentedMany tests were failing because they were passing
NULLor an empty string toNumber::alphadecimalToInt(). So I believe we should continue accepting these two special "degenerate" values as input. Two tests have been added: one to ensure this behavior and other to verify that an exception is thrown for any other non-alphanumeric characters.I'm not sure how to proceed if we want to provide a deprecation message. Perhaps something like this?
@trigger_error('Passing non-alphanumeric characters is deprecated in Number::alphadecimalToInt() and will be removed in Drupal 12.', E_USER_DEPRECATED);Comment #11
vidorado commentedComment #12
smustgrave commentedSo believe we should actually do a deprecation here. #10 close but there's a specific pattern that has to be followed, would check core for examples. But deprecated in 11.2 and required in 12.
Comment #13
vidorado commentedI've created a change record and triggered a deprecation error, as it must be done according to https://www.drupal.org/node/2856615
Additionally, the follow-up issue #3494476: Remove NumberTest::testAlphadecimalToIntReturnsZeroWithNullAndEmptyString() test has been created in order to remove the BC test.
Comment #14
smustgrave commentedWould be deprecated in 11.2
Can't add deprecation for versions with releases out already.
Comment #15
vidorado commentedOops, sorry! :) I wasn’t sure which version to include in the message since I don’t really know when this MR will be merged. I initially put 11.0.0 and later forgot to revisit it.
So, should we always deprecate for the next minor version as an estimate?
Comment #16
smustgrave commentedBelieve feedback has been addressed.
Test covers the new exception, deprecation message for both '' and null.
CR reads fine to me, added versions to it.
LGTM
Comment #18
catchCommitted/pushed to 11.x, thanks!