Skip to content

Commit

Permalink
added PHP version check, fixed #19925 (#19936)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Sep 4, 2023
1 parent 671fbef commit e8c4a7e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.50 under development
------------------------

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


Expand Down
3 changes: 2 additions & 1 deletion framework/helpers/mimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,8 @@
'zmm' => 'application/vnd.handheld-entertainment+xml',
];

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

Expand Down
3 changes: 2 additions & 1 deletion tests/framework/helpers/MimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,8 @@ public function testMimeTypes()
'zmm' => 'application/vnd.handheld-entertainment+xml',
];

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

Expand Down
3 changes: 2 additions & 1 deletion tests/framework/validators/FileValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ public function validMimeTypes()
['test.tar.xz', 'application/x-xz', 'tar.xz'],
]);

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

0 comments on commit e8c4a7e

Please sign in to comment.