Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
update.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\install\module\update_database\task;
015
016 use phpbb\db\migration\exception;
017 use phpbb\db\output_handler\installer_migrator_output_handler;
018 use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
019 use phpbb\install\exception\resource_limit_reached_exception;
020 use phpbb\install\exception\user_interaction_required_exception;
021 use phpbb\install\task_base;
022
023 /**
024 * Database updater task
025 */
026 class update extends task_base
027 {
028 /**
029 * @var \phpbb\cache\driver\driver_interface
030 */
031 protected $cache;
032
033 /**
034 * @var \phpbb\config\config
035 */
036 protected $config;
037
038 /**
039 * @var \phpbb\extension\manager
040 */
041 protected $extension_manager;
042
043 /**
044 * @var \phpbb\filesystem\filesystem
045 */
046 protected $filesystem;
047
048 /**
049 * @var \phpbb\install\helper\config
050 */
051 protected $installer_config;
052
053 /**
054 * @var \phpbb\install\helper\iohandler\iohandler_interface
055 */
056 protected $iohandler;
057
058 /**
059 * @var \phpbb\language\language
060 */
061 protected $language;
062
063 /**
064 * @var \phpbb\log\log
065 */
066 protected $log;
067
068 /**
069 * @var \phpbb\db\migrator
070 */
071 protected $migrator;
072
073 /**
074 * @var \phpbb\user
075 */
076 protected $user;
077
078 /**
079 * @var string
080 */
081 protected $phpbb_root_path;
082
083 /**
084 * Constructor
085 *
086 * @param \phpbb\install\helper\container_factory $container
087 * @param \phpbb\filesystem\filesystem $filesystem
088 * @param \phpbb\install\helper\config $installer_config
089 * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler
090 * @param \phpbb\language\language $language
091 * @param string $phpbb_root_path
092 */
093 public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\filesystem\filesystem $filesystem, \phpbb\install\helper\config $installer_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, \phpbb\language\language $language, $phpbb_root_path)
094 {
095 $this->filesystem = $filesystem;
096 $this->installer_config = $installer_config;
097 $this->iohandler = $iohandler;
098 $this->language = $language;
099 $this->phpbb_root_path = $phpbb_root_path;
100
101 $this->cache = $container->get('cache.driver');
102 $this->config = $container->get('config');
103 $this->extension_manager = $container->get('ext.manager');
104 $this->log = $container->get('log');
105 $this->migrator = $container->get('migrator');
106 $this->user = $container->get('user');
107
108 parent::__construct(true);
109 }
110
111 /**
112 * {@inheritdoc}
113 */
114 public function run()
115 {
116 $this->language->add_lang('migrator');
117
118 if (!isset($this->config['version_update_from']))
119 {
120 $this->config->set('version_update_from', $this->config['version']);
121 }
122
123 $original_version = $this->config['version_update_from'];
124
125 $this->migrator->set_output_handler(
126 new log_wrapper_migrator_output_handler(
127 $this->language,
128 new installer_migrator_output_handler($this->iohandler),
129 $this->phpbb_root_path . 'store/migrations_' . time() . '.log',
130 $this->filesystem
131 )
132 );
133
134 $this->migrator->create_migrations_table();
135
136 $migrations = $this->extension_manager
137 ->get_finder()
138 ->core_path('phpbb/db/migration/data/')
139 ->extension_directory('/migrations')
140 ->get_classes();
141
142 $this->migrator->set_migrations($migrations);
143
144 $migration_step_count = $this->installer_config->get('database_update_migration_steps', -1);
145 if ($migration_step_count < 0)
146 {
147 $migration_step_count = count($this->migrator->get_installable_migrations()) * 2;
148 $this->installer_config->set('database_update_migration_steps', $migration_step_count);
149 }
150
151 $progress_count = $this->installer_config->get('database_update_count', 0);
152 $restart_progress_bar = ($progress_count === 0); // Only "restart" when the update runs for the first time
153 $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar);
154 $this->installer_config->set_task_progress_count($migration_step_count);
155
156 while (!$this->migrator->finished())
157 {
158 try
159 {
160 $this->migrator->update();
161 $progress_count++;
162
163 $last_run_migration = $this->migrator->get_last_run_migration();
164 if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed'])
165 {
166 // We skipped two step, so increment $progress_count by another one
167 $progress_count++;
168 }
169 else if (($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done']) ||
170 ($last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done']))
171 {
172 // We just run a step that wasn't counted yet so make it count
173 $migration_step_count++;
174 }
175
176 $this->iohandler->set_task_count($migration_step_count);
177 $this->installer_config->set_task_progress_count($migration_step_count);
178 $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
179 }
180 catch (exception $e)
181 {
182 $msg = $e->getParameters();
183 array_unshift($msg, $e->getMessage());
184
185 $this->iohandler->add_error_message($msg);
186 throw new user_interaction_required_exception();
187 }
188
189 if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0)
190 {
191 $this->installer_config->set('database_update_count', $progress_count);
192 $this->installer_config->set('database_update_migration_steps', $migration_step_count);
193 throw new resource_limit_reached_exception();
194 }
195 }
196
197 if ($original_version !== $this->config['version'])
198 {
199 $this->log->add(
200 'admin',
201 (isset($this->user->data['user_id'])) ? $this->user->data['user_id'] : ANONYMOUS,
202 $this->user->ip,
203 'LOG_UPDATE_DATABASE',
204 false,
205 array(
206 $original_version,
207 $this->config['version']
208 )
209 );
210 }
211
212 $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL');
213
214 $this->cache->purge();
215
216 $this->config->increment('assets_version', 1);
217 }
218
219 /**
220 * {@inheritdoc}
221 */
222 static public function get_step_count()
223 {
224 return 0;
225 }
226
227 /**
228 * {@inheritdoc}
229 */
230 public function get_task_lang_name()
231 {
232 return '';
233 }
234 }
235