Page MenuHomePhabricator

MimeAnalyzer::improveTypeFromExtension() may return null
Open, Needs TriagePublic

Description

Contrary to the return type declaration, MimeAnalyzer::improveTypeFromExtension( $mime, $ext ) can return null. This occurs whenever $mime is 'unknown/unknown' and $ext is not a known file extension.

This is surprising behavior. If this method is called with an unknown file extension and a MIME type other than unknown/unknown, it returns the original MIME type unmodified. So "improve" sometimes mean "improve or return unmodified", and other times it means "improve or return null".

The only caller I could find is MWFileProps::getPropsFromPath(), which doesn't appear to be expecting null values.

Event Timeline

ori created this task.May 24 2020, 7:18 PM
Restricted Application added a project: Performance-Team. · View Herald TranscriptMay 24 2020, 7:18 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 598274 had a related patch set uploaded (by Ori.livneh; owner: Ori.livneh):
[mediawiki/core@master] mime: Document null return from MimeAnalyzer::improveTypeFromExtension()

https://gerrit.wikimedia.org/r/598274

Change 598274 merged by jenkins-bot:
[mediawiki/core@master] mime: Document null return from MimeAnalyzer::improveTypeFromExtension()

https://gerrit.wikimedia.org/r/598274

Gilles moved this task from Inbox to Radar on the Performance-Team board.May 26 2020, 7:57 PM
Gilles edited projects, added Performance-Team (Radar); removed Performance-Team.