Skip to content

Commit 9047169

Browse files
Merge branch 'develop' of github.com:magento/magento2ce into bugs
2 parents 7518881 + 5a615bb commit 9047169

File tree

36 files changed

+411
-202
lines changed

36 files changed

+411
-202
lines changed

app/code/Magento/Backend/Model/View/Result/Redirect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Backend\Model\UrlInterface;
1111
use Magento\Framework\App;
1212
use Magento\Framework\App\ActionFlag;
13+
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
1314

1415
class Redirect extends \Magento\Framework\Controller\Result\Redirect
1516
{
@@ -56,7 +57,7 @@ public function setRefererOrBaseUrl()
5657
/**
5758
* {@inheritdoc}
5859
*/
59-
protected function render(App\ResponseInterface $response)
60+
protected function render(HttpResponseInterface $response)
6061
{
6162
$this->session->setIsUrlNotice($this->actionFlag->get('', AbstractAction::FLAG_IS_URLS_CHECKED));
6263
return parent::render($response);

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ private function processRangeNumeric(FilterInterface $filter, $query, $attribute
179179
$tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : '';
180180
$table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}");
181181
$select = $this->connection->select();
182-
$linkIdField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
182+
$entityField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getIdentifierField();
183183

184184
$currentStoreId = $this->scopeResolver->getScope()->getId();
185185

186186
$select->from(['e' => $this->resource->getTableName('catalog_product_entity')], ['entity_id'])
187187
->join(
188188
['main_table' => $table],
189-
"main_table.{$linkIdField} = e.{$linkIdField}",
189+
"main_table.{$entityField} = e.{$entityField}",
190190
[]
191191
)
192192
->columns([$filter->getField() => 'main_table.value'])

app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ public function isEverythingAllowed()
147147
*/
148148
public function getResourcesTreeJson()
149149
{
150-
$resources = $this->_resourceProvider->getAclResources();
151-
$aclResourcesTree = $this->_integrationData->mapResources($resources[1]['children']);
150+
$aclResourcesTree = $this->_integrationData->mapResources($this->getAclResources());
152151

153152
return $this->encoder->encode($aclResourcesTree);
154153
}
@@ -166,12 +165,29 @@ public function getSelectedResourcesJson()
166165
{
167166
$selectedResources = $this->_selectedResources;
168167
if ($this->isEverythingAllowed()) {
169-
$resources = $this->_resourceProvider->getAclResources();
170-
$selectedResources = $this->_getAllResourceIds($resources[1]['children']);
168+
$selectedResources = $this->_getAllResourceIds($this->getAclResources());
171169
}
172170
return $this->encoder->encode($selectedResources);
173171
}
174172

173+
/**
174+
* Get lit of all ACL resources declared in the system.
175+
*
176+
* @return array
177+
*/
178+
private function getAclResources()
179+
{
180+
$resources = $this->_resourceProvider->getAclResources();
181+
$configResource = array_filter(
182+
$resources,
183+
function ($node) {
184+
return $node['id'] == 'Magento_Backend::admin';
185+
}
186+
);
187+
$configResource = reset($configResource);
188+
return isset($configResource['children']) ? $configResource['children'] : [];
189+
}
190+
175191
/**
176192
* Whether tree has any resources.
177193
*

app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Integration\Block\Adminhtml\Integration\Edit\Tab;
88

9-
use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
109
use Magento\Integration\Controller\Adminhtml\Integration as IntegrationController;
1110
use Magento\Integration\Model\Integration as IntegrationModel;
1211

@@ -174,11 +173,25 @@ public function isEverythingAllowed()
174173
* @return array
175174
*/
176175
public function getTree()
176+
{
177+
return $this->integrationData->mapResources($this->getAclResources());
178+
}
179+
180+
/**
181+
* Get lit of all ACL resources declared in the system.
182+
*
183+
* @return array
184+
*/
185+
private function getAclResources()
177186
{
178187
$resources = $this->aclResourceProvider->getAclResources();
179-
$rootArray = $this->integrationData->mapResources(
180-
isset($resources[1]['children']) ? $resources[1]['children'] : []
188+
$configResource = array_filter(
189+
$resources,
190+
function ($node) {
191+
return $node['id'] == 'Magento_Backend::admin';
192+
}
181193
);
182-
return $rootArray;
194+
$configResource = reset($configResource);
195+
return isset($configResource['children']) ? $configResource['children'] : [];
183196
}
184197
}

app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,16 @@ public function testGetTree()
155155
{
156156
$this->webapiBlock = $this->getWebapiBlock();
157157
$resources = [
158-
1 => [ 'children' => [1, 2, 3] ]
158+
['id' => 'Magento_Backend::admin', 'children' => ['resource1', 'resource2', 'resource3']],
159+
['id' => 'Invalid_Node', 'children' => ['resource4', 'resource5', 'resource6']]
159160
];
160161
$this->aclResourceProvider->expects($this->once())
161162
->method('getAclResources')
162163
->will($this->returnValue($resources));
163164
$rootArray = "rootArrayValue";
164165
$this->integrationHelper->expects($this->once())
165166
->method('mapResources')
166-
->with([1, 2, 3])
167+
->with(['resource1', 'resource2', 'resource3'])
167168
->will($this->returnValue($rootArray));
168169
$this->assertEquals($rootArray, $this->webapiBlock->getTree());
169170
}
@@ -197,7 +198,7 @@ public function isEverythingAllowedWithSavedFromDataProvider()
197198
return [
198199
'root resource in array' => [
199200
2,
200-
['all_resources' => 0, 'resource'=>[2, 3]],
201+
['all_resources' => 0, 'resource' => [2, 3]],
201202
true
202203
],
203204
'root resource not in array' => [

app/code/Magento/OfflineShipping/Setup/InstallSchema.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
*/
1616
class InstallSchema implements InstallSchemaInterface
1717
{
18+
/**
19+
* @var string
20+
*/
21+
private static $quoteConnectionName = 'checkout';
22+
23+
/**
24+
* @var string
25+
*/
26+
private static $salesConnectionName = 'sales';
27+
1828
/**
1929
* {@inheritdoc}
2030
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -105,32 +115,32 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
105115
['unsigned' => true, 'nullable' => false, 'default' => '0'],
106116
'Simple Free Shipping'
107117
);
108-
$installer->getConnection()->addColumn(
109-
$installer->getTable('sales_order_item'),
118+
$installer->getConnection(self::$salesConnectionName)->addColumn(
119+
$installer->getTable('sales_order_item', self::$salesConnectionName),
110120
'free_shipping',
111121
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
112122
null,
113123
['unsigned' => true, 'nullable' => false, 'default' => '0'],
114124
'Free Shipping'
115125
);
116-
$installer->getConnection()->addColumn(
117-
$installer->getTable('quote_address'),
126+
$installer->getConnection(self::$quoteConnectionName)->addColumn(
127+
$installer->getTable('quote_address', self::$quoteConnectionName),
118128
'free_shipping',
119129
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
120130
null,
121131
['unsigned' => true, 'nullable' => false, 'default' => '0'],
122132
'Free Shipping'
123133
);
124-
$installer->getConnection()->addColumn(
125-
$installer->getTable('quote_item'),
134+
$installer->getConnection(self::$quoteConnectionName)->addColumn(
135+
$installer->getTable('quote_item', self::$quoteConnectionName),
126136
'free_shipping',
127137
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
128138
null,
129139
['unsigned' => true, 'nullable' => false, 'default' => '0'],
130140
'Free Shipping'
131141
);
132-
$installer->getConnection()->addColumn(
133-
$installer->getTable('quote_address_item'),
142+
$installer->getConnection(self::$quoteConnectionName)->addColumn(
143+
$installer->getTable('quote_address_item', self::$quoteConnectionName),
134144
'free_shipping',
135145
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
136146
null,

app/code/Magento/OfflineShipping/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"magento/module-backend": "100.2.*",
99
"magento/module-shipping": "100.2.*",
1010
"magento/module-catalog": "101.1.*",
11-
"magento/module-sales": "100.2.*",
1211
"magento/module-sales-rule": "100.2.*",
1312
"magento/module-directory": "100.2.*",
1413
"magento/module-quote": "100.2.*",
1514
"magento/framework": "100.2.*"
1615
},
1716
"suggest": {
1817
"magento/module-checkout": "100.2.*",
18+
"magento/module-sales": "100.2.*",
1919
"magento/module-offline-shipping-sample-data": "Sample Data version:100.2.*"
2020
},
2121
"type": "magento2-module",

app/code/Magento/Persistent/Setup/InstallSchema.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
*/
1616
class InstallSchema implements InstallSchemaInterface
1717
{
18+
/**
19+
* @var string
20+
*/
21+
private static $connectionName = 'checkout';
22+
1823
/**
1924
* {@inheritdoc}
2025
*/
@@ -97,8 +102,8 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
97102
* Alter quote table with is_persistent flag
98103
*
99104
*/
100-
$installer->getConnection()->addColumn(
101-
$installer->getTable('quote'),
105+
$installer->getConnection(self::$connectionName)->addColumn(
106+
$installer->getTable('quote', self::$connectionName),
102107
'is_persistent',
103108
[
104109
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,

app/code/Magento/Quote/Setup/QuoteSetup.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class QuoteSetup extends EavSetup
2929
*/
3030
protected $_encryptor;
3131

32+
/**
33+
* @var string
34+
*/
35+
private static $connectionName = 'checkout';
36+
3237
/**
3338
* @param ModuleDataSetupInterface $setup
3439
* @param Context $context
@@ -70,8 +75,11 @@ public function __construct(
7075
*/
7176
protected function _flatTableExist($table)
7277
{
73-
$tablesList = $this->getSetup()->getConnection()->listTables();
74-
return in_array(strtoupper($this->getSetup()->getTable($table)), array_map('strtoupper', $tablesList));
78+
$tablesList = $this->getSetup()->getConnection(self::$connectionName)->listTables();
79+
return in_array(
80+
strtoupper($this->getSetup()->getTable($table, self::$connectionName)),
81+
array_map('strtoupper', $tablesList)
82+
);
7583
}
7684

7785
/**
@@ -107,13 +115,15 @@ public function addAttribute($entityTypeId, $code, array $attr)
107115
*/
108116
protected function _addFlatAttribute($table, $attribute, $attr)
109117
{
110-
$tableInfo = $this->getSetup()->getConnection()->describeTable($this->getSetup()->getTable($table));
118+
$tableInfo = $this->getSetup()
119+
->getConnection(self::$connectionName)
120+
->describeTable($this->getSetup()->getTable($table, self::$connectionName));
111121
if (isset($tableInfo[$attribute])) {
112122
return $this;
113123
}
114124
$columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
115-
$this->getSetup()->getConnection()->addColumn(
116-
$this->getSetup()->getTable($table),
125+
$this->getSetup()->getConnection(self::$connectionName)->addColumn(
126+
$this->getSetup()->getTable($table, self::$connectionName),
117127
$attribute,
118128
$columnDefinition
119129
);

app/code/Magento/Quote/Setup/UpgradeSchema.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
*/
1515
class UpgradeSchema implements UpgradeSchemaInterface
1616
{
17+
/**
18+
* @var string
19+
*/
20+
private static $connectionName = 'checkout';
21+
1722
/**
1823
* {@inheritdoc}
1924
*/
@@ -22,16 +27,16 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
2227
$setup->startSetup();
2328

2429
if (version_compare($context->getVersion(), '2.0.1', '<')) {
25-
$setup->getConnection()->addIndex(
26-
$setup->getTable('quote_id_mask'),
27-
$setup->getIdxName('quote_id_mask', ['masked_id']),
30+
$setup->getConnection(self::$connectionName)->addIndex(
31+
$setup->getTable('quote_id_mask', self::$connectionName),
32+
$setup->getIdxName('quote_id_mask', ['masked_id'], '', self::$connectionName),
2833
['masked_id']
2934
);
3035
}
3136

3237
if (version_compare($context->getVersion(), '2.0.2', '<')) {
33-
$setup->getConnection()->changeColumn(
34-
$setup->getTable('quote_address'),
38+
$setup->getConnection(self::$connectionName)->changeColumn(
39+
$setup->getTable('quote_address', self::$connectionName),
3540
'street',
3641
'street',
3742
[

app/code/Magento/Sales/Setup/SalesSetup.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/**
1616
* Setup Model of Sales Module
1717
* @codeCoverageIgnore
18+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1819
*/
1920
class SalesSetup extends \Magento\Eav\Setup\EavSetup
2021
{
@@ -48,6 +49,11 @@ class SalesSetup extends \Magento\Eav\Setup\EavSetup
4849
*/
4950
protected $encryptor;
5051

52+
/**
53+
* @var string
54+
*/
55+
private static $connectionName = 'sales';
56+
5157
/**
5258
* @param ModuleDataSetupInterface $setup
5359
* @param Context $context
@@ -105,8 +111,11 @@ public function __construct(
105111
*/
106112
protected function _flatTableExist($table)
107113
{
108-
$tablesList = $this->getSetup()->getConnection()->listTables();
109-
return in_array(strtoupper($this->getSetup()->getTable($table)), array_map('strtoupper', $tablesList));
114+
$tablesList = $this->getSetup()->getConnection(self::$connectionName)->listTables();
115+
return in_array(
116+
strtoupper($this->getSetup()->getTable($table, self::$connectionName)),
117+
array_map('strtoupper', $tablesList)
118+
);
110119
}
111120

112121
/**
@@ -143,13 +152,15 @@ public function addAttribute($entityTypeId, $code, array $attr)
143152
*/
144153
protected function _addFlatAttribute($table, $attribute, $attr)
145154
{
146-
$tableInfo = $this->getSetup()->getConnection()->describeTable($this->getSetup()->getTable($table));
155+
$tableInfo = $this->getSetup()
156+
->getConnection(self::$connectionName)
157+
->describeTable($this->getSetup()->getTable($table, self::$connectionName));
147158
if (isset($tableInfo[$attribute])) {
148159
return $this;
149160
}
150161
$columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
151-
$this->getSetup()->getConnection()->addColumn(
152-
$this->getSetup()->getTable($table),
162+
$this->getSetup()->getConnection(self::$connectionName)->addColumn(
163+
$this->getSetup()->getTable($table, self::$connectionName),
153164
$attribute,
154165
$columnDefinition
155166
);
@@ -169,8 +180,8 @@ protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId)
169180
{
170181
if (in_array($entityTypeId, $this->_flatEntitiesGrid) && !empty($attr['grid'])) {
171182
$columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
172-
$this->getSetup()->getConnection()->addColumn(
173-
$this->getSetup()->getTable($table . '_grid'),
183+
$this->getSetup()->getConnection(self::$connectionName)->addColumn(
184+
$this->getSetup()->getTable($table . '_grid', self::$connectionName),
174185
$attribute,
175186
$columnDefinition
176187
);

0 commit comments

Comments
 (0)