Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 8.75 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\console\command\update;
 015   
 016  use phpbb\config\config;
 017  use phpbb\exception\exception_interface;
 018  use phpbb\language\language;
 019  use phpbb\user;
 020  use Symfony\Component\Console\Input\InputInterface;
 021  use Symfony\Component\Console\Input\InputArgument;
 022  use Symfony\Component\Console\Input\InputOption;
 023  use Symfony\Component\Console\Output\OutputInterface;
 024  use Symfony\Component\Console\Style\SymfonyStyle;
 025  use Symfony\Component\DependencyInjection\ContainerInterface;
 026   
 027  class check extends \phpbb\console\command\command
 028  {
 029      /** @var config */
 030      protected $config;
 031   
 032      /** @var \Symfony\Component\DependencyInjection\ContainerBuilder */
 033      protected $phpbb_container;
 034   
 035      /**
 036       * @var language
 037       */
 038      private $language;
 039   
 040      /**
 041      * Construct method
 042      */
 043      public function __construct(user $user, config $config, ContainerInterface $phpbb_container, language $language)
 044      {
 045          $this->config = $config;
 046          $this->phpbb_container = $phpbb_container;
 047          $this->language = $language;
 048   
 049          $this->language->add_lang(array('acp/common', 'acp/extensions'));
 050   
 051          parent::__construct($user);
 052      }
 053   
 054      /**
 055      * Configures the service.
 056      *
 057      * Sets the name and description of the command.
 058      *
 059      * @return null
 060      */
 061      protected function configure()
 062      {
 063          $this
 064              ->setName('update:check')
 065              ->setDescription($this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK'))
 066              ->addArgument('ext-name', InputArgument::OPTIONAL, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1'))
 067              ->addOption('stability', null, InputOption::VALUE_REQUIRED, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY'))
 068              ->addOption('cache', 'c', InputOption::VALUE_NONE, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE'))
 069          ;
 070      }
 071   
 072      /**
 073      * Executes the command.
 074      *
 075      * Checks if an update is available.
 076      * If at least one is available, a message is printed and if verbose mode is set the list of possible updates is printed.
 077      * If their is none, nothing is printed unless verbose mode is set.
 078      *
 079      * @param InputInterface $input Input stream, used to get the options.
 080      * @param OutputInterface $output Output stream, used to print messages.
 081      * @return int 0 if the board is up to date, 1 if it is not and 2 if an error occurred.
 082      * @throws \RuntimeException
 083      */
 084      protected function execute(InputInterface $input, OutputInterface $output)
 085      {
 086          $io = new SymfonyStyle($input, $output);
 087   
 088          $recheck = true;
 089          if ($input->getOption('cache'))
 090          {
 091              $recheck = false;
 092          }
 093   
 094          $stability = null;
 095          if ($input->getOption('stability'))
 096          {
 097              $stability = $input->getOption('stability');
 098              if (!($stability == 'stable') && !($stability == 'unstable'))
 099              {
 100                  $io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability));
 101                  return 3;
 102              }
 103          }
 104   
 105          $ext_name = $input->getArgument('ext-name');
 106          if ($ext_name != null)
 107          {
 108              if ($ext_name == 'all')
 109              {
 110                  return $this->check_all_ext($io, $stability, $recheck);
 111              }
 112              else
 113              {
 114                  return $this->check_ext($input, $io, $stability, $recheck, $ext_name);
 115              }
 116          }
 117          else
 118          {
 119              return $this->check_core($input, $io, $stability, $recheck);
 120          }
 121      }
 122   
 123      /**
 124       * Check if a given extension is up to date
 125       *
 126       * @param InputInterface    $input        Input stream, used to get the options.
 127       * @param SymfonyStyle        $io            IO handler, for formatted and unified IO
 128       * @param string            $stability    Force a given stability
 129       * @param bool                $recheck    Disallow the use of the cache
 130       * @param string            $ext_name    The extension name
 131       * @return int
 132       */
 133      protected function check_ext(InputInterface $input, SymfonyStyle $io, $stability, $recheck, $ext_name)
 134      {
 135          try
 136          {
 137              $ext_manager = $this->phpbb_container->get('ext.manager');
 138              $md_manager = $ext_manager->create_extension_metadata_manager($ext_name);
 139              $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
 140   
 141              $metadata = $md_manager->get_metadata('all');
 142              if ($input->getOption('verbose'))
 143              {
 144                  $io->title($md_manager->get_metadata('display-name'));
 145   
 146                  $io->note($this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $metadata['version']);
 147              }
 148   
 149              if (!empty($updates_available))
 150              {
 151                  if ($input->getOption('verbose'))
 152                  {
 153                      $io->caution($this->language->lang('NOT_UP_TO_DATE', $metadata['name']));
 154   
 155                      $this->display_versions($io, $updates_available);
 156                  }
 157   
 158                  return 1;
 159              }
 160              else
 161              {
 162                  if ($input->getOption('verbose'))
 163                  {
 164                      $io->success($this->language->lang('UPDATE_NOT_NEEDED'));
 165                  }
 166   
 167                  return 0;
 168              }
 169          }
 170          catch (\RuntimeException $e)
 171          {
 172              $io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name));
 173   
 174              return 1;
 175          }
 176      }
 177   
 178      /**
 179       * Check if the core is up to date
 180       *
 181       * @param InputInterface    $input        Input stream, used to get the options.
 182       * @param SymfonyStyle        $io            IO handler, for formatted and unified IO
 183       * @param string            $stability    Force a given stability
 184       * @param bool                $recheck    Disallow the use of the cache
 185       * @return int
 186       */
 187      protected function check_core(InputInterface $input, SymfonyStyle $io, $stability, $recheck)
 188      {
 189          $version_helper = $this->phpbb_container->get('version_helper');
 190          $version_helper->force_stability($stability);
 191   
 192          $updates_available = $version_helper->get_suggested_updates($recheck);
 193   
 194          if ($input->getOption('verbose'))
 195          {
 196              $io->title('phpBB core');
 197   
 198              $io->note( $this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $this->config['version']);
 199          }
 200   
 201          if (!empty($updates_available))
 202          {
 203              $io->caution($this->language->lang('UPDATE_NEEDED'));
 204   
 205              if ($input->getOption('verbose'))
 206              {
 207                  $this->display_versions($io, $updates_available);
 208              }
 209   
 210              return 1;
 211          }
 212          else
 213          {
 214              if ($input->getOption('verbose'))
 215              {
 216                  $io->success($this->language->lang('UPDATE_NOT_NEEDED'));
 217              }
 218   
 219              return 0;
 220          }
 221      }
 222   
 223      /**
 224      * Check if all the available extensions are up to date
 225      *
 226      * @param SymfonyStyle    $io            IO handler, for formatted and unified IO
 227      * @param string            $stability    Stability specifier string
 228      * @param bool            $recheck    Disallow the use of the cache
 229      * @return int
 230      */
 231      protected function check_all_ext(SymfonyStyle $io, $stability, $recheck)
 232      {
 233          /** @var \phpbb\extension\manager $ext_manager */
 234          $ext_manager = $this->phpbb_container->get('ext.manager');
 235   
 236          $rows = [];
 237   
 238          foreach ($ext_manager->all_available() as $ext_name => $ext_path)
 239          {
 240              $row = [];
 241              $row[] = sprintf("<info>%s</info>", $ext_name);
 242              $md_manager = $ext_manager->create_extension_metadata_manager($ext_name);
 243              try
 244              {
 245                  $metadata = $md_manager->get_metadata('all');
 246                  if (isset($metadata['extra']['version-check']))
 247                  {
 248                      try {
 249                          $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
 250                          if (!empty($updates_available))
 251                          {
 252                              $versions = array_map(function($entry)
 253                              {
 254                                  return $entry['current'];
 255                              }, $updates_available);
 256   
 257                              $row[] = sprintf("<comment>%s</comment>", $metadata['version']);
 258                              $row[] = implode(', ', $versions);
 259                          }
 260                          else
 261                          {
 262                              $row[] = sprintf("<info>%s</info>", $metadata['version']);
 263                              $row[] = '';
 264                          }
 265                      } catch (\RuntimeException $e) {
 266                          $row[] = $metadata['version'];
 267                          $row[] = '';
 268                      }
 269                  }
 270                  else
 271                  {
 272                      $row[] = $metadata['version'];
 273                      $row[] = '';
 274                  }
 275              }
 276              catch (exception_interface $e)
 277              {
 278                  $exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
 279                  $row[] = '<error>' . $exception_message . '</error>';
 280              }
 281              catch (\RuntimeException $e)
 282              {
 283                  $row[] = '<error>' . $e->getMessage() . '</error>';
 284              }
 285   
 286              $rows[] = $row;
 287          }
 288   
 289          $io->table([
 290              $this->language->lang('EXTENSION_NAME'),
 291              $this->language->lang('CURRENT_VERSION'),
 292              $this->language->lang('LATEST_VERSION'),
 293          ], $rows);
 294   
 295          return 0;
 296      }
 297   
 298      /**
 299      * Display the details of the available updates
 300      *
 301      * @param SymfonyStyle    $io                    IO handler, for formatted and unified IO
 302      * @param array            $updates_available    The list of the available updates
 303      */
 304      protected function display_versions(SymfonyStyle $io, $updates_available)
 305      {
 306          $io->section($this->language->lang('UPDATES_AVAILABLE'));
 307   
 308          $rows = [];
 309          foreach ($updates_available as $version_data)
 310          {
 311              $row = ['', '', ''];
 312              $row[0] = $version_data['current'];
 313   
 314              if (isset($version_data['announcement']))
 315              {
 316                  $row[1] = $version_data['announcement'];
 317              }
 318   
 319              if (isset($version_data['download']))
 320              {
 321                  $row[2] = $version_data['download'];
 322              }
 323   
 324              $rows[] = $row;
 325          }
 326   
 327          $io->table([
 328              $this->language->lang('VERSION'),
 329              $this->language->lang('ANNOUNCEMENT_TOPIC'),
 330              $this->language->lang('DOWNLOAD_LATEST'),
 331          ], $rows);
 332      }
 333  }
 334