Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 0064e2b

Browse files
MAGETWO-87562: [EngCom Team] Batch 33. Forwardports to 2.3-develop #1361
2 parents 9e95852 + 9e3a010 commit 0064e2b

File tree

46 files changed

+1440
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1440
-318
lines changed

app/code/Magento/Backup/Model/Db.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public function createBackup(\Magento\Framework\Backup\Db\BackupInterface $backu
173173
}
174174
}
175175
$backup->write($this->getResource()->getTableForeignKeysSql());
176+
$backup->write($this->getResource()->getTableTriggersSql());
176177
$backup->write($this->getResource()->getFooter());
177178

178179
$this->getResource()->commitTransaction();

app/code/Magento/Backup/Model/ResourceModel/Db.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,31 @@ public function getTableForeignKeysSql($tableName = null)
114114
return $fkScript;
115115
}
116116

117+
/**
118+
* Return triggers for table(s).
119+
*
120+
* @param string|null $tableName
121+
* @param bool $addDropIfExists
122+
* @return string
123+
*/
124+
public function getTableTriggersSql($tableName = null, $addDropIfExists = true)
125+
{
126+
$triggerScript = '';
127+
if (!$tableName) {
128+
$tables = $this->getTables();
129+
foreach ($tables as $table) {
130+
$tableTriggerScript = $this->_resourceHelper->getTableTriggersSql($table, $addDropIfExists);
131+
if (!empty($tableTriggerScript)) {
132+
$triggerScript .= "\n" . $tableTriggerScript;
133+
}
134+
}
135+
} else {
136+
$triggerScript = $this->getTableTriggersSql($tableName, $addDropIfExists);
137+
}
138+
139+
return $triggerScript;
140+
}
141+
117142
/**
118143
* Retrieve table status
119144
*

app/code/Magento/Backup/Model/ResourceModel/Helper.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,40 @@ public function restoreTransactionIsolationLevel()
337337
{
338338
$this->getConnection()->query('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
339339
}
340+
341+
/**
342+
* Get create script for triggers.
343+
*
344+
* @param string $tableName
345+
* @param boolean $addDropIfExists
346+
* @param boolean $stripDefiner
347+
* @return string
348+
*/
349+
public function getTableTriggersSql($tableName, $addDropIfExists = false, $stripDefiner = true)
350+
{
351+
$script = "--\n-- Triggers structure for table `{$tableName}`\n--\n";
352+
$triggers = $this->getConnection()->query('SHOW TRIGGERS LIKE \''. $tableName . '\'')->fetchAll();
353+
354+
if (!$triggers) {
355+
return '';
356+
}
357+
foreach ($triggers as $trigger) {
358+
if ($addDropIfExists) {
359+
$script .= 'DROP TRIGGER IF EXISTS ' . $trigger['Trigger'] . ";\n";
360+
}
361+
$script .= "delimiter ;;\n";
362+
363+
$triggerData = $this->getConnection()->query('SHOW CREATE TRIGGER '. $trigger['Trigger'])->fetch();
364+
if ($stripDefiner) {
365+
$cleanedScript = preg_replace('/DEFINER=[^\s]*/', '', $triggerData['SQL Original Statement']);
366+
$script .= $cleanedScript . "\n";
367+
} else {
368+
$script .= $triggerData['SQL Original Statement'] . "\n";
369+
}
370+
$script .= ";;\n";
371+
$script .= "delimiter ;\n";
372+
}
373+
374+
return $script;
375+
}
340376
}

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/options.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ $stores = $block->getStoresSortedBySortOrder();
8888
$values = [];
8989
foreach($block->getOptionValues() as $value) {
9090
$value = $value->getData();
91-
$values[] = is_array($value) ? array_map("htmlspecialchars_decode", $value) : $value;
91+
$values[] = is_array($value) ? array_map(function($str) {
92+
return htmlspecialchars_decode($str, ENT_QUOTES);
93+
}, $value) : $value;
9294
}
9395
?>
9496
<script type="text/x-magento-init">

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ protected function createCategory($name, $parentId)
119119
$category->setIsActive(true);
120120
$category->setIncludeInMenu(true);
121121
$category->setAttributeSetId($category->getDefaultAttributeSetId());
122-
$category->save();
123-
$this->categoriesCache[$category->getId()] = $category;
122+
try {
123+
$category->save();
124+
$this->categoriesCache[$category->getId()] = $category;
125+
} catch (\Exception $e) {
126+
$this->addFailedCategory($category, $e);
127+
}
124128

