diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php index 2f6048b4fd..40bc16b439 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php @@ -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) { diff --git a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php index 4d7f0e0cdf..ed61d381dc 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/download_updated_files.php @@ -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, ), )); diff --git a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php index fbb465cc66..3acb965f6b 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php @@ -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; }