forked from extern/egroupware
* History: fix timestamps broken by 19.1 update storing diffs using timestamp of preceeding row
This commit is contained in:
parent
6fc90f471b
commit
4b1b02bff6
@ -11,7 +11,7 @@
|
||||
/* Basic information about this app */
|
||||
$setup_info['api']['name'] = 'api';
|
||||
$setup_info['api']['title'] = 'EGroupware API';
|
||||
$setup_info['api']['version'] = '19.1';
|
||||
$setup_info['api']['version'] = '19.1.001';
|
||||
$setup_info['api']['versions']['current_header'] = '1.29';
|
||||
// maintenance release in sync with changelog in doc/rpm-build/debian.changes
|
||||
$setup_info['api']['versions']['maintenance_release'] = '19.1.20190917';
|
||||
|
@ -611,6 +611,8 @@ function api_upgrade17_9_001()
|
||||
$time = number_format((microtime(true)-$start)/60, 1);
|
||||
if ($total) echo "$total history-records converted in $time minutes to diff with a total of $saved MB saved\n";
|
||||
|
||||
$GLOBALS['do_NOT_run_api_upgrade19_1'] = true; // marker for api_upgrade_19_1 to NOT run
|
||||
|
||||
return $GLOBALS['setup_info']['api']['currentver'] = '17.9.002';
|
||||
}
|
||||
|
||||
@ -623,3 +625,34 @@ function api_upgrade17_9_002()
|
||||
{
|
||||
return $GLOBALS['setup_info']['api']['currentver'] = '19.1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix egw_history_log.history_timestamps accidently set to time of update
|
||||
*
|
||||
* We can only set them to the time of the preceeding entry / row!
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function api_upgrade19_1()
|
||||
{
|
||||
// do NOT run if fixed api_upgrade17_9_001 was used / we run direct after it
|
||||
if (empty($GLOBALS['do_NOT_run_api_upgrade19_1']) &&
|
||||
// we have no updated / diffed row
|
||||
(($broken_update_starttime = $GLOBALS['egw_setup']->db->select('egw_history_log',
|
||||
'MIN(history_timestamp)', ['history_old_value' => Api\Storage\Tracking::DIFF_MARKER],
|
||||
__LINE__, __FILE__)->fetchColumn())))
|
||||
{
|
||||
$endtime = new Api\DateTime($broken_update_starttime, Api\DateTime::$server_timezone);
|
||||
$endtime->add('+ 6 hours'); // we estimate update does not take longer then 6 hours
|
||||
$max_endtime = $endtime->format(Api\DateTime::DATABASE);
|
||||
|
||||
// set timestamps in estimated update window to the one of the preceeding row
|
||||
$GLOBALS['egw_setup']->db->query('UPDATE egw_history_log SET history_timestamp='.
|
||||
'(SELECT history_timestamp FROM egw_history_log prev WHERE egw_history_log.history_id > prev.history_id AND prev.history_old_value != '.
|
||||
$GLOBALS['egw_setup']->db->quote(Api\Storage\Tracking::DIFF_MARKER).' ORDER BY prev.history_id DESC LIMIT 1)'.
|
||||
" WHERE history_timestamp BETWEEN '$broken_update_starttime' AND '$max_endtime'".
|
||||
" AND history_old_value=".$GLOBALS['egw_setup']->db->quote(Api\Storage\Tracking::DIFF_MARKER),
|
||||
__LINE__, __FILE__);
|
||||
}
|
||||
return $GLOBALS['setup_info']['api']['currentver'] = '19.1.001';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user