? Success
Pull Request for # 6008

User tests: Successful: Unsuccessful:

avatar Erftralle
Erftralle
10 Feb 2015

This is a pull request for issue #6008.
It fixes the applying of wrong filters in the case, that the function is called without parameters.

If using the JInput::getArray() function without parameters e.g.

        $mypostdata = $myapp->input->post->getArray();

and the post data contains variables having values matching a JInputFilter type e.g. 'integer', 'int', 'float' etc. these values will be applied as filter in the following function code:

                if (is_null($datasource))
                {
                    $results[$k] = $this->get($k, null, $v);
                }

When calling the function without parameters the function uses the class property 'data', which is an associative array with variable names and their values.

So, a POST variable 'myinputstring' containing a string value 'integer' will be returned as an integer containing a 0, which is definetly a wrong behaviour.

Wouldn't it be better to detect a parameterless function call to apply 'RAW' filters in that case?

avatar Erftralle Erftralle - open - 10 Feb 2015
avatar joomla-cms-bot joomla-cms-bot - change - 10 Feb 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 12 Feb 2015
Category Libraries
avatar zero-24 zero-24 - change - 12 Feb 2015
The description was changed
Rel_Number 6008
Relation Type Pull Request for
avatar Erftralle
Erftralle - comment - 12 Feb 2015

Unfortunately Joomla! doesn't use the JInput::getArray() function itself. But if you like, use the following method to detect the bug quickly and to test the fix for it.

Test instructions

Please install Joomla-3.2-Hello-World-Component Step 10, create a menu item and append the following code lines to the file components/com_helloworld/views/helloworld/tmpl/default.php:

<h4>The following test code is executed to demonstrate the bug in JInput::getArray():</h4>
<pre>
JFactory::getApplication()->input->set('my-input-string', 'integer');
$this->testdata = JFactory::getApplication()->input->getArray();
</pre>
<?php JFactory::getApplication()->input->set('my-input-string', 'integer');
      $this->testdata = JFactory::getApplication()->input->getArray(); ?>
<p>The variable <b>type</b> of <code>$this->testdata['my-input-string']</code> is <b><?php echo gettype($this->testdata['my-input-string'])?></b> (... it should be <b>string</b>)</p>
<p>The variable <b>value</b> of <code>$this->testdata['my-input-string']</code> is <b><?php echo $this->testdata['my-input-string']?></b> (... it should be the string <b>&#39;integer&#39;</b>)</p>

Compare the output for the variable type and value before and after applying the patch.

avatar RickR2H
RickR2H - comment - 10 Apr 2015

Easy to test and the fix inconfirmed!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6035.
avatar RickR2H RickR2H - test_item - 10 Apr 2015 - Tested successfully
avatar hvdmeer
hvdmeer - comment - 10 Apr 2015

@test Tested and output as described.


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

avatar zero-24 zero-24 - change - 10 Apr 2015
Status Pending Ready to Commit
avatar hvdmeer hvdmeer - test_item - 10 Apr 2015 - Tested successfully
avatar zero-24
zero-24 - comment - 10 Apr 2015

RTC based on testing. Thanks!


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

avatar zero-24 zero-24 - change - 10 Apr 2015
Labels Added: ?
avatar roland-d roland-d - change - 10 Apr 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-04-10 15:15:49
avatar roland-d roland-d - close - 10 Apr 2015
avatar roland-d roland-d - close - 10 Apr 2015
avatar zero-24 zero-24 - close - 10 Apr 2015
avatar Erftralle
Erftralle - comment - 10 Apr 2015

@RickR2H @hvdmeer Thanks a lot for testing.

@zero-24 I just wanted to add the version number to the documentation block of the new function but the fix has already been merged by @roland-d . I don't know what to do know, please advise me. Thanks.

avatar zero24 zero24 - reference | - 10 Apr 15
avatar zero-24
zero-24 - comment - 10 Apr 2015

@Erftralle i have just open a new PR here: #6736 That fixes the since tag. Thanks :smile:

avatar Erftralle
Erftralle - comment - 11 Apr 2015

@zero-24 Thanks!

avatar zero-24 zero-24 - change - 14 Oct 2015
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment