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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

check_update.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 4.68 KiB


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              $this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND');
126              $this->set_test_passed(false);
127   
128              // If there are no update files, we can't check the version etc
129              // However, we can let the users run migrations if they really want to...
130              $this->installer_config->set('disable_filesystem_update', true);
131              return true;
132          }
133   
134          // Recover version numbers
135          $update_info = array();
136          @include($this->phpbb_root_path . 'install/update/index.' . $this->php_ext);
137          $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
138          $update_version = false;
139   
140          if ($info !== false)
141          {
142              $update_version = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false;
143          }
144   
145          // Get current and latest version
146          try
147          {
148              $latest_version = $this->version_helper->get_latest_on_current_branch(true);
149          }
150          catch (\RuntimeException $e)
151          {
152              $latest_version = $update_version;
153          }
154   
155          $current_version = (!empty($this->config['version_update_from'])) ? $this->config['version_update_from'] : $this->config['version'];
156   
157          // Check if the update package
158          if (!$this->update_helper->phpbb_version_compare($current_version, $update_version, '<'))
159          {
160              $this->iohandler->add_error_message('NO_UPDATE_FILES_UP_TO_DATE');
161              $this->tests_passed = false;
162          }
163   
164          // Check if the update package works with the installed version
165          if (empty($info['version']['from']) || $info['version']['from'] !== $current_version)
166          {
167              $this->iohandler->add_error_message(array('INCOMPATIBLE_UPDATE_FILES', $current_version, $info['version']['from'], $update_version));
168              $this->tests_passed = false;
169          }
170   
171          // check if this is the latest update package
172          if ($this->update_helper->phpbb_version_compare($update_version, $latest_version, '<'))
173          {
174              $this->iohandler->add_warning_message(array('OLD_UPDATE_FILES', $info['version']['from'], $update_version, $latest_version));
175          }
176   
177          return $this->tests_passed;
178      }
179   
180      /**
181       * {@inheritdoc}
182       */
183      static public function get_step_count()
184      {
185          return 0;
186      }
187   
188      /**
189       * {@inheritdoc}
190       */
191      public function get_task_lang_name()
192      {
193          return '';
194      }
195  }
196