Skip to content

Commit 44f284d

Browse files
author
Melnikov, Igor(imelnikov)
committed
Merge pull request #259 from magento-extensibility/MAGETWO-46445-correct-erroneous-negative-recommendation
[Extensibility] Bug fixes
2 parents 33b13b6 + b5dc13b commit 44f284d

File tree

25 files changed

+256
-52
lines changed

25 files changed

+256
-52
lines changed

app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
namespace Magento\Config\Model\Config\Structure\Element\Group;
77

8-
class Proxy extends \Magento\Config\Model\Config\Structure\Element\Group
8+
class Proxy extends \Magento\Config\Model\Config\Structure\Element\Group implements
9+
\Magento\Framework\ObjectManager\NoninterceptableInterface
910
{
1011
/**
1112
* Object manager

app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66
namespace Magento\Config\Model\Config\Structure\Search;
77

8-
class Proxy implements \Magento\Config\Model\Config\Structure\SearchInterface
8+
class Proxy implements
9+
\Magento\Config\Model\Config\Structure\SearchInterface,
10+
\Magento\Framework\ObjectManager\NoninterceptableInterface
911
{
1012
/**
1113
* Object manager

app/code/Magento/Deploy/Model/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected function compile(
161161
DirectoryList::DI,
162162
]
163163
);
164-
$cmd = $this->functionCallPath . 'setup:di:compile-multi-tenant';
164+
$cmd = $this->functionCallPath . 'setup:di:compile';
165165

166166
/**
167167
* exec command is necessary for now to isolate the autoloaders in the compiler from the memory state

app/code/Magento/PageCache/Model/System/Config/Source/Application.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
*/
1010
namespace Magento\PageCache\Model\System\Config\Source;
1111

12+
use Magento\Framework\Option\ArrayInterface;
13+
use Magento\PageCache\Model\Config;
14+
1215
/**
1316
* Class Application
14-
*
1517
*/
16-
class Application implements \Magento\Framework\Option\ArrayInterface
18+
class Application implements ArrayInterface
1719
{
1820
/**
1921
* Options getter
@@ -24,12 +26,12 @@ public function toOptionArray()
2426
{
2527
return [
2628
[
27-
'value' => \Magento\PageCache\Model\Config::BUILT_IN,
28-
'label' => __('Built-in Application (Not Recommended for Production Use)')
29+
'value' => Config::BUILT_IN,
30+
'label' => __('Built-in Cache')
2931
],
3032
[
31-
'value' => \Magento\PageCache\Model\Config::VARNISH,
32-
'label' => __('Varnish Caching')
33+
'value' => Config::VARNISH,
34+
'label' => __('Varnish Cache (Recommended)')
3335
]
3436
];
3537
}
@@ -42,9 +44,8 @@ public function toOptionArray()
4244
public function toArray()
4345
{
4446
return [
45-
\Magento\PageCache\Model\Config::BUILT_IN =>
46-
__('Built-in Application (Not Recommended for Production Use)'),
47-
\Magento\PageCache\Model\Config::VARNISH => __('Varnish Caching')
47+
Config::BUILT_IN => __('Built-in Cache'),
48+
Config::VARNISH => __('Varnish Cache (Recommended)')
4849
];
4950
}
5051
}

app/code/Magento/PageCache/i18n/en_US.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"Export VCL","Export VCL"
22
"Ttl value ""%1"" is not valid. Please use only numbers equal or greater than zero.","Ttl value ""%1"" is not valid. Please use only numbers equal or greater than zero."
3-
"Built-in Application (Not Recommended for Production Use)","Built-in Application (Not Recommended for Production Use)"
4-
"Varnish Caching","Varnish Caching"
3+
"Built-in Cache","Built-in Cache"
4+
"Varnish Cache (Recommended)","Varnish Cache (Recommended)"
55
"Full Page Cache","Full Page Cache"
66
"Caching Application","Caching Application"
77
"Varnish Configuration","Varnish Configuration"

dev/tests/functional/tests/app/Magento/Swagger/Test/Page/SwaggerUiPage.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(BrowserInterface $browser)
6060
*/
6161
public function open()
6262
{
63-
$this->browser->open($this->url);
63+
$this->openSwaggerUrl();
6464
$this->waitForPageToLoad();
6565
}
6666

@@ -209,4 +209,29 @@ function () use ($browser, $selector, $strategy) {
209209
}
210210
);
211211
}
212+
213+
/**
214+
* Wait to open swagger url
215+
*
216+
* This is to work around an issue with selenium web driver randomly returns browser url as "about:blank"
217+
* when open swagger page
218+
*
219+
* @return bool|null
220+
*/
221+
private function openSwaggerUrl()
222+
{
223+
$browser = $this->browser;
224+
$pattern = self::MCA;
225+
return $browser->waitUntil(
226+
function () use ($browser, $pattern) {
227+
try {
228+
$url = $_ENV['app_frontend_url'] . $pattern;
229+
$browser->open($url);
230+
return true;
231+
} catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
232+
return false;
233+
}
234+
}
235+
);
236+
}
212237
}

dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceProxy.php.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace;
77
* Copyright © 2015 Magento. All rights reserved.
88
* See COPYING.txt for license details.
99
*/
10-
class Proxy extends \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
10+
class Proxy extends \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace implements \Magento\Framework\ObjectManager\NoninterceptableInterface
1111
{
1212
/**
1313
* Object Manager instance

lib/internal/Magento/Framework/App/AreaList/Proxy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*/
88
namespace Magento\Framework\App\AreaList;
99

10-
class Proxy extends \Magento\Framework\App\AreaList
10+
class Proxy extends \Magento\Framework\App\AreaList implements
11+
\Magento\Framework\ObjectManager\NoninterceptableInterface
1112
{
1213
/**
1314
* Object Manager instance

lib/internal/Magento/Framework/App/Cache/Proxy.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
namespace Magento\Framework\App\Cache;
7+
8+
use \Magento\Framework\App\CacheInterface;
9+
use \Magento\Framework\ObjectManager\NoninterceptableInterface;
610

711
/**
812
* System cache proxy model
913
*/
10-
namespace Magento\Framework\App\Cache;
11-
12-
use Magento\Framework\App\CacheInterface;
13-
14-
class Proxy implements CacheInterface
14+
class Proxy implements
15+
CacheInterface,
16+
NoninterceptableInterface
1517
{
1618
/**
1719
* @var \Magento\Framework\ObjectManagerInterface

lib/internal/Magento/Framework/App/Route/ConfigInterface/Proxy.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/**
1111
* Proxy class for \Magento\Framework\App\ResourceConnection
1212
*/
13-
class Proxy implements \Magento\Framework\App\Route\ConfigInterface
13+
class Proxy implements
14+
\Magento\Framework\App\Route\ConfigInterface,
15+
\Magento\Framework\ObjectManager\NoninterceptableInterface
1416
{
1517
/**
1618
* Object Manager instance

lib/internal/Magento/Framework/DataObject/Copy/Config/Data/Proxy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/**
99
* Proxy class for @see \Magento\Framework\DataObject\Copy\Config\Data
1010
*/
11-
class Proxy extends \Magento\Framework\DataObject\Copy\Config\Data
11+
class Proxy extends \Magento\Framework\DataObject\Copy\Config\Data implements
12+
\Magento\Framework\ObjectManager\NoninterceptableInterface
1213
{
1314
/**
1415
* Object Manager instance

lib/internal/Magento/Framework/Interception/ObjectManager/Config/Developer.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,31 @@
88
namespace Magento\Framework\Interception\ObjectManager\Config;
99

1010
use Magento\Framework\Interception\ObjectManager\ConfigInterface;
11+
use Magento\Framework\ObjectManager\DefinitionInterface;
12+
use Magento\Framework\ObjectManager\RelationsInterface;
13+
use Magento\Framework\ObjectManager\InterceptableValidator;
1114

1215
class Developer extends \Magento\Framework\ObjectManager\Config\Config implements ConfigInterface
1316
{
17+
/**
18+
* @var InterceptableValidator
19+
*/
20+
private $interceptableValidator;
21+
22+
/**
23+
* @param RelationsInterface $relations
24+
* @param DefinitionInterface $definitions
25+
* @param InterceptableValidator $interceptableValidator
26+
*/
27+
public function __construct(
28+
RelationsInterface $relations = null,
29+
DefinitionInterface $definitions = null,
30+
InterceptableValidator $interceptableValidator = null
31+
) {
32+
$this->interceptableValidator = $interceptableValidator ?: new InterceptableValidator();
33+
parent::__construct($relations, $definitions);
34+
}
35+
1436
/**
1537
* @var \Magento\Framework\Interception\ConfigInterface
1638
*/
@@ -36,7 +58,9 @@ public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInte
3658
public function getInstanceType($instanceName)
3759
{
3860
$type = parent::getInstanceType($instanceName);
39-
if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($instanceName)) {
61+
if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($instanceName)
62+
&& $this->interceptableValidator->validate($instanceName)
63+
) {
4064
return $type . '\\Interceptor';
4165
}
4266
return $type;

lib/internal/Magento/Framework/Mview/Config/Data/Proxy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/**
99
* Proxy class for \Magento\Framework\Mview\Config\Data
1010
*/
11-
class Proxy extends \Magento\Framework\Mview\Config\Data
11+
class Proxy extends \Magento\Framework\Mview\Config\Data implements
12+
\Magento\Framework\ObjectManager\NoninterceptableInterface
1213
{
1314
/**
1415
* Object Manager instance

lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract
1414
*/
1515
const ENTITY_TYPE = 'proxy';
1616

17+
/**
18+
* Marker interface
19+
*/
20+
const NON_INTERCEPTABLE_INTERFACE = '\Magento\Framework\ObjectManager\NoninterceptableInterface';
21+
1722
/**
1823
* @param string $modelClassName
1924
* @return string
@@ -131,9 +136,10 @@ protected function _generateCode()
131136
$reflection = new \ReflectionClass($typeName);
132137

133138
if ($reflection->isInterface()) {
134-
$this->_classGenerator->setImplementedInterfaces([$typeName]);
139+
$this->_classGenerator->setImplementedInterfaces([$typeName, self::NON_INTERCEPTABLE_INTERFACE]);
135140
} else {
136141
$this->_classGenerator->setExtendedClass($typeName);
142+
$this->_classGenerator->setImplementedInterfaces([self::NON_INTERCEPTABLE_INTERFACE]);
137143
}
138144
return parent::_generateCode();
139145
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\ObjectManager;
7+
8+
class InterceptableValidator
9+
{
10+
/**
11+
* @param string $className
12+
* @return bool
13+
*/
14+
public function validate($className)
15+
{
16+
return !$this->isInterceptor($className) && $this->isInterceptable($className);
17+
}
18+
19+
/**
20+
*
21+
* Check if instance type is interceptor
22+
*
23+
* @param string $instanceName
24+
* @return bool
25+
*/
26+
private function isInterceptor($instanceName)
27+
{
28+
return $this->endsWith($instanceName, '\Interceptor');
29+
}
30+
31+
/**
32+
*
33+
* Check if instance type is interceptable
34+
*
35+
* @param string $instanceName
36+
* @return bool
37+
*/
38+
private function isInterceptable($instanceName)
39+
{
40+
return !is_subclass_of(
41+
$instanceName,
42+
\Magento\Framework\ObjectManager\Code\Generator\Proxy::NON_INTERCEPTABLE_INTERFACE
43+
);
44+
}
45+
46+
/**
47+
* Check if a string ends with a substring
48+
*
49+
* @param string $haystack
50+
* @param string $needle
51+
* @return bool
52+
*/
53+
private function endsWith($haystack, $needle)
54+
{
55+
// Search forward starting from end minus needle length characters
56+
$temp = strlen($haystack) - strlen($needle);
57+
return $needle === '' || ($temp >= 0 && strpos($haystack, $needle, $temp) !== false);
58+
}
59+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\ObjectManager;
7+
8+
/**
9+
* Marker interface, used to identify proxies for which we don't need to generate interceptors
10+
*/
11+
interface NoninterceptableInterface
12+
{
13+
}

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleProxy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Magento\Framework\ObjectManager\Code\Generator;
33
/**
44
* Proxy class for @see \Magento\Framework\ObjectManager\Code\Generator\Sample
55
*/
6-
class Sample_Proxy extends \Magento\Framework\ObjectManager\Code\Generator\Sample
6+
class Sample_Proxy extends \Magento\Framework\ObjectManager\Code\Generator\Sample implements \Magento\Framework\ObjectManager\NoninterceptableInterface
77
{
88
/**
99
* Object Manager instance
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\ObjectManager\Test\Unit;
7+
8+
require __DIR__ . '/_files/Proxy.php';
9+
10+
class InterceptableValidatorTest extends \PHPUnit_Framework_TestCase
11+
{
12+
public function testValidate()
13+
{
14+
$interceptableValidator = new \Magento\Framework\ObjectManager\InterceptableValidator();
15+
$this->assertFalse(
16+
$interceptableValidator->validate(
17+
'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Interceptor'
18+
)
19+
);
20+
$this->assertFalse(
21+
$interceptableValidator->validate(
22+
'Magento\Test\Di\Proxy'
23+
)
24+
);
25+
}
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Test\Di;
7+
8+
class Proxy implements \Magento\Framework\ObjectManager\NoninterceptableInterface
9+
{
10+
}

0 commit comments

Comments
 (0)