Closed FoxxMD closed 8 years ago
Yup, same problem here.
Thank you guys for reporting the bug. I'll release a fix soon in the next maintenance release.
same problem, when you want to add NULL as value. i.e. ...->add(['tag' => ['@name' => 'dog', 'desc' => NULL]]); Exception: Input type not supported. In function: FluidXml\FluidInsertionHandler->handleInsertion()
Using NULL as a value seems to work fine for me, but I am also having the same issue with blank strings. A fix would be much appreciated!
@daniele-orlando Do you know when you estimate the next maintenance release will be? I've just committed to using fluidxml on a project, and wondering if I should patch it myself in the mean time or just wait a few days. Thanks!
For me the empty string '' works fine... LOL. but I fixed myself the NULL problem, by changing the
if (\is_string($v)) {
line (this is the line 112) to
if (\is_string($v) || $v == NULL) {
in the protected function recognizeStringMixed($k, $v)
function in FluidInsertionHandler.php file. I don't know what else I break with this, but now it's working for me with NULL and '' too on PHP 5.6...
Also I can get some funny errors when I build wrongly the array which I use to convert into XML. (I using array at most cases to build XML)
Hi guys. I pushed a maintenance release which includes a fix for the issue with empty-strings/null-values and more tests to prevent this from happening again. Please check it out and reopen the issue if you still have problems.
Happy coding!
I found something, I don't know this issue cause it or not...
DOMException: Invalid Character Error in function DOMElement->__construct() (fluidxml/source/FluidXml/FluidInsertionHandler.php 202 row).
Code which cause it:
$arr = array(
'data1' => 'SEAT',
'data2' => '040',
'data3' => 'A00',
'data4' => '1',
'data5' => '',
'data6' => NULL,
'data7' => '1020',
'data8' => '2016-07-12 15:00',
'data9' => 12,
'data10' => 1,
'data11' => 'N',
'data12' => 'C',
'data13' => 0,
'data14' => 0,
'data15' => 0,
'data16' => 0,
'data17' => 0,
'data18' => 1197,
'data19 ' => 77,
'data20' => '1212',
'data21' => '01',
'data22' => 'F',
'data23' => '1986-01-01',
'data24' => 1,
'data25' => '35101',
'data26' => '2016-07-12',
'data27' => '2010',
'data28' => 1,
'data29' => 0,
'data30' => 0,
'data31' => 0,
'data32' => 0,
'data33' => 0,
'data34' => 0,
'data35' => 0,
'data36' => 'N',
'data37' => 'N',
'data38' => 'N',
'data39' => 'N',
'data40' => 'N',
'data41' => 'N',
'data42' => 'N',
'data43' => 0,
'data44' => 'N',
'data45' => 'N',
'data46' => 0,
'data47' => 0,
'data48' => 0,
'data49' => NULL,
'data50' => 0,
'data51' => 0,
'data52' => 0,
'data53' => 0,
'data54' => NULL,
'data55' => NULL,
'data56' => NULL,
'data57' => NULL,
'data58' => NULL,
'data59' => NULL,
'data60' => 1,
'data61' => 'B',
'data62' => '2015-01-01',
'data63' => 2013,
'data64' => 'I',
);
$fxml = new FluidXml('d');
$fxml->add(["data" => $arr]);
I can't reopen this issue because the collaborator closed it...
@golddragon007 can you iterate through that array and do ->add()
one element at a time to figure out which one is causing the problem?
I don't iterate through on it, but I put a logger before the 202 row, and it says the last item which was tried is:
'data19 ' => 77,
So the variables:
$name = 'data19';
$value = 77;
$uri = NULL;
Than comes the $el = new \DOMElement($name, $value, $uri);
line, which falls. I can't understand whats the problem with this data.
NOTE:
Maybe this is the black magic.
Oh crap, there was a space after the key....
Yes, you have a space in the tag name.
If you do this, because you are sooo lazy and the 'something' condition isn't true, it will fall processing at the array place:
if (something) {
$array = [
"key1" => "value1",
"key2" => "value2",
"key3" => "value3",
]
}
$fxml = new FluidXml('root');
$fxml->add([
"keys1" => "value1",
"keys2" => "value2",
"keys3" => "value3",
$array,
"keys4" => "value4",
"keys5" => "value5",
]);
In this case the $array
is NULL
and you will get "Input type not supported." error. But if the $array = []
it will work (it's ignores).
Possible to handle the 0 => NULL
and 0 => []
types/values or whatever is it as same?
If the value being added for a node is empty an exception is thrown:
Uninitialized string offset: 0