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

create_schema_file.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 4.06 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_database\task;
015   
016  use phpbb\install\exception\resource_limit_reached_exception;
017   
018  /**
019   * Create database schema
020   */
021  class create_schema_file extends \phpbb\install\task_base
022  {
023      /**
024       * @var \phpbb\install\helper\config
025       */
026      protected $config;
027   
028      /**
029       * @var \phpbb\db\driver\driver_interface
030       */
031      protected $db;
032   
033      /**
034       * @var \phpbb\filesystem\filesystem_interface
035       */
036      protected $filesystem;
037   
038      /**
039       * @var string
040       */
041      protected $phpbb_root_path;
042   
043      /**
044       * @var string
045       */
046      protected $php_ext;
047   
048      /**
049       * Constructor
050       *
051       * @param \phpbb\install\helper\config                            $config                Installer's config provider
052       * @param \phpbb\install\helper\database                        $db_helper            Installer's database helper
053       * @param \phpbb\filesystem\filesystem_interface                $filesystem            Filesystem service
054       * @param string                                                $phpbb_root_path    Path phpBB's root
055       * @param string                                                $php_ext            Extension of PHP files
056       */
057      public function __construct(\phpbb\install\helper\config $config,
058                                  \phpbb\install\helper\database $db_helper,
059                                  \phpbb\filesystem\filesystem_interface $filesystem,
060                                  $phpbb_root_path,
061                                  $php_ext)
062      {
063          $dbms = $db_helper->get_available_dbms($config->get('dbms'));
064          $dbms = $dbms[$config->get('dbms')]['DRIVER'];
065   
066          $this->db                = new $dbms();
067          $this->db->sql_connect(
068              $config->get('dbhost'),
069              $config->get('dbuser'),
070              $config->get('dbpasswd'),
071              $config->get('dbname'),
072              $config->get('dbport'),
073              false,
074              false
075          );
076   
077          $this->config            = $config;
078          $this->filesystem        = $filesystem;
079          $this->phpbb_root_path    = $phpbb_root_path;
080          $this->php_ext            = $php_ext;
081   
082          parent::__construct(true);
083      }
084   
085      /**
086       * {@inheritdoc}
087       */
088      public function run()
089      {
090          // Generate database schema
091          if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json'))
092          {
093              $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json');
094              $this->config->set('change_table_prefix', true);
095          }
096          else
097          {
098              global $table_prefix;
099   
100              // As this task may take a large amount of time to complete refreshing the page might be necessary for some
101              // server configurations with limited resources
102              if (!$this->config->get('pre_schema_forced_refresh', false))
103              {
104                  if ($this->config->get_time_remaining() < 5)
105                  {
106                      $this->config->set('pre_schema_forced_refresh', true);
107                      throw new resource_limit_reached_exception();
108                  }
109              }
110   
111              $table_prefix = $this->config->get('table_prefix');
112   
113              if (!defined('CONFIG_TABLE'))
114              {
115                  // We need to include the constants file for the table constants
116                  // when we generate the schema from the migration files.
117                  include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
118              }
119   
120              $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext);
121              $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
122              $factory = new \phpbb\db\tools\factory();
123              $db_tools = $factory->get($this->db, true);
124              $schema_generator = new \phpbb\db\migration\schema_generator(
125                  $migrator_classes,
126                  new \phpbb\config\config(array()),
127                  $this->db,
128                  $db_tools,
129                  $this->phpbb_root_path,
130                  $this->php_ext,
131                  $table_prefix
132              );
133              $db_table_schema = $schema_generator->get_schema();
134              $db_table_schema = json_encode($db_table_schema, JSON_PRETTY_PRINT);
135   
136              $this->config->set('change_table_prefix', false);
137          }
138   
139          $fp = @fopen($this->phpbb_root_path . 'store/schema.json', 'wb');
140          if (!$fp)
141          {
142              throw new \Exception('INST_SCHEMA_FILE_NOT_WRITABLE');
143          }
144   
145          fwrite($fp, $db_table_schema);
146          fclose($fp);
147      }
148   
149      /**
150       * {@inheritdoc}
151       */
152      static public function get_step_count()
153      {
154          return 1;
155      }
156   
157      /**
158       * {@inheritdoc}
159       */
160      public function get_task_lang_name()
161      {
162          return 'TASK_CREATE_DATABASE_SCHEMA_FILE';
163      }
164  }
165