Skip to content

Commit

Permalink
Merge pull request magento#906 from magento-engcom/merge-mainline
Browse files Browse the repository at this point in the history
Merge mainline
  • Loading branch information
Volodymyr Kublytskyi authored Apr 13, 2018
2 parents d554b34 + 99f7d58 commit 201bc31
Show file tree
Hide file tree
Showing 1,269 changed files with 51,010 additions and 14,017 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
language: php
php:
- 7.1
- 7.2
env:
global:
- COMPOSER_BIN_DIR=~/bin
Expand All @@ -32,6 +33,16 @@ env:
- TEST_SUITE=integration INTEGRATION_INDEX=2
- TEST_SUITE=integration INTEGRATION_INDEX=3
- TEST_SUITE=functional
matrix:
exclude:
- php: 7.1
env: TEST_SUITE=static
- php: 7.1
env: TEST_SUITE=js GRUNT_COMMAND=spec
- php: 7.1
env: TEST_SUITE=js GRUNT_COMMAND=static
- php: 7.1
env: TEST_SUITE=functional
cache:
apt: true
directories:
Expand Down
14 changes: 12 additions & 2 deletions app/code/Magento/AdminNotification/Block/System/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,34 @@ class Messages extends \Magento\Backend\Block\Template

/**
* @var \Magento\Framework\Json\Helper\Data
* @deprecated
*/
protected $jsonHelper;

/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $serializer;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
* @param array $data
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages,
\Magento\Framework\Json\Helper\Data $jsonHelper,
array $data = []
array $data = [],
\Magento\Framework\Serialize\Serializer\Json $serializer = null
) {
$this->jsonHelper = $jsonHelper;
parent::__construct($context, $data);
$this->_messages = $messages;
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Serialize\Serializer\Json::class);
}

