Commit graph

13 commits

Author SHA1 Message Date
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Timo Tijhof
7f000f8681 Re-introduce use of mime_content_type()
Follows-up eac059c722. See also https://stackoverflow.com/a/39676272/319266.

This function was never deprecated. For a short time, the www.php.net
manual page for `mime_content_type` wrongly documented it as having been
deprecated in PHP 5.3, but this wasn't true, and it has been present in
every PHP version since PHP 4.3, including PHP 7 and HHVM 2.3+.

Between PHP 4.3.0-4.3.2 and PHP 5.0-5.3, the function would be absent
if the Mimemagic extension was not enabled at compile-time. However, while
mime_content_type was first introduced by the Mimemagic PHP ext, it is
backend by the Finfo extension since PHP 5.3.0.

Confirmed via https://3v4l.org/IQC1Q.

* CSSMin: Revert conditional use of finfo back to unconditional use
  of mime_content_type.

* MimeAnalyzer: Replace conditional use of finfo with unconditional use
  use of mime_content_type. Also remove the now-redundant 'else' branch.
  The 'else' branch existed because this code was written at a time where
  MediaWiki still supported PHP 4, of which some minor versions could
  sometimes be compiled without this function.

Change-Id: Iee4a0b6f616a469bb779c40e386045f9c3200446
2017-07-27 02:18:43 +00:00
Mark Holmquist
bef66f7428 Add (hacky) check for webm audio files
If there is no video track in a webm file, it's supposed to be audio/webm,
but since we assume every webm file is video/webm, that's never worked.
This should slightly improve searching for audio files.

Bug: T156135
Change-Id: Iac749233e87b3622ff416ad503aedef3df0d0f1d
2017-07-11 14:06:19 -05:00
jenkins-bot
f7e1770fb8 Merge "Add 3D filetype for STL files" 2017-06-22 16:49:40 +00:00
Matthias Mullie
2647cbc4a4 Add media type based filtering to Special:NewFiles
Change-Id: Iff6e25055489f2181d6f9868e9250e03a54b91b7
2017-06-08 16:07:06 +02:00
jenkins-bot
ed92b00ea5 Merge "MimeAnalyzer: Detect magic bytes for mp3" 2017-05-19 12:14:27 +00:00
Derk-Jan Hartman
0a9008cbe1 MimeAnalyzer: Detect magic bytes for mp3
Unit tests in follow up patch

Bug: T115170
Change-Id: Ie1a63aa319cebbb2efb3cdc478416f5947078cbe
2017-05-19 13:33:25 +02:00
Paladox
54c56da85a Fix php code style
Preparation change for updating mediawiki code sniffer to 0.8.0

Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2
2017-05-05 12:03:54 +00:00
Mark Holmquist
a2f5d05ae8 Add 3D filetype for STL files
Other filetypes use the text/plain MIME type, so we'll have to do something
else to support them.

Bug: T157348
Change-Id: Id78a504302fa664b353a4c45bdc5d99f95a0180a
2017-04-17 17:01:52 +02:00
Derk-Jan Hartman
a95673a694 Special case opus mime detction
Bug: T151352
Change-Id: I44be5d6b407752b39fc8148d31e9f01de28014dc
2017-01-14 12:21:37 -08:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
Aaron Schulz
0d87d67d61 Move MimeMagic code to libs/mime/MimeAnalyzer.php
* The later resides in /libs with related files.
* Explose MimeAnalyzer as a service.
* Keep MimeMagic::singleton() as a b/c alias.
* MimeMagic::applyDefaultConfig() will bootstrap the service
  with all of the old config, extension hook handler, and
  detector command shell-out behavior.

Change-Id: Ie2695a52e7a3bcfda9f7fa83659a9ff31b372bc3
2016-10-15 00:05:16 +00:00