Skip to content

Commit 4b26fd2

Browse files
Merge pull request #423 from magento-cloud/MAGECLOUD-3195
MAGECLOUD-3195: Fix patch "MAGETWO-57414__load_static_assets_without_…
2 parents 5419380 + d0e56d4 commit 4b26fd2

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

patches.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"~2.1.4": "MAGETWO-57413__move_vendor_path_autoloader__2.1.4.patch"
2121
},
2222
"Allow static assets to be loaded without URL rewrites": {
23-
"~2.1.4": "MAGETWO-57414__load_static_assets_without_rewrites__2.1.4.patch"
23+
"2.1.4 - 2.1.16": "MAGETWO-57414__load_static_assets_without_rewrites__2.1.4.patch",
24+
"~2.1.17": "MAGETWO-57414__load_static_assets_without_rewrites__2.1.17.patch"
2425
},
2526
"Don't attempt to use non-existent setup areas": {
2627
"~2.1.4": "MAGETWO-45357__avoid_nonexistent_setup_area__2.1.4.patch"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Ticket MAGETWO-57414
2+
diff -Naur a/vendor/magento/framework/App/StaticResource.php b/vendor/magento/framework/App/StaticResource.php
3+
index d591deb..6344322 100644
4+
--- a/vendor/magento/framework/App/StaticResource.php
5+
+++ b/vendor/magento/framework/App/StaticResource.php
6+
@@ -94,24 +94,40 @@ class StaticResource implements \Magento\Framework\AppInterface
7+
{
8+
// disabling profiling when retrieving static resource
9+
\Magento\Framework\Profiler::reset();
10+
- $appMode = $this->state->getMode();
11+
- if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) {
12+
+ $path = $this->getResourcePath();
13+
+ if (!isset($path)) {
14+
$this->response->setHttpResponseCode(404);
15+
- } else {
16+
- $path = $this->request->get('resource');
17+
- $params = $this->parsePath($path);
18+
- $this->state->setAreaCode($params['area']);
19+
- $this->objectManager->configure($this->configLoader->load($params['area']));
20+
- $file = $params['file'];
21+
- unset($params['file']);
22+
- $asset = $this->assetRepo->createAsset($file, $params);
23+
- $this->response->setFilePath($asset->getSourceFile());
24+
- $this->publisher->publish($asset);
25+
+ return $this->response;
26+
}
27+
+
28+
+ $params = $this->parsePath($path);
29+
+ $this->state->setAreaCode($params['area']);
30+
+ $this->objectManager->configure($this->configLoader->load($params['area']));
31+
+ $file = $params['file'];
32+
+ unset($params['file']);
33+
+ $asset = $this->assetRepo->createAsset($file, $params);
34+
+ $this->response->setFilePath($asset->getSourceFile());
35+
+ $this->publisher->publish($asset);
36+
return $this->response;
37+
}
38+
39+
/**
40+
+ * Retrieve the path from either the GET parameter or the request
41+
+ * URI, depending on whether webserver rewrites are in use.
42+
+ */
43+
+ protected function getResourcePath() {
44+
+ $path = $this->request->get('resource');
45+
+ if (isset($path)) {
46+
+ return $path;
47+
+ }
48+
+
49+
+ $path = $this->request->getUri()->getPath();
50+
+ if (preg_match("~^/static/(?:version\d*/)?(.*)$~", $path, $matches)) {
51+
+ return $matches[1];
52+
+ }
53+
+ }
54+
+
55+
+ /**
56+
* @inheritdoc
57+
*/
58+
public function catchException(Bootstrap $bootstrap, \Exception $exception)

0 commit comments

Comments
 (0)