Merge pull request #4677 from marc1706/ticket/15050

[ticket/15050] Use new file when new file already exists
This commit is contained in:
Máté Bartus 2017-01-29 14:40:02 +01:00
commit cd4ceb2487

View file

@ -132,7 +132,9 @@ class diff_files extends task_base
$file_contents = array(); $file_contents = array();
// Handle the special case when user created a file with the filename that is now new in the core // Handle the special case when user created a file with the filename that is now new in the core
$file_contents[0] = (file_exists($old_path . $filename)) ? file_get_contents($old_path . $filename) : ''; if (file_exists($old_path . $filename))
{
$file_contents[0] = file_get_contents($old_path . $filename);
$filenames = array( $filenames = array(
$this->phpbb_root_path . $filename, $this->phpbb_root_path . $filename,
@ -167,6 +169,25 @@ class diff_files extends task_base
); );
unset($diff); unset($diff);
}
else
{
$new_file_content = file_get_contents($new_path . $filename);
if ($new_file_content === false)
{
$this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
unset($new_file_content );
throw new user_interaction_required_exception();
}
// Save new file content to cache
$this->cache->put(
'_file_' . md5($filename),
base64_encode($new_file_content)
);
unset($new_file_content);
}
$progress_count++; $progress_count++;
$this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count); $this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count);