Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function write(string $content, ?array $metadata = null): void
}

$ser = preg_replace_callback('/;O:(\d+):"/', static fn ($m) => ';O:'.(9 + $m[1]).':"Tracking\\', $ser);
$ser = preg_replace_callback('/s:(\d+):"\0[^\0]++\0/', static fn ($m) => 's:'.($m[1] - \strlen($m[0]) + 6).':"', $ser);
$ser = preg_replace_callback('/s:(\d+):"(\0[^\0]++\0)/', static fn ($m) => 's:'.($m[1] - \strlen($m[2])).':"', $ser);
$ser = unserialize($ser, ['allowed_classes' => false]);
$ser = @json_encode($ser, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE) ?: [];
$ser = str_replace('"__PHP_Incomplete_Class_Name":"Tracking\\\\', '"@type":"', $ser);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Symfony\Component\Config\Tests\Fixtures;

use Symfony\Component\Config\Resource\ResourceInterface;

class ResourceWithVeryVeryVeryVeryVeryVeryVeryVeryLongName implements ResourceInterface
{
public function __construct(private string $resource)
{
}

public function __toString(): string
{
return __CLASS__;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\ResourceCheckerConfigCache;
use Symfony\Component\Config\ResourceCheckerInterface;
use Symfony\Component\Config\Tests\Fixtures\ResourceWithVeryVeryVeryVeryVeryVeryVeryVeryLongName;
use Symfony\Component\Config\Tests\Resource\ResourceStub;

class ResourceCheckerConfigCacheTest extends TestCase
Expand Down Expand Up @@ -170,4 +171,21 @@ public function testCacheWithCustomMetaFile()
],
], \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
}

public function testCacheWithResourceWithLongPropertyId()
{
$cache = new ResourceCheckerConfigCache($this->cacheFile);
$cache->write('foo', [new ResourceWithVeryVeryVeryVeryVeryVeryVeryVeryLongName(__FILE__)]);

$this->assertStringNotEqualsFile($this->cacheFile.'.meta', '');

$this->assertStringEqualsFile($this->cacheFile.'.meta.json', json_encode([
'resources' => [
[
'@type' => ResourceWithVeryVeryVeryVeryVeryVeryVeryVeryLongName::class,
'resource' => __FILE__,
],
],
], \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
}
}
Loading