Skip to content

Commit

Permalink
MAGETWO-87056: [EngCom Team] Batch 2. Forwardports to 2.3-develop #1283
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko authored Jan 29, 2018
2 parents a1338c6 + 9ef1621 commit 4ba9235
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 19 deletions.
7 changes: 5 additions & 2 deletions app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,14 @@ public function getAllChildren($asArray = false)
/**
* Retrieve children ids comma separated
*
* @param boolean $recursive
* @param boolean $isActive
* @param boolean $sortByPosition
* @return string
*/
public function getChildren()
public function getChildren($recursive = false, $isActive = true, $sortByPosition = false)
{
return implode(',', $this->getResource()->getChildren($this, false));
return implode(',', $this->getResource()->getChildren($this, $recursive, $isActive, $sortByPosition));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,10 @@ public function isInRootCategoryList($category)
* @param \Magento\Catalog\Model\Category $category
* @param bool $recursive
* @param bool $isActive
* @param bool $sortByPosition
* @return array
*/
public function getChildren($category, $recursive = true, $isActive = true)
public function getChildren($category, $recursive = true, $isActive = true, $sortByPosition = false)
{
$select = $this->getConnection()->select()->from(
$this->getMainStoreTable($category->getStoreId()),
Expand All @@ -619,6 +620,9 @@ public function getChildren($category, $recursive = true, $isActive = true)
if ($isActive) {
$select->where('is_active = ?', '1');
}
if ($sortByPosition) {
$select->order('position ASC');
}
$_categories = $this->getConnection()->fetchAll($select);
$categoriesIds = [];
foreach ($_categories as $_category) {
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,4 @@ Payment,Payment
"Not yet calculated","Not yet calculated"
"We received your order!","We received your order!"
"Thank you for your purchase!","Thank you for your purchase!"
"optional", "optional"
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Block,Block
"Enable Page","Enable Page"
Content,Content
"Content Heading","Content Heading"
"Search Engine Optimisation","Search Engine Optimisation"
"Search Engine Optimization","Search Engine Optimization"
"Meta Title","Meta Title"
"Meta Keywords","Meta Keywords"
"Meta Description","Meta Description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<fieldset name="search_engine_optimisation" sortOrder="20">
<settings>
<collapsible>true</collapsible>
<label translate="true">Search Engine Optimisation</label>
<label translate="true">Search Engine Optimization</label>
</settings>
<field name="identifier" formElement="input">
<argument name="data" xsi:type="array">
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Indexer/Model/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ public function reindexAll()
$state->save();
$this->getView()->resume();
throw $exception;
} catch (\Error $error) {
$state->setStatus(StateInterface::STATUS_INVALID);
$state->save();
$this->getView()->resume();
throw $error;
}
}
}
Expand Down
50 changes: 50 additions & 0 deletions app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,56 @@ function () {
$this->model->reindexAll();
}

/**
* @expectedException \Error
* @expectedExceptionMessage Test Engine Error
*/
public function testReindexAllWithError()
{

$indexId = 'indexer_internal_name';
$this->loadIndexer($indexId);

$stateMock = $this->createPartialMock(
\Magento\Indexer\Model\Indexer\State::class,
['load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save']
);
$stateMock->expects($this->once())->method('load')->with($indexId, 'indexer_id')->will($this->returnSelf());
$stateMock->expects($this->never())->method('setIndexerId');
$stateMock->expects($this->once())->method('getId')->will($this->returnValue(1));
$stateMock->expects($this->exactly(2))->method('setStatus')->will($this->returnSelf());
$stateMock->expects($this->once())->method('getStatus')->will($this->returnValue('idle'));
$stateMock->expects($this->exactly(2))->method('save')->will($this->returnSelf());
$this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock));

$this->viewMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
$this->viewMock->expects($this->never())->method('suspend');
$this->viewMock->expects($this->once())->method('resume');

$actionMock = $this->createPartialMock(
\Magento\Framework\Indexer\ActionInterface::class,
['executeFull', 'executeList', 'executeRow']
);
$actionMock->expects($this->once())->method('executeFull')->will(
$this->returnCallback(
function () {
throw new \Error('Test Engine Error');
}
)
);
$this->actionFactoryMock->expects(
$this->once()
)->method(
'create'
)->with(
'Some\Class\Name'
)->will(
$this->returnValue($actionMock)
);

$this->model->reindexAll();
}

protected function getIndexerData()
{
return [
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Sales/Helper/Guest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public function loadValidOrder(App\RequestInterface $request)
public function getBreadcrumbs(\Magento\Framework\View\Result\Page $resultPage)
{
$breadcrumbs = $resultPage->getLayout()->getBlock('breadcrumbs');
if (!$breadcrumbs) {
return;
}
$breadcrumbs->addCrumb(
'home',
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
};

window.localStorage.__proto__ = window.localStorage = new Storage('local');
window.sessionStorage.__proto__ = window.sessionStorag = new Storage('session');
window.sessionStorage.__proto__ = window.sessionStorage = new Storage('session');
})();
}
</script>
23 changes: 17 additions & 6 deletions app/code/Magento/Widget/Model/Config/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function _convertDepends($source)
{
$depends = [];
foreach ($source->childNodes as $childNode) {
if ($childNode->nodeName == '#text') {
if ($childNode->nodeName === '#text') {
continue;
}
if ($childNode->nodeName !== 'parameter') {
Expand All @@ -231,12 +231,23 @@ protected function _convertDepends($source)
);
}
$parameterAttributes = $childNode->attributes;
$depends[$parameterAttributes->getNamedItem(
'name'
)->nodeValue] = [
'value' => $parameterAttributes->getNamedItem('value')->nodeValue,
];
$dependencyName = $parameterAttributes->getNamedItem('name')->nodeValue;
$dependencyValue = $parameterAttributes->getNamedItem('value')->nodeValue;

if (!isset($depends[$dependencyName])) {
$depends[$dependencyName] = [
'value' => $dependencyValue,
];

continue;
} else if (!isset($depends[$dependencyName]['values'])) {
$depends[$dependencyName]['values'] = [$depends[$dependencyName]['value']];
unset($depends[$dependencyName]['value']);
}

$depends[$dependencyName]['values'][] = $dependencyValue;
}

return $depends;
}

Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Widget/etc/widget.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
<xs:annotation>
<xs:documentation>List of parameters this parameter depends on.</xs:documentation>
</xs:annotation>
<xs:all>
<xs:sequence maxOccurs="unbounded">
<xs:element name="parameter" type="dependsParameterType" />
</xs:all>
</xs:sequence>
</xs:complexType>
</xs:schema>
4 changes: 2 additions & 2 deletions app/code/Magento/Widget/etc/widget_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
<xs:annotation>
<xs:documentation>List of parameters this parameter depends on.</xs:documentation>
</xs:annotation>
<xs:all>
<xs:sequence maxOccurs="unbounded">
<xs:element name="parameter" type="dependsParameterType" />
</xs:all>
</xs:sequence>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
line-height: @toolbar-mode-icon-font-size + 2;
margin: 0;
padding: 7px 0;
position: absolute;
text-align: left;
top: 0;
vertical-align: middle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</custom_design>
<seo>
<class>\Magento\Backend\Test\Block\Widget\Tab</class>
<selector>//div[div/strong/span[text()="Search Engine Optimisation"]]</selector>
<selector>//div[div/strong/span[text()="Search Engine Optimization"]]</selector>
<strategy>xpath</strategy>
<fields>
<identifier />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ public function testGetChildren()
$this->assertEquals(array_diff([4, 13], explode(',', $this->_model->getChildren())), []);
}

public function testGetChildrenSorted()
{
$this->_model->load(2);
$unsorted = explode(',', $this->_model->getChildren());
sort($unsorted);
$this->assertEquals(array_diff($unsorted, explode(',', $this->_model->getChildren(true, true, true))), []);
}

public function testGetPathInStore()
{
$this->_model->load(5);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/View/Model/Layout/Merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ private function getXmlErrors($libXmlErrors)
protected function _getPhysicalTheme(\Magento\Framework\View\Design\ThemeInterface $theme)
{
$result = $theme;
while ($result->getId() && !$result->isPhysical()) {
while ($result !== null && $result->getId() && !$result->isPhysical()) {
$result = $result->getParentTheme();
}
if (!$result) {
Expand Down
1 change: 1 addition & 0 deletions setup/src/Magento/Setup/Model/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ private function installOrderIncrementPrefix($orderIncrementPrefix)
public function installAdminUser($data)
{
$this->assertDbConfigExists();
$data += ['db-prefix' => $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX)];
$setup = $this->setupFactory->create($this->context->getResources());
$adminAccount = $this->adminAccountFactory->create($setup->getConnection(), (array)$data);
$adminAccount->save();
Expand Down

0 comments on commit 4ba9235

Please sign in to comment.