add_log_message() public method

Note: When an array is passed into the parameters below, it will be resolved as printf($param[0], $param[1], ...).
public add_log_message ( string | array $log_title, string | boolean | array $log_description = false )
$log_title string | array Title of the log message
$log_description string | boolean | array Description of the log, or false if the log description is not available
 /**
  * {@inheritdoc}
  */
 public function write($message, $verbosity)
 {
     if ($verbosity <= migrator_output_handler_interface::VERBOSITY_VERBOSE) {
         $this->iohandler->add_log_message($message);
         $this->iohandler->send_response();
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Recover install progress
     $task_name = $this->recover_progress();
     $task_found = false;
     /**
      * @var string							$name	ID of the service
      * @var \phpbb\install\task_interface	$task	Task object
      */
     foreach ($this->task_collection as $name => $task) {
         // Run until there are available resources
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             throw new resource_limit_reached_exception();
         }
         // Skip forward until the next task is reached
         if (!$task_found) {
             if ($name === $task_name || empty($task_name)) {
                 $task_found = true;
                 if ($name === $task_name) {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         // Check if we can run the task
         if (!$task->is_essential() && !$task->check_requirements()) {
             $this->iohandler->add_log_message(array('SKIP_TASK', $name));
             $this->install_config->increment_current_task_progress($this->task_step_count[$name]);
             continue;
         }
         if ($this->allow_progress_bar) {
             // Only increment progress by one, as if a task has more than one steps
             // then that should be incremented in the task itself
             $this->install_config->increment_current_task_progress();
         }
         $task->run();
         // Log install progress
         $this->install_config->set_finished_task($name);
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         $this->iohandler->send_response();
     }
     // Module finished, so clear task progress
     $this->install_config->set_finished_task('');
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Recover install progress
     $task_index = $this->recover_progress();
     $iterator = $this->task_collection->getIterator();
     if ($task_index < $iterator->count()) {
         $iterator->seek($task_index);
     } else {
         $this->install_config->set_finished_task(0);
         return;
     }
     while ($iterator->valid()) {
         $task = $iterator->current();
         $name = $iterator->key();
         // Check if we can run the task
         if (!$task->is_essential() && !$task->check_requirements()) {
             $this->iohandler->add_log_message(array('SKIP_TASK', $name));
             $this->install_config->increment_current_task_progress($this->task_step_count[$name]);
         } else {
             // Send progress information
             if ($this->allow_progress_bar) {
                 $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
                 $this->iohandler->send_response();
             }
             $task->run();
             if ($this->allow_progress_bar) {
                 // Only increment progress by one, as if a task has more than one steps
                 // then that should be incremented in the task itself
                 $this->install_config->increment_current_task_progress();
             }
         }
         $task_index++;
         $this->install_config->set_finished_task($task_index);
         $iterator->next();
         // Send progress information
         if ($this->allow_progress_bar) {
             $this->iohandler->set_progress($task->get_task_lang_name(), $this->install_config->get_current_task_progress());
         }
         $this->iohandler->send_response();
         // Stop execution if resource limit is reached
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             throw new resource_limit_reached_exception();
         }
     }
     // Module finished, so clear task progress
     $this->install_config->set_finished_task(0);
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->user->session_begin();
     $this->user->setup(array('common', 'acp/common', 'cli'));
     $install_extensions = $this->iohandler->get_input('install-extensions', array());
     $all_available_extensions = $this->extension_manager->all_available();
     $i = $this->install_config->get('install_extensions_index', 0);
     $available_extensions = array_slice($all_available_extensions, $i);
     // Install extensions
     foreach ($available_extensions as $ext_name => $ext_path) {
         if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) {
             continue;
         }
         try {
             $this->extension_manager->enable($ext_name);
             $extensions = $this->get_extensions();
             if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) {
                 // Create log
                 $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name));
                 $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name));
             } else {
                 $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
             }
         } catch (\Exception $e) {
             // Add fail log and continue
             $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
         }
         $i++;
         // Stop execution if resource limit is reached
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             break;
         }
     }
     $this->install_config->set('install_extensions_index', $i);
     if ($i < sizeof($all_available_extensions)) {
         throw new resource_limit_reached_exception();
     }
 }
