Skip to content

Commit 5a173f8

Browse files
ENGCOM-2104: Fix type hint of customer-data updateSectionId parameters #16115
- Merge Pull Request #16115 from Vinai/magento2:fix-customer-data-typehint - Merged commits: 1. 7a8c24b 2. fc1c1d2 3. 73b02f8 4. 3275cd7
2 parents aa4b734 + 3275cd7 commit 5a173f8

File tree

9 files changed

+90
-90
lines changed

9 files changed

+90
-90
lines changed

app/code/Magento/Customer/Controller/Section/Load.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ public function execute()
7070
$sectionNames = $this->getRequest()->getParam('sections');
7171
$sectionNames = $sectionNames ? array_unique(\explode(',', $sectionNames)) : null;
7272

73-
$updateSectionId = $this->getRequest()->getParam('update_section_id');
74-
if ('false' === $updateSectionId) {
75-
$updateSectionId = false;
73+
$forceNewSectionTimestamp = $this->getRequest()->getParam('force_new_section_timestamp');
74+
if ('false' === $forceNewSectionTimestamp) {
75+
$forceNewSectionTimestamp = false;
7676
}
77-
$response = $this->sectionPool->getSectionsData($sectionNames, (bool)$updateSectionId);
77+
$response = $this->sectionPool->getSectionsData($sectionNames, (bool)$forceNewSectionTimestamp);
7878
} catch (\Exception $e) {
7979
$resultJson->setStatusHeader(
8080
\Zend\Http\Response::STATUS_CODE_400,

app/code/Magento/Customer/CustomerData/Section/Identifier.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function __construct(
4343
/**
4444
* Init mark(identifier) for sections
4545
*
46-
* @param bool $forceUpdate
46+
* @param bool $forceNewTimestamp
4747
* @return int
4848
*/
49-
public function initMark($forceUpdate)
49+
public function initMark($forceNewTimestamp)
5050
{
51-
if ($forceUpdate) {
51+
if ($forceNewTimestamp) {
5252
$this->markId = time();
5353
return $this->markId;
5454
}
@@ -68,18 +68,18 @@ public function initMark($forceUpdate)
6868
*
6969
* @param array $sectionsData
7070
* @param null $sectionNames
71-
* @param bool $updateIds
71+
* @param bool $forceNewTimestamp
7272
* @return array
7373
*/
74-
public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
74+
public function markSections(array $sectionsData, $sectionNames = null, $forceNewTimestamp = false)
7575
{
7676
if (!$sectionNames) {
7777
$sectionNames = array_keys($sectionsData);
7878
}
79-
$markId = $this->initMark($updateIds);
79+
$markId = $this->initMark($forceNewTimestamp);
8080

8181
foreach ($sectionNames as $name) {
82-
if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
82+
if ($forceNewTimestamp || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
8383
$sectionsData[$name][self::SECTION_KEY] = $markId;
8484
}
8585
}

app/code/Magento/Customer/CustomerData/SectionPool.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public function __construct(
5555
/**
5656
* {@inheritdoc}
5757
*/
58-
public function getSectionsData(array $sectionNames = null, $updateIds = false)
58+
public function getSectionsData(array $sectionNames = null, $forceNewTimestamp = false)
5959
{
6060
$sectionsData = $sectionNames ? $this->getSectionDataByNames($sectionNames) : $this->getAllSectionData();
61-
$sectionsData = $this->identifier->markSections($sectionsData, $sectionNames, $updateIds);
61+
$sectionsData = $this->identifier->markSections($sectionsData, $sectionNames, $forceNewTimestamp);
6262
return $sectionsData;
6363
}
6464

app/code/Magento/Customer/CustomerData/SectionPoolInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ interface SectionPoolInterface
1414
* Get section data by section names. If $sectionNames is null then return all sections data
1515
*
1616
* @param array $sectionNames
17-
* @param bool $updateIds
17+
* @param bool $forceNewTimestamp
1818
* @return array
1919
*/
20-
public function getSectionsData(array $sectionNames = null, $updateIds = false);
20+
public function getSectionsData(array $sectionNames = null, $forceNewTimestamp = false);
2121
}

app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ protected function setUp()
8181
}
8282

8383
/**
84-
* @param $sectionNames
85-
* @param $updateSectionID
86-
* @param $sectionNamesAsArray
87-
* @param $updateIds
84+
* @param string $sectionNames
85+
* @param bool $forceNewSectionTimestamp
86+
* @param string[] $sectionNamesAsArray
87+
* @param bool $forceNewTimestamp
8888
* @dataProvider executeDataProvider
8989
*/
90-
public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArray, $updateIds)
90+
public function testExecute($sectionNames, $forceNewSectionTimestamp, $sectionNamesAsArray, $forceNewTimestamp)
9191
{
9292
$this->resultJsonFactoryMock->expects($this->once())
9393
->method('create')
@@ -101,12 +101,12 @@ public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArra
101101

102102
$this->httpRequestMock->expects($this->exactly(2))
103103
->method('getParam')
104-
->withConsecutive(['sections'], ['update_section_id'])
105-
->willReturnOnConsecutiveCalls($sectionNames, $updateSectionID);
104+
->withConsecutive(['sections'], ['force_new_section_timestamp'])
105+
->willReturnOnConsecutiveCalls($sectionNames, $forceNewSectionTimestamp);
106106

107107
$this->sectionPoolMock->expects($this->once())
108108
->method('getSectionsData')
109-
->with($sectionNamesAsArray, $updateIds)
109+
->with($sectionNamesAsArray, $forceNewTimestamp)
110110
->willReturn([
111111
'message' => 'some message',
112112
'someKey' => 'someValue'
@@ -131,15 +131,15 @@ public function executeDataProvider()
131131
return [
132132
[
133133
'sectionNames' => 'sectionName1,sectionName2,sectionName3',
134-
'updateSectionID' => 'updateSectionID',
134+
'forceNewSectionTimestamp' => 'forceNewSectionTimestamp',
135135
'sectionNamesAsArray' => ['sectionName1', 'sectionName2', 'sectionName3'],
136-
'updateIds' => true
136+
'forceNewTimestamp' => true
137137
],
138138
[
139139
'sectionNames' => null,
140-
'updateSectionID' => null,
140+
'forceNewSectionTimestamp' => null,
141141
'sectionNamesAsArray' => null,
142-
'updateIds' => false
142+
'forceNewTimestamp' => false
143143
],
144144
];
145145
}

app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testGetSectionsDataAllSections()
6363

6464
$this->identifierMock->expects($this->once())
6565
->method('markSections')
66-
//check also default value for $updateIds = false
66+
//check also default value for $forceTimestamp = false
6767
->with($allSectionsData, $sectionNames, false)
6868
->willReturn($identifierResult);
6969
$modelResult = $this->model->getSectionsData($sectionNames);

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ define([
7474

7575
/**
7676
* @param {Object} sectionNames
77-
* @param {Number} updateSectionId
77+
* @param {Boolean} forceNewSectionTimestamp
7878
* @return {*}
7979
*/
80-
getFromServer: function (sectionNames, updateSectionId) {
80+
getFromServer: function (sectionNames, forceNewSectionTimestamp) {
8181
var parameters;
8282

8383
sectionNames = sectionConfig.filterClientSideSections(sectionNames);
8484
parameters = _.isArray(sectionNames) ? {
8585
sections: sectionNames.join(',')
8686
} : [];
87-
parameters['update_section_id'] = updateSectionId;
87+
parameters['force_new_section_timestamp'] = forceNewSectionTimestamp;
8888

8989
return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {
9090
throw new Error(jqXHR);
@@ -322,11 +322,11 @@ define([
322322

323323
/**
324324
* @param {Array} sectionNames
325-
* @param {Number} updateSectionId
325+
* @param {Boolean} forceNewSectionTimestamp
326326
* @return {*}
327327
*/
328-
reload: function (sectionNames, updateSectionId) {
329-
return dataProvider.getFromServer(sectionNames, updateSectionId).done(function (sections) {
328+
reload: function (sectionNames, forceNewSectionTimestamp) {
329+
return dataProvider.getFromServer(sectionNames, forceNewSectionTimestamp).done(function (sections) {
330330
$(document).trigger('customer-data-reload', [sectionNames]);
331331
buffer.update(sections);
332332
});

0 commit comments

Comments
 (0)