-
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: Breaking: Differentiate between kilobyte/kibibyte and megabyte/mebibyte #9277
base: 4.6
Are you sure you want to change the base?
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 |
For the next PR, could you use a specific branch name (other than
$ gh pr checkout 9277
remote: Enumerating objects: 97, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 97 (delta 57), reused 70 (delta 32), pack-reused 0 (from 0)
Unpacking objects: 100% (97/97), 27.88 KiB | 68.00 KiB/s, done.
From github.com:codeigniter4/CodeIgniter4
* branch refs/pull/9277/head -> FETCH_HEAD
hint: Diverging branches can't be fast-forwarded, you need to either:
hint:
hint: git merge --no-ff
hint:
hint: or:
hint:
hint: git rebase
hint:
hint: Disable this message with "git config advice.diverging false"
fatal: Not possible to fast-forward, aborting.
failed to run git: exit status 128 |
Sure, will do, sorry for the inconvenience 😇 |
Co-authored-by: kenjis <[email protected]>
Co-authored-by: Michal Sniatala <[email protected]>
Co-authored-by: Michal Sniatala <[email protected]>
Co-authored-by: Michal Sniatala <[email protected]>
* reorder cases and function * add DocBlock for return and throws
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 🤯 |
|
||
.. literalinclude:: files/005.php | ||
:lines: 2- | ||
|
||
A ``RuntimeException`` will be thrown if the file does not exist or an error occurs. | ||
|
||
getSizeByBinaryUnit() | ||
===================== | ||
|
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.
.. versionadded:: 4.6.0 |
|
||
getSizeByMetricUnit() | ||
===================== | ||
|
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.
.. versionadded:: 4.6.0 |
@@ -277,6 +277,9 @@ Deprecations | |||
- The properties ``$arguments`` and ``$argumentsClass`` of ``Filters`` have | |||
been deprecated. No longer used. | |||
- The ``Filters::getArguments()`` method has been deprecated. No longer used. | |||
- **File:** | |||
- The function ``getSizeByUnit()`` of ``File`` has been deprecated. | |||
Use either ``getSizeByBinaryUnit()`` or ``getSizeByMetricUnit()`` instead. |
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.
Please add the new methods in the Enhancements section:
https://github.com/codeigniter4/CodeIgniter4/blob/4.6/user_guide_src/source/changelogs/v4.6.0.rst#libraries
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.
Will do. Two separate bullet point, or both in one?
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.
One line would be sufficient.
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: