Project

General

Profile

Task #90847

Updated by Bill Dagou over 4 years ago

Sorry, I don't know how to choose the tracker, actually it's not a bug, but should be a suggestion. 

 I was working on an FE ext, and it involves in displaying the banners on the page with some access controls, like Anonymous, User Group 1, User Group 2, and etc. So, I was using @array@ to store the group IDs, 0 for Anonymous. I can save the access array to the DB like 0,1,2, but can not get it from the DB. 

 After digging the core files, I found the @array@ is mapped to @string@ with @implode()@ in the DataMapper::getPlainValue() 
 <pre><code class="php"> 
 ... 
 if (TypeHandlingUtility::isValidTypeForMultiValueComparison($input)) { 
     $plainValueArray = []; 
     foreach ($input as $inputElement) { 
         $plainValueArray[] = $this->getPlainValue($inputElement, $columnMap); 
     } 
     $parameter = implode(',', $plainValueArray); 
 } 
 ... 
 </code></pre> 

 while in DataMapper::thawProperties(), it is 
 <pre><code class="php"> 
 ... 
 case 'array': 
     // $propertyValue = $this->mapArray($row[$columnName]); // Not supported, yet! 
     break; 
 ... 
 </code></pre> 

 and it's not supported since v7, maybe even earlier. 

 So, my suggestion is, adding more detailed if conditions in @getPlainValue()@, so the real array could be mapped correctly, you known like the index, the two dimensional arrays, and more. 

 <pre><code class="php"> 
 ... 
 if ($input instanceof \SplObjectStorage || $input instanceof Persistence\ObjectStorage) Persistence\ObjectStorage::class) { 
     $plainValueArray = []; 
     foreach ($input as $inputElement) { 
         $plainValueArray[] = $this->getPlainValue($inputElement, $columnMap); 
     } 
     $parameter = implode(',', $plainValueArray); 
 } elseif (TypeHandlingUtility::isValidTypeForMultiValueComparison($input)) { 
     $parameter = serialize($input); 
 } 
 ... 
 </code></pre> 

 Thus, the array could be retrieved with @unserialize()@ in @thawProperties()@. 

 Maybe the suggestion is not as good, but I think it worthes a try. 

 Thank you!

Back