Skip to content

Commit 77bc93f

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #18215: fix wysiwyg editor not decoding base64 filenames special chars (by @adammada) - #18280: [Backport] Change sort order for customer group options (by @dmytro-ch) - #18086: Cast products "getStoreId()" to int, closes #18079 (by @sreichel) - #16885: [Fix] Do not modify current list of countries with require states during setup upgrade (by @jalogut) Fixed GitHub Issues: - #18138: WYSIWYG editor fails to parse directives of files with special characters in URL (so random files) (reported by @adammada) has been fixed in #18215 by @adammada in 2.2-develop branch Related commits: 1. 4e62fe3 2. bf2efff - #18101: Wrong sort order for customer groups in customer grid filter (reported by @sreichel) has been fixed in #18280 by @dmytro-ch in 2.2-develop branch Related commits: 1. 484bbba 2. dd9b294 - #18079: Inconsistent return type for getStoreId() (reported by @sreichel) has been fixed in #18086 by @sreichel in 2.2-develop branch Related commits: 1. 9d8b04a
2 parents 4557bfe + 89e5c60 commit 77bc93f

File tree

6 files changed

+114
-83
lines changed

6 files changed

+114
-83
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
7171

7272
const CACHE_TAG = 'cat_c';
7373

74+
/**
75+
* Category Store Id
76+
*/
77+
const STORE_ID = 'store_id';
78+
7479
/**#@+
7580
* Constants
7681
*/
@@ -588,12 +593,12 @@ public function getStoreIds()
588593
*
589594
* If store id is underfined for category return current active store id
590595
*
591-
* @return integer
596+
* @return int
592597
*/
593598
public function getStoreId()
594599
{
595-
if ($this->hasData('store_id')) {
596-
return (int)$this->_getData('store_id');
600+
if ($this->hasData(self::STORE_ID)) {
601+
return (int)$this->_getData(self::STORE_ID);
597602
}
598603
return (int)$this->_storeManager->getStore()->getId();
599604
}
@@ -609,7 +614,7 @@ public function setStoreId($storeId)
609614
if (!is_numeric($storeId)) {
610615
$storeId = $this->_storeManager->getStore($storeId)->getId();
611616
}
612-
$this->setData('store_id', $storeId);
617+
$this->setData(self::STORE_ID, $storeId);
613618
$this->getResource()->setStoreId($storeId);
614619
return $this;
615620
}

app/code/Magento/Catalog/Model/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ protected function getCustomAttributesCodes()
525525
public function getStoreId()
526526
{
527527
if ($this->hasData(self::STORE_ID)) {
528-
return $this->getData(self::STORE_ID);
528+
return (int)$this->getData(self::STORE_ID);
529529
}
530-
return $this->_storeManager->getStore()->getId();
530+
return (int)$this->_storeManager->getStore()->getId();
531531
}
532532

533533
/**

app/code/Magento/Customer/Model/GroupManagement.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
namespace Magento\Customer\Model;
99

1010
use Magento\Customer\Api\Data\GroupInterface;
11+
use Magento\Customer\Api\Data\GroupInterfaceFactory;
12+
use Magento\Customer\Api\GroupRepositoryInterface;
13+
use Magento\Framework\Api\FilterBuilder;
1114
use Magento\Framework\Api\SearchCriteriaBuilder;
15+
use Magento\Framework\Api\SortOrderBuilder;
1216
use Magento\Framework\App\Config\ScopeConfigInterface;
13-
use Magento\Framework\Api\FilterBuilder;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Data\Collection;
1419
use Magento\Framework\Exception\NoSuchEntityException;
1520
use Magento\Store\Model\StoreManagerInterface;
16-
use Magento\Customer\Api\GroupRepositoryInterface;
17-
use Magento\Customer\Api\Data\GroupInterfaceFactory;
18-
use Magento\Customer\Model\GroupFactory;
1921

2022
/**
23+
* The class contains methods for getting information about a customer group
24+
*
2125
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2226
*/
2327
class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
@@ -65,6 +69,11 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
6569
*/
6670
protected $filterBuilder;
6771

