Skip to content

Commit 3811867

Browse files
Merge pull request #5222 from magento-qwerty/MC-29564
[CIA] Remove all SID from URLs
2 parents 27076ca + 35ae15b commit 3811867

File tree

34 files changed

+243
-218
lines changed

34 files changed

+243
-218
lines changed

app/code/Magento/Backend/Block/Media/Uploader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _construct()
8787

8888
$this->setId($this->getId() . '_Uploader');
8989

90-
$uploadUrl = $this->_urlBuilder->addSessionParam()->getUrl('adminhtml/*/upload');
90+
$uploadUrl = $this->_urlBuilder->getUrl('adminhtml/*/upload');
9191
$this->getConfig()->setUrl($uploadUrl);
9292
$this->getConfig()->setParams(['form_key' => $this->getFormKey()]);
9393
$this->getConfig()->setFileField('file');

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function _prepareLayout()
9595
);
9696

9797
$this->getUploader()->getConfig()->setUrl(
98-
$this->_urlBuilder->addSessionParam()->getUrl('catalog/product_gallery/upload')
98+
$this->_urlBuilder->getUrl('catalog/product_gallery/upload')
9999
)->setFileField(
100100
'image'
101101
)->setFilters(

app/code/Magento/Catalog/Model/Product/Url.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,10 @@ public function getUrlInStore(\Magento\Catalog\Model\Product $product, $params =
101101
*/
102102
public function getProductUrl($product, $useSid = null)
103103
{
104-
if ($useSid === null) {
105-
$useSid = $this->sidResolver->getUseSessionInUrl();
106-
}
107-
108104
$params = [];
109105
if (!$useSid) {
110106
$params['_nosid'] = true;
111107
}
112-
113108
return $this->getUrl($product, $params);
114109
}
115110

app/code/Magento/Catalog/Test/Unit/Model/Product/UrlTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,11 @@ public function testGetUrl(
159159
$this->assertEquals($requestPathProduct, $this->model->getUrlInStore($product, $routeParams));
160160
break;
161161
case 'getProductUrl':
162-
$this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, true));
162+
$this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, null));
163163
$this->sidResolver
164-
->expects($this->once())
164+
->expects($this->never())
165165
->method('getUseSessionInUrl')
166166
->will($this->returnValue(true));
167-
$this->assertEquals($requestPathProduct, $this->model->getProductUrl($product, null));
168167
break;
169168
}
170169
}
@@ -212,7 +211,7 @@ public function getUrlDataProvider()
212211
1,
213212
1,
214213
[],
215-
['_direct' => '/product/url/path', '_query' => []],
214+
['_direct' => '/product/url/path', '_query' => [], '_nosid' => true],
216215
null,
217216
null,
218217
]

app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Uploader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function __construct(
3535
}
3636

3737
/**
38+
* Constructor
39+
*
3840
* @return void
3941
*/
4042
protected function _construct()
@@ -49,7 +51,7 @@ protected function _construct()
4951
$files[] = '*.' . $ext;
5052
}
5153
$this->getConfig()->setUrl(
52-
$this->_urlBuilder->addSessionParam()->getUrl('cms/*/upload', ['type' => $type])
54+
$this->_urlBuilder->getUrl('cms/*/upload', ['type' => $type])
5355
)->setFileField(
5456
'image'
5557
)->setFilters(

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ protected function getRows()
447447
'smallImage' => '${$.provider}:${$.parentScope}.small_image',
448448
],
449449
'uploaderConfig' => [
450-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
450+
'url' => $this->urlBuilder->getUrl(
451451
'catalog/product_gallery/upload'
452452
),
453453
],

app/code/Magento/Customer/Model/Session.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* @method string getNoReferer()
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
22+
* @SuppressWarnings(PHPMD.TooManyFields)
2223
* @since 100.0.2
2324
*/
2425
class Session extends \Magento\Framework\Session\SessionManager
@@ -108,6 +109,11 @@ class Session extends \Magento\Framework\Session\SessionManager
108109
*/
109110
protected $response;
110111

112+
/**
113+
* @var AccountConfirmation
114+
*/
115+
private $accountConfirmation;
116+
111117
/**
112118
* Session constructor.
113119
*
@@ -511,13 +517,6 @@ public function authenticate($loginUrl = null)
511517
$this->response->setRedirect($loginUrl);
512518
} else {
513519
$arguments = $this->_customerUrl->getLoginUrlParams();
514-
if ($this->_createUrl()->getUseSession()) {
515-
$arguments += [
516-
'_query' => [
517-
$this->sidResolver->getSessionIdQueryParam($this->_session) => $this->_session->getSessionId(),
518-
]
519-
];
520-
}
521520
$this->response->setRedirect(
522521
$this->_createUrl()->getUrl(\Magento\Customer\Model\Url::ROUTE_ACCOUNT_LOGIN, $arguments)
523522
);
@@ -535,8 +534,6 @@ public function authenticate($loginUrl = null)
535534
*/
536535
protected function _setAuthUrl($key, $url)
537536
{
538-
$url = $this->_coreUrl->removeRequestParam($url, $this->sidResolver->getSessionIdQueryParam($this));
539-
// Add correct session ID to URL if needed
540537
$url = $this->_createUrl()->getRebuiltUrl($url);
541538
return $this->storage->setData($key, $url);
542539
}

