Skip to content

Commit a2913a7

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MAGETWO-83415-advanced-configuration-settings
2 parents ee271d3 + 1f0c4c8 commit a2913a7

File tree

19 files changed

+224
-528
lines changed

19 files changed

+224
-528
lines changed

app/code/Magento/CatalogUrlRewrite/Model/Storage/DbStorage.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,37 @@
1212
class DbStorage extends BaseDbStorage
1313
{
1414
/**
15-
* @param array $data
16-
* @return \Magento\Framework\DB\Select
15+
* {@inheritDoc}
1716
*/
1817
protected function prepareSelect(array $data)
1918
{
19+
$metadata = [];
20+
if (array_key_exists(UrlRewrite::METADATA, $data)) {
21+
$metadata = $data[UrlRewrite::METADATA];
22+
unset($data[UrlRewrite::METADATA]);
23+
}
24+
2025
$select = $this->connection->select();
21-
$select->from(['url_rewrite' => $this->resource->getTableName('url_rewrite')])
22-
->joinLeft(
23-
['relation' => $this->resource->getTableName(Product::TABLE_NAME)],
24-
'url_rewrite.url_rewrite_id = relation.url_rewrite_id'
25-
)
26-
->where('url_rewrite.entity_id IN (?)', $data['entity_id'])
27-
->where('url_rewrite.entity_type = ?', $data['entity_type'])
28-
->where('url_rewrite.store_id IN (?)', $data['store_id']);
29-
if (empty($data[UrlRewrite::METADATA]['category_id'])) {
26+
$select->from([
27+
'url_rewrite' => $this->resource->getTableName(self::TABLE_NAME)
28+
]);
29+
$select->joinLeft(
30+
['relation' => $this->resource->getTableName(Product::TABLE_NAME)],
31+
'url_rewrite.url_rewrite_id = relation.url_rewrite_id'
32+
);
33+
34+
foreach ($data as $column => $value) {
35+
$select->where('url_rewrite.' . $column . ' IN (?)', $value);
36+
}
37+
if (empty($metadata['category_id'])) {
3038
$select->where('relation.category_id IS NULL');
3139
} else {
32-
$select->where('relation.category_id = ?', $data[UrlRewrite::METADATA]['category_id']);
40+
$select->where(
41+
'relation.category_id = ?',
42+
$metadata['category_id']
43+
);
3344
}
45+
3446
return $select;
3547
}
3648
}

app/code/Magento/Directory/etc/zip_codes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
<zip countryCode="JP">
208208
<codes>
209209
<code id="pattern_1" active="true" example="123-4567">^[0-9]{3}-[0-9]{4}$</code>
210-
<code id="pattern_2" active="true" example="123">^[0-9]{3}$</code>
210+
<code id="pattern_2" active="true" example="1234567">^[0-9]{7}$</code>
211211
</codes>
212212
</zip>
213213
<zip countryCode="JE">

app/code/Magento/PageCache/etc/varnish4.vcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ sub vcl_deliver {
187187
unset resp.http.Age;
188188
}
189189

190+
# Not letting browser to cache non-static files.
191+
if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
192+
set resp.http.Pragma = "no-cache";
193+
set resp.http.Expires = "-1";
194+
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
195+
}
196+
190197
unset resp.http.X-Magento-Debug;
191198
unset resp.http.X-Magento-Tags;
192199
unset resp.http.X-Powered-By;

app/code/Magento/PageCache/etc/varnish5.vcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ sub vcl_deliver {
188188
unset resp.http.Age;
189189
}
190190

191+
# Not letting browser to cache non-static files.
192+
if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
193+
set resp.http.Pragma = "no-cache";
194+
set resp.http.Expires = "-1";
195+
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
196+
}
197+
191198
unset resp.http.X-Magento-Debug;
192199
unset resp.http.X-Magento-Tags;
193200
unset resp.http.X-Powered-By;

app/code/Magento/Reports/view/adminhtml/templates/grid.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $numColumns = sizeof($block->getColumns());
3131
type="text"
3232
id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from') ?>"
3333
name="report_from"
34-
value="<?= /* @escapeNotVerified */ $block->getFilter('report_from') ?>">
34+
value="<?= $block->escapeHtml($block->getFilter('report_from')) ?>">
3535
<span id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_from_advice') ?>"></span>
3636
</span>
3737

@@ -44,7 +44,7 @@ $numColumns = sizeof($block->getColumns());
4444
type="text"
4545
id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to') ?>"
4646
name="report_to"
47-
value="<?= /* @escapeNotVerified */ $block->getFilter('report_to') ?>"/>
47+
value="<?= $block->escapeHtml($block->getFilter('report_to')) ?>"/>
4848
<span id="<?= /* @escapeNotVerified */ $block->getSuffixId('period_date_to_advice') ?>"></span>
4949
</span>
5050

app/code/Magento/Sales/Model/Order/Shipment/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function getOrderItem()
144144
* Declare qty
145145
*
146146
* @param float $qty
147-
* @return \Magento\Sales\Model\Order\Invoice\Item
147+
* @return \Magento\Sales\Model\Order\Shipment\Item
148148
* @throws \Magento\Framework\Exception\LocalizedException
149149
*/
150150
public function setQty($qty)

