From 086624407651eaff7e28e3f6cd8d5123ee0ecf16 Mon Sep 17 00:00:00 2001 From: Diego Cabrejas Date: Sat, 24 Mar 2018 13:14:09 +0000 Subject: [PATCH] magento-engcom/php-7.2-support#67: Eliminate usage of Zend_Mime from Magento 2 Open Source - Add Magento's own Mime class to replace usage of Zend_Mime --- .../Downloadable/Controller/Download.php | 2 +- .../Unit/Controller/Download/LinkTest.php | 4 +-- .../Test/Legacy/_files/obsolete_classes.php | 3 +- lib/internal/Magento/Framework/HTTP/Mime.php | 28 +++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 lib/internal/Magento/Framework/HTTP/Mime.php diff --git a/app/code/Magento/Downloadable/Controller/Download.php b/app/code/Magento/Downloadable/Controller/Download.php index f0bef425d4b45..583b5a33c6b9c 100644 --- a/app/code/Magento/Downloadable/Controller/Download.php +++ b/app/code/Magento/Downloadable/Controller/Download.php @@ -64,7 +64,7 @@ protected function _processDownload($path, $resourceType) $contentDisposition = $helper->getContentDisposition(); if (!$contentDisposition || in_array($contentType, $this->disallowedContentTypes)) { // For security reasons we force browsers to download the file instead of opening it. - $contentDisposition = \Zend_Mime::DISPOSITION_ATTACHMENT; + $contentDisposition = \Magento\Framework\HTTP\Mime::DISPOSITION_ATTACHMENT; } $response->setHeader('Content-Disposition', $contentDisposition . '; filename=' . $fileName); diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php index f2e288d75a40a..7e756c1790a26 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php @@ -492,8 +492,8 @@ public function linkNotAvailableDataProvider() public function downloadTypesDataProvider() { return [ - ['mimeType' => 'text/html', 'disposition' => \Zend_Mime::DISPOSITION_ATTACHMENT], - ['mimeType' => 'image/jpeg', 'disposition' => \Zend_Mime::DISPOSITION_INLINE], + ['mimeType' => 'text/html', 'disposition' => \Magento\Framework\HTTP\Mime::DISPOSITION_ATTACHMENT], + ['mimeType' => 'image/jpeg', 'disposition' => \Magento\Framework\HTTP\Mime::DISPOSITION_INLINE], ]; } } diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index f75f89c05eaec..1faf2a5a4aa19 100755 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -4234,5 +4234,6 @@ 'Magento\Elasticsearch\Test\Unit\Model\SearchAdapter\ConnectionManagerTest', 'Magento\Elasticsearch\Test\Unit\SearchAdapter\ConnectionManagerTest' ], - ['Zend_Feed', 'Zend\Feed'] + ['Zend_Feed', 'Zend\Feed'], + ['Zend_Mime', 'Magento\Framework\HTTP\Mime'], ]; diff --git a/lib/internal/Magento/Framework/HTTP/Mime.php b/lib/internal/Magento/Framework/HTTP/Mime.php new file mode 100644 index 0000000000000..7979fb2b7d10e --- /dev/null +++ b/lib/internal/Magento/Framework/HTTP/Mime.php @@ -0,0 +1,28 @@ +