Closed Riches closed 2 years ago
Hi @Riches, when you tried the 3.102 and 3.103 version, was it with the same DoctrineORMAdmin version ? (to be sure it's related to the 3.103 version of the SonataAdmin bundle).
I already did some fix like https://github.com/sonata-project/SonataAdminBundle/pull/7360. Did you try with the latest version ?
It's kinda weird, because in the RetrieveAutocompleteItemsAction
, we're setting
$filter->setCondition(FilterInterface::CONDITION_OR);
if (null !== $previousFilter) {
$filter->setPreviousFilter($previousFilter);
}
and then it's supposed to be supported in https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/3.x/src/Filter/Filter.php
cc @phansys
Many kind thanks for your reply, I hope we can get to the bottom of this.
My apologies, after looking a bit more closely it doesn't look like the issue lies in the SonataAdminBundle as I've managed to update that to 3.107.1 and it works as long as I hold DoctrineOrmAdminBundle back to 3.34.3, upgrading to 3.35.0 or the latest (for the 3.x branch) 3.35.1 brings back the issue. SonataAdminBundle 3.102 holds the version of DoctrineOrmAdminBundle back to a maximum version of 3.34.3, which is why it looked like this was the last working version.
Please let me know if I can help in providing any more information.
My apologies, after looking a bit more closely it doesn't look like the issue lies in the SonataAdminBundle as I've managed to update that to 3.107.1 and it works as long as I hold DoctrineOrmAdminBundle back to 3.34.3, upgrading to 3.35.0 or the latest (for the 3.x branch) 3.35.1 brings back the issue. SonataAdminBundle 3.102 holds the version of DoctrineOrmAdminBundle back to a maximum version of 3.34.3, which is why it looked like this was the last working version.
So if I understand correctly, this was introduce by the 3.35.0 release of DoctrineORMAdminBundle Changes are here: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/compare/3.34.3...3.35.0
It must be related to https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1477 then.
In your example, when looking at https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Action/RetrieveAutocompleteItemsAction.php#L122-L156
The filter "name" has the condition OR set. The filter "name" won't have a previous filter. The filter "productCode" has the condition OR set. the filter "productCode" has the previous filter "name".
It would be interesting for you to add some dump in this method in order to know what is happening in this method instead. @Riches ; seems like the productCode filter doesn't reach the code
if ($this->hasPreviousFilter()) {
$previousFilter = $this->getPreviousFilter();
if ($previousFilter->hasConditionGroup()) {
$conditionGroup = $previousFilter->getConditionGroup();
$conditionGroup->add($parameter);
$this->setConditionGroup($conditionGroup);
return;
}
}
and instead add a AND condition...
Maybe it's related to the reorder filter call https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Action/RetrieveAutocompleteItemsAction.php#L155
Unbeknownst to me the application I am working on overrode the RetrieveAutocompleteItemsAction service with their own implementation, and that is the source of the problem here. I regret not discovering this before reporting the issue, my greatest apologies for wasting your time and will investigate more closely myself before reporting next time!
Sonata packages
show
``` sonata-project/admin-bundle 3.107.1 4.7.0 The missing Symfony Admin Generator sonata-project/block-bundle 3.23.3 4.9.1 Symfony SonataBlockBundle sonata-project/cache 2.2.0 2.2.0 Cache library sonata-project/doctrine-extensions 1.16.0 1.16.0 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 3.35.1 4.2.1 Integrate Doctrine ORM into the SonataAdminBundle sonata-project/exporter 2.10.1 2.10.1 Lightweight Exporter library sonata-project/form-extensions 1.12.4 1.12.4 Symfony form extensions sonata-project/formatter-bundle 4.6.1 4.6.1 Symfony SonataFormatterBundle sonata-project/media-bundle 3.31.0 3.37.1 Symfony SonataMediaBundle sonata-project/twig-extensions 1.9.1 1.9.1 Sonata twig extensions ```
Symfony packages
show
``` symfony/asset v4.4.27 v6.0.1 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files ... symfony/cache v5.4.2 v6.0.2 Provides an extended PSR-6, PSR-16 (and tags) implementation symfony/cache-contracts v2.5.0 v3.0.0 Generic abstractions related to caching symfony/config v4.4.36 v6.0.2 Helps you find, load, combine, autofill and validate configuration values of any kind symfony/console v4.4.36 v6.0.2 Eases the creation of beautiful and testable command line interfaces symfony/debug v4.4.36 v4.4.36 Provides tools to ease debugging PHP code symfony/dependency-injection v4.4.36 v6.0.2 Allows you to standardize and centralize the way objects are constructed in your application symfony/deprecation-contracts v2.5.0 v3.0.0 A generic function and convention to trigger deprecation notices symfony/doctrine-bridge v4.4.36 v6.0.2 Provides integration for Doctrine with various Symfony components symfony/dotenv v4.4.36 v6.0.2 Registers environment variables from a .env file symfony/error-handler v4.4.36 v6.0.2 Provides tools to manage errors and ease debugging PHP code symfony/event-dispatcher v4.4.34 v6.0.2 Provides tools that allow your application components to communicate with each other by dispat... symfony/event-dispatcher-contracts v1.1.11 v3.0.0 Generic abstractions related to dispatching event symfony/expression-language v4.4.34 v6.0.1 Provides an engine that can compile and evaluate expressions symfony/filesystem v5.4.0 v6.0.0 Provides basic utilities for the filesystem symfony/finder v4.4.36 v6.0.2 Finds files and directories via an intuitive fluent interface symfony/flex v2.0.1 v2.0.1 Composer plugin for Symfony symfony/form v4.4.36 v6.0.2 Allows to easily create, process and reuse HTML forms symfony/framework-bundle v4.4.36 v6.0.2 Provides a tight integration between Symfony components and the Symfony full-stack framework symfony/http-client v4.4.36 v6.0.2 Provides powerful methods to fetch HTTP resources synchronously or asynchronously symfony/http-client-contracts v2.5.0 v3.0.0 Generic abstractions related to HTTP clients symfony/http-foundation v4.4.36 v6.0.2 Defines an object-oriented layer for the HTTP specification symfony/http-kernel v4.4.36 v6.0.2 Provides a structured process for converting a Request into a Response symfony/intl v5.4.2 v6.0.1 Provides a PHP replacement layer for the C intl extension that includes additional data from t... symfony/lock v5.4.2 v6.0.2 Creates and manages locks, a mechanism to provide exclusive access to a shared resource symfony/mercure v0.6.1 v0.6.1 Symfony Mercure Component symfony/mercure-bundle v0.3.4 v0.3.4 Symfony MercureBundle symfony/messenger v4.4.36 v6.0.2 Helps applications send and receive messages to/from other applications or via message queues symfony/mime v5.4.2 v6.0.2 Allows manipulating MIME messages symfony/monolog-bridge v5.2.12 v6.0.1 Provides integration for Monolog with various Symfony components symfony/monolog-bundle v3.7.1 v3.7.1 Symfony MonologBundle symfony/options-resolver v5.4.0 v6.0.0 Provides an improved replacement for the array_replace PHP function symfony/phpunit-bridge v6.0.0 v6.0.0 Provides utilities for PHPUnit, especially user deprecation notices management symfony/polyfill-intl-grapheme v1.24.0 v1.24.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-php80 v1.24.0 v1.24.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/polyfill-php81 v1.24.0 v1.24.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions symfony/process v4.4.36 v6.0.2 Executes commands in sub-processes symfony/property-access v5.4.2 v6.0.2 Provides functions to read and write from/to an object or array using a simple string notation symfony/property-info v5.4.2 v6.0.2 Extracts information about PHP class' properties using metadata of popular sources symfony/rate-limiter v5.3.4 v6.0.2 Provides a Token Bucket implementation to rate limit input and output in your application symfony/routing v4.4.34 v6.0.1 Maps an HTTP request to a set of configuration variables symfony/security-acl v3.2.0 v3.2.0 Symfony Security Component - ACL (Access Control List) symfony/security-bundle v4.4.36 v6.0.2 Provides a tight integration of the Security component into the Symfony full-stack framework symfony/security-core v4.4.36 v6.0.2 Symfony Security Component - Core Library symfony/security-csrf v4.4.27 v6.0.1 Symfony Security Component - CSRF Library symfony/security-guard v4.4.27 v5.4.0 Symfony Security Component - Guard symfony/security-http v4.4.36 v6.0.2 Symfony Security Component - HTTP Integration symfony/serializer v4.4.36 v6.0.2 Handles serializing and deserializing data structures, including object graphs, into array str... symfony/service-contracts v2.5.0 v3.0.0 Generic abstractions related to writing services symfony/stopwatch v4.4.27 v6.0.0 Provides a way to profile code symfony/string v5.4.2 v6.0.2 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and graphem... symfony/swiftmailer-bundle v3.5.3 v3.5.3 Symfony SwiftmailerBundle symfony/templating v5.4.0 v6.0.2 Provides all the tools needed to build any kind of template system symfony/translation v4.4.34 v6.0.2 Provides tools to internationalize your application symfony/translation-contracts v2.5.0 v3.0.0 Generic abstractions related to translation symfony/twig-bridge v4.4.36 v6.0.2 Provides integration for Twig with various Symfony components symfony/twig-bundle v4.4.36 v6.0.1 Provides a tight integration of Twig into the Symfony full-stack framework symfony/validator v4.4.36 v6.0.2 Provides tools to validate values symfony/var-dumper v5.4.2 v6.0.2 Provides mechanisms for walking through any arbitrary PHP variable symfony/var-exporter v6.0.0 v6.0.0 Allows exporting any serializable PHP data structure to plain PHP code symfony/web-link v5.2.12 v6.0.1 Manages links between resources symfony/web-profiler-bundle v4.4.31 v6.0.2 Provides a development tool that gives detailed information about the execution of any request symfony/workflow v4.4.27 v6.0.2 Provides tools for managing a workflow or finite state machine symfony/yaml v4.4.36 v6.0.2 Loads and dumps YAML files ```
PHP version
Subject
Since 3.103.0 ModelAutocompleteType incorrectly uses AND instead of OR in query when array of multiple search properties are provided.
We use a ModelAutocompleteType like so
With filters like so
On 3.102.0 using the ModelTypecompleteType results in a DQL query
p0_.prod_name LIKE ? OR p0_.prod_code
whereas upgrading to 3.103.0 results in a DQL queryp0_.prod_name LIKE ? AND p0_.prod_code
. Which appears to be a bug. I cannot find this new behaviour documented anywhere.I did find that this issue was subtly mentioned in a previous issue, although I'm not sure if it was directly addressed. https://github.com/sonata-project/SonataAdminBundle/pull/7530#issuecomment-945149167