Skip to content

Commit

Permalink
merge 2.3-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepa4man committed Nov 20, 2018
2 parents 91edcc5 + 1a805d0 commit 3563671
Show file tree
Hide file tree
Showing 305 changed files with 9,013 additions and 1,098 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ env:
- TEST_SUITE=integration INTEGRATION_INDEX=2
- TEST_SUITE=integration INTEGRATION_INDEX=3
- TEST_SUITE=functional
- TEST_SUITE=graphql-api-functional
matrix:
exclude:
- php: 7.1
Expand All @@ -43,6 +44,8 @@ matrix:
env: TEST_SUITE=js GRUNT_COMMAND=static
- php: 7.1
env: TEST_SUITE=functional
- php: 7.1
env: TEST_SUITE=graphql-api-functional
cache:
apt: true
directories:
Expand All @@ -61,5 +64,6 @@ script:

# The scripts for grunt/phpunit type tests
- if [ $TEST_SUITE == "functional" ]; then dev/tests/functional/vendor/phpunit/phpunit/phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- if [ $TEST_SUITE != "functional" ] && [ $TEST_SUITE != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- if [ $TEST_SUITE != "functional" ] && [ $TEST_SUITE != "js"] && [ $TEST_SUITE != "graphql-api-functional" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi
- if [ $TEST_SUITE == "js" ]; then grunt $GRUNT_COMMAND; fi
- if [ $TEST_SUITE == "graphql-api-functional" ]; then phpunit -c dev/tests/api-functional; fi
40 changes: 40 additions & 0 deletions app/code/Magento/Backend/Block/DataProviders/ImageUploadConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Block\DataProviders;

use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Backend\Model\Image\UploadResizeConfigInterface;

/**
* Provides additional data for image uploader
*/
class ImageUploadConfig implements ArgumentInterface
{
/**
* @var UploadResizeConfigInterface
*/
private $imageUploadConfig;

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

/**
* Get image resize configuration
*
* @return int
*/
public function getIsResizeEnabled(): int
{
return (int)$this->imageUploadConfig->isResizeEnabled();
}
}
22 changes: 17 additions & 5 deletions app/code/Magento/Backend/Block/Media/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Image\Adapter\UploadConfigInterface;
use Magento\Backend\Model\Image\UploadResizeConfigInterface;

/**
* Adminhtml media library uploader
Expand Down Expand Up @@ -38,8 +39,15 @@ class Uploader extends \Magento\Backend\Block\Widget
*/
private $jsonEncoder;

/**
* @var UploadResizeConfigInterface
*/
private $imageUploadConfig;

/**
* @var UploadConfigInterface
* @deprecated
* @see \Magento\Backend\Model\Image\UploadResizeConfigInterface
*/
private $imageConfig;

Expand All @@ -49,18 +57,22 @@ class Uploader extends \Magento\Backend\Block\Widget
* @param array $data
* @param Json $jsonEncoder
* @param UploadConfigInterface $imageConfig
* @param UploadResizeConfigInterface $imageUploadConfig
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\File\Size $fileSize,
array $data = [],
Json $jsonEncoder = null,
UploadConfigInterface $imageConfig = null
UploadConfigInterface $imageConfig = null,
UploadResizeConfigInterface $imageUploadConfig = null
) {
$this->_fileSizeService = $fileSize;
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
$this->imageConfig = $imageConfig ?: ObjectManager::getInstance()->get(UploadConfigInterface::class);

$this->imageConfig = $imageConfig
?: ObjectManager::getInstance()->get(UploadConfigInterface::class);
$this->imageUploadConfig = $imageUploadConfig
?: ObjectManager::getInstance()->get(UploadResizeConfigInterface::class);
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -111,7 +123,7 @@ public function getFileSizeService()
*/
public function getImageUploadMaxWidth()
{
return $this->imageConfig->getMaxWidth();
return $this->imageUploadConfig->getMaxWidth();
}

/**
Expand All @@ -121,7 +133,7 @@ public function getImageUploadMaxWidth()
*/
public function getImageUploadMaxHeight()
{
return $this->imageConfig->getMaxHeight();
return $this->imageUploadConfig->getMaxHeight();
}

/**
Expand Down
38 changes: 18 additions & 20 deletions app/code/Magento/Backend/Model/AdminPathConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,37 @@ public function __construct(
}

/**
* {@inheritdoc}
*
* @param \Magento\Framework\App\RequestInterface $request
* @return string
* @inheritdoc
*/
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
{
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
}

/**
* {@inheritdoc}
*
* @param string $path
* @return bool
* @inheritdoc
*/
public function shouldBeSecure($path)
{
return parse_url(
(string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'),
PHP_URL_SCHEME
) === 'https'
|| $this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)
&& parse_url(
(string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'),
PHP_URL_SCHEME
) === 'https';
$baseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
if (parse_url($baseUrl, PHP_URL_SCHEME) === 'https') {
return true;
}

if ($this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)) {
if ($this->backendConfig->isSetFlag('admin/url/use_custom')) {
$adminBaseUrl = (string)$this->coreConfig->getValue('admin/url/custom', 'default');
} else {
$adminBaseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
}
return parse_url($adminBaseUrl, PHP_URL_SCHEME) === 'https';
}

return false;
}

/**
* {@inheritdoc}
*
* @return string
* @inheritdoc
*/
public function getDefaultPath()
{
Expand Down
72 changes: 72 additions & 0 deletions app/code/Magento/Backend/Model/Image/UploadResizeConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Model\Image;

/**
* Image uploader config provider.
*/
class UploadResizeConfig implements UploadResizeConfigInterface
{
/**
* Config path for the maximal image width value
*/
const XML_PATH_MAX_WIDTH_IMAGE = 'system/upload_configuration/max_width';

/**
* Config path for the maximal image height value
*/
const XML_PATH_MAX_HEIGHT_IMAGE = 'system/upload_configuration/max_height';

/**
* Config path for the maximal image height value
*/
const XML_PATH_ENABLE_RESIZE = 'system/upload_configuration/enable_resize';

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $config;

/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
*/
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $config)
{
$this->config = $config;
}

/**
* Get maximal width value for resized image
*
* @return int
*/
public function getMaxWidth(): int
{
return (int)$this->config->getValue(self::XML_PATH_MAX_WIDTH_IMAGE);
}

/**
* Get maximal height value for resized image
*
* @return int
*/
public function getMaxHeight(): int
{
return (int)$this->config->getValue(self::XML_PATH_MAX_HEIGHT_IMAGE);
}

/**
* Get config value for frontend resize
*
* @return bool
*/
public function isResizeEnabled(): bool
{
return (bool)$this->config->getValue(self::XML_PATH_ENABLE_RESIZE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Model\Image;

/**
* Interface UploadResizeConfigInterface
*
* Used to retrieve configuration for frontend image uploader
*/
interface UploadResizeConfigInterface
{
/**
* Get maximal width value for resized image
*
* @return int
*/
public function getMaxWidth(): int;

/**
* Get maximal height value for resized image
*
* @return int
*/
public function getMaxHeight(): int;

/**
* Get config value for frontend resize
*
* @return bool
*/
public function isResizeEnabled(): bool;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<page name="WebConfigurationPage" url="admin/system_config/edit/section/web/" area="admin" module="Backend">
<section name="WYSIWYGOptionsSection"/>
</page>
<page name="GeneralConfigurationPage" url="admin/system_config/edit/section/general/" area="admin" module="Backend">
<section name="LocaleOptionsSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="LocaleOptionsSection">
<element name="sectionHeader" type="text" selector="#general_locale-head"/>
<element name="timezone" type="select" selector="#general_locale_timezone"/>
</section>
</sections>
44 changes: 31 additions & 13 deletions app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,35 @@ public function testGetCurrentSecureUrl()
* @param $unsecureBaseUrl
* @param $useSecureInAdmin
* @param $secureBaseUrl
* @param $useCustomUrl
* @param $customUrl
* @param $expected
* @dataProvider shouldBeSecureDataProvider
*/
public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
{
$coreConfigValueMap = [
public function testShouldBeSecure(
$unsecureBaseUrl,
$useSecureInAdmin,
$secureBaseUrl,
$useCustomUrl,
$customUrl,
$expected
) {
$coreConfigValueMap = $this->returnValueMap([
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl],
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl],
];
$this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
$this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
['admin/url/custom', 'default', null, $customUrl],
]);
$backendConfigFlagsMap = $this->returnValueMap([
[\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, $useSecureInAdmin],
['admin/url/use_custom', $useCustomUrl],
]);
$this->coreConfig->expects($this->atLeast(1))->method('getValue')
->will($coreConfigValueMap);
$this->coreConfig->expects($this->atMost(2))->method('getValue')
->will($coreConfigValueMap);

$this->backendConfig->expects($this->atMost(2))->method('isSetFlag')
->will($backendConfigFlagsMap);
$this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
}

Expand All @@ -96,13 +114,13 @@ public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureB
public function shouldBeSecureDataProvider()
{
return [
['http://localhost/', false, 'default', false],
['http://localhost/', true, 'default', false],
['https://localhost/', false, 'default', true],
['https://localhost/', true, 'default', true],
['http://localhost/', false, 'https://localhost/', false],
['http://localhost/', true, 'https://localhost/', true],
['https://localhost/', true, 'https://localhost/', true],
['http://localhost/', false, 'default', false, '', false],
['http://localhost/', true, 'default', false, '', false],
['https://localhost/', false, 'default', false, '', true],
['https://localhost/', true, 'default', false, '', true],
['http://localhost/', false, 'https://localhost/', false, '', false],
['http://localhost/', true, 'https://localhost/', false, '', true],
['https://localhost/', true, 'https://localhost/', false, '', true],
];
}

Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Backend/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@
</arguments>
</type>
<preference for="CsrfRequestValidator" type="Magento\Backend\App\Request\BackendValidator" />
<preference for="Magento\Backend\Model\Image\UploadResizeConfigInterface" type="Magento\Backend\Model\Image\UploadResizeConfig" />
</config>
Loading

0 comments on commit 3563671

Please sign in to comment.