-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: Differentiate between kilobyte/kibibyte and megabyte/mebibyte #9277
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find all places with method.
user_guide_src/source/libraries/files.rst
user_guide_src/source/libraries/uploaded_files.rst
user_guide_src/source/libraries/files/005.php
user_guide_src/source/libraries/files/013.php
add changelog to user_guide_src/source/changelogs/v4.6.0.rst
Will do, will add. |
Why do you need this enhancement? |
#9271 (comment) |
I got your intention. I don't think it is worth adding this breaking change. Because many devs do not need this feature. |
How do we address |
I might be getting you wrong, but new parameter is exactly what I did, didn't I? Regarding number_to_size(): |
If we merge this PR, existing apps may break. Because the behavior will change. -$kilobytes = $file->getSizeByUnit('kb'); // 250.880
+$kilobytes = $file->getSizeByUnit('kb'); // 256.901 This is a breaking change, and we would like to avoid to break existing apps as possible. Adding a new parameter means something like this: $kilobytes = $file->getSizeByUnit('kb'); // 250.880
$kilobytes = $file->getSizeByUnit('kb', false); // 256.901 This does not break existing apps. |
Ah, I see. Well, I personally think introducing breaking changes from time to time is unavoidable, but I can absolutely see the impact vs benefit side of this very instance. |
Yes, adding new method(s) is an option. |
"Boolean" methods are usually better separated. This is clearly visible in the code |
Yeah, also not a big fan of bool params to distinguish between behaviors. It would also violate the S in SOLID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a new parameter $precision to the this method? This would make it more flexible and allow for better control over the precision of the output.
And |
Somebody motivated to enrich the contribution guide about how to run all the code checks locally? 😇 Edit: Just took a look into the running checks and noticed the composer scripts. Didn't even know those were a thing 🤯 |
@ThomasMeschke could you address the remaining review comments? and squash the commits? so we can merge this PR |
Which comments do you mean? I though I got all of them... |
@ThomasMeschke Well, that's strange - usually, GitHub would resolve a conversation automatically if the changes to the files were made, but here for some reason, it didn't happen. The unresolved conversations are an indicator for us that not all requested changes were implemented. In the future, please resolve the conversation manually if you see that your changes weren't taken into account. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can squash on merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I didn't see it was already resolved albeit no indication it was resolved. 😅
Thank you, @ThomasMeschke |
Notice
This originated from another PR: #9271
Description
Noticed that the file size calculation mixes up the SI unit prefixes with the NIST/IEC unit prefixes, by taking "kb" and "mb" but calculating "kib" and "mib".
Fixed by providing both possibilities.
This therefore will break existing code!
Checklist: