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

Error "Too few parameter given" on widget filter when associate with a Widget Listing on a BusinessPage #979

Open
MadeWilson opened this issue Aug 7, 2017 · 0 comments

Comments

@MadeWilson
Copy link
Contributor

MadeWilson commented Aug 7, 2017

Description

When creating a widget filter for a widget list, build in query mode on a business page and using
:currentEntity variable in the query. An exception is thrown Too few parameters given in query.

There are a few victoire and widget structural problem involve in this issue.
If we take a look at the actual WidgetFilter mechanics we goes with the following UML.

Uploading actual.png…

Here we can see that the core block for filter is made with BaseFilter extended class. The first problem with that is this sort off class are based on Form AbstractType class from Symfony. But they do way to much, the buildQuery method is called to build the request generated after filtered the widget list. This Method make no sense in this class since she should only build a form.

The buildForm method do here job, but she do more and not with the correct tools. Instead of building here query (used to populate the select field of the widget) with the Victoire QueryHelper, she used a custom method from ArticleRepository who are poorly coded (filterWithListingQuery).

The result of that method is query like the following:

SELECT t_tag 
 FROM Victoire\Bundle\BlogBundle\Entity\Tag t_tag 
 INNER JOIN t_tag.articles t_article 
 WHERE t_article IN(
     SELECT article 
     FROM Victoire\Bundle\BlogBundle\Entity\Article article 
     WHERE (article.status = :status 
     OR (article.status = :scheduled_status 
     AND article.publishedAt <= :now)) 
     AND article IN(
         SELECT item 
         FROM Victoire\Bundle\BlogBundle\Entity\Article item 
         LEFT JOIN item.blog blog where item.category=:currentEntity
    )
)

The issue comes from the fact that at this point doctrine doesn't know the value he has to associate with the parameter :currentEntity.

Resolution Ideas

The Query helper has a method to build a query for a widget using the :currentEntity parameter.
We should remove completely the method coming from the ArticleRepository and add a new sort of service using the QueryHelper. Idealy we should have, for the initial query building the select, a class based on the tag's EntityRepository and able to use the QueryHelper. And another to generate the filter's results on the widget list.

Related to

Bundle -- -- --
Analytics Page
Blog X Query X
BusinessEntity X Seo
BusinessPage Sitemap
Core Template
Criteria Twig
Filter X User
Form ViewReference
I18n Widget X
Media WidgetMap
UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants