finish_progress() public méthode

Finish the progress bar
public finish_progress ( string $message_lang_key )
$message_lang_key string Language key for the message
Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->language->add_lang('migrator');
     if (!isset($this->config['version_update_from'])) {
         $this->config->set('version_update_from', $this->config['version']);
     }
     $original_version = $this->config['version_update_from'];
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->migrator->create_migrations_table();
     $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes();
     $this->migrator->set_migrations($migrations);
     $migration_count = count($this->migrator->get_migrations());
     $this->iohandler->set_task_count($migration_count, true);
     $progress_count = $this->installer_config->get('database_update_count', 0);
     while (!$this->migrator->finished()) {
         try {
             $this->migrator->update();
             $progress_count++;
             $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
         } catch (exception $e) {
             $msg = $e->getParameters();
             array_unshift($msg, $e->getMessage());
             $this->iohandler->add_error_message($msg);
             $this->iohandler->send_response();
             throw new user_interaction_required_exception();
         }
         if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
             $this->installer_config->set('database_update_count', $progress_count);
             throw new resource_limit_reached_exception();
         }
     }
     if ($original_version !== $this->config['version']) {
         $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version']));
     }
     $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL');
     $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL');
     $this->config->delete('version_update_from');
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Include diff engine
     $this->update_helper->include_file('includes/diff/diff.' . $this->php_ext);
     $this->update_helper->include_file('includes/diff/engine.' . $this->php_ext);
     // Set up basic vars
     $old_path = $this->update_helper->get_path_to_old_update_files();
     $new_path = $this->update_helper->get_path_to_new_update_files();
     $files_to_diff = $this->installer_config->get('update_files', array());
     $files_to_diff = $files_to_diff['update_with_diff'];
     // Set progress bar
     $this->iohandler->set_task_count(count($files_to_diff), true);
     $this->iohandler->set_progress('UPDATE_FILE_DIFF', 0);
     $progress_count = $this->installer_config->get('file_diff_update_count', 0);
     // Recover progress
     $progress_key = $this->installer_config->get('differ_progress_key', -1);
     $progress_recovered = $progress_key === -1;
     $merge_conflicts = $this->installer_config->get('merge_conflict_list', array());
     foreach ($files_to_diff as $key => $filename) {
         if ($progress_recovered === false) {
             if ($progress_key === $key) {
                 $progress_recovered = true;
             }
             continue;
         }
         // Read in files' content
         $file_contents = array();
         // 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) : '';
         $filenames = array($this->phpbb_root_path . $filename, $new_path . $filename);
         foreach ($filenames as $file_to_diff) {
             $file_contents[] = file_get_contents($file_to_diff);
             if ($file_contents[sizeof($file_contents) - 1] === false) {
                 $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
                 unset($file_contents);
                 throw new user_interaction_required_exception();
             }
         }
         $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
         unset($file_contents);
         // Handle conflicts
         if ($diff->get_num_conflicts() !== 0) {
             $merge_conflicts[] = $filename;
         }
         // Save merged output
         $this->cache->put('_file_' . md5($filename), base64_encode(implode("\n", $diff->merged_output())));
         unset($diff);
         $progress_count++;
         $this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count);
         if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
             // Save differ progress
             $this->installer_config->set('differ_progress_key', $key);
             $this->installer_config->set('merge_conflict_list', $merge_conflicts);
             $this->installer_config->set('file_diff_update_count', $progress_count);
             // Request refresh
             throw new resource_limit_reached_exception();
         }
     }
     $this->iohandler->finish_progress('ALL_FILES_DIFFED');
     $this->installer_config->set('merge_conflict_list', $merge_conflicts);
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $new_path = $this->update_helper->get_path_to_new_update_files();
     $file_update_info = $this->installer_config->get('update_files', array());
     $update_type_progress = $this->installer_config->get('file_updater_type_progress', '');
     $update_elem_progress = $this->installer_config->get('file_updater_elem_progress', '');
     $type_progress_found = false;
     $elem_progress_found = false;
     // Progress bar
     $task_count = 0;
     foreach ($file_update_info as $sub_array) {
         $task_count += count($sub_array);
     }
     // Everything is up to date, so just continue
     if ($task_count === 0) {
         return;
     }
     $progress_count = $this->installer_config->get('file_update_progress_count', 0);
     $this->iohandler->set_task_count($task_count, true);
     $this->iohandler->set_progress('UPDATE_UPDATING_FILES', 0);
     $this->file_updater = $this->get_file_updater();
     // File updater fallback logic
     try {
         // Update files
         foreach ($file_update_info as $type => $file_update_vector) {
             if (!$type_progress_found) {
                 if ($type === $update_type_progress || empty($update_elem_progress)) {
                     $type_progress_found = true;
                 } else {
                     continue;
                 }
             }
             foreach ($file_update_vector as $path) {
                 if (!$elem_progress_found) {
                     if ($path === $update_elem_progress || empty($update_elem_progress)) {
                         $elem_progress_found = true;
                     } else {
                         continue;
                     }
                 }
                 switch ($type) {
                     case 'delete':
                         $this->file_updater->delete_file($path);
                         break;
                     case 'new':
                         $this->file_updater->create_new_file($path, $new_path . $path);
                         break;
                     case 'update_without_diff':
                         $this->file_updater->update_file($path, $new_path . $path);
                         break;
                     case 'update_with_diff':
                         $this->file_updater->update_file($path, $this->cache->get('_file_' . md5($path)), true);
                         break;
                 }
                 // Save progress
                 $this->installer_config->set('file_updater_type_progress', $type);
                 $this->installer_config->set('file_updater_elem_progress', $path);
                 $progress_count++;
                 $this->iohandler->set_progress('UPDATE_UPDATING_FILES', $progress_count);
                 if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
                     // Request refresh
                     throw new resource_limit_reached_exception();
                 }
             }
         }
         $this->iohandler->finish_progress('UPDATE_UPDATING_FILES');
     } catch (runtime_exception $e) {
         if ($e instanceof resource_limit_reached_exception) {
             throw new resource_limit_reached_exception();
         }
         $current_method = $this->installer_config->get('file_update_method', '');
         // File updater failed, try to fallback to download file update mode
         if ($current_method !== 'compression') {
             $this->iohandler->add_warning_message(array('UPDATE_FILE_UPDATER_HAS_FAILED', $current_method, 'compression'));
             $this->installer_config->set('file_update_method', 'compression');
             // We only want a simple refresh here
             throw new resource_limit_reached_exception();
         } else {
             // Nowhere to fallback to :(
             // Due to the way the installer handles fatal errors, we need to throw a low level exception
             throw new runtime_exception('UPDATE_FILE_UPDATERS_HAVE_FAILED');
         }
     }
     $file_updater_method = $this->installer_config->get('file_update_method', '');
     if ($file_updater_method === 'compression' || $file_updater_method === 'ftp') {
         $this->file_updater->close();
     }
 }