Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 |
check_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\requirements\task;
015
016 use phpbb\filesystem\filesystem;
017 use phpbb\install\helper\config;
018 use phpbb\install\helper\container_factory;
019 use phpbb\install\helper\iohandler\iohandler_interface;
020 use phpbb\install\helper\update_helper;
021 use phpbb\install\task_base;
022
023 /**
024 * Check the availability of updater files and update version
025 */
026 class check_update extends task_base
027 {
028 /**
029 * @var \phpbb\config\db
030 */
031 protected $config;
032
033 /**
034 * @var filesystem
035 */
036 protected $filesystem;
037
038 /**
039 * @var config
040 */
041 protected $installer_config;
042
043 /**
044 * @var iohandler_interface
045 */
046 protected $iohandler;
047
048 /**
049 * @var update_helper
050 */
051 protected $update_helper;
052
053 /**
054 * @var \phpbb\version_helper
055 */
056 protected $version_helper;
057
058 /**
059 * @var string
060 */
061 protected $phpbb_root_path;
062
063 /**
064 * @var string
065 */
066 protected $php_ext;
067
068 /**
069 * @var bool
070 */
071 protected $tests_passed;
072
073 /**
074 * Constructor
075 *
076 * @param container_factory $container
077 * @param filesystem $filesystem
078 * @param config $config
079 * @param iohandler_interface $iohandler
080 * @param update_helper $update_helper
081 * @param string $phpbb_root_path
082 * @param string $php_ext
083 */
084 public function __construct(container_factory $container, filesystem $filesystem, config $config, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path, $php_ext)
085 {
086 $this->filesystem = $filesystem;
087 $this->installer_config = $config;
088 $this->iohandler = $iohandler;
089 $this->update_helper = $update_helper;
090 $this->phpbb_root_path = $phpbb_root_path;
091 $this->php_ext = $php_ext;
092 $this->tests_passed = true;
093
094 $this->config = $container->get('config');
095 $this->version_helper = $container->get('version_helper');
096
097 parent::__construct(true);
098 }
099
100 /**
101 * Sets $this->tests_passed
102 *
103 * @param bool $is_passed
104 */
105 protected function set_test_passed($is_passed)
106 {
107 // If one test failed, tests_passed should be false
108 $this->tests_passed = $this->tests_passed && $is_passed;
109 }
110
111 /**
112 * {@inheritdoc}
113 */
114 public function run()
115 {
116 // Array of update files
117 $update_files = array(
118 $this->phpbb_root_path . 'install/update',
119 $this->phpbb_root_path . 'install/update/index.' . $this->php_ext,
120 );
121
122 // Check for a valid update directory
123 if (!$this->filesystem->exists($update_files) || !$this->filesystem->is_readable($update_files))
124 {
125 if ($this->iohandler->get_input('update_type', 'all') === 'all')
126 {
127 $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND');
128 $this->set_test_passed(false);
129 }
130
131 // If there are no update files, we can't check the version etc
132 // However, we can let the users run migrations if they really want to...
133 $this->installer_config->set('disable_filesystem_update', true);
134 return true;
135 }
136
137 // Recover version numbers
138 $update_info = array();
139 @include($this->phpbb_root_path . 'install/update/index.' . $this->php_ext);
140 $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
141 $update_version = false;
142
143 if ($info !== false)
144 {
145 $update_version = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false;
146 }
147
148 // Get current and latest version
149 try
150 {
151 $latest_version = $this->version_helper->get_latest_on_current_branch(true);
152 }
153 catch (\RuntimeException $e)
154 {
155 $latest_version = $update_version;
156 }
157
158 $current_version = (!empty($this->config['version_update_from'])) ? $this->config['version_update_from'] : $this->config['version'];
159
160 // Check if the update package
161 if (!$this->update_helper->phpbb_version_compare($current_version, $update_version, '<'))
162 {
163 $this->iohandler->add_error_message('NO_UPDATE_FILES_UP_TO_DATE');
164 $this->tests_passed = false;
165 }
166
167 // Check if the update package works with the installed version
168 if (empty($info['version']['from']) || $info['version']['from'] !== $current_version)
169 {
170 $this->iohandler->add_error_message(array('INCOMPATIBLE_UPDATE_FILES', $current_version, $info['version']['from'], $update_version));
171 $this->tests_passed = false;
172 }
173
174 // check if this is the latest update package
175 if ($this->update_helper->phpbb_version_compare($update_version, $latest_version, '<'))
176 {
177 $this->iohandler->add_warning_message(array('OLD_UPDATE_FILES', $info['version']['from'], $update_version, $latest_version));
178 }
179
180 return $this->tests_passed;
181 }
182
183 /**
184 * {@inheritdoc}
185 */
186 static public function get_step_count()
187 {
188 return 0;
189 }
190
191 /**
192 * {@inheritdoc}
193 */
194 public function get_task_lang_name()
195 {
196 return '';
197 }
198 }
199