app/code/Magento/Search/view/frontend/web/form-mini.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,17 @@ define([
206206

207207
switch (keyCode) {
208208
case $.ui.keyCode.HOME:
209-
this._getFirstVisibleElement().addClass(this.options.selectClass);
210-
this.responseList.selected = this._getFirstVisibleElement();
209+
if (this._getFirstVisibleElement()) {
210+
this._getFirstVisibleElement().addClass(this.options.selectClass);
211+
this.responseList.selected = this._getFirstVisibleElement();
212+
}
211213
break;
212214

213215
case $.ui.keyCode.END:
214-
this._getLastElement().addClass(this.options.selectClass);
215-
this.responseList.selected = this._getLastElement();
216+
if (this._getLastElement()) {
217+
this._getLastElement().addClass(this.options.selectClass);
218+
this.responseList.selected = this._getLastElement();
219+
}
216220
break;
217221

218222
case $.ui.keyCode.ESCAPE:

app/code/Magento/Store/Block/Switcher.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
namespace Magento\Store\Block;
1111

1212
use Magento\Directory\Helper\Data;
13+
use Magento\Store\Api\StoreResolverInterface;
1314
use Magento\Store\Model\Group;
15+
use Magento\Store\Model\Store;
1416

1517
/**
1618
* @api
@@ -217,15 +219,18 @@ public function getStoreName()
217219
/**
218220
* Returns target store post data
219221
*
220-
* @param \Magento\Store\Model\Store $store
222+
* @param Store $store
221223
* @param array $data
222224
* @return string
223225
*/
224-
public function getTargetStorePostData(\Magento\Store\Model\Store $store, $data = [])
226+
public function getTargetStorePostData(Store $store, $data = [])
225227
{
226-
$data[\Magento\Store\Api\StoreResolverInterface::PARAM_NAME] = $store->getCode();
228+
$data[StoreResolverInterface::PARAM_NAME] = $store->getCode();
229+
230+
//We need to set fromStore argument as true because
231+
//it will enable proper URL rewriting during store switching.
227232
return $this->_postDataHelper->getPostData(
228-
$store->getCurrentUrl(false),
233+
$store->getCurrentUrl(true),
229234
$data
230235
);
231236
}

app/code/Magento/Store/Test/Unit/Block/SwitcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testGetTargetStorePostData()
5353
$storeSwitchUrl = 'http://domain.com/stores/store/switch';
5454
$store->expects($this->atLeastOnce())
5555
->method('getCurrentUrl')
56-
->with(false)
56+
->with(true)
5757
->willReturn($storeSwitchUrl);
5858
$this->corePostDataHelper->expects($this->any())
5959
->method('getPostData')

app/code/Magento/UrlRewrite/Controller/Router.php

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
*/
66
namespace Magento\UrlRewrite\Controller;
77

8+
use Magento\Framework\App\RequestInterface;
89
use Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
910
use Magento\UrlRewrite\Model\OptionProvider;
1011
use Magento\UrlRewrite\Model\UrlFinderInterface;
1112
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
13+
use Magento\Framework\App\Request\Http as HttpRequest;
14+
use Magento\Framework\App\Response\Http as HttpResponse;
15+
use Magento\Framework\UrlInterface;
16+
use Magento\Framework\App\Action\Redirect;
17+
use Magento\Framework\App\ActionInterface;
1218

1319
/**
1420
* UrlRewrite Controller Router
@@ -23,7 +29,7 @@ class Router implements \Magento\Framework\App\RouterInterface
2329
protected $actionFactory;
2430

2531
/**
26-
* @var \Magento\Framework\UrlInterface
32+
* @var UrlInterface
2733
*/
2834
protected $url;
2935

@@ -33,7 +39,7 @@ class Router implements \Magento\Framework\App\RouterInterface
3339
protected $storeManager;
3440

3541
/**
36-
* @var \Magento\Framework\App\ResponseInterface
42+
* @var HttpResponse
3743
*/
3844
protected $response;
3945

@@ -44,14 +50,14 @@ class Router implements \Magento\Framework\App\RouterInterface
4450

4551
/**
4652
* @param \Magento\Framework\App\ActionFactory $actionFactory
47-
* @param \Magento\Framework\UrlInterface $url
53+
* @param UrlInterface $url
4854
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
4955
* @param \Magento\Framework\App\ResponseInterface $response
5056
* @param UrlFinderInterface $urlFinder
5157
*/
5258
public function __construct(
5359
\Magento\Framework\App\ActionFactory $actionFactory,
54-
\Magento\Framework\UrlInterface $url,
60+
UrlInterface $url,
5561
\Magento\Store\Model\StoreManagerInterface $storeManager,
5662
\Magento\Framework\App\ResponseInterface $response,
5763
UrlFinderInterface $urlFinder
@@ -64,48 +70,83 @@ public function __construct(
6470
}
6571

6672
/**
67-
* Match corresponding URL Rewrite and modify request
73+
* Match corresponding URL Rewrite and modify request.
6874
*
69-
* @param \Magento\Framework\App\RequestInterface $request
70-
* @return \Magento\Framework\App\ActionInterface|null
75+
* @param RequestInterface|HttpRequest $request
76+
*
77+
* @return ActionInterface|null
7178
*/
72-
public function match(\Magento\Framework\App\RequestInterface $request)
79+
public function match(RequestInterface $request)
7380
{
7481
if ($fromStore = $request->getParam('___from_store')) {
82+
//If we're in the process of switching stores then matching rewrite
83+
//rule from previous store because the URL was not changed yet from
84+
//old store's format.
7585
$oldStoreId = $this->storeManager->getStore($fromStore)->getId();
76-
$oldRewrite = $this->getRewrite($request->getPathInfo(), $oldStoreId);
77-
if ($oldRewrite) {
78-
$rewrite = $this->urlFinder->findOneByData(
86+
$oldRewrite = $this->getRewrite(
87+
$request->getPathInfo(),
88+
$oldStoreId
89+
);
90+
if ($oldRewrite && $oldRewrite->getRedirectType() === 0) {
91+
//If there is a match and it's a correct URL then just
92+
//redirecting to current store's URL equivalent,
93+
//otherwise just continuing finding a rule within current store.
94+
$currentRewrite = $this->urlFinder->findOneByData(
7995
[
8096
UrlRewrite::ENTITY_TYPE => $oldRewrite->getEntityType(),
8197
UrlRewrite::ENTITY_ID => $oldRewrite->getEntityId(),
82-
UrlRewrite::STORE_ID => $this->storeManager->getStore()->getId(),
83-
UrlRewrite::IS_AUTOGENERATED => 1,
98+
UrlRewrite::STORE_ID =>
99+
$this->storeManager->getStore()->getId(),
100+
UrlRewrite::REDIRECT_TYPE => 0,
84101
]
85102
);
86-
if ($rewrite && $rewrite->getRequestPath() !== $oldRewrite->getRequestPath()) {
87-
return $this->redirect($request, $rewrite->getRequestPath(), OptionProvider::TEMPORARY);
103+
if ($currentRewrite
104+
&& $currentRewrite->getRequestPath()
105+
!== $oldRewrite->getRequestPath()
106+
) {
107+
return $this->redirect(
108+
$request,
109+
$this->url->getUrl(
110+
'',
111+
['_direct' => $currentRewrite->getRequestPath()]
112+
),
113+
OptionProvider::TEMPORARY
114+
);
88115
}
89116
}
90117
}
91-
$rewrite = $this->getRewrite($request->getPathInfo(), $this->storeManager->getStore()->getId());
118+
119+
$rewrite = $this->getRewrite(
120+
$request->getPathInfo(),
121+
$this->storeManager->getStore()->getId()
122+
);
123+
92124
if ($rewrite === null) {
125+
//No rewrite rule matching current URl found, continuing with
126+
//processing of this URL.
93127
return null;
94128
}
95-
96129
if ($rewrite->getRedirectType()) {
130+
//Rule requires the request to be redirected to another URL
131+
//and cannot be processed further.
97132
return $this->processRedirect($request, $rewrite);
98133
}
99-
100-
$request->setAlias(\Magento\Framework\UrlInterface::REWRITE_REQUEST_PATH_ALIAS, $rewrite->getRequestPath());
134+
//Rule provides actual URL that can be processed by a controller.
135+
$request->setAlias(
136+
UrlInterface::REWRITE_REQUEST_PATH_ALIAS,
137+
$rewrite->getRequestPath()
138+
);
101139
$request->setPathInfo('/' . $rewrite->getTargetPath());
102-
return $this->actionFactory->create(\Magento\Framework\App\Action\Forward::class);
140+
return $this->actionFactory->create(
141+
\Magento\Framework\App\Action\Forward::class
142+
);
103143
}
104144

105145
/**
106-
* @param \Magento\Framework\App\RequestInterface $request
146+
* @param RequestInterface $request
107147
* @param UrlRewrite $rewrite
108-
* @return \Magento\Framework\App\ActionInterface|null
148+
*
149+
* @return ActionInterface|null
109150
*/
110151
protected function processRedirect($request, $rewrite)
111152
{
@@ -119,16 +160,17 @@ protected function processRedirect($request, $rewrite)
119160
}
120161

121162
/**
122-
* @param \Magento\Framework\App\RequestInterface $request
163+
* @param RequestInterface|HttpRequest $request
123164
* @param string $url
124165
* @param int $code
125-
* @return \Magento\Framework\App\ActionInterface
166+
* @return ActionInterface
126167
*/
127168
protected function redirect($request, $url, $code)
128169
{
129170
$this->response->setRedirect($url, $code);
130171
$request->setDispatched(true);
131-
return $this->actionFactory->create(\Magento\Framework\App\Action\Redirect::class);
172+
173+
return $this->actionFactory->create(Redirect::class);
132174
}
133175

134176
/**

0 commit comments

Comments
 (0)