ArrayFromObject TypeConverter generates both associative and indexed array

Hi,
my team and I are developing an application based on the latest Flow version and we are encountering a strange behaviour (at least as we think of it :wink: ).

We are trying to convert an object, of a custom class, to an array through the propertyMapper and as result we obtain an array, correctly, where those starting object properties, that are objects too, are represented in the original object form and also in a indexed array form, though. For example:

Starting Object:
[OBJECT\NAMESPACE\1]
propertyMapper => TYPO3\Flow\Property\PropertyMapper
id => ‘b4fbdcae-ced4-4006-98cc-789f756db505’ (36)
title => [OBJECT\NAMESPACE\2]
type => ‘array’ (5)
validity => TRUE
default => NULL
data => array(2)
‘default’ (7) => ‘default: szdfg’ (14)
description => [OBJECT\NAMESPACE\2]
type => ‘array’ (5)
validity => TRUE
default => NULL
data => array(2)
‘default’ (7) => ‘default: vgb’ (12)
sku => ‘fcgvhb’ (6)
status => [OBJECT\NAMESPACE\2]
type => ‘array’ (5)
validity => TRUE
default => NULL
data => array(2)
‘default’ (7) => ‘default: 0’ (10)
Flow_Injected_Properties => array(1)
integer 0 => ‘propertyMapper’ (14)

Resulting Array:
array(9)
‘description’ (11) => [OBJECT\NAMESPACE\2]
type => ‘array’ (5)
validity => TRUE
default => NULL
data => array(2)
‘default’ (7) => ‘default: vgb’ (12)
‘id’ (2) => ‘b4fbdcae-ced4-4006-98cc-789f756db505’ (36)
‘sku’ (3) => ‘fcgvhb’ (6)
‘status’ (6) => [OBJECT\NAMESPACE\2]
type => ‘array’ (5)
validity => TRUE
default => NULL
data => array(2)
‘default’ (7) => ‘default: 0’ (10)
‘title’ (5) => [OBJECT\NAMESPACE\2]
type => ‘array’ (5)
validity => TRUE
default => NULL
data => array(2)
‘default’ (7) => ‘default: szdfg’ (14)
integer 0 => array(5)
‘data’ (4) => array(2)
‘default’ (7) => ‘default: vgb’ (12)
‘default’ (7) => array(empty)
‘type’ (4) => ‘array’ (5)
‘validity’ (8) => TRUE
’__type’ (6) => ‘OBJECT\NAMESPACE\2’ (37)
integer 1 => array(5)
‘data’ (4) => array(2)
‘default’ (7) => ‘default: 0’ (10)
‘default’ (7) => array(empty)
‘type’ (4) => ‘array’ (5)
‘validity’ (8) => TRUE
’__type’ (6) => ‘OBJECT\NAMESPACE\2’ (37)
integer 2 => array(5)
‘data’ (4) => array(2)
‘default’ (7) => ‘default: szdfg’ (14)
‘default’ (7) => array(empty)
‘type’ (4) => ‘array’ (5)
‘validity’ (8) => TRUE
’__type’ (6) => ‘OBJECT\NAMESPACE\2’ (37)
’__type’ (6) => ‘OBJECT\NAMESPACE\1’ (35)

If see the properties title, status and description that start as objects get kept as object and converted into indexed arrays 0,1,2 in the resulting array.

Is there a way to avoid this replication? Are we missing something?

Thanks,
Nicola

Seems this is indeed a bug in the ArryFromObjectConverter::getSourceChildPropertiesToBeConverted() method. It returns a numeric array of the property values, while the method is supposed to return an associative array of propertyName => propertyValue (see PropertyMapper::doMapping()).

If you could file an issue on jira.neos.io, that would be great.

For the meanwhile you can just extend that converter and override the method and change the loop like so:

    foreach ($gettableProperties as $propertyName => $gettableProperty) {
        if (is_object($gettableProperty)) {
            $propertiesToConvert[$propertyName] = $gettableProperty;
        }
    }

Sorry for the late answer (kinda busy).
For sure I’ll open up a issue on jira and test the temp solution you suggested us.

Thank you very much.

Bests,
Nicola

FYI: The bugfix for this got merged into 3.0 and will hence be available with the upcoming bugfix releases of Flow 3.x

1 Like

Hi @aberl,
thank you very much for the update and sorry i wasn’t fast enough to open and iusse about it (pretty busy on many Neos projects atm).

Thanks again,
N