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

[BUG] getContent can't handle a taxonomy where clause where contenttype doesn't use the specified taxonomy (singular and multiple) #6050

Closed
graham73may opened this issue Nov 15, 2016 · 6 comments
Assignees

Comments

@graham73may
Copy link
Contributor

graham73may commented Nov 15, 2016

If you have a number of contenttypes e.g.:

  • pages
  • events
  • reports

And only pages and reports have the tags taxonomy then:

$app['query']->getContent(('pages','events','reports'), ['tags' => 'soapbox']);

Throws an error:

Twig_Error_Runtime in Template.php line 218: 
An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT projects.*, GROUP_CONCAT(incomingrelation.id) as _incomingrelation_id, GROUP_CONCAT(incomingrelation.from_id) as _incomingrelation_fromid, GROUP_CONCAT(incomingrelation.from_contenttype) as _incomingrelation_fromcontenttype FROM bolt_projects projects LEFT JOIN bolt_relations incomingrelation ON projects.id = incomingrelation.to_id AND incomingrelation.to_contenttype='projects' WHERE (tags.slug = ?) AND (tags.slug = ?) AND (tags.slug = ?) AND (tags.slug = ?) AND (tags.slug = ?) AND (projects.tags = ?) GROUP BY projects.id' with params ["soapbox", "soapbox", "soapbox", "soapbox", "soapbox", "soapbox"]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tags.slug' in 'where clause'") in "page.twig" at line 24.

P.s. Sorry for the multiple edits, hit enter and it submitted the form ¬_¬

@graham73may graham73may changed the title [BUG] getContent can't handle multiple contenttypes with a taxonomy where clause if all post types do not have the [BUG] getContent can't handle multiple contenttypes with a taxonomy where clause Nov 15, 2016
@graham73may graham73may changed the title [BUG] getContent can't handle multiple contenttypes with a taxonomy where clause [BUG] getContent can't taxonomy where clause where contenttype doesn't use that taxonomy (singular and multiple) Nov 15, 2016
@graham73may
Copy link
Contributor Author

Tested what happens if you try to use a taxonomy where clause on a single content type that doesn't use the taxonomy:

$app['query']->getContent('events', ['tags' => 'soapbox']);

Also throws an error, not sure if this is intended?

@graham73may graham73may changed the title [BUG] getContent can't taxonomy where clause where contenttype doesn't use that taxonomy (singular and multiple) [BUG] getContent can't handle a taxonomy where clause where contenttype doesn't use the specified taxonomy (singular and multiple) Nov 15, 2016
@graham73may
Copy link
Contributor Author

graham73may commented Nov 15, 2016

This may be related:

Trying to do an OR filter by multiple taxonomies throws a similar error:

        // Contenttypes string
        $query_contenttypes_string = ('pages', 'events', 'reports');

        // Taxonomy where array
        $query_tax_where_array = [
            'categories ||| tags' => 'Commissioning || Evaluation ||| poetry || architecture || nonfiction || research || math',
        ];

        $results = $app['query']->getContent($query_contenttypes_string, $query_tax_where_array);

Error:

Uncaught Exception: Twig_Error_Runtime
Twig_Error_Runtime in Template.php line 218: 
An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT news.*, GROUP_CONCAT(people.id) as _people_id, GROUP_CONCAT(people.to_id) as _people_toid, GROUP_CONCAT(incomingrelation.id) as _incomingrelation_id, GROUP_CONCAT(incomingrelation.from_id) as _incomingrelation_fromid, GROUP_CONCAT(incomingrelation.from_contenttype) as _incomingrelation_fromcontenttype, GROUP_CONCAT(newstypes.id ORDER BY newstypes.id ASC) as _newstypes_id, GROUP_CONCAT(newstypes.slug ORDER BY newstypes.id ASC) as _newstypes_slug, GROUP_CONCAT(newstypes.name ORDER BY newstypes.id ASC) as _newstypes_name, GROUP_CONCAT(newstypes.taxonomytype ORDER BY newstypes.id ASC) as _newstypes_taxonomytype, GROUP_CONCAT(categories.id ORDER BY categories.id ASC) as _categories_id, GROUP_CONCAT(categories.slug ORDER BY categories.id ASC) as _categories_slug, GROUP_CONCAT(categories.name ORDER BY categories.id ASC) as _categories_name, GROUP_CONCAT(categories.taxonomytype ORDER BY categories.id ASC) as _categories_taxonomytype, GROUP_CONCAT(tags.id ORDER BY tags.id ASC) as _tags_id, GROUP_CONCAT(tags.slug ORDER BY tags.id ASC) as _tags_slug, GROUP_CONCAT(tags.name ORDER BY tags.id ASC) as _tags_name, GROUP_CONCAT(tags.taxonomytype ORDER BY tags.id ASC) as _tags_taxonomytype FROM bolt_news news LEFT JOIN bolt_relations people ON news.id = people.from_id AND people.from_contenttype='news' AND people.to_contenttype='people' LEFT JOIN bolt_relations incomingrelation ON news.id = incomingrelation.to_id AND incomingrelation.to_contenttype='news' LEFT JOIN bolt_taxonomy newstypes ON news.id = newstypes.content_id AND newstypes.contenttype='news' AND newstypes.taxonomytype='newstypes' LEFT JOIN bolt_taxonomy categories ON news.id = categories.content_id AND categories.contenttype='news' AND categories.taxonomytype='categories' LEFT JOIN bolt_taxonomy tags ON news.id = tags.content_id AND tags.contenttype='news' AND tags.taxonomytype='tags' WHERE (news.categories = ?) OR (news.tags = ?) GROUP BY news.id, news.id, news.id, news.id, news.id' with params ["Commissioning || Evaluation", "poetry || architecture || nonfiction || research || math"]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'news.categories' in 'where clause'") in "record.twig" at line 16.

What's different in this instance, is news definitely has the categories taxonomy, but a Column not found error is thrown?

EDIT: Done some more testing and this error is thrown when multiple contenttypes are used $query_contenttypes_string = ('pages', 'events', 'reports'); and when a single contenttype is used $query_contenttypes_string = 'events';

@rossriley rossriley self-assigned this Nov 15, 2016
@graham73may
Copy link
Contributor Author

Trying to search for if a relationList (Extension) plugin using the where param also fails:

Fails (Multi content type, all have the related_content column):

    $results = $app['query']->getContent(('pages','events','reports'), [
            'related_content' => '%charts/5%',
        ]);

Works (single content type):

    $results = $app['query']->getContent('events', [
            'related_content' => '%charts/5%',
        ]);

Multi-failure message:

Uncaught Exception: Twig_Error_Runtime
Twig_Error_Runtime in Template.php line 218: 
An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT resources.*, GROUP_CONCAT(people.id) as _people_id, GROUP_CONCAT(people.to_id) as _people_toid, GROUP_CONCAT(incomingrelation.id) as _incomingrelation_id, GROUP_CONCAT(incomingrelation.from_id) as _incomingrelation_fromid, GROUP_CONCAT(incomingrelation.from_contenttype) as _incomingrelation_fromcontenttype, GROUP_CONCAT(resourcetypes.id ORDER BY resourcetypes.id ASC) as _resourcetypes_id, GROUP_CONCAT(resourcetypes.slug ORDER BY resourcetypes.id ASC) as _resourcetypes_slug, GROUP_CONCAT(resourcetypes.name ORDER BY resourcetypes.id ASC) as _resourcetypes_name, GROUP_CONCAT(resourcetypes.taxonomytype ORDER BY resourcetypes.id ASC) as _resourcetypes_taxonomytype, GROUP_CONCAT(priorities.id ORDER BY priorities.id ASC) as _priorities_id, GROUP_CONCAT(priorities.slug ORDER BY priorities.id ASC) as _priorities_slug, GROUP_CONCAT(priorities.name ORDER BY priorities.id ASC) as _priorities_name, GROUP_CONCAT(priorities.taxonomytype ORDER BY priorities.id ASC) as _priorities_taxonomytype, GROUP_CONCAT(categories.id ORDER BY categories.id ASC) as _categories_id, GROUP_CONCAT(categories.slug ORDER BY categories.id ASC) as _categories_slug, GROUP_CONCAT(categories.name ORDER BY categories.id ASC) as _categories_name, GROUP_CONCAT(categories.taxonomytype ORDER BY categories.id ASC) as _categories_taxonomytype, GROUP_CONCAT(tags.id ORDER BY tags.id ASC) as _tags_id, GROUP_CONCAT(tags.slug ORDER BY tags.id ASC) as _tags_slug, GROUP_CONCAT(tags.name ORDER BY tags.id ASC) as _tags_name, GROUP_CONCAT(tags.taxonomytype ORDER BY tags.id ASC) as _tags_taxonomytype FROM bolt_resources resources LEFT JOIN bolt_relations people ON resources.id = people.from_id AND people.from_contenttype='resources' AND people.to_contenttype='people' LEFT JOIN bolt_relations incomingrelation ON resources.id = incomingrelation.to_id AND incomingrelation.to_contenttype='resources' LEFT JOIN bolt_taxonomy resourcetypes ON resources.id = resourcetypes.content_id AND resourcetypes.contenttype='resources' AND resourcetypes.taxonomytype='resourcetypes' LEFT JOIN bolt_taxonomy priorities ON resources.id = priorities.content_id AND priorities.contenttype='resources' AND priorities.taxonomytype='priorities' LEFT JOIN bolt_taxonomy categories ON resources.id = categories.content_id AND categories.contenttype='resources' AND categories.taxonomytype='categories' LEFT JOIN bolt_taxonomy tags ON resources.id = tags.content_id AND tags.contenttype='resources' AND tags.taxonomytype='tags' WHERE (news.related_content LIKE ?) AND (resources.related_content LIKE ?) GROUP BY resources.id, resources.id, resources.id, resources.id, resources.id, resources.id' with params ["%charts\/5%", "%charts\/5%"]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'news.related_content' in 'where clause'") in "record.twig" at line 16.

@graham73may
Copy link
Contributor Author

@GawainLynch This issue is not fixed yet - The fix breaks if more than one where parameter is used. tags ||| categories. Could you reopen this please?

@GwendolenLynch
Copy link
Contributor

OK, good to know. FYI this was auto-closed by GitHub's merge button on #6054

@GwendolenLynch
Copy link
Contributor

Finally fixed in #6061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants