Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!is_array($value)) {
         return null === $value ? 'N;' : 'a:0:{}';
     }
     // MySQL will crap out on corrupt UTF8 leading to broken serialized strings
     array_walk($value, function (&$entry) {
         $entry = UTF8Helper::toUTF8($entry);
     });
     $serialized = serialize($value);
     return $serialized;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!is_array($value)) {
         return null === $value ? 'N;' : 'a:0:{}';
     }
     // MySQL will crap out on corrupt UTF8 leading to broken serialized strings
     array_walk($value, function (&$entry) {
         $entry = UTF8Helper::toUTF8($entry);
     });
     $serialized = serialize($value);
     if (strpos($serialized, chr(0)) !== false) {
         throw new \Doctrine\DBAL\Types\ConversionException('Serialized array includes null-byte. This cannot be saved as a text. Please check if you not provided object with protected or private members.');
     }
     return $serialized;
 }