Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6b68e1

Browse filesBrowse files
committed
Merge branch '3.3' into 3.4
* 3.3: [Config] Fix dumped files invalidation by OPCache [DI] Allow setting any public non-initialized services
2 parents 8b7b902 + 0a963d2 commit d6b68e1
Copy full SHA for d6b68e1

File tree

4 files changed

+31
-9
lines changed
Filter options

4 files changed

+31
-9
lines changed

‎src/Symfony/Component/Config/ResourceCheckerConfigCache.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ResourceCheckerConfigCache.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public function write($content, array $metadata = null)
132132
// discard chmod failure (some filesystem may not support it)
133133
}
134134
}
135+
136+
if (\function_exists('opcache_invalidate') && ini_get('opcache.enable')) {
137+
@opcache_invalidate($this->file, true);
138+
}
135139
}
136140

137141
/**

‎src/Symfony/Component/DependencyInjection/Container.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Container.php
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public function set($id, $service)
183183
unset($this->aliases[$id]);
184184
}
185185

186+
$wasSet = isset($this->services[$id]);
186187
$this->services[$id] = $service;
187188

188189
if (null === $service) {
@@ -196,11 +197,11 @@ public function set($id, $service)
196197
} else {
197198
@trigger_error(sprintf('Setting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
198199
}
199-
} elseif (isset($this->fileMap[$id]) || isset($this->methodMap[$id])) {
200+
} elseif ($wasSet && (isset($this->fileMap[$id]) || isset($this->methodMap[$id]))) {
200201
if (null === $service) {
201-
@trigger_error(sprintf('Unsetting the "%s" pre-defined service is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
202+
@trigger_error(sprintf('Unsetting the "%s" service after it\'s been initialized is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
202203
} else {
203-
@trigger_error(sprintf('Setting the "%s" pre-defined service is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
204+
@trigger_error(sprintf('Setting the "%s" service after it\'s been initialized is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
204205
}
205206
}
206207
}

‎src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
+17-3Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,29 @@ public function testSetReplacesAlias()
196196

197197
/**
198198
* @group legacy
199-
* @expectedDeprecation Unsetting the "bar" pre-defined service is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
199+
* @expectedDeprecation Unsetting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
200200
*/
201-
public function testSetWithNullResetPredefinedService()
201+
public function testSetWithNullOnInitializedPredefinedService()
202202
{
203203
$sc = new Container();
204204
$sc->set('foo', new \stdClass());
205205
$sc->set('foo', null);
206206
$this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
207207

208+
$sc = new ProjectServiceContainer();
209+
$sc->get('bar');
210+
$sc->set('bar', null);
211+
$this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
212+
}
213+
214+
public function testSetWithNullOnUninitializedPredefinedService()
215+
{
216+
$sc = new Container();
217+
$sc->set('foo', new \stdClass());
218+
$sc->get('foo', null);
219+
$sc->set('foo', null);
220+
$this->assertFalse($sc->has('foo'), '->set() with null service resets the service');
221+
208222
$sc = new ProjectServiceContainer();
209223
$sc->set('bar', null);
210224
$this->assertTrue($sc->has('bar'), '->set() with null service resets the pre-defined service');
@@ -502,7 +516,7 @@ public function testRequestAnInternalSharedPrivateServiceIsDeprecated()
502516

503517
/**
504518
* @group legacy
505-
* @expectedDeprecation Setting the "bar" pre-defined service is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
519+
* @expectedDeprecation Setting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
506520
*/
507521
public function testReplacingAPreDefinedServiceIsDeprecated()
508522
{

‎src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,23 +287,24 @@ public function testFrozenContainerWithoutAliases()
287287

288288
/**
289289
* @group legacy
290-
* @expectedDeprecation Setting the "bar" pre-defined service is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
290+
* @expectedDeprecation Setting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
291291
*/
292292
public function testOverrideServiceWhenUsingADumpedContainer()
293293
{
294294
require_once self::$fixturesPath.'/php/services9.php';
295295
require_once self::$fixturesPath.'/includes/foo.php';
296296

297297
$container = new \ProjectServiceContainer();
298-
$container->set('bar', $bar = new \stdClass());
299298
$container->setParameter('foo_bar', 'foo_bar');
299+
$container->get('bar');
300+
$container->set('bar', $bar = new \stdClass());
300301

301302
$this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service');
302303
}
303304

304305
/**
305306
* @group legacy
306-
* @expectedDeprecation Setting the "bar" pre-defined service is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
307+
* @expectedDeprecation Setting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
307308
*/
308309
public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne()
309310
{
@@ -312,6 +313,8 @@ public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFrom
312313
require_once self::$fixturesPath.'/includes/classes.php';
313314

314315
$container = new \ProjectServiceContainer();
316+
$container->setParameter('foo_bar', 'foo_bar');
317+
$container->get('bar');
315318
$container->set('bar', $bar = new \stdClass());
316319

317320
$this->assertSame($bar, $container->get('foo')->bar, '->set() overrides an already defined service');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.