Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
magento-engcom-team authored Sep 28, 2018
2 parents 4557bfe + 89e5c60 commit 77bc93f
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 83 deletions.
13 changes: 9 additions & 4 deletions app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements

const CACHE_TAG = 'cat_c';

/**
* Category Store Id
*/
const STORE_ID = 'store_id';

/**#@+
* Constants
*/
Expand Down Expand Up @@ -588,12 +593,12 @@ public function getStoreIds()
*
* If store id is underfined for category return current active store id
*
* @return integer
* @return int
*/
public function getStoreId()
{
if ($this->hasData('store_id')) {
return (int)$this->_getData('store_id');
if ($this->hasData(self::STORE_ID)) {
return (int)$this->_getData(self::STORE_ID);
}
return (int)$this->_storeManager->getStore()->getId();
}
Expand All @@ -609,7 +614,7 @@ public function setStoreId($storeId)
if (!is_numeric($storeId)) {
$storeId = $this->_storeManager->getStore($storeId)->getId();
}
$this->setData('store_id', $storeId);
$this->setData(self::STORE_ID, $storeId);
$this->getResource()->setStoreId($storeId);
return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,9 @@ protected function getCustomAttributesCodes()
public function getStoreId()
{
if ($this->hasData(self::STORE_ID)) {
return $this->getData(self::STORE_ID);
return (int)$this->getData(self::STORE_ID);
}
return $this->_storeManager->getStore()->getId();
return (int)$this->_storeManager->getStore()->getId();
}

/**
Expand Down
38 changes: 28 additions & 10 deletions app/code/Magento/Customer/Model/GroupManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
namespace Magento\Customer\Model;

use Magento\Customer\Api\Data\GroupInterface;
use Magento\Customer\Api\Data\GroupInterfaceFactory;
use Magento\Customer\Api\GroupRepositoryInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Data\Collection;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Api\GroupRepositoryInterface;
use Magento\Customer\Api\Data\GroupInterfaceFactory;
use Magento\Customer\Model\GroupFactory;

/**
* The class contains methods for getting information about a customer group
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
Expand Down Expand Up @@ -65,6 +69,11 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
*/
protected $filterBuilder;

/**
* @var SortOrderBuilder
*/
private $sortOrderBuilder;

/**
* @param StoreManagerInterface $storeManager
* @param ScopeConfigInterface $scopeConfig
Expand All @@ -73,6 +82,7 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
* @param GroupInterfaceFactory $groupDataFactory
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
* @param SortOrderBuilder $sortOrderBuilder
*/
public function __construct(
StoreManagerInterface $storeManager,
Expand All @@ -81,7 +91,8 @@ public function __construct(
GroupRepositoryInterface $groupRepository,
GroupInterfaceFactory $groupDataFactory,
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder
FilterBuilder $filterBuilder,
SortOrderBuilder $sortOrderBuilder = null
) {
$this->storeManager = $storeManager;
$this->scopeConfig = $scopeConfig;
Expand All @@ -90,10 +101,12 @@ public function __construct(
$this->groupDataFactory = $groupDataFactory;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->sortOrderBuilder = $sortOrderBuilder ?: ObjectManager::getInstance()
->get(SortOrderBuilder::class);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function isReadonly($groupId)
{
Expand All @@ -107,7 +120,7 @@ public function isReadonly($groupId)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getDefaultGroup($storeId = null)
{
Expand All @@ -133,15 +146,15 @@ public function getDefaultGroup($storeId = null)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getNotLoggedInGroup()
{
return $this->groupRepository->getById(self::NOT_LOGGED_IN_ID);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getLoggedInGroups()
{
Expand All @@ -155,15 +168,20 @@ public function getLoggedInGroups()
->setConditionType('neq')
->setValue(self::CUST_GROUP_ALL)
->create();
$groupNameSortOrder = $this->sortOrderBuilder
->setField('customer_group_code')
->setDirection(Collection::SORT_ORDER_ASC)
->create();
$searchCriteria = $this->searchCriteriaBuilder
->addFilters($notLoggedInFilter)
->addFilters($groupAll)
->addSortOrder($groupNameSortOrder)
->create();
return $this->groupRepository->getList($searchCriteria)->getItems();
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getAllCustomersGroup()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ public function setForegroundCountries($foregroundCountries)
}

/**
* @deprecated use \Magento\Directory\Helper\Data::getCountriesWithStatesRequired() instead
*
* Get list of countries with required states
*
* @return \Magento\Directory\Model\Country[]
Expand Down
133 changes: 67 additions & 66 deletions app/code/Magento/Directory/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(Data $directoryData)
}

/**
* Upgrades data for Directry module.
* Upgrades data for Directory module.
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
Expand All @@ -41,10 +41,10 @@ public function __construct(Data $directoryData)
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->addCountryRegions($setup, $this->getDataForCroatia());
$this->addCountryRegions($setup, 'HR', $this->getDataForCroatia());
}
if (version_compare($context->getVersion(), '2.0.2', '<')) {
$this->addCountryRegions($setup, $this->getDataForIndia());
$this->addCountryRegions($setup, 'IN', $this->getDataForIndia());
}
}

Expand All @@ -56,27 +56,27 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
private function getDataForCroatia()
{
return [
['HR', 'HR-01', 'Zagrebačka županija'],
['HR', 'HR-02', 'Krapinsko-zagorska županija'],
['HR', 'HR-03', 'Sisačko-moslavačka županija'],
['HR', 'HR-04', 'Karlovačka županija'],
['HR', 'HR-05', 'Varaždinska županija'],
['HR', 'HR-06', 'Koprivničko-križevačka županija'],
['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'],
['HR', 'HR-08', 'Primorsko-goranska županija'],
['HR', 'HR-09', 'Ličko-senjska županija'],
['HR', 'HR-10', 'Virovitičko-podravska županija'],
['HR', 'HR-11', 'Požeško-slavonska županija'],
['HR', 'HR-12', 'Brodsko-posavska županija'],
['HR', 'HR-13', 'Zadarska županija'],
['HR', 'HR-14', 'Osječko-baranjska županija'],
['HR', 'HR-15', 'Šibensko-kninska županija'],
['HR', 'HR-16', 'Vukovarsko-srijemska županija'],
['HR', 'HR-17', 'Splitsko-dalmatinska županija'],
['HR', 'HR-18', 'Istarska županija'],
['HR', 'HR-19', 'Dubrovačko-neretvanska županija'],
['HR', 'HR-20', 'Međimurska županija'],
['HR', 'HR-21', 'Grad Zagreb']
'HR-01' => 'Zagrebačka županija',
'HR-02' => 'Krapinsko-zagorska županija',
'HR-03' => 'Sisačko-moslavačka županija',
'HR-04' => 'Karlovačka županija',
'HR-05' => 'Varaždinska županija',
'HR-06' => 'Koprivničko-križevačka županija',
'HR-07' => 'Bjelovarsko-bilogorska županija',
'HR-08' => 'Primorsko-goranska županija',
'HR-09' => 'Ličko-senjska županija',
'HR-10' => 'Virovitičko-podravska županija',
'HR-11' => 'Požeško-slavonska županija',
'HR-12' => 'Brodsko-posavska županija',
'HR-13' => 'Zadarska županija',
'HR-14' => 'Osječko-baranjska županija',
'HR-15' => 'Šibensko-kninska županija',
'HR-16' => 'Vukovarsko-srijemska županija',
'HR-17' => 'Splitsko-dalmatinska županija',
'HR-18' => 'Istarska županija',
'HR-19' => 'Dubrovačko-neretvanska županija',
'HR-20' => 'Međimurska županija',
'HR-21' => 'Grad Zagreb',
];
}

Expand All @@ -88,73 +88,74 @@ private function getDataForCroatia()
private function getDataForIndia()
{
return [
['IN', 'AN', 'Andaman and Nicobar Islands'],
['IN', 'AP', 'Andhra Pradesh'],
['IN', 'AR', 'Arunachal Pradesh'],
['IN', 'AS', 'Assam'],
['IN', 'BR', 'Bihar'],
['IN', 'CH', 'Chandigarh'],
['IN', 'CT', 'Chhattisgarh'],
['IN', 'DN', 'Dadra and Nagar Haveli'],
['IN', 'DD', 'Daman and Diu'],
['IN', 'DL', 'Delhi'],
['IN', 'GA', 'Goa'],
['IN', 'GJ', 'Gujarat'],
['IN', 'HR', 'Haryana'],
['IN', 'HP', 'Himachal Pradesh'],
['IN', 'JK', 'Jammu and Kashmir'],
['IN', 'JH', 'Jharkhand'],
['IN', 'KA', 'Karnataka'],
['IN', 'KL', 'Kerala'],
['IN', 'LD', 'Lakshadweep'],
['IN', 'MP', 'Madhya Pradesh'],
['IN', 'MH', 'Maharashtra'],
['IN', 'MN', 'Manipur'],
['IN', 'ML', 'Meghalaya'],
['IN', 'MZ', 'Mizoram'],
['IN', 'NL', 'Nagaland'],
['IN', 'OR', 'Odisha'],
['IN', 'PY', 'Puducherry'],
['IN', 'PB', 'Punjab'],
['IN', 'RJ', 'Rajasthan'],
['IN', 'SK', 'Sikkim'],
['IN', 'TN', 'Tamil Nadu'],
['IN', 'TG', 'Telangana'],
['IN', 'TR', 'Tripura'],
['IN', 'UP', 'Uttar Pradesh'],
['IN', 'UT', 'Uttarakhand'],
['IN', 'WB', 'West Bengal']
'AN' => 'Andaman and Nicobar Islands',
'AP' => 'Andhra Pradesh',
'AR' => 'Arunachal Pradesh',
'AS' => 'Assam',
'BR' => 'Bihar',
'CH' => 'Chandigarh',
'CT' => 'Chhattisgarh',
'DN' => 'Dadra and Nagar Haveli',
'DD' => 'Daman and Diu',
'DL' => 'Delhi',
'GA' => 'Goa',
'GJ' => 'Gujarat',
'HR' => 'Haryana',
'HP' => 'Himachal Pradesh',
'JK' => 'Jammu and Kashmir',
'JH' => 'Jharkhand',
'KA' => 'Karnataka',
'KL' => 'Kerala',
'LD' => 'Lakshadweep',
'MP' => 'Madhya Pradesh',
'MH' => 'Maharashtra',
'MN' => 'Manipur',
'ML' => 'Meghalaya',
'MZ' => 'Mizoram',
'NL' => 'Nagaland',
'OR' => 'Odisha',
'PY' => 'Puducherry',
'PB' => 'Punjab',
'RJ' => 'Rajasthan',
'SK' => 'Sikkim',
'TN' => 'Tamil Nadu',
'TG' => 'Telangana',
'TR' => 'Tripura',
'UP' => 'Uttar Pradesh',
'UT' => 'Uttarakhand',
'WB' => 'West Bengal',
];
}

/**
* Add country regions data to appropriate tables.
*
* @param ModuleDataSetupInterface $setup
* @param string $countryId
* @param array $data
* @return void
*/
private function addCountryRegions(ModuleDataSetupInterface $setup, array $data)
private function addCountryRegions(ModuleDataSetupInterface $setup, string $countryId, array $data)
{
/**
* Fill table directory/country_region
* Fill table directory/country_region_name for en_US locale
*/
foreach ($data as $row) {
$bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
foreach ($data as $code => $name) {
$bind = ['country_id' => $countryId, 'code' => $code, 'default_name' => $name];
$setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
$regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
$bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
$bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $name];
$setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
}

/**
* Upgrade core_config_data general/region/state_required field.
*/
$countries = $this->directoryData->getCountryCollection()->getCountriesWithRequiredStates();
$setup->getConnection()->update(
$setup->getTable('core_config_data'),
[
'value' => implode(',', array_keys($countries))
'value' => new \Zend_Db_Expr("CONCAT(value, '," . $countryId . "')")
],
[
'scope="default"',
Expand Down
7 changes: 6 additions & 1 deletion lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,12 @@ define([
decodeDirectives: function (content) {
// escape special chars in directives url to use it in regular expression
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));
reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)')),
uriReg = /___directive\/(.*)\/key\//g;

content = content.replace(uriReg, function (match) {
return decodeURIComponent(match);
});

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

0 comments on commit 77bc93f

Please sign in to comment.