From d0e56d4c5c5c5390957325b29ad85884c14453f3 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Tue, 26 Feb 2019 11:22:50 -0600 Subject: [PATCH] MAGECLOUD-3195: Fix patch "MAGETWO-57414__load_static_assets_without_rewrites__2.1.4.patch" for 2.1.17 --- patches.json | 3 +- ...atic_assets_without_rewrites__2.1.17.patch | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 patches/MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch diff --git a/patches.json b/patches.json index cc733bc76a..7f1d9d262a 100644 --- a/patches.json +++ b/patches.json @@ -20,7 +20,8 @@ "~2.1.4": "MAGETWO-57413__move_vendor_path_autoloader__2.1.4.patch" }, "Allow static assets to be loaded without URL rewrites": { - "~2.1.4": "MAGETWO-57414__load_static_assets_without_rewrites__2.1.4.patch" + "2.1.4 - 2.1.16": "MAGETWO-57414__load_static_assets_without_rewrites__2.1.4.patch", + "~2.1.17": "MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch" }, "Don't attempt to use non-existent setup areas": { "~2.1.4": "MAGETWO-45357__avoid_nonexistent_setup_area__2.1.4.patch" diff --git a/patches/MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch b/patches/MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch new file mode 100644 index 0000000000..e397a0d4df --- /dev/null +++ b/patches/MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch @@ -0,0 +1,58 @@ +Ticket MAGETWO-57414 +diff -Naur a/vendor/magento/framework/App/StaticResource.php b/vendor/magento/framework/App/StaticResource.php +index d591deb..6344322 100644 +--- a/vendor/magento/framework/App/StaticResource.php ++++ b/vendor/magento/framework/App/StaticResource.php +@@ -94,24 +94,40 @@ class StaticResource implements \Magento\Framework\AppInterface + { + // disabling profiling when retrieving static resource + \Magento\Framework\Profiler::reset(); +- $appMode = $this->state->getMode(); +- if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { ++ $path = $this->getResourcePath(); ++ if (!isset($path)) { + $this->response->setHttpResponseCode(404); +- } else { +- $path = $this->request->get('resource'); +- $params = $this->parsePath($path); +- $this->state->setAreaCode($params['area']); +- $this->objectManager->configure($this->configLoader->load($params['area'])); +- $file = $params['file']; +- unset($params['file']); +- $asset = $this->assetRepo->createAsset($file, $params); +- $this->response->setFilePath($asset->getSourceFile()); +- $this->publisher->publish($asset); ++ return $this->response; + } ++ ++ $params = $this->parsePath($path); ++ $this->state->setAreaCode($params['area']); ++ $this->objectManager->configure($this->configLoader->load($params['area'])); ++ $file = $params['file']; ++ unset($params['file']); ++ $asset = $this->assetRepo->createAsset($file, $params); ++ $this->response->setFilePath($asset->getSourceFile()); ++ $this->publisher->publish($asset); + return $this->response; + } + + /** ++ * Retrieve the path from either the GET parameter or the request ++ * URI, depending on whether webserver rewrites are in use. ++ */ ++ protected function getResourcePath() { ++ $path = $this->request->get('resource'); ++ if (isset($path)) { ++ return $path; ++ } ++ ++ $path = $this->request->getUri()->getPath(); ++ if (preg_match("~^/static/(?:version\d*/)?(.*)$~", $path, $matches)) { ++ return $matches[1]; ++ } ++ } ++ ++ /** + * @inheritdoc + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception)