mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-18 06:38:43 +01:00
[ticket/16570] Support continuing update on manually merging files
PHPBB3-16570
This commit is contained in:
parent
314ab17edd
commit
0502b9cc22
@ -155,13 +155,47 @@ class diff_files extends task_base
|
||||
|
||||
$diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
|
||||
|
||||
$file_is_merged = $diff->merged_output() === $file_contents[1];
|
||||
|
||||
// Handle conflicts
|
||||
if ($diff->get_num_conflicts() !== 0)
|
||||
{
|
||||
// Check if current file content is merge of new or original file
|
||||
$tmp = [
|
||||
'file1' => $file_contents[1],
|
||||
'file2' => implode("\n", $diff->merged_new_output()),
|
||||
];
|
||||
|
||||
$diff2 = new \diff($tmp['file1'], $tmp['file2']);
|
||||
$empty = $diff2->is_empty();
|
||||
|
||||
if (!$empty)
|
||||
{
|
||||
unset($tmp, $diff2);
|
||||
|
||||
// We check if the user merged with his output
|
||||
$tmp = [
|
||||
'file1' => $file_contents[1],
|
||||
'file2' => implode("\n", $diff->merged_orig_output()),
|
||||
];
|
||||
|
||||
$diff2 = new \diff($tmp['file1'], $tmp['file2']);
|
||||
$empty = $diff2->is_empty();
|
||||
}
|
||||
|
||||
unset($diff2);
|
||||
|
||||
if (!$empty && in_array($filename, $merge_conflicts))
|
||||
{
|
||||
$merge_conflicts[] = $filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
$file_is_merged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($diff->merged_output() !== $file_contents[1])
|
||||
if (!$file_is_merged)
|
||||
{
|
||||
// Save merged output
|
||||
$this->cache->put(
|
||||
@ -223,6 +257,7 @@ class diff_files extends task_base
|
||||
|
||||
$this->iohandler->finish_progress('ALL_FILES_DIFFED');
|
||||
$this->installer_config->set('merge_conflict_list', $merge_conflicts);
|
||||
$this->installer_config->set('differ_progress_key', -1);
|
||||
|
||||
foreach ($update_files as $type => $files)
|
||||
{
|
||||
|
@ -87,7 +87,8 @@ class download_updated_files extends task_base
|
||||
$file_update_info = $this->installer_config->get('update_files', array());
|
||||
|
||||
// Display download box only if the archive won't be empty
|
||||
if (!empty($file_update_info) && !(isset($file_update_info['delete']) && count($file_update_info) == 1))
|
||||
$display_download_link = !empty($file_update_info) && !(isset($file_update_info['delete']) && count($file_update_info) == 1);
|
||||
if ($display_download_link)
|
||||
{
|
||||
// Render download box
|
||||
$this->iohandler->add_download_link(
|
||||
@ -107,7 +108,7 @@ class download_updated_files extends task_base
|
||||
'database_update_submit' => array(
|
||||
'label' => 'UPDATE_CONTINUE_UPDATE_PROCESS',
|
||||
'type' => 'submit',
|
||||
'disabled' => !empty($file_update_info),
|
||||
'disabled' => $display_download_link,
|
||||
),
|
||||
));
|
||||
|
||||
|
@ -172,11 +172,15 @@ class update_files extends task_base
|
||||
$this->file_updater->update_file($path, $new_path . $path);
|
||||
break;
|
||||
case 'update_with_diff':
|
||||
$cache_diff_filename = '_file_' . md5($path);
|
||||
if ($this->cache->_exists($cache_diff_filename))
|
||||
{
|
||||
$this->file_updater->update_file(
|
||||
$path,
|
||||
base64_decode($this->cache->get('_file_' . md5($path))),
|
||||
base64_decode($this->cache->get($cache_diff_filename)),
|
||||
true
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user