? Pending

User tests: Successful: Unsuccessful:

avatar npostman
npostman
21 Apr 2017

Summary of Changes

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);

Testing Instructions

$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"
);

Expected result

$query2 should have a HAVING statement to only select results that have ALL the tags.

Actual result

$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

Documentation Changes Required

None

avatar npostman npostman - open - 21 Apr 2017
avatar npostman npostman - change - 21 Apr 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 21 Apr 2017
Category Libraries
avatar franz-wohlkoenig franz-wohlkoenig - change - 21 Apr 2017
Category Libraries com_tags Libraries
avatar zero-24 zero-24 - test_item - 21 Apr 2017 - Tested successfully
avatar zero-24
zero-24 - comment - 21 Apr 2017

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.

avatar PhilETaylor
PhilETaylor - comment - 5 May 2017

I have tested this item successfully on ea7be6c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15454.

avatar PhilETaylor PhilETaylor - test_item - 5 May 2017 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 May 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 May 2017

RTC after two successful tests.

avatar rdeutz rdeutz - change - 9 May 2017
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: ?
avatar rdeutz rdeutz - close - 9 May 2017
avatar rdeutz rdeutz - merge - 9 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 9 May 2017
Category Libraries com_tags Libraries

Add a Comment

Login with GitHub to post a comment