Skip to content

Commit 52d8203

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 9925c8e + 48d8d43 commit 52d8203

File tree

6 files changed

+58
-27
lines changed

6 files changed

+58
-27
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Page/Index.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
use Magento\Framework\App\Action\HttpGetActionInterface;
99
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\App\Request\DataPersistorInterface;
1012
use Magento\Framework\View\Result\PageFactory;
1113

1214
/**
@@ -26,16 +28,24 @@ class Index extends \Magento\Backend\App\Action implements HttpGetActionInterfac
2628
*/
2729
protected $resultPageFactory;
2830

31+
/**
32+
* @var DataPersistorInterface
33+
*/
34+
private $dataPersistor;
35+
2936
/**
3037
* @param Context $context
3138
* @param PageFactory $resultPageFactory
39+
* @param DataPersistorInterface $dataPersistor
3240
*/
3341
public function __construct(
3442
Context $context,
35-
PageFactory $resultPageFactory
43+
PageFactory $resultPageFactory,
44+
DataPersistorInterface $dataPersistor = null
3645
) {
3746
parent::__construct($context);
3847
$this->resultPageFactory = $resultPageFactory;
48+
$this->dataPersistor = $dataPersistor ?: ObjectManager::getInstance()->get(DataPersistorInterface::class);
3949
}
4050

4151
/**
@@ -52,8 +62,7 @@ public function execute()
5262
$resultPage->addBreadcrumb(__('Manage Pages'), __('Manage Pages'));
5363
$resultPage->getConfig()->getTitle()->prepend(__('Pages'));
5464

55-
$dataPersistor = $this->_objectManager->get(\Magento\Framework\App\Request\DataPersistorInterface::class);
56-
$dataPersistor->clear('cms_page');
65+
$this->dataPersistor->clear('cms_page');
5766

5867
return $resultPage;
5968
}

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ define([
12541254
dataMergeStrategy: this.options.gallerySwitchStrategy
12551255
});
12561256
}
1257-
1257+
gallery.first();
12581258
} else if (justAnImage && justAnImage.img) {
12591259
context.find('.product-image-photo').attr('src', justAnImage.img);
12601260
}

lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
namespace Magento\Framework\Mview\Test\Unit\View;
88

9+
/**
10+
* Test Coverage for Changelog View.
11+
*
12+
* @see \Magento\Framework\Mview\View\Changelog
13+
*/
914
class ChangelogTest extends \PHPUnit\Framework\TestCase
1015
{
1116
/**
@@ -45,7 +50,7 @@ public function testInstanceOf()
4550
}
4651

4752
/**
48-
* @expectedException \Exception
53+
* @expectedException \Magento\Framework\DB\Adapter\ConnectionException
4954
* @expectedExceptionMessage The write connection to the database isn't available. Please try again later.
5055
*/
5156
public function testCheckConnectionException()
@@ -74,7 +79,7 @@ public function testGetViewId()
7479
}
7580

7681
/**
77-
* @expectedException \Exception
82+
* @expectedException \DomainException
7883
* @expectedExceptionMessage View's identifier is not set
7984
*/
8085
public function testGetNameWithException()
@@ -101,6 +106,10 @@ public function testGetVersion()
101106
$this->assertEquals(10, $this->model->getVersion());
102107
}
103108

109+
/**
110+
* @expectedException \Magento\Framework\Exception\RuntimeException
111+
* @expectedExceptionMessage Table status for viewIdtest_cl is incorrect. Can`t fetch version id.
112+
*/
104113
public function testGetVersionWithExceptionNoAutoincrement()
105114
{
106115
$changelogTableName = 'viewIdtest_cl';
@@ -111,8 +120,6 @@ public function testGetVersionWithExceptionNoAutoincrement()
111120
->method('fetchRow')
112121
->will($this->returnValue([]));
113122

114-
$this->expectException('Exception');
115-
$this->expectExceptionMessage("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id.");
116123
$this->model->setViewId('viewIdtest');
117124
$this->model->getVersion();
118125
}
@@ -215,10 +222,10 @@ public function testGetList()
215222
$this->connectionMock->expects($this->once())
216223
->method('fetchCol')
217224
->with($selectMock)
218-
->will($this->returnValue(['some_data']));
225+
->will($this->returnValue([1]));
219226

220227
$this->model->setViewId('viewIdtest');
221-
$this->assertEquals(['some_data'], $this->model->getList(1, 2));
228+
$this->assertEquals([1], $this->model->getList(1, 2));
222229
}
223230

224231
public function testGetListWithException()

