Skip to content

Commit e6ad9c1

Browse files
committed
Merge branch '2.2-develop' into config-set-option-lock-env
2 parents 97af2a7 + 83a9b9c commit e6ad9c1

File tree

115 files changed

+1532
-612
lines changed

Some content is hidden

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

115 files changed

+1532
-612
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results.
66

77
## Magento system requirements
8-
[Magento system requirements](http://devdocs.magento.com/magento-system-requirements.html)
8+
[Magento system requirements](http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements2.html)
99

1010
## Install Magento
1111
To install Magento, see either:
1212

1313
* [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento.
14-
* [Installation guide](http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html)
14+
* [Installation guide](http://devdocs.magento.com/guides/v2.2/install-gde/bk-install-guide.html)
1515

1616
<h2>Contributing to the Magento 2 code base</h2>
1717
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
@@ -22,8 +22,8 @@ To learn about issues, click [here][2]. To open an issue, click [here][3].
2222

2323
To suggest documentation improvements, click [here][4].
2424

25-
[1]: <http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html>
26-
[2]: <http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#report>
25+
[1]: <http://devdocs.magento.com/guides/v2.2/contributor-guide/contributing.html>
26+
[2]: <http://devdocs.magento.com/guides/v2.2/contributor-guide/contributing.html#report>
2727
[3]: <https://github.com/magento/magento2/issues>
2828
[4]: <http://devdocs.magento.com>
2929

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function createBackup(\Magento\Framework\Backup\Db\BackupInterface $backu
154154

155155
if ($tableStatus->getDataLength() > self::BUFFER_LENGTH) {
156156
if ($tableStatus->getAvgRowLength() < self::BUFFER_LENGTH) {
157-
$limit = floor(self::BUFFER_LENGTH / $tableStatus->getAvgRowLength());
157+
$limit = floor(self::BUFFER_LENGTH / max($tableStatus->getAvgRowLength(), 1));
158158
$multiRowsLength = ceil($tableStatus->getRows() / $limit);
159159
} else {
160160
$limit = 1;
@@ -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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,30 @@ public function getTableForeignKeysSql($tableName = null)
114114
return $fkScript;
115115
}
116116

117+
/**
118+
* Return triggers fro 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+
return $triggerScript;
139+
}
140+
117141
/**
118142
* Retrieve table status
119143
*

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/Bundle/Model/ResourceModel/Option.php

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,39 @@ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
8181
{
8282
parent::_afterSave($object);
8383

84-
$condition = [
84+
$conditions = [
8585
'option_id = ?' => $object->getId(),
8686
'store_id = ? OR store_id = 0' => $object->getStoreId(),
8787
'parent_product_id = ?' => $object->getParentId()
8888
];
8989

9090
$connection = $this->getConnection();
91-
$connection->delete($this->getTable('catalog_product_bundle_option_value'), $condition);
9291

93-
$data = new \Magento\Framework\DataObject();
94-
$data->setOptionId($object->getId())
95-
->setStoreId($object->getStoreId())
96-
->setParentProductId($object->getParentId())
97-
->setTitle($object->getTitle());
98-
99-
$connection->insert($this->getTable('catalog_product_bundle_option_value'), $data->getData());
100-
101-
/**
102-
* also saving default value if this store view scope
103-
*/
92+
if ($this->isOptionPresent($conditions)) {
93+
$connection->update(
94+
$this->getTable('catalog_product_bundle_option_value'),
95+
[
96+
'title' => $object->getTitle()
97+
],
98+
$conditions
99+
);
100+
} else {
101+
$data = new \Magento\Framework\DataObject();
102+
$data->setOptionId($object->getId())
103+
->setStoreId($object->getStoreId())
104+
->setParentProductId($object->getParentId())
105+
->setTitle($object->getTitle());
104106

105-
if ($object->getStoreId()) {
106-
$data->setStoreId(0);
107-
$data->setTitle($object->getDefaultTitle());
108107
$connection->insert($this->getTable('catalog_product_bundle_option_value'), $data->getData());
108+
109+
/**
110+
* also saving default value if this store view scope
111+
*/
112+
if ($object->getStoreId()) {
113+
$data->setStoreId(0);
114+
$data->setTitle($object->getDefaultTitle());
115+
$connection->insert($this->getTable('catalog_product_bundle_option_value'), $data->getData());
116+
}
109117
}
110118

111119
return $this;
@@ -210,4 +218,26 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
210218

211219
return $this;
212220
}
221+
222+
/**
223+
* Is Bundle option present in the database
224+
*
225+
* @param array $conditions
226+
*
227+
* @return bool
228+
*/
229+
private function isOptionPresent($conditions)
230+
{
231+
$connection = $this->getConnection();
232+
233+
$select = $connection->select()->from($this->getTable('catalog_product_bundle_option_value'));
234+
foreach ($conditions as $condition => $conditionValue) {
235+
$select->where($condition, $conditionValue);
236+
}
237+
$select->limit(1);
238+
239+
$rowSelect = $connection->fetchRow($select);
240+
241+
return (is_array($rowSelect) && !empty($rowSelect));
242+
}
213243
}

app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function getStoreSwitcherHtml()
228228
public function getLoadTreeUrl($expanded = null)
229229
{
230230
$params = ['_current' => true, 'id' => null, 'store' => null];
231-
if (is_null($expanded) && $this->_backendSession->getIsTreeWasExpanded() || $expanded == true) {
231+
if ($expanded === null && $this->_backendSession->getIsTreeWasExpanded() || $expanded == true) {
232232
$params['expand_all'] = true;
233233
}
234234
return $this->getUrl('*/*/categoriesJson', $params);

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ public function getOptionValues()
313313
$value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
314314
$option->getOptionId(),
315315
'title',
316-
is_null($option->getStoreTitle())
316+
$option->getStoreTitle() === null
317317
);
318-
$value['scopeTitleDisabled'] = is_null($option->getStoreTitle()) ? 'disabled' : null;
318+
$value['scopeTitleDisabled'] = $option->getStoreTitle() === null ? 'disabled' : null;
319319
}
320320

321321
if ($option->getGroupByType() == ProductCustomOptionInterface::OPTION_GROUP_SELECT) {
@@ -341,22 +341,22 @@ public function getOptionValues()
341341
$value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
342342
$_value->getOptionId(),
343343
'title',
344-
is_null($_value->getStoreTitle()),
344+
$_value->getStoreTitle() === null,
345345
$_value->getOptionTypeId()
346346
);
347-
$value['optionValues'][$i]['scopeTitleDisabled'] = is_null(
348-
$_value->getStoreTitle()
347+
$value['optionValues'][$i]['scopeTitleDisabled'] = (
348+
$_value->getStoreTitle() === null
349349
) ? 'disabled' : null;
350350
if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE) {
351351
$value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
352352
$_value->getOptionId(),
353353
'price',
354-
is_null($_value->getstorePrice()),
354+
$_value->getstorePrice() === null,
355355
$_value->getOptionTypeId(),
356356
['$(this).up(1).previous()']
357357
);
358-
$value['optionValues'][$i]['scopePriceDisabled'] = is_null(
359-
$_value->getStorePrice()
358+
$value['optionValues'][$i]['scopePriceDisabled'] = (
359+
$_value->getStorePrice() === null
360360
) ? 'disabled' : null;
361361
}
362362
}
@@ -379,9 +379,9 @@ public function getOptionValues()
379379
$value['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
380380
$option->getOptionId(),
381381
'price',
382-
is_null($option->getStorePrice())
382+
$option->getStorePrice() === null
383383
);
384-
$value['scopePriceDisabled'] = is_null($option->getStorePrice()) ? 'disabled' : null;
384+
$value['scopePriceDisabled'] = $option->getStorePrice() === null ? 'disabled' : null;
385385
}
386386
}
387387
$values[] = new \Magento\Framework\DataObject($value);

app/code/Magento/Catalog/Block/Product/ProductList/Related.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function getItems()
121121
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
122122
* @see https://github.com/magento/magento2/issues/5897
123123
*/
124-
if (is_null($this->_itemCollection)) {
124+
if ($this->_itemCollection === null) {
125125
$this->_prepareData();
126126
}
127127
return $this->_itemCollection;

app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getItemCollection()
140140
* getIdentities() depends on _itemCollection populated, but it can be empty if the block is hidden
141141
* @see https://github.com/magento/magento2/issues/5897
142142
*/
143-
if (is_null($this->_itemCollection)) {
143+
if ($this->_itemCollection === null) {
144144
$this->_prepareData();
145145
}
146146
return $this->_itemCollection;
@@ -151,7 +151,7 @@ public function getItemCollection()
151151
*/
152152
public function getItems()
153153
{
154-
if (is_null($this->_items)) {
154+
if ($this->_items === null) {
155155
$this->_items = $this->getItemCollection()->getItems();
156156
}
157157
return $this->_items;

app/code/Magento/Catalog/Helper/Product/View.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
122122
// Load default page handles and page configurations
123123
if ($params && $params->getBeforeHandles()) {
124124
foreach ($params->getBeforeHandles() as $handle) {
125-
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
126125
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], $handle, false);
126+
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
127127
}
128128
}
129-
130-
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku]);
129+
131130
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], null, false);
131+
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku]);
132132

133133
if ($params && $params->getAfterHandles()) {
134134
foreach ($params->getAfterHandles() as $handle) {
135-
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
136135
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], $handle, false);
136+
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
137137
}
138138
}
139139

0 commit comments

Comments
 (0)