craftcms / craftcms/cms

Category query search fails for one particular category in the group.

Open
#3,076 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

This is a very weird issue. I have a template that performs a category query in the following fashion:
{% set platformCategory = craft.categories.group('categoryGroup').search(category).one() %}

I get the category variable from the current URL. I have a total of 4 categories in that group. This query works on all of them except for the last category in the group (I checked this dynamically and by hard-coding the queries).

After further inspection, I found that the three categories that work have neighboring IDs (14,15,16) and the one that fails is not a neighbor (28).

If you perform this query {% set platformCategory = craft.categories.group('categoryGroup').id(28).one() %} Craft will actually return a succesful response that will render the elements based on that category.

It's an extremely weird issue and I have no reasons to suspect this is a bug on my side since I have been able to make queries for 3 of the 4 categories. I already cleared my cache and search indexes with no success.

Please advice.

Steps to reproduce

See above.

Additional info
  • Craft version: Craft Pro 3.0.14
  • PHP version: 7.1.16
  • Database driver & version: MySQL 5.7.19
  • Plugins & versions:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is identified in the report. Start by reproducing the category query from the template with Craft 3.0.14, comparing the failing category search with the successful id query and checking whether the search index is involved. Done means the category query returns the category with ID 28 and its elements render as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
backend, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.