/** * {@inheritdoc} */ public function run() { if (!$this->config->get('populate_migration_refresh_before', false)) { if ($this->config->get_time_remaining() < 1) { $this->config->set('populate_migration_refresh_before', true); throw new resource_limit_reached_exception(); } } $finder = $this->extension_manager->get_finder(); $migrations = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $this->migrator->populate_migrations($migrations); }
/** * Create a non-cached UrlMatcher * * @param \phpbb\extension\manager $manager Extension manager * @param RequestContext $context Symfony RequestContext object * @return UrlMatcher */ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path) { $provider = new \phpbb\controller\provider(); $provider->find_routing_files($manager->get_finder()); $routes = $provider->find($root_path)->get_routes(); return new UrlMatcher($routes, $context); }
/** * {@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_step_count = $this->installer_config->get('database_update_migration_steps', -1); if ($migration_step_count < 0) { $migration_step_count = count($this->migrator->get_installable_migrations()) * 2; $this->installer_config->set('database_update_migration_steps', $migration_step_count); } $progress_count = $this->installer_config->get('database_update_count', 0); $restart_progress_bar = $progress_count === 0; // Only "restart" when the update runs for the first time $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar); $this->installer_config->set_task_progress_count($migration_step_count); while (!$this->migrator->finished()) { try { $this->migrator->update(); $progress_count++; $last_run_migration = $this->migrator->get_last_run_migration(); if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) { // We skipped two step, so increment $progress_count by another one $progress_count++; } else { if ($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done'] || $last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done']) { // We just run a step that wasn't counted yet so make it count $migration_step_count++; } } $this->iohandler->set_task_count($migration_step_count); $this->installer_config->set_task_progress_count($migration_step_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); 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); $this->installer_config->set('database_update_migration_steps', $migration_step_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->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }
protected function execute(InputInterface $input, OutputInterface $output) { $migrations = $this->extension_manager->get_finder()->set_extensions(array())->core_path('phpbb/db/migration/data/')->get_classes(); $tips = $migrations; foreach ($migrations as $migration_class) { foreach ($migration_class::depends_on() as $dependency) { $tips_key = array_search($dependency, $tips); if ($tips_key !== false) { unset($tips[$tips_key]); } } } $output->writeln("\t\tarray("); foreach ($tips as $migration) { $output->writeln("\t\t\t'{$migration}',"); } $output->writeln("\t\t);"); }
/** * Get file names from Topic Preview's CSS files * * @return Array of file names * @access protected */ protected function get_themes() { $finder = $this->ext_manager->get_finder(); // Find css files in ext/vse/topicpreview/styles/all/theme/ $files = $finder->extension_suffix('.css')->extension_directory('/styles/all/theme')->find_from_extension('topicpreview', $this->phpbb_root_path . 'ext/vse/topicpreview/'); // Get just basenames of array keys $files = array_map(function ($value) { return basename($value, '.css'); }, array_keys($files)); return $files; }
/** * Auto add the specified language file from across all extensions * * This is a modified copy of the add_mod_info in functions_module.php */ public function add($lang_file) { $finder = $this->ext_manager->get_finder(); // We grab the language files from the default, English and user's language. // So we can fall back to the other files like we do when using add_lang() $default_lang_files = $english_lang_files = array(); // Search for board default language if it's not the user language if ($this->config['default_lang'] != $this->user->lang_name) { $default_lang_files = $finder->prefix($lang_file)->suffix(".{$this->php_ext}")->extension_directory('/language/' . basename($this->config['default_lang']))->core_path('language/' . basename($this->config['default_lang']) . '/')->find(); } // Search for english, if its not the default or user language if ($this->config['default_lang'] != 'en' && $this->user->lang_name != 'en') { $english_lang_files = $finder->prefix($lang_file)->suffix(".{$this->php_ext}")->extension_directory('/language/en')->core_path('language/en/')->find(); } // Find files in the user's language $user_lang_files = $finder->prefix($lang_file)->suffix(".{$this->php_ext}")->extension_directory('/language/' . $this->user->lang_name)->core_path('language/' . $this->user->lang_name . '/')->find(); $lang_files = array_unique(array_merge($user_lang_files, $english_lang_files, $default_lang_files)); foreach ($lang_files as $lang_file => $ext_name) { $this->user->add_lang_ext($ext_name, $lang_file); } }
/** * Constructor * * @param \phpbb\template\template $template Template object * @param \phpbb\user $user User object * @param \phpbb\config\config $config Config object * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object * @param \phpbb\request\request_interface $request phpBB request object * @param \phpbb\filesystem $filesystem The filesystem object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->symfony_request = $symfony_request; $this->request = $request; $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->find_routing_files($manager->get_finder()); $this->route_collection = $provider->find($phpbb_root_path)->get_routes(); }
/** * Get file names from Topic Preview's CSS files * * @return array File name data */ protected function get_themes() { $finder = $this->ext_manager->get_finder(); // Find css files in ext/vse/topicpreview/styles/all/theme/ $themes = $finder->extension_suffix('.css')->extension_directory('/styles/all/theme')->find_from_extension('topicpreview', $this->phpbb_root_path . 'ext/vse/topicpreview/'); // Get just basenames of array keys $themes = array_map(function ($value) { return basename($value, '.css'); }, array_keys($themes)); // Add option for native browser tooltip (aka no theme) $themes[] = self::NO_THEME; return $themes; }
/** * Get available module information from module files * * @param string $module_class Class of the module (acp, ucp, mcp etc...) * @param string $module ID of module * @param bool $use_all_available Use all available instead of just all * enabled extensions * * @return array Array with module information gathered from module info files. */ public function get_module_infos($module_class, $module = '', $use_all_available = false) { $directory = $this->phpbb_root_path . 'includes/' . $module_class . '/info/'; $fileinfo = array(); $finder = $this->extension_manager->get_finder($use_all_available); $modules = $finder->extension_suffix('_module')->extension_directory("/{$module_class}")->core_path("includes/{$module_class}/info/")->core_prefix($module_class . '_')->get_classes(true); foreach ($modules as $cur_module) { // Skip entries we do not need if we know the module we are // looking for if ($module && strpos(str_replace('\\', '_', $cur_module), $module) === false && $module !== $cur_module) { continue; } $info_class = preg_replace('/_module$/', '_info', $cur_module); // If the class does not exist it might be following the old // format. phpbb_acp_info_acp_foo needs to be turned into // acp_foo_info and the respective file has to be included // manually because it does not support auto loading $old_info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); $old_info_class = $old_info_class_file . '_info'; if (class_exists($old_info_class)) { $info_class = $old_info_class; } else { if (!class_exists($info_class)) { $info_class = $old_info_class; // need to check class exists again because previous checks triggered autoloading if (!class_exists($info_class) && file_exists($directory . $old_info_class_file . '.' . $this->php_ext)) { include $directory . $old_info_class_file . '.' . $this->php_ext; } } } if (class_exists($info_class)) { $info = new $info_class(); $module_info = $info->module(); $main_class = isset($module_info['filename']) ? $module_info['filename'] : $cur_module; $fileinfo[$main_class] = $module_info; } } ksort($fileinfo); return $fileinfo; }
/** * {@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); }
protected function load_migrations() { $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes(); $this->migrator->set_migrations($migrations); return $this->migrator->get_migrations(); }
/** * Get image paths/names from ABBC3's icons folder * * @return Array of file data from ./ext/vse/abbc3/images/icons * @access protected */ protected function get_images() { $finder = $this->extension_manager->get_finder(); return $finder->extension_suffix('.gif')->extension_directory('/images/icons')->find_from_extension('abbc3', $this->root_path . $this->ext_root_path); }
/** * {@inheritdoc} */ public function run() { $finder = $this->extension_manager->get_finder(); $migrations = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $this->migrator->populate_migrations($migrations); }
/** * Populate migrations for the installation * * This "installs" all migrations from (root path)/phpbb/db/migrations/data. * "installs" means it adds all migrations to the migrations table, but does not * perform any of the actions in the migrations. * * @param \phpbb\extension\manager $extension_manager * @param \phpbb\db\migrator $migrator */ function populate_migrations($extension_manager, $migrator) { $finder = $extension_manager->get_finder(); $migrations = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $migrator->populate_migrations($migrations); }
public function setUp() { $this->extension_manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array('vendor2/foo' => array('ext_name' => 'vendor2/foo', 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/'), 'vendor3/bar' => array('ext_name' => 'vendor3/bar', 'ext_active' => '1', 'ext_path' => 'ext/vendor3/bar/'))); $this->finder = $this->extension_manager->get_finder(); }
/** * Find files * * @param string $path The path to search in * @param string $prefix The prefix to search for * @param string $suffix The suffix to search for * @return array Array of found file paths * @access protected */ protected function find($path, $prefix, $suffix) { $finder = $this->extension_manager->get_finder(); return $finder->set_extensions(array('phpbb/pages'))->prefix($prefix)->suffix($suffix)->core_path("{$path}/")->extension_directory("/{$path}")->find(); }