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

install_extensions.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 5.29 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\install_finish\task;
 015   
 016  use phpbb\config\db;
 017  use phpbb\install\exception\resource_limit_reached_exception;
 018   
 019  /**
 020   * Installs extensions that exist in ext folder upon install
 021   */
 022  class install_extensions extends \phpbb\install\task_base
 023  {
 024      /**
 025       * @var \phpbb\install\helper\config
 026       */
 027      protected $install_config;
 028   
 029      /**
 030       * @var \phpbb\install\helper\iohandler\iohandler_interface
 031       */
 032      protected $iohandler;
 033   
 034      /**
 035       * @var db
 036       */
 037      protected $config;
 038   
 039      /**
 040       * @var \phpbb\log\log_interface
 041       */
 042      protected $log;
 043   
 044      /**
 045       * @var \phpbb\user
 046       */
 047      protected $user;
 048   
 049      /** @var \phpbb\extension\manager */
 050      protected $extension_manager;
 051   
 052      /** @var \Symfony\Component\Finder\Finder */
 053      protected $finder;
 054   
 055      /** @var string Extension table */
 056      protected $extension_table;
 057   
 058      /** @var \phpbb\db\driver\driver_interface */
 059      protected $db;
 060   
 061      /**
 062       * Constructor
 063       *
 064       * @param \phpbb\install\helper\container_factory                $container
 065       * @param \phpbb\install\helper\config                            $install_config
 066       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler
 067       * @param string                                                $phpbb_root_path phpBB root path
 068       */
 069      public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path)
 070      {
 071          $this->install_config    = $install_config;
 072          $this->iohandler        = $iohandler;
 073          $this->extension_table = $container->get_parameter('tables.ext');
 074   
 075          $this->log                = $container->get('log');
 076          $this->config            = $container->get('config');
 077          $this->user                = $container->get('user');
 078          $this->extension_manager = $container->get('ext.manager');
 079          $this->db                = $container->get('dbal.conn');
 080          $this->finder = new \Symfony\Component\Finder\Finder();
 081          $this->finder->in($phpbb_root_path . 'ext/')
 082              ->ignoreUnreadableDirs()
 083              ->depth('< 3')
 084              ->files()
 085              ->name('composer.json');
 086   
 087          /** @var \phpbb\cache\driver\driver_interface $cache */
 088          $cache = $container->get('cache.driver');
 089          $cache->destroy('config');
 090   
 091          global $config;
 092          $config = new db(
 093              $this->db,
 094              $cache,
 095              $container->get_parameter('tables.config')
 096          );
 097   
 098          // Make sure asset version exists in config. Otherwise we might try to
 099          // insert the assets_version setting into the database and cause a
 100          // duplicate entry error.
 101          if (!isset($this->config['assets_version']))
 102          {
 103              $this->config['assets_version'] = 0;
 104          }
 105   
 106          parent::__construct(true);
 107      }
 108   
 109      /**
 110       * {@inheritdoc}
 111       */
 112      public function run()
 113      {
 114          $this->user->session_begin();
 115          $this->user->setup(array('common', 'acp/common', 'cli'));
 116   
 117          $install_extensions = $this->iohandler->get_input('install-extensions', array());
 118   
 119          $all_available_extensions = $this->extension_manager->all_available();
 120          $i = $this->install_config->get('install_extensions_index', 0);
 121          $available_extensions = array_slice($all_available_extensions, $i);
 122   
 123          // Install extensions
 124          foreach ($available_extensions as $ext_name => $ext_path)
 125          {
 126              if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions))
 127              {
 128                  continue;
 129              }
 130   
 131              try
 132              {
 133                  $extension = $this->extension_manager->get_extension($ext_name);
 134   
 135                  if (!$extension->is_enableable())
 136                  {
 137                      $this->iohandler->add_log_message(array('CLI_EXTENSION_NOT_ENABLEABLE', $ext_name));
 138                      continue;
 139                  }
 140   
 141                  $this->extension_manager->enable($ext_name);
 142                  $extensions = $this->get_extensions();
 143   
 144                  if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active'])
 145                  {
 146                      // Create log
 147                      $this->log->add('admin', ANONYMOUS, $this->user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name));
 148                      $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name));
 149                  }
 150                  else
 151                  {
 152                      $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
 153                  }
 154              }
 155              catch (\Exception $e)
 156              {
 157                  // Add fail log and continue
 158                  $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
 159              }
 160   
 161              $i++;
 162   
 163              // Stop execution if resource limit is reached
 164              if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
 165              {
 166                  break;
 167              }
 168          }
 169   
 170          $this->install_config->set('install_extensions_index', $i);
 171   
 172          if ($i < count($all_available_extensions))
 173          {
 174              throw new resource_limit_reached_exception();
 175          }
 176      }
 177   
 178      /**
 179       * {@inheritdoc}
 180       */
 181      static public function get_step_count()
 182      {
 183          return 1;
 184      }
 185   
 186      /**
 187       * {@inheritdoc}
 188       */
 189      public function get_task_lang_name()
 190      {
 191          return 'TASK_INSTALL_EXTENSIONS';
 192      }
 193   
 194      /**
 195       * Get extensions from database
 196       *
 197       * @return array List of extensions
 198       */
 199      private function get_extensions()
 200      {
 201          $sql = 'SELECT *
 202              FROM ' . $this->extension_table;
 203   
 204          $result = $this->db->sql_query($sql);
 205          $extensions_row = $this->db->sql_fetchrowset($result);
 206          $this->db->sql_freeresult($result);
 207   
 208          $extensions = array();
 209   
 210          foreach ($extensions_row as $extension)
 211          {
 212              $extensions[$extension['ext_name']] = $extension;
 213          }
 214   
 215          ksort($extensions);
 216   
 217          return $extensions;
 218      }
 219  }
 220