? Failure

User tests: Successful: Unsuccessful:

avatar matrikular
matrikular
2 Jun 2017

Summary of Changes

If you want to process raw post data send to an (open) api, you probably would use something similar to this.: $payload = $this->input->json->getArray();

This is fine when (valid) data was send. In case of an empty request though, a null value is passed to JInput::getArrayRecursive(), which results in the following warning:

Warning: Invalid argument supplied for foreach() in [...]\libraries\joomla\input\input.php on line 230

Testing Instructions

First, create a test controller "foobar" with the following content in e.g. /components/com_users/controllers/foobar.php

<?php

defined('_JEXEC') or die;

class UsersControllerFoobar extends JControllerLegacy
{
	public function foobar()
	{
        $payload = $this->input->json->getArray();

		print_r($payload);

		JFactory::getApplication()->close();
	}
}

Send a POST request with the content type "application/json" to that controller and leave out the payload / data. It shouldn't matter if you use curl, your browser console and / or an addons to do that.

Expected result

The expected result would be an empty array.

Actual result

The warning mentioned above appears.

avatar matrikular matrikular - open - 2 Jun 2017
avatar matrikular matrikular - change - 2 Jun 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 Jun 2017
Category Libraries
avatar matrikular matrikular - change - 3 Jun 2017
Labels Added: ?
avatar chmst
chmst - comment - 7 Jun 2017

I have tested this item successfully on c2b8d7e

I've tested this item successfully following the testing instructions; It works as described.


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

avatar chmst chmst - test_item - 7 Jun 2017 - Tested successfully
avatar fancyFranci
fancyFranci - comment - 14 Feb 2018

I give up. Which url leads me to the controller from the test instructions? I have a tool (postman), I have the controller, I just don't know how to get there :/


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

avatar matrikular matrikular - change - 13 Jul 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-07-13 10:51:47
Closed_By matrikular
avatar matrikular matrikular - close - 13 Jul 2020

Add a Comment

Login with GitHub to post a comment