Skip to content

Commit

Permalink
Merge pull request #1024 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko committed Apr 13, 2017
2 parents 23f7456 + 3f58731 commit 9224419
Show file tree
Hide file tree
Showing 68 changed files with 1,115 additions and 236 deletions.
2 changes: 1 addition & 1 deletion COPYING.txt
Expand Up @@ -6,4 +6,4 @@ http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.

Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
Please see <insert file name of the MEE license> for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.
Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.
26 changes: 25 additions & 1 deletion README.md
Expand Up @@ -27,9 +27,33 @@ To suggest documentation improvements, click [here][4].
[3]: <https://github.com/magento/magento2/issues>
[4]: <http://devdocs.magento.com>

<h3>Labels applied by the Magento team</h3>

| Label | Description |
| ------------- |-------------|
| ![DOC](http://devdocs.magento.com/common/images/github_DOC.png) | Affects Documentation domain. |
| ![PROD](http://devdocs.magento.com/common/images/github_PROD.png) | Affects the Product team (mostly feature requests or business logic change). |
| ![TECH](http://devdocs.magento.com/common/images/github_TECH.png) | Affects Architect Group (mostly to make decisions around technology changes). |
| ![accept](http://devdocs.magento.com/common/images/github_accept.png) | The pull request has been accepted and will be merged into mainline code. |
| ![reject](http://devdocs.magento.com/common/images/github_reject.png) | The pull request has been rejected and will not be merged into mainline code. Possible reasons can include but are not limited to: issue has already been fixed in another code contribution, or there is an issue with the code contribution. |
| ![bug report](http://devdocs.magento.com/common/images/github_bug.png) | The Magento Team has confirmed that this issue contains the minimum required information to reproduce. |
| ![acknowledged](http://devdocs.magento.com/common/images/gitHub_acknowledged.png) | The Magento Team has validated the issue and an internal ticket has been created. |
| ![acknowledged](http://devdocs.magento.com/common/images/github_inProgress.png) | The internal ticket is currently in progress, fix is scheduled to be delivered. |
| ![acknowledged](http://devdocs.magento.com/common/images/github_needsUpdate.png) | The Magento Team needs additional information from the reporter to properly prioritize and process the issue or pull request. |

<h2>Reporting security issues</h2>

To report security vulnerabilities in Magento software or web sites, please e-mail <a href="mailto:security@magento.com">security@magento.com</a>. Please do not report security issues using GitHub. Be sure to encrypt your e-mail with our <a href="https://info2.magento.com/rs/magentoenterprise/images/security_at_magento.asc">encryption key</a> if it includes sensitive information. Learn more about reporting security issues <a href="https://magento.com/security/reporting-magento-security-issue">here</a>.

Stay up-to-date on the latest vulnerabilities and patches for Magento by signing up for <a href="https://magento.com/security/sign-up">Security Alert Notifications</a>.
Stay up-to-date on the latest security news and patches for Magento by signing up for <a href="https://magento.com/security/sign-up">Security Alert Notifications</a>.

<h2>License</h2>

Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license

http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.

Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.

2 changes: 1 addition & 1 deletion app/code/Magento/Backend/etc/adminhtml/system.xml
Expand Up @@ -33,7 +33,7 @@
<class>separator-top</class>
<label>Store Email Addresses</label>
<tab>general</tab>
<resource>Magento_Backend::trans_email</resource>
<resource>Magento_Config::trans_email</resource>
<group id="ident_custom1" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Email 1</label>
<field id="email" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Bundle/view/base/web/js/price-bundle.js
Expand Up @@ -239,7 +239,6 @@ define([

switch (optionType) {
case 'radio':

case 'select-one':

if (optionType === 'radio' && !element.is(':checked')) {
Expand Down
Expand Up @@ -154,7 +154,11 @@ private function setMessageToResponse($response, $messages)
*/
private function checkUniqueOption(DataObject $response, array $options = null)
{
if (is_array($options) && !$this->isUniqueAdminValues($options['value'], $options['delete'])) {
if (is_array($options)
&& isset($options['value'])
&& isset($options['delete'])
&& !$this->isUniqueAdminValues($options['value'], $options['delete'])
) {
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);
$response->setError(true);
}
Expand Down
24 changes: 19 additions & 5 deletions app/code/Magento/Catalog/Model/Product/Option/Type/File.php
Expand Up @@ -33,9 +33,16 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType

/**
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
* @deprecated
* @see $mediaDirectory
*/
protected $_rootDirectory;

/**
* @var \Magento\Framework\Filesystem\Directory\WriteInterface
*/
private $mediaDirectory;

/**
* Core file storage database
*
Expand Down Expand Up @@ -114,7 +121,9 @@ public function __construct(
$this->_escaper = $escaper;
$this->_coreFileStorageDatabase = $coreFileStorageDatabase;
$this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class);
/** The _rootDirectory is deprecated. The field is initialized for backward compatibility */
$this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
$this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->validatorInfo = $validatorInfo;
$this->validatorFile = $validatorFile;
$this->serializer = $serializer ? $serializer : ObjectManager::getInstance()->get(Json::class);
Expand Down Expand Up @@ -466,13 +475,18 @@ public function copyQuoteToOrder()
$quotePath = $value['quote_path'];
$orderPath = $value['order_path'];

if (!$this->_rootDirectory->isFile($quotePath) || !$this->_rootDirectory->isReadable($quotePath)) {
if (!$this->mediaDirectory->isFile($quotePath) || !$this->mediaDirectory->isReadable($quotePath)) {
throw new \Exception();
}
$this->_coreFileStorageDatabase->copyFile(
$this->_rootDirectory->getAbsolutePath($quotePath),
$this->_rootDirectory->getAbsolutePath($orderPath)
);

if ($this->_coreFileStorageDatabase->checkDbUsage()) {
$this->_coreFileStorageDatabase->copyFile(
$this->mediaDirectory->getAbsolutePath($quotePath),
$this->mediaDirectory->getAbsolutePath($orderPath)
);
} else {
$this->mediaDirectory->copyFile($quotePath, $orderPath);
}
} catch (\Exception $e) {
return $this;
}
Expand Down
25 changes: 18 additions & 7 deletions app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php
Expand Up @@ -105,13 +105,7 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
* If there is not price skip saving price
*/

if ($object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FIELD ||
$object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_AREA ||
$object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FILE ||
$object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE ||
$object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME ||
$object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME
) {
if (in_array($object->getType(), $this->getPriceTypes())) {
//save for store_id = 0
if (!$object->getData('scope', 'price')) {
$statement = $connection->select()->from(
Expand Down Expand Up @@ -569,6 +563,23 @@ public function getSearchableData($productId, $storeId)

return $searchData;
}

/**
* All Option Types that support price and price_type
*
* @return string[]
*/
public function getPriceTypes()
{
return [
\Magento\Catalog\Model\Product\Option::OPTION_TYPE_FIELD,
\Magento\Catalog\Model\Product\Option::OPTION_TYPE_AREA,
\Magento\Catalog\Model\Product\Option::OPTION_TYPE_FILE,
\Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE,
\Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME,
\Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME,
];
}

/**
* @return \Magento\Framework\EntityManager\MetadataPool
Expand Down
Expand Up @@ -9,7 +9,7 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\SerializationException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadInterface;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\DriverPool;

/**
Expand All @@ -25,9 +25,9 @@ class FileTest extends \PHPUnit_Framework_TestCase
protected $objectManager;

/**
* @var ReadInterface|\PHPUnit_Framework_MockObject_MockObject
* @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $rootDirectory;
protected $mediaDirectory;

/**
* @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
Expand Down Expand Up @@ -67,13 +67,13 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$this->rootDirectory = $this->getMockBuilder(ReadInterface::class)
$this->mediaDirectory = $this->getMockBuilder(WriteInterface::class)
->getMock();

$this->filesystemMock->expects($this->any())
->method('getDirectoryRead')
->method('getDirectoryWrite')
->with(DirectoryList::MEDIA, DriverPool::FILE)
->willReturn($this->rootDirectory);
->willReturn($this->mediaDirectory);

$this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
->disableOriginalConstructor()
Expand All @@ -95,7 +95,7 @@ protected function setUp()

$this->coreFileStorageDatabase = $this->getMock(
\Magento\MediaStorage\Helper\File\Storage\Database::class,
['copyFile'],
['copyFile', 'checkDbUsage'],
[],
'',
false
Expand Down Expand Up @@ -166,7 +166,7 @@ public function testGetCustomizedView()
);
}

public function testCopyQuoteToOrder()
public function testCopyQuoteToOrderWithDbUsage()
{
$optionMock = $this->getMockBuilder(OptionInterface::class)
->disableOriginalConstructor()
Expand All @@ -187,25 +187,29 @@ function ($value) {
}
);

$optionMock->expects($this->any())
$optionMock->expects($this->once())
->method('getValue')
->will($this->returnValue($quoteValue));

$this->rootDirectory->expects($this->any())
$this->mediaDirectory->expects($this->once())
->method('isFile')
->with($this->equalTo($quotePath))
->will($this->returnValue(true));

$this->rootDirectory->expects($this->any())
$this->mediaDirectory->expects($this->once())
->method('isReadable')
->with($this->equalTo($quotePath))
->will($this->returnValue(true));

$this->rootDirectory->expects($this->any())
$this->mediaDirectory->expects($this->exactly(2))
->method('getAbsolutePath')
->will($this->returnValue('/file.path'));

$this->coreFileStorageDatabase->expects($this->any())
$this->coreFileStorageDatabase->expects($this->once())
->method('checkDbUsage')
->willReturn(true);

$this->coreFileStorageDatabase->expects($this->once())
->method('copyFile')
->will($this->returnValue('true'));

Expand All @@ -218,6 +222,62 @@ function ($value) {
);
}

public function testCopyQuoteToOrderWithoutUsage()
{
$optionMock = $this->getMockBuilder(OptionInterface::class)
->disableOriginalConstructor()
->setMethods(['getValue'])
->getMockForAbstractClass();

$quotePath = '/quote/path/path/uploaded.file';
$orderPath = '/order/path/path/uploaded.file';

$quoteValue = "{\"quote_path\":\"$quotePath\",\"order_path\":\"$orderPath\"}";

$this->serializer->expects($this->once())
->method('unserialize')
->with($quoteValue)
->willReturnCallback(
function ($value) {
return json_decode($value, true);
}
);

$optionMock->expects($this->once())
->method('getValue')
->will($this->returnValue($quoteValue));

$this->mediaDirectory->expects($this->once())
->method('isFile')
->with($this->equalTo($quotePath))
->will($this->returnValue(true));

$this->mediaDirectory->expects($this->once())
->method('isReadable')
->with($this->equalTo($quotePath))
->will($this->returnValue(true));

$this->mediaDirectory->expects($this->never())
->method('getAbsolutePath')
->will($this->returnValue('/file.path'));

$this->coreFileStorageDatabase->expects($this->once())
->method('checkDbUsage')
->willReturn(false);

$this->coreFileStorageDatabase->expects($this->any())
->method('copyFile')
->willReturn(false);

$fileObject = $this->getFileObject();
$fileObject->setData('configuration_item_option', $optionMock);

$this->assertInstanceOf(
\Magento\Catalog\Model\Product\Option\Type\File::class,
$fileObject->copyQuoteToOrder()
);
}

public function testGetFormattedOptionValue()
{
$resultValue = ['result'];
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/view/base/web/js/price-box.js
Expand Up @@ -38,9 +38,9 @@ define([
* Widget creating.
*/
_create: function createPriceBox() {
this.cache = {};
var box = this.element;

this.cache = {};
this._setDefaultsFromPriceConfig();
this._setDefaultsFromDataSet();

Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Catalog/view/base/web/js/price-options.js
Expand Up @@ -43,7 +43,6 @@ define([

switch (optionType) {
case 'text':

case 'textarea':
changes[optionHash] = optionValue ? optionConfig.prices : {};
break;
Expand Down
Expand Up @@ -23,7 +23,7 @@ $_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();

if ($_attributeLabel && $_attributeLabel == 'default') {
$_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel();
$_attributeLabel = $_product->getResource()->getAttribute($_code)->getStoreLabel();
}
if ($_attributeType && $_attributeType == 'text') {
$_attributeValue = ($_helper->productAttribute($_product, $_product->$_call(), $_code)) ? $_product->getAttributeText($_code) : '';
Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/Customer/etc/adminhtml/system.xml
Expand Up @@ -180,6 +180,19 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="account_information" translate="label" type="text" sortOrder="35" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Account Information Options</label>
<field id="change_email_template" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Change Email Template</label>
<comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
</field>
<field id="change_email_and_password_template" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Change Email and Password Template</label>
<comment>Email template chosen based on theme fallback when "Default" option is selected.</comment>
<source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
</field>
</group>
<group id="address" translate="label" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Name and Address Options</label>
<field id="street_lines" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
Expand Down

0 comments on commit 9224419

Please sign in to comment.