Beispiel #5
0
 /**
  * Run phpBB installer
  */
 public function run()
 {
     if ($this->iohandler instanceof ajax_iohandler) {
         $this->iohandler->acquire_lock();
     }
     // Load install progress
     $this->install_config->load_config();
     if (!$this->install_config->get('cache_purged_before', false) && $this->purge_cache_before) {
         /** @var \phpbb\cache\driver\driver_interface $cache */
         $cache = $this->container_factory->get('cache.driver');
         $cache->purge();
         $this->install_config->set('cache_purged_before', true);
     }
     // Recover install progress
     $module_index = $this->recover_progress();
     // Variable used to check if the install process have been finished
     $install_finished = false;
     $fail_cleanup = false;
     $send_refresh = false;
     // We are installing something, so the introduction stage can go now...
     $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction'));
     $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction'));
     if ($this->install_config->get_task_progress_count() === 0) {
         // Count all tasks in the current installer modules
         $step_count = 0;
         /** @var \phpbb\install\module_interface $module */
         foreach ($this->installer_modules as $name => $module) {
             $module_step_count = $module->get_step_count();
             $step_count += $module_step_count;
             $this->module_step_count[$name] = $module_step_count;
         }
         // Set task count
         $this->install_config->set_task_progress_count($step_count);
     }
     // Set up progress information
     $this->iohandler->set_task_count($this->install_config->get_task_progress_count());
     try {
         $iterator = $this->installer_modules->getIterator();
         if ($module_index < $iterator->count()) {
             $iterator->seek($module_index);
         } else {
             $iterator->seek($module_index - 1);
             $iterator->next();
         }
         while ($iterator->valid()) {
             $module = $iterator->current();
             $name = $iterator->key();
             // Check if module should be executed
             if (!$module->is_essential() && !$module->check_requirements()) {
                 $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
                 $this->iohandler->add_log_message(array('SKIP_MODULE', $name));
                 $this->install_config->increment_current_task_progress($this->module_step_count[$name]);
             } else {
                 // Set the correct stage in the navigation bar
                 $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path());
                 $this->iohandler->send_response();
                 $module->run();
                 $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
             }
             $module_index++;
             $iterator->next();
             // Save progress
             $this->install_config->set_active_module($name, $module_index);
             if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)) {
                 throw new resource_limit_reached_exception();
             }
         }
         // Installation finished
         $install_finished = true;
         if ($this->iohandler instanceof cli_iohandler) {
             $this->iohandler->add_success_message('INSTALLER_FINISHED');
         } else {
             global $SID;
             $acp_url = $this->web_root . 'adm/index.php' . $SID;
             $this->iohandler->add_success_message('INSTALLER_FINISHED', array('ACP_LINK', $acp_url));
         }
     } catch (user_interaction_required_exception $e) {
         $this->iohandler->send_response(true);
     } catch (resource_limit_reached_exception $e) {
         $send_refresh = true;
     } catch (jump_to_restart_point_exception $e) {
         $this->install_config->jump_to_restart_point($e->get_restart_point_name());
         $send_refresh = true;
     } catch (\Exception $e) {
         $this->iohandler->add_error_message($e->getMessage());
         $this->iohandler->send_response(true);
         $fail_cleanup = true;
     }
     if ($this->iohandler instanceof ajax_iohandler) {
         $this->iohandler->release_lock();
     }
     if ($install_finished) {
         // Send install finished message
         $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count());
         $this->iohandler->send_response(true);
     } else {
         if ($send_refresh) {
             $this->iohandler->request_refresh();
             $this->iohandler->send_response(true);
         }
     }
     // Save install progress
     try {
         if ($install_finished || $fail_cleanup) {
             $this->install_config->clean_up_config_file();
             $this->cache->purge();
             try {
                 /** @var \phpbb\cache\driver\driver_interface $cache */
                 $cache = $this->container_factory->get('cache.driver');
                 $cache->purge();
             } catch (cannot_build_container_exception $e) {
                 // Do not do anything, this just means there is no config.php yet
             }
         } else {
             $this->install_config->save_config();
         }
     } catch (installer_config_not_writable_exception $e) {
         // It is allowed to fail this test during requirements testing
         $progress_data = $this->install_config->get_progress_data();
         if ($progress_data['last_task_module_name'] !== 'installer.module.requirements_install') {
             $this->iohandler->add_error_message('INSTALLER_CONFIG_NOT_WRITABLE');
         }
     }
 }