/**
Expand Down Expand Up @@ -117,7 +127,7 @@ protected function _getMessagesUrl()
*/
public function getSystemMessageDialogJson()
{
return $this->jsonHelper->jsonEncode(
return $this->serializer->serialize(
[
'systemMessageDialog' => [
'buttons' => [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public function getPopupTitle()
$messageCount = count($this->_messages->getUnread());
if ($messageCount > 1) {
return __('You have %1 new system messages', $messageCount);
} else {
return __('You have %1 new system message', $messageCount);
}
return __('You have %1 new system message', $messageCount);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/AdminNotification/Block/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ protected function _getLatestItem()
{
if ($this->_latestItem == null) {
$items = array_values($this->_criticalCollection->getItems());
$this->_latestItem = false;
if (count($items)) {
$this->_latestItem = $items[0];
} else {
$this->_latestItem = false;
}
}
return $this->_latestItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
namespace Magento\AdminNotification\Controller\Adminhtml\System\Message;

use Magento\Framework\Controller\ResultFactory;

class ListAction extends \Magento\Backend\App\AbstractAction
{
/**
Expand All @@ -15,6 +17,7 @@ class ListAction extends \Magento\Backend\App\AbstractAction

/**
* @var \Magento\Framework\Json\Helper\Data
* @deprecated
*/
protected $jsonHelper;

Expand All @@ -41,7 +44,7 @@ public function __construct(
}

/**
* @return void
* @return \Magento\Framework\Controller\Result\Json
*/
public function execute()
{
Expand All @@ -63,6 +66,9 @@ public function execute()
. 'Please refresh the web page to clear the notice alert.',
];
}
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($result);
return $resultJson;
}
}
13 changes: 6 additions & 7 deletions app/code/Magento/AdminNotification/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
"sort-packages": true
},
"require": {
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
"php": "~7.1.3||~7.2.0",
"lib-libxml": "*",
"magento/framework": "100.3.*",
"magento/module-backend": "100.3.*",
"magento/module-media-storage": "100.3.*",
"magento/module-store": "100.3.*",
"magento/module-ui": "100.3.*"
"magento/framework": "*",
"magento/module-backend": "*",
"magento/module-media-storage": "*",
"magento/module-store": "*",
"magento/module-ui": "*"
},
"type": "magento2-module",
"version": "100.3.0-dev",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,8 @@ protected function _getCustomerGroupById(
): string {
if ($allGroups !== 0) {
return ImportAdvancedPricing::VALUE_ALL_GROUPS;
} else {
return $this->_groupRepository->getById($groupId)->getCode();
}
return $this->_groupRepository->getById($groupId)->getCode();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,8 @@ protected function deleteProductTierPrices(array $listSku, $table)
$this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, 0);
return false;
}
} else {
return false;
}
return false;
}

/**
Expand Down
19 changes: 9 additions & 10 deletions app/code/Magento/AdvancedPricingImportExport/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
"sort-packages": true
},
"require": {
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
"magento/framework": "100.3.*",
"magento/module-catalog": "101.2.*",
"magento/module-catalog-import-export": "100.3.*",
"magento/module-catalog-inventory": "100.3.*",
"magento/module-customer": "100.3.*",
"magento/module-eav": "100.3.*",
"magento/module-import-export": "100.3.*",
"magento/module-store": "100.3.*"
"php": "~7.1.3||~7.2.0",
"magento/framework": "*",
"magento/module-catalog": "*",
"magento/module-catalog-import-export": "*",
"magento/module-catalog-inventory": "*",
"magento/module-customer": "*",
"magento/module-eav": "*",
"magento/module-import-export": "*",
"magento/module-store": "*"
},
"type": "magento2-module",
"version": "100.3.0-dev",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
19 changes: 9 additions & 10 deletions app/code/Magento/AdvancedSearch/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
"sort-packages": true
},
"require": {
"magento/framework": "100.3.*",
"magento/module-backend": "100.3.*",
"magento/module-catalog": "101.2.*",
"magento/module-catalog-search": "100.3.*",
"magento/module-config": "100.3.*",
"magento/module-customer": "100.3.*",
"magento/module-search": "100.3.*",
"magento/module-store": "100.3.*",
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0"
"magento/framework": "*",
"magento/module-backend": "*",
"magento/module-catalog": "*",
"magento/module-catalog-search": "*",
"magento/module-config": "*",
"magento/module-customer": "*",
"magento/module-search": "*",
"magento/module-store": "*",
"php": "~7.1.3||~7.2.0"
},
"type": "magento2-module",
"version": "100.3.0-dev",
"license": [
"proprietary"
],
Expand Down
42 changes: 41 additions & 1 deletion app/code/Magento/Amqp/Setup/ConfigOptionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ConfigOptionsList implements ConfigOptionsListInterface
const INPUT_KEY_QUEUE_AMQP_PASSWORD = 'amqp-password';
const INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST = 'amqp-virtualhost';
const INPUT_KEY_QUEUE_AMQP_SSL = 'amqp-ssl';
const INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS = 'amqp-ssl-options';

/**
* Path to the values in the deployment config
Expand All @@ -35,6 +36,7 @@ class ConfigOptionsList implements ConfigOptionsListInterface
const CONFIG_PATH_QUEUE_AMQP_PASSWORD = 'queue/amqp/password';
const CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST = 'queue/amqp/virtualhost';
const CONFIG_PATH_QUEUE_AMQP_SSL = 'queue/amqp/ssl';
const CONFIG_PATH_QUEUE_AMQP_SSL_OPTIONS = 'queue/amqp/ssl_options';

/**
* Default values
Expand Down Expand Up @@ -109,6 +111,13 @@ public function getOptions()
'Amqp SSL',
self::DEFAULT_AMQP_SSL
),
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS,
TextConfigOption::FRONTEND_WIZARD_TEXTAREA,
self::CONFIG_PATH_QUEUE_AMQP_SSL_OPTIONS,
'Amqp SSL Options (JSON)',
self::DEFAULT_AMQP_SSL
),
];
}

Expand Down Expand Up @@ -140,6 +149,21 @@ public function createConfig(array $data, DeploymentConfig $deploymentConfig)
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_SSL)) {
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_SSL, $data[self::INPUT_KEY_QUEUE_AMQP_SSL]);
}
if (!$this->isDataEmpty(
$data,
self::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS
)) {
$options = json_decode(
$data[self::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS],
true
);
if ($options !== null) {
$configData->set(
self::CONFIG_PATH_QUEUE_AMQP_SSL_OPTIONS,
$options
);
}
}
}

return [$configData];
Expand All @@ -154,12 +178,28 @@ public function validate(array $options, DeploymentConfig $deploymentConfig)

if (isset($options[self::INPUT_KEY_QUEUE_AMQP_HOST])
&& $options[self::INPUT_KEY_QUEUE_AMQP_HOST] !== '') {
if (!$this->isDataEmpty(
$options,
self::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS
)) {
$sslOptions = json_decode(
$options[self::INPUT_KEY_QUEUE_AMQP_SSL_OPTIONS],
true
);
} else {
$sslOptions = null;
}
$isSslEnabled = !empty($options[self::INPUT_KEY_QUEUE_AMQP_SSL])
&& $options[self::INPUT_KEY_QUEUE_AMQP_SSL] !== 'false';

$result = $this->connectionValidator->isConnectionValid(
$options[self::INPUT_KEY_QUEUE_AMQP_HOST],
$options[self::INPUT_KEY_QUEUE_AMQP_PORT],
$options[self::INPUT_KEY_QUEUE_AMQP_USER],
$options[self::INPUT_KEY_QUEUE_AMQP_PASSWORD],
$options[self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST]
$options[self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST],
$isSslEnabled,
$sslOptions
);

if (!$result) {
Expand Down
49 changes: 39 additions & 10 deletions app/code/Magento/Amqp/Setup/ConnectionValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@
*/
namespace Magento\Amqp\Setup;

use PhpAmqpLib\Connection\AMQPStreamConnection;
use Magento\Framework\Amqp\Connection\Factory as ConnectionFactory;
use Magento\Framework\Amqp\Connection\FactoryOptions;

/**
* Class ConnectionValidator - validates Amqp related settings
*/
class ConnectionValidator
{
/**
* @var ConnectionFactory
*/
private $connectionFactory;

/**
* @param ConnectionFactory $connectionFactory
*/
public function __construct(ConnectionFactory $connectionFactory)
{
$this->connectionFactory = $connectionFactory;
}

/**
* Checks Amqp Connection
*
Expand All @@ -20,18 +34,33 @@ class ConnectionValidator
* @param string $user
* @param string $password
* @param string $virtualHost
* @param bool $ssl
* @param string[]|null $sslOptions
* @return bool true if the connection succeeded, false otherwise
*/
public function isConnectionValid($host, $port, $user, $password = '', $virtualHost = '')
{
public function isConnectionValid(
$host,
$port,
$user,
$password = '',
$virtualHost = '',
bool $ssl = false,
array $sslOptions = null
) {
try {
$connection = new AMQPStreamConnection(
$host,
$port,
$user,
$password,
$virtualHost
);
$options = new FactoryOptions();
$options->setHost($host);
$options->setPort($port);
$options->setUsername($user);
$options->setPassword($password);
$options->setVirtualHost($virtualHost);
$options->setSslEnabled($ssl);

if ($sslOptions) {
$options->setSslOptions($sslOptions);
}

$connection = $this->connectionFactory->create($options);

$connection->close();
} catch (\Exception $e) {
Expand Down
Loading

0 comments on commit 201bc31

Please sign in to comment.