Skip to content

Commit cf70d3a

Browse files
committed
bug #39091 [Config] Recheck glob brace support after GlobResource was serialized (wouterj)
This PR was merged into the 4.4 branch. Discussion ---------- [Config] Recheck glob brace support after GlobResource was serialized | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - cc @bastnic This bug was reported on Symfony Slack: `$this->globBrace` is set to `null` after unserialization from the `.meta` file. Instead of serializing this property, I decided to reinitialize the property after unserialization. I think that's a safer option (e.g. it works when the cache is build on a different server with different globBrace support than the one running the application). Commits ------- d953477 Reinitialize globBrace after unserialization
2 parents beeafb1 + d953477 commit cf70d3a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Symfony/Component/Config/Resource/GlobResource.php

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ public function __sleep(): array
9494
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
9595
}
9696

97+
/**
98+
* @internal
99+
*/
100+
public function __wakeup(): void
101+
{
102+
$this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0;
103+
}
104+
97105
/**
98106
* @return \Traversable
99107
*/

src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,17 @@ public function testUnbalancedBraceFallback()
194194

195195
$this->assertSame([], array_keys(iterator_to_array($resource)));
196196
}
197+
198+
public function testSerializeUnserialize()
199+
{
200+
$dir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
201+
$resource = new GlobResource($dir, '/Resource', true);
202+
203+
$newResource = unserialize(serialize($resource));
204+
205+
$p = new \ReflectionProperty($resource, 'globBrace');
206+
$p->setAccessible(true);
207+
208+
$this->assertEquals($p->getValue($resource), $p->getValue($newResource));
209+
}
197210
}

0 commit comments

Comments
 (0)