-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from magento-cloud/MAGECLOUD-3195
MAGECLOUD-3195: Fix patch "MAGETWO-57414__load_static_assets_without_…
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
patches/MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |