? Failure

User tests: Successful: Unsuccessful:

avatar RickR2H
RickR2H
10 Jul 2015

Steps to reproduce the issue

Create 3 articles (Test article 1, Test article 2, Test article 3)
Create 3 Tags in the Tags Component (Tag 1, Tag 2, Tag 3)
Add to all the three articles all three tags
Create a menu item of the type "Compact list of tagged items"
Select in the menu item all the three tags in the Tag field
Select content type Article.

Access the menu item and the warning "Notice: Array to string conversion in C:\xampp\htdocs\joomla\libraries\joomla\filter\input.php on line 201" should be there.

Expected result

There should be no Notice warning

Actual result

A warning "Notice: Array to string conversion in C:\xampp\htdocs\joomla\libraries\joomla\filter\input.php on line 201"
The list of the articles which have the corresponding tags

System information (as much as possible)

PHP versie 5.6.9
Webserver Apache
WebServer naar PHP interface litespeed
Joomla! versie Joomla! 3.4.3 Stable [ Ember ] 2-July-2015 16:00 GMT
Joomla! Platform versie Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
Gebruikersagent Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36

Additional comments

Please check the code an I hope it does not break anything...

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar RickR2H RickR2H - open - 10 Jul 2015
avatar RickR2H RickR2H - change - 10 Jul 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 Jul 2015
Labels Added: ?
avatar photodude
photodude - comment - 10 Jul 2015

@RickR2H
Just my opinion, but reading over your PR I don't think your addressing the issue correctly. You have attempted to deal with the array to string conversion in one CASE; but reading the "clean" method docblock, all of the $type cases are affected any time the $source variable is an array (as "intended" by the docblock var definition for the $source)

Since $source is intended to be a string or an array of strings, any fix should address all $type cases rather than just the singular case in your PR. I'm not sure what the best why to deal with that is, but it looks like maybe creating a new variable that is only the first string of the $source variable to run through the $type switch case.

Maybe something like this pseudo-code before the switch case

// Are we dealing with an array or a string for the $source?
if (is_array($source))
{
// Get the first string value of the $source array and assign it to a new (string) variable for `preg_match()`
}
else
{
// The new variable = $source when it's just a string
}

Then change all the references in the cases that need a string value for preg_match() to use the new variable rather than $source. The exception is to not change the default case since it correctly deals with $source as is.

Another way to address this would be to consider changing preg_match() for preg_grep() since preg_grep() accepts an input array. Or to specify that we only want the first value from $source when at each preg_match() case. but as I said, I'm not sure what the best why to deal with this issue is.

PS I think this might be a framework issue rather than a CMS issue. I would suggest a PR in the framework for the input filter clean function https://github.com/joomla-framework/filter
Then the change can be back ported from the framework to the CMS

It looks like there is a fair amount of work needed on the clean function.

avatar photodude
photodude - comment - 11 Jul 2015

I gave it a shot, turns out to be a bit more complicated. You can check out my attempt https://github.com/photodude/filter/blob/patch-2/src/InputFilter.php

With the additional checks and function calls, I ended up with a single data scenario that fails. (an array with arrays for data)
https://travis-ci.org/joomla-framework/filter/jobs/70484294

avatar zero-24 zero-24 - change - 12 Jul 2015
Category Libraries
avatar RickR2H RickR2H - change - 17 Aug 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-08-17 23:01:30
Closed_By RickR2H
avatar RickR2H RickR2H - close - 17 Aug 2015
avatar RickR2H RickR2H - close - 17 Aug 2015
avatar RickR2H RickR2H - head_ref_deleted - 17 Aug 2015
avatar Bakual
Bakual - comment - 18 Aug 2015

Check com_tags, the error is most likely there and not in the filter class.

The thing is that com_tags is very strange in that the id parameter can either contain an integer (what we are used to), an array of integer (probably your case with multiple tags) or even a coma-separated list of ids.
I'm betting the issue is somewhere there :smile:

avatar photodude
photodude - comment - 27 Nov 2015

@Bakual I believe this is an issue in framework filter clean() method. I have fixed my PR that should address this issue.

joomla-framework/filter#13

avatar photodude
photodude - comment - 27 Nov 2015

@RickR2H could you test my PR in the Framework Filter library to see if this resolves the warnings you were seeing?

joomla-framework/filter#13

avatar photodude
photodude - comment - 3 Dec 2015

I have tested the steps listed in this issue with Joomla! 3.4.2, 3.4.3, 3.4.4, 3.4.5, and the staging branch
With a bitnami stack
PHP Version 5.4.39
Database Version 5.5.42

I was unable to replicate this issue. Either it was a fluke or we are missing something in the steps that caused the issue.

Add a Comment

Login with GitHub to post a comment