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

add_tables.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.33 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 tables
020   */
021  class add_tables 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\db\tools\tools_interface
035       */
036      protected $db_tools;
037   
038      /**
039       * @var \phpbb\filesystem\filesystem_interface
040       */
041      protected $filesystem;
042   
043      /**
044       * @var string
045       */
046      protected $schema_file_path;
047   
048      /**
049       * Constructor
050       *
051       * @param \phpbb\install\helper\config                $config
052       * @param \phpbb\install\helper\database            $db_helper
053       * @param \phpbb\filesystem\filesystem_interface    $filesystem
054       * @param string                                    $phpbb_root_path
055       */
056      public function __construct(\phpbb\install\helper\config $config,
057                                  \phpbb\install\helper\database $db_helper,
058                                  \phpbb\filesystem\filesystem_interface $filesystem,
059                                  $phpbb_root_path)
060      {
061          $dbms = $db_helper->get_available_dbms($config->get('dbms'));
062          $dbms = $dbms[$config->get('dbms')]['DRIVER'];
063          $factory = new \phpbb\db\tools\factory();
064   
065          $this->db                = new $dbms();
066          $this->db->sql_connect(
067              $config->get('dbhost'),
068              $config->get('dbuser'),
069              $config->get('dbpasswd'),
070              $config->get('dbname'),
071              $config->get('dbport'),
072              false,
073              false
074          );
075   
076          $this->config            = $config;
077          $this->db_tools            = $factory->get($this->db);
078          $this->filesystem        = $filesystem;
079          $this->schema_file_path    = $phpbb_root_path . 'store/schema.json';
080   
081          parent::__construct(true);
082      }
083   
084      /**
085       * {@inheritdoc}
086       */
087      public function run()
088      {
089          $this->db->sql_return_on_error(true);
090   
091          $table_prefix = $this->config->get('table_prefix');
092          $change_prefix = $this->config->get('change_table_prefix', true);
093   
094          if (!defined('CONFIG_TABLE'))
095          {
096              // CONFIG_TABLE is required by sql_create_index() to check the
097              // length of index names. However table_prefix is not defined
098              // here yet, so we need to create the constant ourselves.
099              define('CONFIG_TABLE', $table_prefix . 'config');
100          }
101   
102          $db_table_schema = @file_get_contents($this->schema_file_path);
103          $db_table_schema = json_decode($db_table_schema, true);
104          $total = sizeof($db_table_schema);
105          $i = $this->config->get('add_table_index', 0);
106          $db_table_schema = array_slice($db_table_schema, $i);
107   
108          foreach ($db_table_schema as $table_name => $table_data)
109          {
110              $i++;
111   
112              $this->db_tools->sql_create_table(
113                  ( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ),
114                  $table_data
115              );
116   
117              // Stop execution if resource limit is reached
118              if ($this->config->get_time_remaining() <= 0 || $this->config->get_memory_remaining() <= 0)
119              {
120                  break;
121              }
122          }
123   
124          $this->config->set('add_table_index', $i);
125   
126          if ($i < $total)
127          {
128              throw new resource_limit_reached_exception();
129          }
130          else
131          {
132              @unlink($this->schema_file_path);
133          }
134      }
135   
136      /**
137       * {@inheritdoc}
138       */
139      static public function get_step_count()
140      {
141          return 1;
142      }
143   
144      /**
145       * {@inheritdoc}
146       */
147      public function get_task_lang_name()
148      {
149          return 'TASK_CREATE_TABLES';
150      }
151  }
152