X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDBStructure.php;h=914846590be264ed833d1b683013d997fc813031;hb=a98a614f402c4d43d5fa665cc2468508d1558c67;hp=f461cedd5137b0af40bd0a0a045d43b48c61e2ea;hpb=8eb3bddc2a6cdbded1fa8ba694a4f443cd2fa072;p=friendica.git diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index f461cedd51..914846590b 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1,6 +1,6 @@ get("system", "post_update_version", PostUpdate::VERSION); + if ($postupdate < PostUpdate::VERSION) { + echo DI::l10n()->t('The post update is at version %d, it has to be at %d to safely drop the tables.', $postupdate, PostUpdate::VERSION); + return; + } + $old_tables = ['fserver', 'gcign', 'gcontact', 'gcontact-relation', 'gfollower' ,'glink', 'item-delivery-data', - 'item_id', 'poll', 'poll_result', 'queue', 'retriever_rule', 'sign', 'spam', 'term']; + 'item-activity', 'item-content', 'item_id', 'participation', 'poll', 'poll_result', 'queue', 'retriever_rule', + 'deliverq', 'dsprphotoq', 'ffinder', 'sign', 'spam', 'term', 'user-item', 'thread', 'item']; $tables = DBA::selectToArray(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_NAME'], ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']); @@ -185,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'; @@ -231,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]; } } @@ -1225,7 +1241,7 @@ class DBStructure } elseif ($verbose) { echo "Zero permissionset already added\n"; } - if (!self::existsForeignKeyForField('item', 'psid')) { + if (self::existsTable('item') && !self::existsForeignKeyForField('item', 'psid')) { $sets = DBA::p("SELECT `psid`, `item`.`uid`, `item`.`private` FROM `item` LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid` WHERE `permissionset`.`id` IS NULL AND NOT `psid` IS NULL");