* MySQL 8.0: fix DB backup recorded Int columns as TinyInt and stalls restore

* MySQL 8.0: timestamp columns had no default and did not update automatic
This commit is contained in:
ralf 2022-11-01 18:45:33 +01:00
parent a767bdef1e
commit 75c07334df
3 changed files with 15 additions and 11 deletions

View File

@ -505,9 +505,10 @@ class Backup
*
* @param resource $f file opened with fopen for reading
* @param int|string $insert_n_rows =500 how many rows to insert in one sql statement, or string with column-name used as unique key for insert
* @param bool $only_egw=false true: only restore egw_* tables, setting this to true often helps to import/update ancient EGroupware dumps
* @returns int number of rows read from csv file
*/
function db_restore($f, $insert_n_rows=500)
function db_restore($f, $insert_n_rows=500, bool $only_egw=false)
{
$convert_to_system_charset = true;
$table = null;
@ -560,7 +561,10 @@ class Backup
}
unset($def);
//echo "<pre>$table_name => ".self::write_array($schema,1)."</pre>\n";
$this->schema_proc->CreateTable($table_name, $schema);
if (!$only_egw || preg_match('/^egw_/', $table_name))
{
$this->schema_proc->CreateTable($table_name, $schema);
}
}
continue;
}
@ -594,7 +598,7 @@ class Backup
}
if ($table) // do we already reached the data part
{
$import = true;
$import = !$only_egw || (bool)preg_match('/^egw_/', $table_name);
$data = self::csv_split($line, $cols, $blobs, $bools);
if ($table == 'egw_async' && in_array('##last-check-run##',$data))
@ -882,7 +886,7 @@ class Backup
//echo "function backup($f)<br>"; // !
@set_time_limit(0);
$dir = $this->files_dir; // $GLOBALS['egw_info']['server']['files_dir'];
// we may have to clean up old backup - left overs
// we may have to clean up old backup - leftovers
if (is_dir($dir.'/database_backup'))
{
self::remove_dir_content($dir.'/database_backup/');

View File

@ -1330,7 +1330,7 @@ class Schema
{
$definition['fd'][$name]['precision'] = 8;
}
elseif ($column->max_length > 6 || !$column->max_length)
elseif ($column->max_length > 6 || $column->max_length <= 0)
{
$definition['fd'][$name]['precision'] = 4;
}

12
composer.lock generated
View File

@ -799,16 +799,16 @@
},
{
"name": "egroupware/adodb-php",
"version": "5.20.6",
"version": "5.20.7",
"source": {
"type": "git",
"url": "https://github.com/EGroupware/ADOdb.git",
"reference": "c9a0b97038104af27336c2f752dc4216cbccf7bf"
"reference": "2bc7b262d9739c2869d53a120822fc6efeb63a44"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/EGroupware/ADOdb/zipball/c9a0b97038104af27336c2f752dc4216cbccf7bf",
"reference": "c9a0b97038104af27336c2f752dc4216cbccf7bf",
"url": "https://api.github.com/repos/EGroupware/ADOdb/zipball/2bc7b262d9739c2869d53a120822fc6efeb63a44",
"reference": "2bc7b262d9739c2869d53a120822fc6efeb63a44",
"shasum": ""
},
"require": {
@ -853,7 +853,7 @@
"issues": "https://github.com/ADOdb/ADOdb/issues",
"source": "https://github.com/ADOdb/ADOdb"
},
"time": "2022-04-26T06:46:16+00:00"
"time": "2022-11-01T17:36:51+00:00"
},
{
"name": "egroupware/bookmarks",
@ -12332,5 +12332,5 @@
"platform-overrides": {
"php": "7.4"
},
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.2.0"
}