lib/internal/Magento/Framework/Mview/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function update()
285285
for ($vsFrom = $lastVersionId; $vsFrom < $currentVersionId; $vsFrom += $versionBatchSize) {
286286
// Don't go past the current version for atomicy.
287287
$versionTo = min($currentVersionId, $vsFrom + $versionBatchSize);
288-
$ids = array_map('intval', $this->getChangelog()->getList($vsFrom, $versionTo));
288+
$ids = $this->getChangelog()->getList($vsFrom, $versionTo);
289289

290290
// We run the actual indexer in batches.
291291
// Chunked AFTER loading to avoid duplicates in separate chunks.

lib/internal/Magento/Framework/Mview/View/Changelog.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66

77
namespace Magento\Framework\Mview\View;
88

9+
use Magento\Framework\DB\Adapter\ConnectionException;
10+
use Magento\Framework\Exception\RuntimeException;
911
use Magento\Framework\Phrase;
1012

13+
/**
14+
* Class Changelog for manipulations with the mview_state table.
15+
*/
1116
class Changelog implements ChangelogInterface
1217
{
1318
/**
@@ -41,6 +46,7 @@ class Changelog implements ChangelogInterface
4146

4247
/**
4348
* @param \Magento\Framework\App\ResourceConnection $resource
49+
* @throws ConnectionException
4450
*/
4551
public function __construct(\Magento\Framework\App\ResourceConnection $resource)
4652
{
@@ -53,12 +59,14 @@ public function __construct(\Magento\Framework\App\ResourceConnection $resource)
5359
* Check DB connection
5460
*
5561
* @return void
56-
* @throws \Exception
62+
* @throws ConnectionException
5763
*/
5864
protected function checkConnection()
5965
{
6066
if (!$this->connection) {
61-
throw new \Exception("The write connection to the database isn't available. Please try again later.");
67+
throw new ConnectionException(
68+
new Phrase("The write connection to the database isn't available. Please try again later.")
69+
);
6270
}
6371
}
6472

@@ -154,14 +162,15 @@ public function getList($fromVersionId, $toVersionId)
154162
(int)$toVersionId
155163
);
156164

157-
return $this->connection->fetchCol($select);
165+
return array_map('intval', $this->connection->fetchCol($select));
158166
}
159167

160168
/**
161169
* Get maximum version_id from changelog
170+
*
162171
* @return int
163172
* @throws ChangelogTableNotExistsException
164-
* @throws \Exception
173+
* @throws RuntimeException
165174
*/
166175
public function getVersion()
167176
{
@@ -173,7 +182,9 @@ public function getVersion()
173182
if (isset($row['Auto_increment'])) {
174183
return (int)$row['Auto_increment'] - 1;
175184
} else {
176-
throw new \Exception("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id.");
185+
throw new RuntimeException(
186+
new Phrase("Table status for %1 is incorrect. Can`t fetch version id.", [$changelogTableName])
187+
);
177188
}
178189
}
179190

@@ -182,13 +193,15 @@ public function getVersion()
182193
*
183194
* Build a changelog name by concatenating view identifier and changelog name suffix.
184195
*
185-
* @throws \Exception
196+
* @throws \DomainException
186197
* @return string
187198
*/
188199
public function getName()
189200
{
190201
if (strlen($this->viewId) == 0) {
191-
throw new \Exception("View's identifier is not set");
202+
throw new \DomainException(
203+
new Phrase("View's identifier is not set")
204+
);
192205
}
193206
return $this->viewId . '_' . self::NAME_SUFFIX;
194207
}
@@ -216,6 +229,8 @@ public function setViewId($viewId)
216229
}
217230

218231
/**
232+
* Get view's identifier
233+
*
219234
* @return string
220235
*/
221236
public function getViewId()

lib/web/mage/validation.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@
990990
minValidRange = $.mage.parseNumber(validRange[1]);
991991
maxValidRange = $.mage.parseNumber(validRange[2]);
992992
result = result &&
993-
(isNaN(minValidRange) || minValue >= minValidRange) &&
994-
(isNaN(maxValidRange) || maxValue <= maxValidRange);
993+
(isNaN(minValidRange) || minValue >= minValidRange) &&
994+
(isNaN(maxValidRange) || maxValue <= maxValidRange);
995995
}
996996
}
997997

@@ -1115,8 +1115,8 @@
11151115
options = p.find('input');
11161116

11171117
return options.map(function (el) {
1118-
return $(el).val();
1119-
}).length > 0;
1118+
return $(el).val();
1119+
}).length > 0;
11201120
},
11211121
$.mage.__('Please select one of the options above.')
11221122
],
@@ -1932,15 +1932,15 @@
19321932
* @param {jQuery.Event} event
19331933
* @param {Object} validation
19341934
*/
1935-
listenFormValidateHandler: function (event, validation) {
1935+
listenFormValidateHandler: function (event, validation) {
19361936
var firstActive = $(validation.errorList[0].element || []),
19371937
lastActive = $(validation.findLastActive() ||
19381938
validation.errorList.length && validation.errorList[0].element || []),
1939-
parent, windowHeight, successList;
1939+
windowHeight = $(window).height(),
1940+
parent, successList;
19401941

19411942
if (lastActive.is(':hidden')) {
19421943
parent = lastActive.parent();
1943-
windowHeight = $(window).height();
19441944
$('html, body').animate({
19451945
scrollTop: parent.offset().top - windowHeight / 2
19461946
});
@@ -1958,8 +1958,8 @@
19581958
}
19591959

19601960
if (firstActive.length) {
1961-
$('html, body').stop().animate({
1962-
scrollTop: firstActive.offset().top
1961+
$('body').stop().animate({
1962+
scrollTop: firstActive.offset().top - windowHeight / 2
19631963
});
19641964
firstActive.focus();
19651965
}

0 commit comments

Comments
 (0)