]> git.mxchange.org Git - friendica.git/commitdiff
Separate the char from the binary handling
authorMichael <heluecht@pirati.ca>
Mon, 24 May 2021 20:07:39 +0000 (20:07 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 24 May 2021 20:07:39 +0000 (20:07 +0000)
src/Database/DBStructure.php

index 04ba956bc973e2ddea7a8a1537752b71c7658181..914846590be264ed833d1b683013d997fc813031 100644 (file)
@@ -242,8 +242,10 @@ class DBStructure
                foreach ($fieldnames as $field) {
                        if (isset($data[$field])) {
                                // Limit the length of varchar, varbinary, char and binrary fields
-                               if (is_string($data[$field]) && preg_match("/[char|binary]\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
+                               if (is_string($data[$field]) && preg_match("/char\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
                                        $data[$field] = mb_substr($data[$field], 0, $result[1]);
+                               } elseif (is_string($data[$field]) && preg_match("/binary\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
+                                       $data[$field] = substr($data[$field], 0, $result[1]);
                                }
                                $fields[$field] = $data[$field];
                        }