Skip to content

Commit e8c4a7e

Browse files
schmunk42samdarkBizley
authored
added PHP version check, fixed #19925 (#19936)
* added PHP version check, fixed #19925 * added CHANGELOG line * fixed typo * fixed typo --------- Co-authored-by: Alexander Makarov <[email protected]> Co-authored-by: Bizley <[email protected]>
1 parent 671fbef commit e8c4a7e

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Yii Framework 2 Change Log
44
2.0.50 under development
55
------------------------
66

7+
- Bug #19925: Improved PHP version check when handling MIME types (schmunk42)
78
- Bug #19940: File Log writer without newline (terabytesoftw)
89

910

framework/helpers/mimeTypes.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@
10031003
'zmm' => 'application/vnd.handheld-entertainment+xml',
10041004
];
10051005

1006-
if (PHP_VERSION_ID >= 80100) {
1006+
# fix for bundled libmagic bug, see also https://github.com/yiisoft/yii2/issues/19925
1007+
if ((PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80122) || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80209)) {
10071008
$mimeTypes = array_replace($mimeTypes, array('xz' => 'application/octet-stream'));
10081009
}
10091010

tests/framework/helpers/MimeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,8 @@ public function testMimeTypes()
10311031
'zmm' => 'application/vnd.handheld-entertainment+xml',
10321032
];
10331033

1034-
if (PHP_VERSION_ID >= 80100) {
1034+
# fix for bundled libmagic bug, see also https://github.com/yiisoft/yii2/issues/19925
1035+
if ((PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80122) || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80209)) {
10351036
$coreMimeTypes = array_replace($coreMimeTypes, array('xz' => 'application/octet-stream'));
10361037
}
10371038

tests/framework/validators/FileValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ public function validMimeTypes()
546546
['test.tar.xz', 'application/x-xz', 'tar.xz'],
547547
]);
548548

549-
if (PHP_VERSION_ID >= 80100) {
549+
# fix for bundled libmagic bug, see also https://github.com/yiisoft/yii2/issues/19925
550+
if ((PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80122) || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80209)) {
550551
$v81_zx = ['test.tar.xz', 'application/octet-stream', 'tar.xz'];
551552
array_pop($validMimeTypes);
552553
$validMimeTypes[] = $v81_zx;

0 commit comments

Comments
 (0)