Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes description
After fixing the FAQ tree in glpi-project/glpi#12922, I've noticed that it was still incorrect in formcreator.
If you have at least one visible article then all categories will be shown (even if these categories have no visible articles themselves).
This seems caused by an incorrect SQL query:
The column that is supposed to count the visible items in a category actually count the number of visible articles in the whole FAQ (as you can see in the
WHERE
clause - no restriction on current category).If I compare the code to the one used in the core (there is two very similar functions - maybe formcreator should reuse the core code here instead of rewriting it).
Formcreator
inc.knowbase.class.php
:Core
Src/Knowbase.php
:You can see that the core code have the correct
WHERE
clause that limit the scope to the current category, while the formcreator code seems to have an uselessJOIN
instead (that must be removed for theWHERE
to work as it target the same table).After copying the core code, the SQL request work as expected:
References
!25026
glpi-project/glpi#12922