Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Mime] handle passing custom mime types as string#36716
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
mcneely commentedMay 5, 2020
| Q | A |
|---|---|
| Branch? | 4.4 |
| Bug fix? | yes |
| New feature? | no |
| Deprecations? | no |
| Tickets | Fix#36715 |
| License | MIT |
| Doc PR | none |
| Fix's issue where custom mimetypes were failing |
Uh oh!
There was an error while loading.Please reload this page.
xabbuh commentedMay 6, 2020
I am not sure that this qualifies as a bug fix. Reading the code it clear that the constructor expects a list of extensions not a single one. Maybe we should clarify that by adding a docblock? Like this: /** * @param array<string, array<int, string>> $map */publicfunction__construct(array$map = []){// ...} |
mcneely commentedMay 6, 2020
@xabbuh |
xabbuh commentedMay 6, 2020
What I wanted to say is that this was probably not supposed to work: $mt =newMimeTypes(['text/bar' =>'foo',]); It should have been written like this instead: $mt =newMimeTypes(['text/bar' => ['foo'],]); |
mcneely commentedMay 6, 2020
What's wrong with adding that in? |
xabbuh commentedMay 7, 2020
There's nothing wrong with it. I am just questioning whether this has been an intended usage. Depending on the answer this patch would either be a bugfix or a new feature. |
mcneely commentedMay 7, 2020
@xabbuh I have removed the line of convenience code you're so caught up on. Now it's only a bug fix. |
mcneely commentedMay 7, 2020
@nicolas-grekas I think the 7.1 integration just needs to be rerun, some sort of hiccup, probably because of 2 commits back to back. |
nicolas-grekas commentedMay 7, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
At least there is a bug thatif you pass a string, it explodes. |
xabbuh commentedMay 8, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I misunderstood the comment I replied to. I understand the issue now and the proposed change fixes it. 👍 |
| foreach ($extensionsas$extension) { | ||
| $this->mimeTypes[$extension] =$mimeType; | ||
| $this->mimeTypes[$extension] =$this->mimeTypes[$extension] ?? []; | ||
| array_push($this->mimeTypes[$extension],$mimeType); |
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.
You can shorten the patch a bit by using[]:
$this->mimeTypes[$extension][] =$mimeType;
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.
done.
xabbuh left a comment
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.
with a minor change
3b84d0d to0921423CompareUh oh!
There was an error while loading.Please reload this page.
fabpot commentedMay 9, 2020
Thank you@mcneely. |