72+
/**
73+
* @var SortOrderBuilder
74+
*/
75+
private $sortOrderBuilder;
76+
6877
/**
6978
* @param StoreManagerInterface $storeManager
7079
* @param ScopeConfigInterface $scopeConfig
@@ -73,6 +82,7 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
7382
* @param GroupInterfaceFactory $groupDataFactory
7483
* @param SearchCriteriaBuilder $searchCriteriaBuilder
7584
* @param FilterBuilder $filterBuilder
85+
* @param SortOrderBuilder $sortOrderBuilder
7686
*/
7787
public function __construct(
7888
StoreManagerInterface $storeManager,
@@ -81,7 +91,8 @@ public function __construct(
8191
GroupRepositoryInterface $groupRepository,
8292
GroupInterfaceFactory $groupDataFactory,
8393
SearchCriteriaBuilder $searchCriteriaBuilder,
84-
FilterBuilder $filterBuilder
94+
FilterBuilder $filterBuilder,
95+
SortOrderBuilder $sortOrderBuilder = null
8596
) {
8697
$this->storeManager = $storeManager;
8798
$this->scopeConfig = $scopeConfig;
@@ -90,10 +101,12 @@ public function __construct(
90101
$this->groupDataFactory = $groupDataFactory;
91102
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
92103
$this->filterBuilder = $filterBuilder;
104+
$this->sortOrderBuilder = $sortOrderBuilder ?: ObjectManager::getInstance()
105+
->get(SortOrderBuilder::class);
93106
}
94107

95108
/**
96-
* {@inheritdoc}
109+
* @inheritdoc
97110
*/
98111
public function isReadonly($groupId)
99112
{
@@ -107,7 +120,7 @@ public function isReadonly($groupId)
107120
}
108121

109122
/**
110-
* {@inheritdoc}
123+
* @inheritdoc
111124
*/
112125
public function getDefaultGroup($storeId = null)
113126
{
@@ -133,15 +146,15 @@ public function getDefaultGroup($storeId = null)
133146
}
134147

135148
/**
136-
* {@inheritdoc}
149+
* @inheritdoc
137150
*/
138151
public function getNotLoggedInGroup()
139152
{
140153
return $this->groupRepository->getById(self::NOT_LOGGED_IN_ID);
141154
}
142155

143156
/**
144-
* {@inheritdoc}
157+
* @inheritdoc
145158
*/
146159
public function getLoggedInGroups()
147160
{
@@ -155,15 +168,20 @@ public function getLoggedInGroups()
155168
->setConditionType('neq')
156169
->setValue(self::CUST_GROUP_ALL)
157170
->create();
171+
$groupNameSortOrder = $this->sortOrderBuilder
172+
->setField('customer_group_code')
173+
->setDirection(Collection::SORT_ORDER_ASC)
174+
->create();
158175
$searchCriteria = $this->searchCriteriaBuilder
159176
->addFilters($notLoggedInFilter)
160177
->addFilters($groupAll)
178+
->addSortOrder($groupNameSortOrder)
161179
->create();
162180
return $this->groupRepository->getList($searchCriteria)->getItems();
163181
}
164182

165183
/**
166-
* {@inheritdoc}
184+
* @inheritdoc
167185
*/
168186
public function getAllCustomersGroup()
169187
{

app/code/Magento/Directory/Model/ResourceModel/Country/Collection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ public function setForegroundCountries($foregroundCountries)
349349
}
350350

351351
/**
352+
* @deprecated use \Magento\Directory\Helper\Data::getCountriesWithStatesRequired() instead
353+
*
352354
* Get list of countries with required states
353355
*
354356
* @return \Magento\Directory\Model\Country[]

app/code/Magento/Directory/Setup/UpgradeData.php

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(Data $directoryData)
3232
}
3333

3434
/**
35-
* Upgrades data for Directry module.
35+
* Upgrades data for Directory module.
3636
*
3737
* @param ModuleDataSetupInterface $setup
3838
* @param ModuleContextInterface $context
@@ -41,10 +41,10 @@ public function __construct(Data $directoryData)
4141
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
4242
{
4343
if (version_compare($context->getVersion(), '2.0.1', '<')) {
44-
$this->addCountryRegions($setup, $this->getDataForCroatia());
44+
$this->addCountryRegions($setup, 'HR', $this->getDataForCroatia());
4545
}
4646
if (version_compare($context->getVersion(), '2.0.2', '<')) {
47-
$this->addCountryRegions($setup, $this->getDataForIndia());
47+
$this->addCountryRegions($setup, 'IN', $this->getDataForIndia());
4848
}
4949
}
5050

@@ -56,27 +56,27 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
5656
private function getDataForCroatia()
5757
{
5858
return [
59-
['HR', 'HR-01', 'Zagrebačka županija'],
60-
['HR', 'HR-02', 'Krapinsko-zagorska županija'],
61-
['HR', 'HR-03', 'Sisačko-moslavačka županija'],
62-
['HR', 'HR-04', 'Karlovačka županija'],
63-
['HR', 'HR-05', 'Varaždinska županija'],
64-
['HR', 'HR-06', 'Koprivničko-križevačka županija'],
65-
['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'],
66-
['HR', 'HR-08', 'Primorsko-goranska županija'],
67-
['HR', 'HR-09', 'Ličko-senjska županija'],
68-
['HR', 'HR-10', 'Virovitičko-podravska županija'],
69-
['HR', 'HR-11', 'Požeško-slavonska županija'],
70-
['HR', 'HR-12', 'Brodsko-posavska županija'],
71-
['HR', 'HR-13', 'Zadarska županija'],
72-
['HR', 'HR-14', 'Osječko-baranjska županija'],
73-
['HR', 'HR-15', 'Šibensko-kninska županija'],
74-
['HR', 'HR-16', 'Vukovarsko-srijemska županija'],
75-
['HR', 'HR-17', 'Splitsko-dalmatinska županija'],
76-
['HR', 'HR-18', 'Istarska županija'],
77-
['HR', 'HR-19', 'Dubrovačko-neretvanska županija'],
78-
['HR', 'HR-20', 'Međimurska županija'],
79-
['HR', 'HR-21', 'Grad Zagreb']
59+
'HR-01' => 'Zagrebačka županija',
60+
'HR-02' => 'Krapinsko-zagorska županija',
61+
'HR-03' => 'Sisačko-moslavačka županija',
62+
'HR-04' => 'Karlovačka županija',
63+
'HR-05' => 'Varaždinska županija',
64+
'HR-06' => 'Koprivničko-križevačka županija',
65+
'HR-07' => 'Bjelovarsko-bilogorska županija',
66+
'HR-08' => 'Primorsko-goranska županija',
67+
'HR-09' => 'Ličko-senjska županija',
68+
'HR-10' => 'Virovitičko-podravska županija',
69+
'HR-11' => 'Požeško-slavonska županija',
70+
'HR-12' => 'Brodsko-posavska županija',
71+
'HR-13' => 'Zadarska županija',
72+
'HR-14' => 'Osječko-baranjska županija',
73+
'HR-15' => 'Šibensko-kninska županija',
74+
'HR-16' => 'Vukovarsko-srijemska županija',
75+
'HR-17' => 'Splitsko-dalmatinska županija',
76+
'HR-18' => 'Istarska županija',
77+
'HR-19' => 'Dubrovačko-neretvanska županija',
78+
'HR-20' => 'Međimurska županija',
79+
'HR-21' => 'Grad Zagreb',
8080
];
8181
}
8282

@@ -88,73 +88,74 @@ private function getDataForCroatia()
8888
private function getDataForIndia()
8989
{
9090
return [
91-
['IN', 'AN', 'Andaman and Nicobar Islands'],
92-
['IN', 'AP', 'Andhra Pradesh'],
93-
['IN', 'AR', 'Arunachal Pradesh'],
94-
['IN', 'AS', 'Assam'],
95-
['IN', 'BR', 'Bihar'],
96-
['IN', 'CH', 'Chandigarh'],
97-
['IN', 'CT', 'Chhattisgarh'],
98-
['IN', 'DN', 'Dadra and Nagar Haveli'],
99-
['IN', 'DD', 'Daman and Diu'],
100-
['IN', 'DL', 'Delhi'],
101-
['IN', 'GA', 'Goa'],
102-
['IN', 'GJ', 'Gujarat'],
103-
['IN', 'HR', 'Haryana'],
104-
['IN', 'HP', 'Himachal Pradesh'],
105-
['IN', 'JK', 'Jammu and Kashmir'],
106-
['IN', 'JH', 'Jharkhand'],
107-
['IN', 'KA', 'Karnataka'],
108-
['IN', 'KL', 'Kerala'],
109-
['IN', 'LD', 'Lakshadweep'],
110-
['IN', 'MP', 'Madhya Pradesh'],
111-
['IN', 'MH', 'Maharashtra'],
112-
['IN', 'MN', 'Manipur'],
113-
['IN', 'ML', 'Meghalaya'],
114-
['IN', 'MZ', 'Mizoram'],
115-
['IN', 'NL', 'Nagaland'],
116-
['IN', 'OR', 'Odisha'],
117-
['IN', 'PY', 'Puducherry'],
118-
['IN', 'PB', 'Punjab'],
119-
['IN', 'RJ', 'Rajasthan'],
120-
['IN', 'SK', 'Sikkim'],
121-
['IN', 'TN', 'Tamil Nadu'],
122-
['IN', 'TG', 'Telangana'],
123-
['IN', 'TR', 'Tripura'],
124-
['IN', 'UP', 'Uttar Pradesh'],
125-
['IN', 'UT', 'Uttarakhand'],
126-
['IN', 'WB', 'West Bengal']
91+
'AN' => 'Andaman and Nicobar Islands',
92+
'AP' => 'Andhra Pradesh',
93+
'AR' => 'Arunachal Pradesh',
94+
'AS' => 'Assam',
95+
'BR' => 'Bihar',
96+
'CH' => 'Chandigarh',
97+
'CT' => 'Chhattisgarh',
98+
'DN' => 'Dadra and Nagar Haveli',
99+
'DD' => 'Daman and Diu',
100+
'DL' => 'Delhi',
101+
'GA' => 'Goa',
102+
'GJ' => 'Gujarat',
103+
'HR' => 'Haryana',
104+
'HP' => 'Himachal Pradesh',
105+
'JK' => 'Jammu and Kashmir',
106+
'JH' => 'Jharkhand',
107+
'KA' => 'Karnataka',
108+
'KL' => 'Kerala',
109+
'LD' => 'Lakshadweep',
110+
'MP' => 'Madhya Pradesh',
111+
'MH' => 'Maharashtra',
112+
'MN' => 'Manipur',
113+
'ML' => 'Meghalaya',
114+
'MZ' => 'Mizoram',
115+
'NL' => 'Nagaland',
116+
'OR' => 'Odisha',
117+
'PY' => 'Puducherry',
118+
'PB' => 'Punjab',
119+
'RJ' => 'Rajasthan',
120+
'SK' => 'Sikkim',
121+
'TN' => 'Tamil Nadu',
122+
'TG' => 'Telangana',
123+
'TR' => 'Tripura',
124+
'UP' => 'Uttar Pradesh',
125+
'UT' => 'Uttarakhand',
126+
'WB' => 'West Bengal',
127127
];
128128
}
129129

130130
/**
131131
* Add country regions data to appropriate tables.
132132
*
133133
* @param ModuleDataSetupInterface $setup
134+
* @param string $countryId
134135
* @param array $data
135136
* @return void
136137
*/
137-
private function addCountryRegions(ModuleDataSetupInterface $setup, array $data)
138+
private function addCountryRegions(ModuleDataSetupInterface $setup, string $countryId, array $data)
138139
{
139140
/**
140141
* Fill table directory/country_region
141142
* Fill table directory/country_region_name for en_US locale
142143
*/
143-
foreach ($data as $row) {
144-
$bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
144+
foreach ($data as $code => $name) {
145+
$bind = ['country_id' => $countryId, 'code' => $code, 'default_name' => $name];
145146
$setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
146147
$regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
147-
$bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
148+
$bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $name];
148149
$setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
149150
}
151+
150152
/**
151153
* Upgrade core_config_data general/region/state_required field.
152154
*/
153-
$countries = $this->directoryData->getCountryCollection()->getCountriesWithRequiredStates();
154155
$setup->getConnection()->update(
155156
$setup->getTable('core_config_data'),
156157
[
157-
'value' => implode(',', array_keys($countries))
158+
'value' => new \Zend_Db_Expr("CONCAT(value, '," . $countryId . "')")
158159
],
159160
[
160161
'scope="default"',

lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,12 @@ define([
461461
decodeDirectives: function (content) {
462462
// escape special chars in directives url to use it in regular expression
463463
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
464-
reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));
464+
reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)')),
465+
uriReg = /___directive\/(.*)\/key\//g;
466+
467+
content = content.replace(uriReg, function (match) {
468+
return decodeURIComponent(match);
469+
});
465470

466471
return content.gsub(reg, function (match) { //eslint-disable-line no-extra-bind
467472
return Base64.mageDecode(match[1]);

0 commit comments

Comments
 (0)