[ticket/12325] Automatic update should notify about outdated files

PHPBB3-12325
This commit is contained in:
Tristan Darricau 2014-05-23 22:59:46 +02:00
parent 3d19776037
commit 6e6891f841
3 changed files with 66 additions and 7 deletions

View file

@ -348,6 +348,25 @@
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF .deleted -->
<h2>{L_FILES_DELETED}</h2>
<p>{L_FILES_DELETED_EXPLAIN}</p>
<fieldset>
<legend><img src="{T_IMAGE_PATH}icon_delete.gif" alt="{L_STATUS_DELETED}" /></legend>
<!-- BEGIN deleted -->
<dl>
<dt style="width: 60%;"><strong><!-- IF deleted.DIR_PART -->{deleted.DIR_PART}<br /><!-- ENDIF -->{deleted.FILE_PART}</strong>
</dt>
<dd style="margin-{S_CONTENT_FLOW_BEGIN}{L_COLON} 60%;">
<!-- IF not deleted.S_BINARY -->[<a href="{deleted.U_SHOW_DIFF}" onclick="diff_popup(this.href); return false;">{deleted.L_SHOW_DIFF}</a>]<!-- ELSE -->{L_BINARY_FILE}<!-- ENDIF -->
</dd>
</dl>
<!-- END deleted -->
</fieldset>
<!-- ENDIF -->
<br /> <br />
<fieldset class="quick"> <fieldset class="quick">

View file