125129
return $category->getId();
126130
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ protected function setUp()
4949
. self::CHILD_CATEGORY_ID
5050
));
5151

52+
$childCategory->method('save')->willThrowException(new \Exception());
53+
5254
$parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
5355
->disableOriginalConstructor()
5456
->getMock();
@@ -105,6 +107,17 @@ public function testUpsertCategories()
105107
$this->assertArrayHasKey(self::CHILD_CATEGORY_ID, array_flip($categoryIds));
106108
}
107109

110+
/**
111+
* Tests case when newly created category save throws exception.
112+
*/
113+
public function testCreateCategoryException()
114+
{
115+
$method = new \ReflectionMethod(CategoryProcessor::class, 'createCategory');
116+
$method->setAccessible(true);
117+
$method->invoke($this->categoryProcessor, self::CHILD_CATEGORY_NAME, self::PARENT_CATEGORY_ID);
118+
$this->assertNotEmpty($this->categoryProcessor->getFailedCategories());
119+
}
120+
108121
public function testClearFailedCategories()
109122
{
110123
$dummyFailedCategory = [

app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -33,76 +33,77 @@
3333
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
3434
<div class="products-<?= /* @noEscape */ $mode ?> <?= /* @noEscape */ $mode ?>">
3535
<ol class="product-items <?= /* @noEscape */ $type ?>">
36+
<?php $iterator = 1; ?>
3637
<?php foreach ($items as $_item): ?>
37-
<li class="product-item">
38-
<div class="product-item-info">
39-
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>" class="product-item-photo">
40-
<?= $block->getImage($_item, $image)->toHtml() ?>
41-
</a>
42-
<div class="product-item-details">
43-
<strong class="product-item-name">
44-
<a title="<?= $block->escapeHtml($_item->getName()) ?>"
45-
href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
46-
class="product-item-link">
47-
<?= $block->escapeHtml($_item->getName()) ?>
48-
</a>
49-
</strong>
50-
<?php
51-
echo $block->getProductPriceHtml($_item, $type);
52-
?>
38+
<?= /* @noEscape */ ($iterator++ == 1) ? '<li class="product-item">' : '</li><li class="product-item">' ?>
39+
<div class="product-item-info">
40+
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>" class="product-item-photo">
41+
<?= $block->getImage($_item, $image)->toHtml() ?>
42+
</a>
43+
<div class="product-item-details">
44+
<strong class="product-item-name">
45+
<a title="<?= $block->escapeHtml($_item->getName()) ?>"
46+
href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
47+
class="product-item-link">
48+
<?= $block->escapeHtml($_item->getName()) ?>
49+
</a>
50+
</strong>
51+
<?php
52+
echo $block->getProductPriceHtml($_item, $type);
53+
?>
5354

54-
<?php if ($templateType): ?>
55-
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
56-
<?php endif; ?>
55+
<?php if ($templateType): ?>
56+
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
57+
<?php endif; ?>
5758

58-
<?php if ($showWishlist || $showCompare || $showCart): ?>
59-
<div class="product-item-actions">
60-
<?php if ($showCart): ?>
61-
<div class="actions-primary">
62-
<?php if ($_item->isSaleable()): ?>
63-
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
64-
<button class="action tocart primary" data-mage-init='{"redirectUrl":{"url":"<?= $block->escapeUrl($block->getAddToCartUrl($_item)) ?>"}}' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
65-
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
66-
</button>
67-
<?php else: ?>
68-
<?php
69-
$postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
70-
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
71-
?>
72-
<button class="action tocart primary" data-post='<?= /* @noEscape */ $postData ?>' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
73-
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
74-
</button>
75-
<?php endif; ?>
59+
<?php if ($showWishlist || $showCompare || $showCart): ?>
60+
<div class="product-item-actions">
61+
<?php if ($showCart): ?>
62+
<div class="actions-primary">
63+
<?php if ($_item->isSaleable()): ?>
64+
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
65+
<button class="action tocart primary" data-mage-init='{"redirectUrl":{"url":"<?= $block->escapeUrl($block->getAddToCartUrl($_item)) ?>"}}' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
66+
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
67+
</button>
7668
<?php else: ?>
77-
<?php if ($_item->getIsSalable()): ?>
78-
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
79-
<?php else: ?>
80-
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
81-
<?php endif; ?>
69+
<?php
70+
$postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
71+
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
72+
?>
73+
<button class="action tocart primary" data-post='<?= /* @noEscape */ $postData ?>' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
74+
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
75+
</button>
8276
<?php endif; ?>
83-
</div>
84-
<?php endif; ?>
85-
<?php if ($showWishlist || $showCompare): ?>
86-
<div class="actions-secondary" data-role="add-to-links">
87-
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && $showWishlist): ?>
88-
<a href="#"
89-
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
90-
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
91-
</a>
92-
<?php endif; ?>
93-
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
94-
<?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?>
95-
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
96-
<span><?= $block->escapeHtml(__('Add to Compare')) ?></span>
97-
</a>
77+
<?php else: ?>
78+
<?php if ($_item->getIsSalable()): ?>
79+
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
80+
<?php else: ?>
81+
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
9882
<?php endif; ?>
99-
</div>
100-
<?php endif; ?>
101-
</div>
102-
<?php endif; ?>
103-
</div>
83+
<?php endif; ?>
84+
</div>
85+
<?php endif; ?>
86+
<?php if ($showWishlist || $showCompare): ?>
87+
<div class="actions-secondary" data-role="add-to-links">
88+
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && $showWishlist): ?>
89+
<a href="#"
90+
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
91+
<span><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
92+
</a>
93+
<?php endif; ?>
94+
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
95+
<?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?>
96+
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
97+
<span><?= $block->escapeHtml(__('Add to Compare')) ?></span>
98+
</a>
99+
<?php endif; ?>
100+
</div>
101+
<?php endif; ?>
102+
</div>
103+
<?php endif; ?>
104104
</div>
105-
</li>
105+
</div>
106+
<?= ($iterator == count($items) + 1) ? '</li>' : '' ?>
106107
<?php endforeach ?>
107108
</ol>
108109
</div>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Api;
7+
8+
/**
9+
* Utility Cms Pages
10+
*
11+
* @api
12+
*/
13+
interface GetUtilityPageIdentifiersInterface
14+
{
15+
/**
16+
* Get List Page Identifiers
17+
* @return array
18+
*/
19+
public function execute();
20+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Cms\Model;
7+
8+
use Magento\Cms\Api\GetUtilityPageIdentifiersInterface;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Store\Model\ScopeInterface;
11+
12+
/**
13+
* Utility Cms Pages.
14+
*/
15+
class GetUtilityPageIdentifiers implements GetUtilityPageIdentifiersInterface
16+
{
17+
/**
18+
* @var ScopeConfigInterface
19+
*/
20+
private $scopeConfig;
21+
22+
/**
23+
* UtilityCmsPage constructor.
24+
* @param ScopeConfigInterface $scopeConfig
25+
*/
26+
public function __construct(
27+
ScopeConfigInterface $scopeConfig
28+
) {
29+
$this->scopeConfig = $scopeConfig;
30+
}
31+
32+
/**
33+
* Get List Page Identifiers.
34+
*
35+
* @return array
36+
*/
37+
public function execute()
38+
{
39+
$homePageIdentifier = $this->scopeConfig->getValue(
40+
'web/default/cms_home_page',
41+
ScopeInterface::SCOPE_STORE
42+
);
43+
$noRouteIdentifier = $this->scopeConfig->getValue(
44+
'web/default/cms_no_route',
45+
ScopeInterface::SCOPE_STORE
46+
);
47+
48+
$noCookieIdentifier = $this->scopeConfig->getValue(
49+
'web/default/cms_no_cookies',
50+
ScopeInterface::SCOPE_STORE
51+
);
52+
53+
return [$homePageIdentifier, $noRouteIdentifier, $noCookieIdentifier];
54+
}
55+
}

0 commit comments

Comments
 (0)