Skip to content

Commit a978a4c

Browse files
author
Sergii Kovalenko
committed
MAGETWO-56989: Deployment process can't be executed on separate machine
1 parent 8d0dc6f commit a978a4c

File tree

165 files changed

+6378
-1463
lines changed

Some content is hidden

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

165 files changed

+6378
-1463
lines changed

app/code/Magento/Backend/App/Config.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,66 @@
1010

1111
namespace Magento\Backend\App;
1212

13+
use Magento\Config\App\Config\Type\System;
1314
use Magento\Framework\App\Config\ScopeConfigInterface;
1415

1516
/**
16-
* Backend config accessor
17+
* Backend config accessor.
1718
*/
1819
class Config implements ConfigInterface
1920
{
2021
/**
21-
* @var \Magento\Framework\App\Config\ScopePool
22+
* @var \Magento\Framework\App\Config
2223
*/
23-
protected $_scopePool;
24+
protected $appConfig;
2425

2526
/**
26-
* @param \Magento\Framework\App\Config\ScopePool $scopePool
27+
* @var array
2728
*/
28-
public function __construct(\Magento\Framework\App\Config\ScopePool $scopePool)
29+
private $data;
30+
31+
/**
32+
* @param \Magento\Framework\App\Config $appConfig
33+
* @return void
34+
*/
35+
public function __construct(\Magento\Framework\App\Config $appConfig)
2936
{
30-
$this->_scopePool = $scopePool;
37+
$this->appConfig = $appConfig;
3138
}
3239

3340
/**
34-
* Retrieve config value by path and scope
35-
*
36-
* @param string $path
37-
* @return mixed
41+
* @inheritdoc
3842
*/
3943
public function getValue($path)
4044
{
41-
return $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
45+
if (isset($this->data[$path])) {
46+
return $this->data[$path];
47+
}
48+
49+
$configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
50+
if ($path) {
51+
$configPath .= '/' . $path;
52+
}
53+
return $this->appConfig->get(System::CONFIG_TYPE, $configPath);
4254
}
4355

4456
/**
45-
* Set config value in the corresponding config scope
46-
*
47-
* @param string $path
48-
* @param mixed $value
49-
* @return void
57+
* @inheritdoc
5058
*/
5159
public function setValue($path, $value)
5260
{
53-
$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->setValue($path, $value);
61+
$this->data[$path] = $value;
5462
}
5563

5664
/**
57-
* Retrieve config flag
58-
*
59-
* @param string $path
60-
* @return bool
65+
* @inheritdoc
6166
*/
6267
public function isSetFlag($path)
6368
{
64-
return !!$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
69+
$configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
70+
if ($path) {
71+
$configPath .= '/' . $path;
72+
}
73+
return (bool) $this->appConfig->get(System::CONFIG_TYPE, $configPath);
6574
}
6675
}

