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

Add support for doctrine/annotations 2.0 and remove requirement to doctrine/cache #32

Open
wants to merge 5 commits into
base: 5.x
Choose a base branch
from

Conversation

alexander-schranz
Copy link
Member

@alexander-schranz alexander-schranz commented Feb 16, 2023

TODO

  • Error: Call to undefined method Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() PHP 7.3
  • Error: Class "Doctrine\Common\Annotations\CachedReader" does not exist
  • Error: You have requested a non-existent parameter "container.build_id".

require atleast 1.13 and update CachedReader to the with PSRCachedReader: doctrine/annotations@c66f06b.

This requires that we move from doctrine/cache to symfony/cache psr cache think metadata can use the symfony system cache.

In this case i completely removed the requirement to doctrine/cache and replaced it in all cases with the PSRCacheReader. This is a small BC break which should mostly not have effects on existing systems. Still I would go here with a new Minor release so somebody could still require 5.4.* when still want to use doctrine/cache or older annotations version.

@alexander-schranz alexander-schranz added enhancement New feature or request help wanted Extra attention is needed labels Feb 16, 2023
@alexander-schranz alexander-schranz force-pushed the enhancement/support-doctrine-annotations-2-0 branch from 69e7c46 to c5be651 Compare June 13, 2023 21:39
- php-version: '7.2'
elasticsearch-version: '5.6.14'
lint: false
symfony-version: '^2.8'
Copy link
Member Author

Choose a reason for hiding this comment

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

support for Symfony 2 dropped because of requirement to symfony/cache

@alexander-schranz alexander-schranz force-pushed the enhancement/support-doctrine-annotations-2-0 branch from c5be651 to f04b5c8 Compare June 13, 2023 21:40
@alexander-schranz alexander-schranz force-pushed the enhancement/support-doctrine-annotations-2-0 branch from f04b5c8 to 7167d69 Compare June 13, 2023 21:43
Comment on lines +32 to +46
$hasContainerBuildId = $container->hasParameter('container.build_id');
if (!$hasContainerBuildId) {
// the 'container.build_id' is required for `es.cache_engine` system cache which normally can not
// be constructor inside a compiler pass. This is a workaround to make it work.
// see also:
// - https://github.com/symfony/symfony/blob/52a92926f7fed15cdff399c6921100a10e0d6f61/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L389
// - https://github.com/symfony/symfony/blob/52a92926f7fed15cdff399c6921100a10e0d6f61/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L2322
$hasContainerBuildId = true;
$container->setParameter('container.build_id', hash('crc32', 'Abc123' . time()));
}

$collector = $container->get('es.metadata_collector');
if (!$hasContainerBuildId) {
$container->getParameterBag()->remove('container.build_id');
}
Copy link
Member Author

@alexander-schranz alexander-schranz Jun 13, 2023

Choose a reason for hiding this comment

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

This is required when using the cache.system and access it inside the compile time. Another possibility would be to use the cache.app but which does not require build_id. But metadata normally is invalidated between deployments and should fast readable which normally is job of the cache.system and not the cache.app.

You have requested a non-existent parameter "container.build_id".

@alexander-schranz alexander-schranz force-pushed the enhancement/support-doctrine-annotations-2-0 branch from aef3071 to adeb229 Compare June 13, 2023 22:00
@alexander-schranz alexander-schranz marked this pull request as ready for review June 13, 2023 22:09
Comment on lines +99 to +104
- name: Composer require
if: ${{ matrix.symfony-version == '^4.4' }}
# symfony 4.4 not compatible with doctrine/annotations 2.0: https://github.com/symfony/symfony/issues/48717#issuecomment-1359164836
run: |
composer require --no-update doctrine/annotations:^1.10

Copy link
Member Author

@alexander-schranz alexander-schranz Jun 13, 2023

Choose a reason for hiding this comment

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

Required for: Error: Call to undefined method Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() in PHP 7.3 with Symfony 4.4

@alexander-schranz alexander-schranz changed the title Add support for doctrine/annotations 2.0 Add support for doctrine/annotations 2.0 and remove requirement to doctrine/cache Jun 13, 2023
@alexander-schranz alexander-schranz force-pushed the enhancement/support-doctrine-annotations-2-0 branch from 0b41a5f to 7bc87fa Compare June 13, 2023 22:19
@alexander-schranz alexander-schranz force-pushed the enhancement/support-doctrine-annotations-2-0 branch from 7bc87fa to 11de7a1 Compare June 13, 2023 22:21
@alexander-schranz alexander-schranz removed the help wanted Extra attention is needed label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant