-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Reduce share ID casts #37512
Reduce share ID casts #37512
Conversation
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
Outdated
Show resolved
Hide resolved
ccafe85
to
754c91c
Compare
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
Fixed
Show resolved
Hide resolved
754c91c
to
6cecdc9
Compare
Signed-off-by: jld3103 <jld3103yt@gmail.com>
6cecdc9
to
10af78c
Compare
Also, doing (int)$string will convert to string even if the string is weird, like '10km' will convert to 10. Here if someone tries to call an API method on an invalid share id, it should return an error, not silently work with another share id. So I would add tests for is_numeric and error out if it’s not. |
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.
Cannot judge. I have the impression that there is a mixture of int and string uses on IDs still.
This stuff is already done in the |
I know, I tried fixing it, but it's not completely possible. |
@come-nc @blizzz I should have made more clear what this PR is about. I'm trying to minimize the amounts of casts that happen everywhere for share ids. They get changed quite often because different places use either string or int. IShare uses string, so I converted some places to also use string instead of casting to int and then back to string. |
Please excuse the dumb question, i am not familiar with all the aspects there, but going string everywhere, as by API design, is not possible? |
I think we can do that in most cases. Internally the id is an integer in the database so there needs to be some casting at least. We'd need to make sure that the output of API calls stay integer if they are integers right now. One downside I see is that devs might not be aware that the ids should be valid integers, but then the code is a mess anyway, so it's not much worse. |
Summary
Split out from #37390
Checklist