X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDBStructure.php;h=914846590be264ed833d1b683013d997fc813031;hb=a98a614f402c4d43d5fa665cc2468508d1558c67;hp=0a532fa1f3ccdcd3afe1ab6e67412a516b4ca08b;hpb=2072fb1eed2dbadcd9587e44eef5c855093212b1;p=friendica.git diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 0a532fa1f3..914846590b 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1,6 +1,6 @@ 'TABLES'], ['TABLE_NAME'], ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']); @@ -192,6 +192,9 @@ class DBStructure public static function definition($basePath, $with_addons_structure = true) { if (!self::$definition) { + if (empty($basePath)) { + $basePath = DI::app()->getBasePath(); + } $filename = $basePath . '/static/dbstructure.config.php'; @@ -238,6 +241,12 @@ class DBStructure // Assign all field that are present in the table 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\((\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]; } }