FriendsOfSymfony / FOSElasticaBundle

Elasticsearch PHP integration for your Symfony project using Elastica.
http://friendsofsymfony.github.io
MIT License
1.24k stars 795 forks source link

Class QueryAdapter not found after updating to v6.3.0 #1911

Closed fzberlin23 closed 1 year ago

fzberlin23 commented 1 year ago

Hi,

today i updated friendsofsymfony/elastica-bundle (v6.2.0 => v6.3.0).

php composer.phar update --no-progress --with-all-dependencies

Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 2 updates, 1 removal
  - Removing pagerfanta/pagerfanta (v3.6.2)
  - Upgrading friendsofphp/proxy-manager-lts (v1.0.15 => v1.0.16)
  - Upgrading friendsofsymfony/elastica-bundle (v6.2.0 => v6.3.0)
  - Locking pagerfanta/core (v3.8.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 2 updates, 1 removal
  - Removing pagerfanta/pagerfanta (v3.6.2)
  - Upgrading friendsofphp/proxy-manager-lts (v1.0.15 => v1.0.16): Extracting archive
  - Installing pagerfanta/core (v3.8.0): Extracting archive
  - Upgrading friendsofsymfony/elastica-bundle (v6.2.0 => v6.3.0): Extracting archive

When i run php app/console fos:elastica:populate in my symfony application i get:

In ORMPagerProvider.php line 79:

  Attempted to load class "QueryAdapter" from namespace "Pagerfanta\Doctrine\  
  ORM".                                                                        
  Did you forget a "use" statement for another namespace?                      

fos:elastica:populate [--index [INDEX]] [--no-reset] [--no-delete] [--sleep SLEEP] [--ignore-errors] [--no-overwrite-format] [--first-page FIRST-PAGE] [--last-page LAST-PAGE] [--max-per-page MAX-PER-PAGE] [--pager-persister PAGER-PERSISTER] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

It seems that in ORMPagerProvider.php line 79 the class QueryAdapter is used. But this class does not exist anymore (it existed in pagerfanta/pagerfanta, which was removed).

Does anyone have the same problem? Thank you very much.

mitrae commented 1 year ago

confirm, same error. updated PagerfantaBundle to the latest 3.x - did not help symfony 4.4, php 7.4, elasticsearch 7

cristobaldiaz-aircury commented 1 year ago

Confirmed it happens also upgrading from 5.1 to 6.3. It seems that the issue appeared when switching this requirement in 6.3: pagerfanta/pagerfanta: ^2.4 || ^3.0 for this one pagerfanta/core: ^2.4 || ^3.0

I discovered this workaround: composer require pagerfanta/pagerfanta:^2.4 -W

mbabker commented 1 year ago

You can install whichever adapters your application will need using the list at https://www.babdev.com/open-source/packages/pagerfanta/docs/3.x/installation

The PagerfantaBundle stopped installing the pagerfanta/pagerfanta mono-package with 3.0 and I'm generally encouraging folks to rely on the subsplit packages over the full mono-package (as installing the mono-package brings in a lot of unused code and has a much more complex dependency graph for Composer to deal with compared to the individual packages).

XWB commented 1 year ago

@mbabker You are certainly right, but perhaps we should restore the pagerfanta/pagerfanta dependency for BC reason, and make the split in the next major release?

mbabker commented 1 year ago

Personally, I don't consider #1895 a B/C issue because the root cause is an application relying on transient dependencies.

That said, however, because this bundle isn't checking optional dependencies (as pointed out in https://github.com/FriendsOfSymfony/FOSElasticaBundle/pull/1912#issuecomment-1564477433 the doctrine/orm integration is optional yet FOS\ElasticaBundle\Doctrine\ORMPagerProvider has no safeguards to make sure its dependencies are met), the "safest" option for this bundle is to revert to requiring the mono-package, which will at least ensure all classes in Pagerfanta are always installed for now. Then in future versions, there should be safeguards added at compile-time and runtime to make sure folks aren't configuring things that can't be used (i.e. a check in FOSElasticaExtension::loadIndexPagerProvider() to make sure the needed Doctrine managers are installed for the configured providers or a class_exists() check in the pager provider classes for Pagerfanta adapters) and making sure that all of the optional integrations and their dependencies are documented (i.e. to use the ORM provider install doctrine/orm doctrine/doctrine-bundle pagerfanta/doctrine-orm-adapter).