User tests: Successful: Unsuccessful:
Counting of the number of tags did not accommodate for arrays that are passed in as parameter to \JHelperTags::getTagItemsQuery();
When passed in an array of tags the $ntagsr variable is always 1, causing the $anyOrAll boolean to have no effect on the created query.
Counting of the input tags is now done after converting the parameter to array and sanitizing it.
$ntagsr = count($tagIds);
$tagsHelper = new \JHelperTags;
$anyOrAll = true;
$query1 = $tagsHelper->getTagItemsQuery(
[ 1, 2, 3 ],
[1],
false,
"c.core_created_time",
"DESC",
$anyOrAll,
"all",
"1"
);
$anyOrAll = false;
$query2 = $tagsHelper->getTagItemsQuery(
[ 1, 2, 3 ],
[1],
false,
"c.core_created_time",
"DESC",
$anyOrAll,
"all",
"1"
);
$query2 should have a HAVING statement to only select results that have ALL the tags.
$query1 and $query2 both return the same query. Counting the amount of tags passed to the method is returning 1, causing the HAVING statement to never get added:
// Counting the tags
$ntagsr = substr_count($tagId, ',') + 1;
//Returns 1 when $tagId is an array
// Use HAVING if matching all tags and we are matching more than one tag.
if ($ntagsr > 1 && $anyOrAll != 1 && $includeChildren != 1)
{
// The number of results should equal the number of tags requested.
$query->having("match_count = " . (int) $ntagsr);
}
// This never gets executed when passing in an array
None
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Category | Libraries | ⇒ | com_tags Libraries |
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-05-09 18:44:38 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
|
Category | Libraries com_tags | ⇒ | Libraries |
I have tested this item✅ successfully on ea7be6c
looks much better. If you pass an array there is a warning anyway as substr_count can't handle arrays.
Thanks @npostman !
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15454.