app/code/Magento/Backend/App/ConfigInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface ConfigInterface
1515
/**
1616
* Retrieve config value by path
1717
*
18+
* Path should looks like keys imploded by "/". For example scopes/stores/admin
19+
*
1820
* @param string $path
1921
* @return mixed
2022
* @api
@@ -24,6 +26,7 @@ public function getValue($path);
2426
/**
2527
* Set config value
2628
*
29+
* @deprecated
2730
* @param string $path
2831
* @param mixed $value
2932
* @return void
@@ -34,6 +37,8 @@ public function setValue($path, $value);
3437
/**
3538
* Retrieve config flag
3639
*
40+
* Path should looks like keys imploded by "/". For example scopes/stores/admin
41+
*
3742
* @param string $path
3843
* @return bool
3944
* @api

app/code/Magento/Backend/Test/Unit/App/ConfigTest.php

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77

88
use Magento\Backend\App\Config;
99

10+
/**
11+
* Test reading by path and reading flag from config
12+
*
13+
* @see \Magento\Backend\App\Config
14+
* @package Magento\Backend\Test\Unit\App
15+
*/
1016
class ConfigTest extends \PHPUnit_Framework_TestCase
1117
{
1218
/**
13-
* @var \Magento\Framework\App\Config\ScopePool|\PHPUnit_Framework_MockObject_MockObject
19+
* @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject
1420
*/
15-
protected $sectionPool;
21+
protected $appConfig;
1622

1723
/**
1824
* @var Config
@@ -21,102 +27,64 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
2127

2228
protected function setUp()
2329
{
24-
$this->sectionPool = $this->getMock(
25-
\Magento\Framework\App\Config\ScopePool::class,
26-
['getScope', 'clean'],
30+
$this->appConfig = $this->getMock(
31+
\Magento\Framework\App\Config::class,
32+
['get'],
2733
[],
2834
'',
2935
false
3036
);
31-
$this->model = new \Magento\Backend\App\Config($this->sectionPool);
37+
$this->model = new \Magento\Backend\App\Config($this->appConfig);
3238
}
3339

3440
public function testGetValue()
3541
{
3642
$expectedValue = 'some value';
3743
$path = 'some path';
38-
$configData = $this->getConfigDataMock('getValue');
39-
$configData->expects(
40-
$this->once()
41-
)->method(
42-
'getValue'
43-
)->with(
44-
$this->equalTo($path)
45-
)->will(
46-
$this->returnValue($expectedValue)
47-
);
48-
$this->sectionPool->expects(
44+
$this->appConfig->expects(
4945
$this->once()
5046
)->method(
51-
'getScope'
47+
'get'
5248
)->with(
53-
$this->equalTo('default'),
49+
$this->equalTo('system'),
50+
$this->equalTo('default/' . $path),
5451
$this->isNull()
5552
)->will(
56-
$this->returnValue($configData)
53+
$this->returnValue($expectedValue)
5754
);
5855
$this->assertEquals($expectedValue, $this->model->getValue($path));
5956
}
6057

61-
public function testSetValue()
62-
{
63-
$value = 'some value';
64-
$path = 'some path';
65-
$configData = $this->getConfigDataMock('setValue');
66-
$configData->expects($this->once())->method('setValue')->with($this->equalTo($path), $this->equalTo($value));
67-
$this->sectionPool->expects(
68-
$this->once()
69-
)->method(
70-
'getScope'
71-
)->with(
72-
$this->equalTo('default'),
73-
$this->isNull()
74-
)->will(
75-
$this->returnValue($configData)
76-
);
77-
$this->model->setValue($path, $value);
78-
}
79-
8058
/**
59+
* @param string $configPath
8160
* @param mixed $configValue
8261
* @param bool $expectedResult
8362
* @dataProvider isSetFlagDataProvider
8463
*/
85-
public function testIsSetFlag($configValue, $expectedResult)
64+
public function testIsSetFlag($configPath, $configValue, $expectedResult)
8665
{
87-
$path = 'some path';
88-
$configData = $this->getConfigDataMock('getValue');
89-
$configData->expects(
90-
$this->once()
66+
$this->appConfig->expects(
67+
$this->any()
9168
)->method(
92-
'getValue'
69+
'get'
9370
)->with(
94-
$this->equalTo($path)
71+
$this->equalTo('system'),
72+
$this->equalTo('default/' . $configPath)
9573
)->will(
9674
$this->returnValue($configValue)
9775
);
98-
$this->sectionPool->expects(
99-
$this->once()
100-
)->method(
101-
'getScope'
102-
)->with(
103-
$this->equalTo('default'),
104-
$this->isNull()
105-
)->will(
106-
$this->returnValue($configData)
107-
);
108-
$this->assertEquals($expectedResult, $this->model->isSetFlag($path));
76+
$this->assertEquals($expectedResult, $this->model->isSetFlag($configPath));
10977
}
11078

11179
public function isSetFlagDataProvider()
11280
{
11381
return [
114-
[0, false],
115-
[true, true],
116-
['0', false],
117-
['', false],
118-
['some string', true],
119-
[1, true]
82+
['a', 0, false],
83+
['b', true, true],
84+
['c', '0', false],
85+
['d', '', false],
86+
['e', 'some string', true],
87+
['f', 1, true]
12088
];
12189
}
12290

app/code/Magento/Catalog/Model/Template/Filter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
*/
1515
namespace Magento\Catalog\Model\Template;
1616

17+
/**
18+
* Work with catalog(store, website) urls
19+
*
20+
* @package Magento\Catalog\Model\Template
21+
*/
1722
class Filter extends \Magento\Framework\Filter\Template
1823
{
1924
/**

app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/View.php

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
use Magento\UrlRewrite\Model\UrlPersistInterface;
1414
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1515

16+
/**
17+
* Plugin which is listening store resource model and on save or on delete replace catalog url rewrites
18+
*
19+
* @see \Magento\Store\Model\ResourceModel\Store
20+
* @package Magento\CatalogUrlRewrite\Model\Category\Plugin\Store
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
*/
1623
class View
1724
{
1825
/** @var UrlPersistInterface */
@@ -30,6 +37,11 @@ class View
3037
/** @var ProductUrlRewriteGenerator */
3138
protected $productUrlRewriteGenerator;
3239

40+
/**
41+
* @var AbstractModel
42+
*/
43+
private $origStore;
44+
3345
/**
3446
* @param UrlPersistInterface $urlPersist
3547
* @param CategoryFactory $categoryFactory
@@ -55,31 +67,43 @@ public function __construct(
5567
* Perform updating url for categories and products assigned to the store view
5668
*
5769
* @param \Magento\Store\Model\ResourceModel\Store $subject
58-
* @param \Magento\Store\Model\ResourceModel\Store $result
5970
* @param AbstractModel $store
60-
* @return \Magento\Store\Model\ResourceModel\Store
71+
* @return void
6172
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6273
*/
63-
public function afterSave(
74+
public function beforeSave(
6475
\Magento\Store\Model\ResourceModel\Store $subject,
65-
\Magento\Store\Model\ResourceModel\Store $result,
6676
AbstractModel $store
6777
) {
68-
if ($store->isObjectNew() || $store->dataHasChangedFor('group_id')) {
69-
if (!$store->isObjectNew()) {
70-
$this->urlPersist->deleteByData([UrlRewrite::STORE_ID => $store->getId()]);
71-
}
78+
$this->origStore = $store;
79+
}
7280

73-
$this->urlPersist->replace(
74-
$this->generateCategoryUrls($store->getRootCategoryId(), $store->getId())
75-
);
81+
/**
82+
* Regenerate urls on store after save
83+
*
84+
* @param \Magento\Store\Model\ResourceModel\Store $object
85+
* @param \Magento\Store\Model\ResourceModel\Store $store
86+
* @return \Magento\Store\Model\ResourceModel\Store
87+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
88+
*/
89+
public function afterSave(
90+
\Magento\Store\Model\ResourceModel\Store $object,
91+
\Magento\Store\Model\ResourceModel\Store $store
92+
) {
93+
if ($this->origStore->isObjectNew() || $this->origStore->dataHasChangedFor('group_id')) {
94+
if (!$this->origStore->isObjectNew()) {
95+
$this->urlPersist->deleteByData([UrlRewrite::STORE_ID => $this->origStore->getId()]);
96+
}
7697

7798
$this->urlPersist->replace(
78-
$this->generateProductUrls($store->getWebsiteId(), $store->getOrigData('website_id'), $store->getId())
99+
$this->generateProductUrls(
100+
$this->origStore->getWebsiteId(),
101+
$this->origStore->getOrigData('website_id'),
102+
$this->origStore->getId()
103+
)
79104
);
80105
}
81-
82-
return $result;
106+
return $store;
83107
}
84108

85109
/**

app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Cms\Test\Unit\Model\Template;
77

88
/**
9+
* Work with catalog(store, website) urls
10+
*
911
* @covers \Magento\Cms\Model\Template\Filter
1012
*/
1113
class FilterTest extends \PHPUnit_Framework_TestCase

0 commit comments

Comments
 (0)