Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PsrCachedReader and drop doctrine/cache #1327

Merged
merged 1 commit into from
Jul 1, 2021
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
5 changes: 5 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased
==========

- Use symfony/cache for FileSystem cache implementation instead of doctrine/cache

From 2.x to 3.0.0
=================

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"phpstan/phpdoc-parser": "^0.4 || ^0.5"
},
"suggest": {
"doctrine/cache": "Required if you like to use cache functionality.",
"doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.",
"symfony/cache": "Required if you like to use cache functionality.",
"symfony/yaml": "Required if you'd like to use the YAML metadata format."
},
"require-dev": {
Expand Down
8 changes: 4 additions & 4 deletions src/SerializerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
namespace JMS\Serializer;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\FilesystemCache;
use JMS\Serializer\Accessor\AccessorStrategyInterface;
use JMS\Serializer\Accessor\DefaultAccessorStrategy;
use JMS\Serializer\Builder\DefaultDriverFactory;
Expand Down Expand Up @@ -50,6 +49,7 @@
use Metadata\Cache\FileCache;
use Metadata\MetadataFactory;
use Metadata\MetadataFactoryInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

/**
* Builder for serializer instances.
Expand Down Expand Up @@ -525,8 +525,8 @@ public function build(): Serializer

if (null !== $this->cacheDir) {
$this->createDir($this->cacheDir . '/annotations');
$annotationsCache = new FilesystemCache($this->cacheDir . '/annotations');
$annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug);
$annotationsCache = new FilesystemAdapter('', 0, $this->cacheDir . '/annotations');
Copy link
Collaborator

@goetas goetas Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would result in a breaking change for people who have not yet installed the symfony/cache component.

I would suggest to check it the Symfony\Component\Cache\Adapter\FilesystemAdapter class exists use that, if not fallback to the current caching classes.

$annotationReader = new PsrCachedReader($annotationReader, $annotationsCache, $this->debug);
}
}

Expand Down