app/code/Magento/Customer/Test/Unit/Model/SessionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ public function testAuthenticate()
147147
$urlMock->expects($this->once())
148148
->method('getRebuiltUrl')
149149
->willReturn('');
150-
$this->urlFactoryMock->expects($this->exactly(4))
150+
$this->urlFactoryMock->expects($this->exactly(3))
151151
->method('create')
152152
->willReturn($urlMock);
153-
$urlMock->expects($this->once())
153+
$urlMock->expects($this->never())
154154
->method('getUseSession')
155155
->willReturn(false);
156156

app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @author Magento Core Team <[email protected]>
1212
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1313
*
14-
* @deprecated
14+
* @deprecated in favor of new class which adds grid links
1515
* @see \Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Links
1616
*/
1717
class Links extends \Magento\Backend\Block\Template
@@ -398,7 +398,7 @@ public function getFileFieldName($type)
398398
*/
399399
public function getUploadUrl($type)
400400
{
401-
return $this->_urlFactory->create()->addSessionParam()->getUrl(
401+
return $this->_urlFactory->create()->getUrl(
402402
'adminhtml/downloadable_file/upload',
403403
['type' => $type, '_secure' => true]
404404
);

app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @author Magento Core Team <[email protected]>
1212
*
13-
* @deprecated
13+
* @deprecated because of new class which adds grids samples
1414
* @see \Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Samples
1515
*/
1616
class Samples extends \Magento\Backend\Block\Widget
@@ -250,7 +250,7 @@ public function getUploadButtonHtml()
250250
*/
251251
public function getConfigJson()
252252
{
253-
$url = $this->_urlFactory->create()->addSessionParam()->getUrl(
253+
$url = $this->_urlFactory->create()->getUrl(
254254
'adminhtml/downloadable_file/upload',
255255
['type' => 'samples', '_secure' => true]
256256
);

app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/LinksTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Magento\Framework\Stdlib\ArrayManager;
1818

1919
/**
20-
* Class LinksTest
20+
* Test for class Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Links
2121
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2222
*/
2323
class LinksTest extends \PHPUnit\Framework\TestCase
@@ -169,7 +169,7 @@ public function testModifyMeta()
169169
->method('toOptionArray');
170170
$this->shareableMock->expects($this->once())
171171
->method('toOptionArray');
172-
$this->urlBuilderMock->expects($this->exactly(2))
172+
$this->urlBuilderMock->expects($this->never())
173173
->method('addSessionParam')
174174
->willReturnSelf();
175175
$this->urlBuilderMock->expects($this->exactly(2))

app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SamplesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Magento\Framework\Stdlib\ArrayManager;
1717

1818
/**
19-
* Class SamplesTest
19+
* Test for class Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Samples
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
*/
2222
class SamplesTest extends \PHPUnit\Framework\TestCase
@@ -141,7 +141,7 @@ public function testModifyMeta()
141141
->method('isSingleStoreMode');
142142
$this->typeUploadMock->expects($this->once())
143143
->method('toOptionArray');
144-
$this->urlBuilderMock->expects($this->once())
144+
$this->urlBuilderMock->expects($this->never())
145145
->method('addSessionParam')
146146
->willReturnSelf();
147147
$this->urlBuilderMock->expects($this->once())

app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Links.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Magento\Framework\Exception\ValidatorException;
1717

1818
/**
19-
* Class Links
19+
* Grid class to add links
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
*/
2222
class Links
@@ -162,7 +162,7 @@ protected function addSampleFile(array $linkData, LinkInterface $link)
162162
'name' => $this->downloadableFile->getFileFromPathFile($sampleFile),
163163
'size' => $this->downloadableFile->getFileSize($file),
164164
'status' => 'old',
165-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
165+
'url' => $this->urlBuilder->getUrl(
166166
'adminhtml/downloadable_product_edit/link',
167167
['id' => $link->getId(), 'type' => 'sample', '_secure' => true]
168168
),
@@ -191,7 +191,7 @@ protected function addLinkFile(array $linkData, LinkInterface $link)
191191
'name' => $this->downloadableFile->getFileFromPathFile($linkFile),
192192
'size' => $this->downloadableFile->getFileSize($file),
193193
'status' => 'old',
194-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
194+
'url' => $this->urlBuilder->getUrl(
195195
'adminhtml/downloadable_product_edit/link',
196196
['id' => $link->getId(), 'type' => 'link', '_secure' => true]
197197
),

app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Samples.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Magento\Downloadable\Api\Data\SampleInterface;
1717

1818
/**
19-
* Class Samples
19+
* Class to add samples
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
*/
2222
class Samples
@@ -143,7 +143,7 @@ protected function addSampleFile(array $sampleData, SampleInterface $sample)
143143
'name' => $this->downloadableFile->getFileFromPathFile($sampleFile),
144144
'size' => $this->downloadableFile->getFileSize($file),
145145
'status' => 'old',
146-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
146+
'url' => $this->urlBuilder->getUrl(
147147
'adminhtml/downloadable_product_edit/sample',
148148
['id' => $sample->getId(), '_secure' => true]
149149
),

app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ protected function getFileColumn()
339339
'elementTmpl' => 'Magento_Downloadable/components/file-uploader',
340340
'fileInputName' => 'links',
341341
'uploaderConfig' => [
342-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
342+
'url' => $this->urlBuilder->getUrl(
343343
'adminhtml/downloadable_file/upload',
344344
['type' => 'links', '_secure' => true]
345345
),
@@ -406,7 +406,7 @@ protected function getSampleColumn()
406406
'fileInputName' => 'link_samples',
407407
'labelVisible' => false,
408408
'uploaderConfig' => [
409-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
409+
'url' => $this->urlBuilder->getUrl(
410410
'adminhtml/downloadable_file/upload',
411411
['type' => 'link_samples', '_secure' => true]
412412
),

app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Samples.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ protected function getSampleColumn()
273273
'elementTmpl' => 'Magento_Downloadable/components/file-uploader',
274274
'fileInputName' => 'samples',
275275
'uploaderConfig' => [
276-
'url' => $this->urlBuilder->addSessionParam()->getUrl(
276+
'url' => $this->urlBuilder->getUrl(
277277
'adminhtml/downloadable_file/upload',
278278
['type' => 'samples', '_secure' => true]
279279
),

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ public function loadDefault($templateId)
339339
public function getProcessedTemplate(array $variables = [])
340340
{
341341
$processor = $this->getTemplateFilter()
342-
->setUseSessionInUrl(false)
343342
->setPlainTemplateMode($this->isPlain())
344343
->setIsChildTemplate($this->isChildTemplate())
345344
->setTemplateProcessor([$this, 'getTemplateContent']);

app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ protected function setUp()
6969
$this->design = $this->getMockBuilder(\Magento\Framework\View\DesignInterface::class)
7070
->disableOriginalConstructor()
7171
->getMock();
72-
$this->registry = $this->getMockBuilder(\Magento\Framework\Registry::class)
73-
->disableOriginalConstructor()
74-
->getMock();
7572
$this->appEmulation = $this->getMockBuilder(\Magento\Store\Model\App\Emulation::class)
7673
->disableOriginalConstructor()
7774
->getMock();
@@ -177,7 +174,7 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
177174
->disableOriginalConstructor()
178175
->getMock();
179176

180-
$filterTemplate->expects($this->once())
177+
$filterTemplate->expects($this->never())
181178
->method('setUseSessionInUrl')
182179
->with(false)
183180
->will($this->returnSelf());
@@ -253,7 +250,6 @@ public function testGetProcessedTemplateException()
253250
$filterTemplate = $this->getMockBuilder(\Magento\Email\Model\Template\Filter::class)
254251
->setMethods(
255252
[
256-
'setUseSessionInUrl',
257253
'setPlainTemplateMode',
258254
'setIsChildTemplate',
259255
'setDesignParams',
@@ -267,9 +263,7 @@ public function testGetProcessedTemplateException()
267263
)
268264
->disableOriginalConstructor()
269265
->getMock();
270-
$filterTemplate->expects($this->once())
271-
->method('setUseSessionInUrl')
272-
->will($this->returnSelf());
266+
273267
$filterTemplate->expects($this->once())
274268
->method('setPlainTemplateMode')
275269
->will($this->returnSelf());

app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class_exists(\Magento\Newsletter\Model\Template\Filter::class, true);
268268
)
269269
->disableOriginalConstructor()
270270
->getMock();
271-
$filterTemplate->expects($this->once())
271+
$filterTemplate->expects($this->never())
272272
->method('setUseSessionInUrl')
273273
->with(false)
274274
->will($this->returnSelf());

0 commit comments

Comments
 (0)