@ -366,7 +366,7 @@ class install_update extends module
$get_new_list = true; $get_new_list = true;
} }
if (!$get_new_list && $update_list['status'] != -1) if (!$get_new_list && ($update_list['status'] != -1 || $update_list['status_deleted'] != -1))
{ {
$get_new_list = true; $get_new_list = true;
} }
@ -377,17 +377,17 @@ class install_update extends module
$cache->put('_update_list', $update_list); $cache->put('_update_list', $update_list);
// Refresh the page if we are still not finished... // Refresh the page if we are still not finished...
if ($update_list['status'] != -1) if ($update_list['status'] != -1 || $update_list['status_deleted'] != -1)
{ {
$refresh_url = append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"); $refresh_url = append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check");
meta_refresh(2, $refresh_url); meta_refresh(2, $refresh_url);
$template->assign_vars(array( $template->assign_vars(array(
'S_IN_PROGRESS' => true, 'S_IN_PROGRESS' => true,
'S_COLLECTED' => (int) $update_list['status'], 'S_COLLECTED' => (int) $update_list['status'] + (int) $update_list['status_deleted'],
'S_TO_COLLECT' => sizeof($this->update_info['files']), 'S_TO_COLLECT' => sizeof($this->update_info['files']),
'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'], 'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'],
'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files'])), 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files']) + sizeof($this->update_info['deleted'])),
)); ));
return; return;
@ -413,7 +413,7 @@ class install_update extends module
// Now assign the list to the template // Now assign the list to the template
foreach ($update_list as $status => $filelist) foreach ($update_list as $status => $filelist)
{ {
if ($status == 'no_update' || !sizeof($filelist) || $status == 'status') if ($status == 'no_update' || !sizeof($filelist) || $status == 'status' || $status == 'status_deleted')
{ {
continue; continue;
} }
@ -480,7 +480,7 @@ class install_update extends module
$all_up_to_date = true; $all_up_to_date = true;
foreach ($update_list as $status => $filelist) foreach ($update_list as $status => $filelist)
{ {
if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && sizeof($filelist)) if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && $status != 'status_deleted' && sizeof($filelist))
{ {
$all_up_to_date = false; $all_up_to_date = false;
break; break;
@ -822,7 +822,7 @@ class install_update extends module
foreach ($update_list as $status => $files) foreach ($update_list as $status => $files)
{ {
if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status') if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status' || $status == 'status_deleted')
{ {
continue; continue;
} }
@ -1212,6 +1212,16 @@ class install_update extends module
$this->page_title = 'VIEWING_FILE_CONTENTS'; $this->page_title = 'VIEWING_FILE_CONTENTS';
break; break;
case 'deleted':
$diff = $this->return_diff(array(), $phpbb_root_path . $original_file);
$template->assign_var('S_DIFF_NEW_FILE', true);
$diff_mode = 'inline';
$this->page_title = 'VIEWING_FILE_CONTENTS';
break;
} }
$diff_mode_options = ''; $diff_mode_options = '';
@ -1257,7 +1267,9 @@ class install_update extends module
'new_conflict' => array(), 'new_conflict' => array(),
'conflict' => array(), 'conflict' => array(),
'no_update' => array(), 'no_update' => array(),
'deleted' => array(),
'status' => 0, 'status' => 0,
'status_deleted'=> 0,
); );
} }
@ -1337,6 +1349,30 @@ class install_update extends module
} }
$update_list['status'] = -1; $update_list['status'] = -1;
foreach ($this->update_info['deleted'] as $index => $file)
{
if (is_int($update_list['status_deleted']) && $index < $update_list['status_deleted'])
{
continue;
}
if ($num_bytes_processed >= 500 * 1024)
{
return;
}
if (file_exists($phpbb_root_path . $file))
{
$update_list['deleted'][] = array('filename' => $file, 'custom' => false, 'as_expected' => false);
$num_bytes_processed += filesize($phpbb_root_path . $file);
}
$update_list['status_deleted']++;
}
$update_list['status_deleted'] = -1;
/* if (!sizeof($this->update_info['files'])) /* if (!sizeof($this->update_info['files']))
{ {
return $update_list; return $update_list;

View file

@ -431,6 +431,8 @@ $lang = array_merge($lang, array(
'FILE_USED' => 'Information used from', // Single file 'FILE_USED' => 'Information used from', // Single file
'FILES_CONFLICT' => 'Conflict files', 'FILES_CONFLICT' => 'Conflict files',
'FILES_CONFLICT_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. phpBB determined that these files create conflicts if they are tried to be merged. Please investigate the conflicts and try to manually resolve them or continue the update choosing the preferred merging method. If you resolve the conflicts manually check the files again after you modified them. You are also able to choose between the preferred merge method for every file. The first one will result in a file where the conflicting lines from your old file will be lost, the other one will result in losing the changes from the newer file.', 'FILES_CONFLICT_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. phpBB determined that these files create conflicts if they are tried to be merged. Please investigate the conflicts and try to manually resolve them or continue the update choosing the preferred merging method. If you resolve the conflicts manually check the files again after you modified them. You are also able to choose between the preferred merge method for every file. The first one will result in a file where the conflicting lines from your old file will be lost, the other one will result in losing the changes from the newer file.',
'FILES_DELETED' => 'Deleted files',
'FILES_DELETED_EXPLAIN' => 'The following files do not exist in the new version. These files have to be deleted from your installation.',
'FILES_MODIFIED' => 'Modified files', 'FILES_MODIFIED' => 'Modified files',
'FILES_MODIFIED_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. The updated file will be a merge between your modifications and the new file.', 'FILES_MODIFIED_EXPLAIN' => 'The following files are modified and do not represent the original files from the old version. The updated file will be a merge between your modifications and the new file.',
'FILES_NEW' => 'New files', 'FILES_NEW' => 'New files',
@ -501,6 +503,7 @@ $lang = array_merge($lang, array(
'SELECT_DOWNLOAD_FORMAT' => 'Select download archive format', 'SELECT_DOWNLOAD_FORMAT' => 'Select download archive format',
'SELECT_FTP_SETTINGS' => 'Select FTP settings', 'SELECT_FTP_SETTINGS' => 'Select FTP settings',
'SHOW_DIFF_CONFLICT' => 'Show differences/conflicts', 'SHOW_DIFF_CONFLICT' => 'Show differences/conflicts',
'SHOW_DIFF_DELETED' => 'Show file contents',
'SHOW_DIFF_FINAL' => 'Show resulting file', 'SHOW_DIFF_FINAL' => 'Show resulting file',
'SHOW_DIFF_MODIFIED' => 'Show merged differences', 'SHOW_DIFF_MODIFIED' => 'Show merged differences',
'SHOW_DIFF_NEW' => 'Show file contents', 'SHOW_DIFF_NEW' => 'Show file contents',
@ -514,6 +517,7 @@ $lang = array_merge($lang, array(
'STAGE_UPDATE_FILES' => 'Update files', 'STAGE_UPDATE_FILES' => 'Update files',
'STAGE_VERSION_CHECK' => 'Version check', 'STAGE_VERSION_CHECK' => 'Version check',
'STATUS_CONFLICT' => 'Modified file producing conflicts', 'STATUS_CONFLICT' => 'Modified file producing conflicts',
'L_STATUS_DELETED' => 'Deleted file',
'STATUS_MODIFIED' => 'Modified file', 'STATUS_MODIFIED' => 'Modified file',
'STATUS_NEW' => 'New file', 'STATUS_NEW' => 'New file',
'STATUS_NEW_CONFLICT' => 'Conflicting new file', 'STATUS_NEW_CONFLICT' => 'Conflicting new file',