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:
 - magento#18427: [Backport] Fix wrong return type in StockRegistryInterface API (by @lewisvoncken)
 - magento#18390: Backport 2.2 - Don't set a source model on the attribute when it's no� (by @hostep)
 - magento#18403: Fix setup wizard page logo (by @rafaelstz)
 - magento#18425: [Backport] Fixing Snake Case To Camel Case (by @lewisvoncken)
 - magento#18422: [BACKPORT] Replace sort callbacks to spaceship operator (by @lewisvoncken)
 - magento#18389: Backport 2.2 - Introducing a dedicated cron.log file for logging cron� (by @hostep)
 - magento#17823: [FEATURE] [issue-3283] Added Filter Support for Yes/No (boolean) attr� (by @lewisvoncken)
 - magento#18166: Fix table rate failing for zip+4 address magento#17770 (by @magently)
 - magento#18175: Fix category tree in cart price rule magento#17493 (by @magently)


Fixed GitHub Issues:
 - magento#15085: StockRegistryInterface :: getLowStockItems() returns StockStatusCollection instead of StockItemCollection (reported by @jesse-dev) has been fixed in magento#18427 by @lewisvoncken in 2.2-develop branch
   Related commits:
     1. adfb130

 - magento#13156: Updating attribute option data through API will set unwanted source_model on the attribute (reported by @koenner01) has been fixed in magento#18390 by @hostep in 2.2-develop branch
   Related commits:
     1. 3e066db

 - magento#17190: system.log rapidly increasing after Magento CE 2.2.5 update (cron logs) (reported by @mad-develop) has been fixed in magento#18389 by @hostep in 2.2-develop branch
   Related commits:
     1. a251a8d

 - magento#3283: «Yes/No» attributes should be allowed in the Layered Navigation (reported by @dmitry-fedyuk) has been fixed in magento#17823 by @lewisvoncken in 2.2-develop branch
   Related commits:
     1. 952b333
     2. a2d9a6a

 - magento#17770: Table rate fail when using ZIP+4 shipping address (reported by @werfu) has been fixed in magento#18166 by @magently in 2.2-develop branch
   Related commits:
     1. 6e4a4b2

 - magento#17493: Catalog Rule & Selected Categories with level > 3 (reported by @SKovbel) has been fixed in magento#18175 by @magently in 2.2-develop branch
   Related commits:
     1. 9f19592
  • Loading branch information
magento-engcom-team authored Oct 9, 2018
2 parents bb68603 + ab24dbe commit 11d9560
Show file tree
Hide file tree
Showing 26 changed files with 77 additions and 82 deletions.
8 changes: 1 addition & 7 deletions app/code/Magento/Backend/Block/Widget/Button/ButtonList.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ public function getItems()
*/
public function sortButtons(Item $itemA, Item $itemB)
{
$sortOrderA = (int)$itemA->getSortOrder();
$sortOrderB = (int)$itemB->getSortOrder();

if ($sortOrderA == $sortOrderB) {
return 0;
}
return ($sortOrderA < $sortOrderB) ? -1 : 1;
return (int)$itemA->getSortOrder() <=> (int)$itemB->getSortOrder();
}
}
6 changes: 2 additions & 4 deletions app/code/Magento/Bundle/Model/Product/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,10 +1013,8 @@ public function shakeSelections($firstItem, $secondItem)
$secondItem->getPosition(),
$secondItem->getSelectionId(),
];
if ($aPosition == $bPosition) {
return 0;
}
return $aPosition < $bPosition ? -1 : 1;

return $aPosition <=> $bPosition;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ protected function _isOriginalIndexable()
$backendType = $this->getOrigData('backend_type');
$frontendInput = $this->getOrigData('frontend_input');

if ($backendType == 'int' && $frontendInput == 'select') {
if ($backendType == 'int' && ($frontendInput == 'select' || $frontendInput == 'boolean')) {
return true;
} elseif ($backendType == 'varchar' && $frontendInput == 'multiselect') {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function _getIndexableAttributes($multiSelect)
if ($multiSelect == true) {
$select->where('ea.backend_type = ?', 'varchar')->where('ea.frontend_input = ?', 'multiselect');
} else {
$select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input = ?', 'select');
$select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input IN( ? )', ['select', 'boolean']);
}

return $this->getConnection()->fetchCol($select);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function bindAttributeInputType()
{
checkOptionsPanelVisibility();
switchDefaultValueField();
if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
if($('frontend_input') && ($('frontend_input').value=='boolean' || $('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
if($('is_filterable') && !$('is_filterable').getAttribute('readonly')){
$('is_filterable').disabled = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ define([

categoryLoader.on('beforeload', function (treeLoader, node) {
treeLoader.baseParams.id = node.attributes.id;
treeLoader.baseParams.selected = options.jsFormObject.updateElement.value;
});

/* eslint-disable */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getProductStockStatusBySku($productSku, $scopeId = null);
* @param float $qty
* @param int $currentPage
* @param int $pageSize
* @return \Magento\CatalogInventory\Api\Data\StockStatusCollectionInterface
* @return \Magento\CatalogInventory\Api\Data\StockItemCollectionInterface
*/
public function getLowStockItems($scopeId, $qty, $currentPage = 1, $pageSize = 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ public function execute()
if (!($category = $this->_initCategory())) {
return;
}
$selected = $this->getRequest()->getPost('selected', '');
$block = $this->_view->getLayout()->createBlock(
\Magento\Catalog\Block\Adminhtml\Category\Checkboxes\Tree::class
)->setCategoryIds(
[$categoryId]
explode(',', $selected)
);
$this->getResponse()->representJson(
$block->getTreeJson($category)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ protected function _cmp($elementA, $elementB)
$sortIndexB = (float)$elementB['sortOrder'];
}

if ($sortIndexA == $sortIndexB) {
return 0;
}

return $sortIndexA < $sortIndexB ? -1 : 1;
return $sortIndexA <=> $sortIndexB;
}
}
13 changes: 13 additions & 0 deletions app/code/Magento/Cron/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
<type name="Magento\Framework\App\Config\Initial\Converter">
<plugin name="cron_system_config_initial_converter_plugin" type="Magento\Cron\Model\System\Config\Initial\Converter" />
</type>
<virtualType name="Magento\Cron\Model\VirtualLoggerHandler" type="Magento\Framework\Logger\Handler\Base">
<arguments>
<argument name="fileName" xsi:type="string">/var/log/cron.log</argument>
</arguments>
</virtualType>
<virtualType name="Magento\Cron\Model\VirtualLogger" type="Magento\Framework\Logger\Monolog">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="system" xsi:type="object">Magento\Cron\Model\VirtualLoggerHandler</item>
</argument>
</arguments>
</virtualType>
<!-- @api -->
<virtualType name="shellBackground" type="Magento\Framework\Shell">
<arguments>
Expand All @@ -25,6 +37,7 @@
<type name="Magento\Cron\Observer\ProcessCronQueueObserver">
<arguments>
<argument name="shell" xsi:type="object">shellBackground</argument>
<argument name="logger" xsi:type="object">Magento\Cron\Model\VirtualLogger</argument>
</arguments>
</type>
<type name="Magento\Framework\Console\CommandListInterface">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,7 @@ public function getValidator($section)
private function sort(array $data)
{
uasort($data, function (array $a, array $b) {
$a['sort_order'] = $this->getSortOrder($a);
$b['sort_order'] = $this->getSortOrder($b);

if ($a['sort_order'] == $b['sort_order']) {
return 0;
}

return ($a['sort_order'] < $b['sort_order']) ? -1 : 1;
return $this->getSortOrder($a) <=> $this->getSortOrder($b);
});

return $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,11 @@ public function getSource()
{
if (empty($this->_source)) {
if (!$this->getSourceModel()) {
$this->setSourceModel($this->_getDefaultSourceModel());
$this->_source = $this->_getDefaultSourceModel();
} else {
$this->_source = $this->getSourceModel();
}
$source = $this->_universalFactory->create($this->getSourceModel());
$source = $this->_universalFactory->create($this->_source);
if (!$source) {
throw new LocalizedException(
__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
[
'name' => 'is_filterable',
'label' => __("Use in Layered Navigation"),
'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'),
'title' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price'),
'note' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price.'),
'values' => [
['value' => '0', 'label' => __('No')],
['value' => '1', 'label' => __('Filterable (with results)')],
Expand All @@ -70,8 +70,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
[
'name' => 'is_filterable_in_search',
'label' => __("Use in Search Results Layered Navigation"),
'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'),
'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'),
'title' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price'),
'note' => __('Can be used only with catalog input type Yes/No, Dropdown, Multiple Select and Price.'),
'values' => $this->optionList->toOptionArray(),
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="valuesForEnable" xsi:type="array">
<item name="boolean" xsi:type="string">boolean</item>
<item name="select" xsi:type="string">select</item>
<item name="multiselect" xsi:type="string">multiselect</item>
<item name="price" xsi:type="string">price</item>
Expand All @@ -19,7 +20,7 @@
</item>
</argument>
<settings>
<notice translate="true">Can be used only with catalog input type Dropdown, Multiple Select and Price.</notice>
<notice translate="true">Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.</notice>
<dataType>string</dataType>
<label translate="true">Use in Layered Navigation</label>
<dataScope>is_filterable</dataScope>
Expand All @@ -36,6 +37,7 @@
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="valuesForEnable" xsi:type="array">
<item name="boolean" xsi:type="string">boolean</item>
<item name="select" xsi:type="string">select</item>
<item name="multiselect" xsi:type="string">multiselect</item>
<item name="price" xsi:type="string">price</item>
Expand All @@ -45,7 +47,7 @@
</item>
</argument>
<settings>
<notice translate="true">Can be used only with catalog input type Dropdown, Multiple Select and Price.</notice>
<notice translate="true">Can be used only with catalog input type Yes/No (Boolean), Dropdown, Multiple Select and Price.</notice>
<label translate="true">Use in Search Results Layered Navigation</label>
<dataScope>is_filterable_in_search</dataScope>
<imports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function prepareSelect(\Magento\Framework\DB\Select $select)
') OR (',
[
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode_prefix",
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",

// Handle asterisk in dest_zip field
Expand All @@ -51,7 +52,7 @@ public function prepareSelect(\Magento\Framework\DB\Select $select)
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'"
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode_prefix"
]
) . ')';
$select->where($orWhere);
Expand Down Expand Up @@ -85,6 +86,7 @@ public function getBindings()
':country_id' => $this->request->getDestCountryId(),
':region_id' => (int)$this->request->getDestRegionId(),
':postcode' => $this->request->getDestPostcode(),
':postcode_prefix' => $this->getDestPostcodePrefix()
];

// Render condition by condition name
Expand Down Expand Up @@ -112,4 +114,18 @@ public function getRequest()
{
return $this->request;
}

/**
* Returns the entire postcode if it contains no dash
* or the part of it prior to the dash in the other case
* @return string
*/
private function getDestPostcodePrefix()
{
if (!preg_match("/^(.+)-(.+)$/", $this->request->getDestPostcode(), $zipParts)) {
return $this->request->getDestPostcode();
}

return $zipParts[1];
}
}
5 changes: 1 addition & 4 deletions app/code/Magento/Paypal/Model/Express/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,7 @@ protected function _prepareShippingOptions(Address $address, $mayReturnEmpty = f
*/
protected static function cmpShippingOptions(DataObject $option1, DataObject $option2)
{
if ($option1->getAmount() == $option2->getAmount()) {
return 0;
}
return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1;
return $option1->getAmount() <=> $option2->getAmount();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,7 @@ public static function sortHistoryByTimestamp($a, $b)
$createdAtA = $a['created_at'];
$createdAtB = $b['created_at'];

/** @var $createdAtA \DateTime */
if ($createdAtA->getTimestamp() == $createdAtB->getTimestamp()) {
return 0;
}
return $createdAtA->getTimestamp() < $createdAtB->getTimestamp() ? -1 : 1;
return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp();
}

/**
Expand Down
6 changes: 1 addition & 5 deletions app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,7 @@ protected function _sortTotalsList($a, $b)
return 0;
}

if ($a['sort_order'] == $b['sort_order']) {
return 0;
}

return $a['sort_order'] > $b['sort_order'] ? 1 : -1;
return $a['sort_order'] <=> $b['sort_order'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
namespace Magento\Signifyd\Model\CaseServices;

use Magento\Framework\Api\SimpleDataObjectConverter;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
Expand Down Expand Up @@ -73,7 +73,6 @@ public function __construct(
* @param CaseInterface $case
* @param array $data
* @return void
* @throws NotFoundException
* @throws LocalizedException
*/
public function update(CaseInterface $case, array $data)
Expand Down Expand Up @@ -111,7 +110,7 @@ private function setCaseData(CaseInterface $case, array $data)
'orderId'
];
foreach ($data as $key => $value) {
$methodName = 'set' . ucfirst($key);
$methodName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key);
if (!in_array($key, $notResolvedKeys) && method_exists($case, $methodName)) {
call_user_func([$case, $methodName], $value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ define([
get tabsFront() {
return this.attrTabsFront.length ? this.attrTabsFront.closest('li') : $('#front_fieldset-wrapper');
},
selectFields: ['select', 'multiselect', 'price', 'swatch_text', 'swatch_visual'],
selectFields: ['boolean', 'select', 'multiselect', 'price', 'swatch_text', 'swatch_visual'],

/**
* @this {swatchProductAttributes}
Expand Down
9 changes: 1 addition & 8 deletions app/code/Magento/Ui/DataProvider/Modifier/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,7 @@ public function getModifiersInstances()
protected function sort(array $data)
{
usort($data, function (array $a, array $b) {
$a['sortOrder'] = $this->getSortOrder($a);
$b['sortOrder'] = $this->getSortOrder($b);

if ($a['sortOrder'] == $b['sortOrder']) {
return 0;
}

return ($a['sortOrder'] < $b['sortOrder']) ? -1 : 1;
return $this->getSortOrder($a) <=> $this->getSortOrder($b);
});

return $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private function isPropertyDeclaredInDataObject(
$index = array_search($serviceMethodParamName, array_column($methodParams, 'name'));
if ($index !== false) {
$paramObjectType = $methodParams[$index][MethodsMap::METHOD_META_TYPE];
$setter = 'set' . ucfirst(SimpleDataObjectConverter::snakeCaseToCamelCase($objectProperty));
$setter = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($objectProperty);
if (array_key_exists(
$setter,
$this->getMethodsMap()->getMethodsMap($paramObjectType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ protected function sortDownloadableArray(array $fields)
usort(
$fields,
function ($row1, $row2) {
if ($row1['sort_order'] == $row2['sort_order']) {
return 0;
}

return ($row1['sort_order'] < $row2['sort_order']) ? -1 : 1;
return $row1['sort_order'] <=> $row2['sort_order'];
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Magento\Framework\Convert\ConvertArray;
use Magento\Framework\Reflection\DataObjectProcessor;

/**
* Data object converter.
*/
class SimpleDataObjectConverter
{
/**
Expand Down Expand Up @@ -156,14 +159,13 @@ public static function snakeCaseToUpperCamelCase($input)
*/
public static function snakeCaseToCamelCase($input)
{
return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $input))));
return lcfirst(self::snakeCaseToUpperCamelCase($input));
}

/**
* Convert a CamelCase string read from method into field key in snake_case
*
* e.g. DefaultShipping => default_shipping
* Postcode => postcode
* For example [DefaultShipping => default_shipping, Postcode => postcode]
*
* @param string $name
* @return string
Expand Down
Loading

0 comments on commit 11d9560

Please sign in to comment.