Beispiel #6
0
 /**
  * Run phpBB installer
  */
 public function run()
 {
     // Load install progress
     $this->install_config->load_config();
     // Recover install progress
     $module_name = $this->recover_progress();
     $module_found = false;
     // Variable used to check if the install process have been finished
     $install_finished = false;
     $fail_cleanup = false;
     $send_refresh = false;
     // We are installing something, so the introduction stage can go now...
     $this->install_config->set_finished_navigation_stage(array('install', 0, 'introduction'));
     $this->iohandler->set_finished_stage_menu(array('install', 0, 'introduction'));
     if ($this->install_config->get_task_progress_count() === 0) {
         // Count all tasks in the current installer modules
         $step_count = 0;
         /** @var \phpbb\install\module_interface $module */
         foreach ($this->installer_modules as $name => $module) {
             $module_step_count = $module->get_step_count();
             $step_count += $module_step_count;
             $this->module_step_count[$name] = $module_step_count;
         }
         // Set task count
         $this->install_config->set_task_progress_count($step_count);
     }
     // Set up progress information
     $this->iohandler->set_task_count($this->install_config->get_task_progress_count());
     try {
         foreach ($this->installer_modules as $name => $module) {
             // Skip forward until the current task is reached
             if (!$module_found) {
                 if ($module_name === $name || empty($module_name)) {
                     $module_found = true;
                 } else {
                     continue;
                 }
             }
             // Log progress
             $this->install_config->set_active_module($name);
             // Run until there are available resources
             if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
                 throw new resource_limit_reached_exception();
             }
             // Check if module should be executed
             if (!$module->is_essential() && !$module->check_requirements()) {
                 $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
                 $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
                 $this->iohandler->add_log_message(array('SKIP_MODULE', $name));
                 $this->install_config->increment_current_task_progress($this->module_step_count[$name]);
                 continue;
             }
             // Set the correct stage in the navigation bar
             $this->install_config->set_active_navigation_stage($module->get_navigation_stage_path());
             $this->iohandler->set_active_stage_menu($module->get_navigation_stage_path());
             $module->run();
             $this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
             $this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
         }
         // Installation finished
         $install_finished = true;
         if ($this->iohandler instanceof cli_iohandler) {
             $this->iohandler->add_success_message('INSTALLER_FINISHED');
         } else {
             global $SID;
             $acp_url = $this->web_root . 'adm/index.php' . $SID;
             $this->iohandler->add_success_message('INSTALLER_FINISHED', array('ACP_LINK', $acp_url));
         }
     } catch (user_interaction_required_exception $e) {
         // Do nothing
     } catch (resource_limit_reached_exception $e) {
         $send_refresh = true;
     } catch (jump_to_restart_point_exception $e) {
         $this->install_config->jump_to_restart_point($e->get_restart_point_name());
         $send_refresh = true;
     } catch (\Exception $e) {
         $this->iohandler->add_error_message($e->getMessage());
         $this->iohandler->send_response();
         $fail_cleanup = true;
     }
     if ($install_finished) {
         // Send install finished message
         $this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count());
     } else {
         if ($send_refresh) {
             $this->iohandler->request_refresh();
             $this->iohandler->send_response();
         }
     }
     // Save install progress
     try {
         if ($install_finished || $fail_cleanup) {
             $this->install_config->clean_up_config_file();
         } else {
             $this->install_config->save_config();
         }
     } catch (installer_config_not_writable_exception $e) {
         // It is allowed to fail this test during requirements testing
         $progress_data = $this->install_config->get_progress_data();
         if ($progress_data['last_task_module_name'] !== 'installer.module.requirements_install') {
             $this->iohandler->add_error_message('INSTALLER_CONFIG_NOT_WRITABLE');
         }
     }
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->user->session_begin();
     $this->user->setup(array('common', 'acp/common', 'cli'));
     $update_info = $this->install_config->get('update_info_unprocessed', []);
     $version_from = !empty($update_info) ? $update_info['version']['from'] : $this->config['version_update_from'];
     if (!empty($version_from)) {
         $update_extensions = $this->iohandler->get_input('update-extensions', []);
         // Create list of default extensions that need to be enabled in update
         $default_update_extensions = [];
         foreach (self::$default_extensions_update as $version => $extensions) {
             if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) {
                 $default_update_extensions = array_merge($default_update_extensions, $extensions);
             }
         }
         $all_available_extensions = $this->extension_manager->all_available();
         $i = $this->install_config->get('update_extensions_index', 0);
         $available_extensions = array_slice($all_available_extensions, $i);
         // Update available extensions
         foreach ($available_extensions as $ext_name => $ext_path) {
             // Update extensions if:
             //	1) Extension is currently enabled
             //	2) Extension was implicitly defined as needing an update
             //	3) Extension was newly added as default phpBB extension in
             //		this update and should be enabled by default.
             if ($this->extension_manager->is_enabled($ext_name) || in_array($ext_name, $update_extensions) || in_array($ext_name, $default_update_extensions)) {
                 try {
                     $extension_enabled = $this->extension_manager->is_enabled($ext_name);
                     if ($extension_enabled) {
                         $this->extension_manager->disable($ext_name);
                     }
                     $this->extension_manager->enable($ext_name);
                     $extensions = $this->get_extensions();
                     if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) {
                         // Create log
                         $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_UPDATE', time(), array($ext_name));
                         $this->iohandler->add_success_message(array('CLI_EXTENSION_UPDATE_SUCCESS', $ext_name));
                     } else {
                         $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name));
                     }
                     // Disable extensions if it was disabled by the admin before
                     if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) {
                         $this->extension_manager->disable($ext_name);
                     }
                 } catch (\Exception $e) {
                     // Add fail log and continue
                     $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name));
                 }
             }
             $i++;
             // Stop execution if resource limit is reached
             if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
                 break;
             }
         }
         $this->install_config->set('update_extensions_index', $i);
         if ($i < sizeof($all_available_extensions)) {
             throw new resource_limit_reached_exception();
         }
     }
     $this->config->delete('version_update_from');
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }