Repository navigation
fix(dynamix): prevent string offset warning when thousands separator is none - #2789
Lewi (ainto) wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe number-format helpers now use an empty thousands separator when the configured format has no second character. The UPS dashboard header no longer inserts an explicit line break after its status element, and its main text does not wrap or shrink. ChangesNumber Format Helpers
UPS Dashboard Header
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
Description
This PR fixes a PHP warning (
Warning: Uninitialized string offset 1) that occurs inHelpers.phpwhen a user selects the[G] noneoption for the thousands separator in Display Settings.The functions
my_number()andmy_scale()assume that the$display['number']string always contains two characters (a decimal point and a thousands separator). When[G] noneis selected, the string only contains one character (the decimal point), causing a warning when the code attempts to access the second character ($number[1]).How to reproduce the bug
[D] dot : [G] none(or[D] comma : [G] none).Warning: Uninitialized string offset 1 in /usr/local/emhttp/plugins/dynamix/include/Helpers.php on line ...Solution / Changes Made
I used the null coalescing operator (
??) to safely check if the thousands separator character exists before using it. If it doesn't exist (i.e., the user selectednone), it defaults to an empty string''.Modified functions in
/usr/local/emhttp/plugins/dynamix/include/Helpers.php:my_scale()my_number()Impact
[D] dot : [G] comma) will see no change in behavior, as$number[1]will still be correctly read.Summary by CodeRabbit