/** * Collect all file status infos we need for the update by diffing all files */ function get_update_structure(&$update_list, $expected_files) { global $phpbb_root_path, $phpEx, $user; if ($update_list === false) { $update_list = array('up_to_date' => array(), 'new' => array(), 'not_modified' => array(), 'modified' => array(), 'new_conflict' => array(), 'conflict' => array(), 'no_update' => array(), 'deleted' => array(), 'status' => 0, 'status_deleted' => 0); } /* if (!empty($this->update_info['custom'])) { foreach ($this->update_info['custom'] as $original_file => $file_ary) { foreach ($file_ary as $index => $file) { $this->make_update_diff($update_list, $original_file, $file, true); } } } */ // Get a list of those files which are completely new by checking with file_exists... $num_bytes_processed = 0; foreach ($this->update_info['files'] as $index => $file) { if (is_int($update_list['status']) && $index < $update_list['status']) { continue; } if ($num_bytes_processed >= 500 * 1024) { return; } if (!file_exists($phpbb_root_path . $file)) { // Make sure the update files are consistent by checking if the file is in new_files... if (!file_exists($this->new_location . $file)) { trigger_error($user->lang['INCOMPLETE_UPDATE_FILES'], E_USER_ERROR); } // If the file exists within the old directory the file got removed and we will write it back // not a biggie, but we might want to state this circumstance separately later. // if (file_exists($this->old_location . $file)) // { // $update_list['removed'][] = $file; // } /* Only include a new file as new if the underlying path exist // The path normally do not exist if the original style or language has been removed if (file_exists($phpbb_root_path . dirname($file))) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); } else { // Do not include style-related or language-related content if (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0) { $update_list['no_update'][] = $file; } }*/ if (!phpbb_ignore_new_file_on_update($phpbb_root_path, $file)) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); } // unset($this->update_info['files'][$index]); } else { // not modified? $this->make_update_diff($update_list, $file, $file, $expected_files); } $num_bytes_processed += file_exists($this->new_location . $file) ? filesize($this->new_location . $file) : 100 * 1024; $update_list['status']++; } 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']++; } $update_list['status_deleted'] = -1; $update_list['status'] = -1; /* if (!sizeof($this->update_info['files'])) { return $update_list; } // Now diff the remaining files to get information about their status (not modified/modified/up-to-date) // not modified? foreach ($this->update_info['files'] as $index => $file) { $this->make_update_diff($update_list, $file, $file); } // Now to the styles... if (empty($this->update_info['custom'])) { return $update_list; } foreach ($this->update_info['custom'] as $original_file => $file_ary) { foreach ($file_ary as $index => $file) { $this->make_update_diff($update_list, $original_file, $file, true); } } return $update_list;*/ }
/** * @dataProvider ignore_new_file_on_update_data */ public function test_ignore_new_file_on_update($file, $expected) { global $phpbb_root_path; $this->assertEquals($expected, phpbb_ignore_new_file_on_update($phpbb_root_path, $file)); }