Skip to content

Commit f8b51d3

Browse files
authored
Merge pull request #1041 from magento-engcom/develop-prs
[EngCom] Public Pull Requests
2 parents 8d64c71 + 18e4394 commit f8b51d3

File tree

80 files changed

+1766
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1766
-152
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
/.settings
66
atlassian*
77
/nbproject
8+
/robots.txt
9+
/pub/robots.txt
810
/sitemap
911
/sitemap.xml
12+
/pub/sitemap
13+
/pub/sitemap.xml
1014
/.idea
1115
/.gitattributes
1216
/app/config_sandbox

.travis.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ addons:
99
- postfix
1010
language: php
1111
php:
12-
- 5.6.29
1312
- 7.0
1413
env:
1514
global:
@@ -30,12 +29,6 @@ cache:
3029
- $HOME/.nvm
3130
- $HOME/node_modules
3231
- $HOME/yarn.lock
33-
matrix:
34-
exclude:
35-
- php: 5.6.29
36-
env: TEST_SUITE=static
37-
- php: 5.6.29
38-
env: TEST_SUITE=js
3932
before_install: ./dev/travis/before_install.sh
4033
install: composer install --no-interaction --prefer-dist
4134
before_script: ./dev/travis/before_script.sh

app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function getContent();
138138
/**
139139
* Set media gallery content
140140
*
141-
* @param $content \Magento\Framework\Api\Data\ImageContentInterface
141+
* @param \Magento\Framework\Api\Data\ImageContentInterface $content
142142
* @return $this
143143
*/
144144
public function setContent($content);

app/code/Magento/Catalog/Block/Product/View/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function getJsonConfig()
208208
$config = [];
209209
foreach ($this->getOptions() as $option) {
210210
/* @var $option \Magento\Catalog\Model\Product\Option */
211-
if ($option->getGroupByType() == \Magento\Catalog\Model\Product\Option::OPTION_GROUP_SELECT) {
211+
if ($option->hasValues()) {
212212
$tmpPriceValues = [];
213213
foreach ($option->getValues() as $valueId => $value) {
214214
$tmpPriceValues[$valueId] = $this->_getPriceConfiguration($value);

app/code/Magento/Catalog/Model/Product/Option.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ public function getValueById($valueId)
217217
return null;
218218
}
219219

220+
/**
221+
* Whether or not the option type contains sub-values
222+
*
223+
* @param string $type
224+
* @return bool
225+
*/
226+
public function hasValues($type = null)
227+
{
228+
return $this->getGroupByType($type) == self::OPTION_GROUP_SELECT;
229+
}
230+
220231
/**
221232
* @return ProductCustomOptionValuesInterface[]|null
222233
*/

app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function testGetProductSku()
3535
$this->assertEquals($productSku, $this->model->getProductSku());
3636
}
3737

38+
public function testHasValues()
39+
{
40+
$this->model->setType('drop_down');
41+
$this->assertTrue($this->model->hasValues());
42+
43+
$this->model->setType('field');
44+
$this->assertFalse($this->model->hasValues());
45+
}
46+
3847
public function testGetRegularPrice()
3948
{
4049
$priceInfoMock = $this->getMockForAbstractClass(

app/code/Magento/CatalogInventory/Model/StockManagement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function registerProductsSale($items, $websiteId = null)
102102
if (!$stockItem->hasAdminArea()
103103
&& !$this->stockState->checkQty($productId, $orderedQty, $stockItem->getWebsiteId())
104104
) {
105-
$this->getResource()->commit();
105+
$this->getResource()->rollBack();
106106
throw new \Magento\Framework\Exception\LocalizedException(
107107
__('Not all of your products are available in the requested quantity.')
108108
);
@@ -180,7 +180,7 @@ protected function getProductType($productId)
180180
}
181181

182182
/**
183-
* @return Stock
183+
* @return ResourceStock
184184
*/
185185
protected function getResource()
186186
{

app/code/Magento/Cms/Helper/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function prepareResultPage(Action $action, $pageId = null)
152152
$resultPage = $this->resultPageFactory->create();
153153
$this->setLayoutType($inRange, $resultPage);
154154
$resultPage->addHandle('cms_page_view');
155-
$resultPage->addPageLayoutHandles(['id' => $this->_page->getIdentifier()]);
155+
$resultPage->addPageLayoutHandles(['id' => str_replace('/', '_', $this->_page->getIdentifier())]);
156156

157157
$this->_eventManager->dispatch(
158158
'cms_page_render',

app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
*/
1010
namespace Magento\Config\Model\Config\Backend\Admin;
1111

12-
use Magento\Framework\App\Filesystem\DirectoryList;
12+
use Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot;
13+
use Magento\Framework\App\ObjectManager;
1314

1415
class Robots extends \Magento\Framework\App\Config\Value
1516
{
@@ -32,6 +33,7 @@ class Robots extends \Magento\Framework\App\Config\Value
3233
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
3334
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
3435
* @param array $data
36+
* @param DocumentRoot $documentRoot
3537
*/
3638
public function __construct(
3739
\Magento\Framework\Model\Context $context,
@@ -41,10 +43,13 @@ public function __construct(
4143
\Magento\Framework\Filesystem $filesystem,
4244
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
4345
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
44-
array $data = []
46+
array $data = [],
47+
\Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot $documentRoot = null
4548
) {
4649
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
47-
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
50+
51+
$documentRoot = $documentRoot ?: ObjectManager::getInstance()->get(DocumentRoot::class);
52+
$this->_directory = $filesystem->getDirectoryWrite($documentRoot->getPath());
4853
$this->_file = 'robots.txt';
4954
}
5055

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Config\Model\Config\Reader\Source\Deployed;
8+
9+
use Magento\Framework\Config\ConfigOptionsListConstants;
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\App\DeploymentConfig;
12+
13+
/**
14+
* Class DocumentRoot
15+
* @package Magento\Config\Model\Config\Reader\Source\Deployed
16+
*/
17+
class DocumentRoot
18+
{
19+
/**
20+
* @var DeploymentConfig
21+
*/
22+
private $config;
23+
24+
/**
25+
* DocumentRoot constructor.
26+
* @param DeploymentConfig $config
27+
*/
28+
public function __construct(DeploymentConfig $config)
29+
{
30+
$this->config = $config;
31+
}
32+
33+
/**
34+
* A shortcut to load the document root path from the DirectoryList based on the
35+
* deployment configuration.
36+
*
37+
* @return string
38+
*/
39+
public function getPath()
40+
{
41+
return $this->isPub() ? DirectoryList::PUB : DirectoryList::ROOT;
42+
}
43+
44+
/**
45+
* Returns whether the deployment configuration specifies that the document root is
46+
* in the pub/ folder. This affects ares such as sitemaps and robots.txt (and will
47+
* likely be extended to control other areas).
48+
*
49+
* @return bool
50+
*/
51+
public function isPub()
52+
{
53+
return (bool)$this->config->get(ConfigOptionsListConstants::CONFIG_PATH_DOCUMENT_ROOT_IS_PUB);
54+
}
55+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\Test\Unit\Model\Config\Reader\Source\Deployed;
7+
8+
use Magento\Config\Model\Config\Reader;
9+
use Magento\Framework\App\Config;
10+
use Magento\Framework\App\DeploymentConfig;
11+
use Magento\Framework\App\Filesystem\DirectoryList;
12+
use Magento\Framework\Config\ConfigOptionsListConstants;
13+
use Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot;
14+
15+
/**
16+
* Test class for checking settings that defined in config file
17+
*/
18+
class DocumentRootTest extends \PHPUnit_Framework_TestCase
19+
{
20+
/**
21+
* @var Config|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
private $configMock;
24+
25+
/**
26+
* @var DocumentRoot
27+
*/
28+
private $documentRoot;
29+
30+
public function setUp()
31+
{
32+
$this->configMock = $this->getMockBuilder(DeploymentConfig::class)
33+
->disableOriginalConstructor()
34+
->getMock();
35+
36+
$this->documentRoot = new DocumentRoot($this->configMock);
37+
}
38+
39+
/**
40+
* Ensures that the path returned matches the pub/ path.
41+
*/
42+
public function testGetPath()
43+
{
44+
$this->configMockSetForDocumentRootIsPub();
45+
46+
$this->assertSame(DirectoryList::PUB, $this->documentRoot->getPath());
47+
}
48+
49+
/**
50+
* Ensures that the deployment configuration returns the mocked value for
51+
* the pub/ folder.
52+
*/
53+
public function testIsPub()
54+
{
55+
$this->configMockSetForDocumentRootIsPub();
56+
57+
$this->assertSame(true, $this->documentRoot->isPub());
58+
}
59+
60+
private function configMockSetForDocumentRootIsPub()
61+
{
62+
$this->configMock->expects($this->any())
63+
->method('get')
64+
->willReturnMap([
65+
[
66+
ConfigOptionsListConstants::CONFIG_PATH_DOCUMENT_ROOT_IS_PUB,
67+
null,
68+
true
69+
],
70+
]);
71+
}
72+
}

app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function generateVariation(\Magento\Catalog\Api\Data\ProductInterface $pr
2424
/**
2525
* Provide the number of product count
2626
*
27-
* @param null|int $status
27+
* @param int|null $status
2828
* @return int
2929
*/
3030
public function getCount($status = null);
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Developer\Console\Command;
8+
9+
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Magento\Framework\App\DeploymentConfig\Writer;
13+
use Magento\Framework\Config\File\ConfigFilePool;
14+
use Magento\Framework\DB\Logger\LoggerProxy;
15+
16+
class QueryLogDisableCommand extends Command
17+
{
18+
/**
19+
* command name
20+
*/
21+
const COMMAND_NAME = 'dev:query-log:disable';
22+
23+
/**
24+
* Success message
25+
*/
26+
const SUCCESS_MESSAGE = "DB query logging disabled.";
27+
28+
/**
29+
* @var Writer
30+
*/
31+
private $deployConfigWriter;
32+
33+
/**
34+
* QueryLogDisableCommand constructor.
35+
* @param Writer $deployConfigWriter
36+
* @param null $name
37+
*/
38+
public function __construct(
39+
Writer $deployConfigWriter,
40+
$name = null
41+
) {
42+
parent::__construct($name);
43+
$this->deployConfigWriter = $deployConfigWriter;
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
protected function configure()
50+
{
51+
$this->setName(self::COMMAND_NAME)
52+
->setDescription('Disable DB query logging');
53+
54+
parent::configure();
55+
}
56+
57+
/**
58+
* {@inheritdoc}
59+
* @throws \InvalidArgumentException
60+
*/
61+
protected function execute(InputInterface $input, OutputInterface $output)
62+
{
63+
$data = [LoggerProxy::PARAM_ALIAS => LoggerProxy::LOGGER_ALIAS_DISABLED];
64+
$this->deployConfigWriter->saveConfig([ConfigFilePool::APP_ENV => [LoggerProxy::CONF_GROUP_NAME => $data]]);
65+
66+
$output->writeln("<info>". self::SUCCESS_MESSAGE . "</info>");
67+
}
68+
}

0 commit comments

Comments
 (0)