[ Index ]

PHP Cross Reference of phpBB-3.1.10-deutsch

title

Body

[close]

/install/ -> database_update.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  $update_start_time = time();
  15  
  16  /**
  17  * @ignore
  18  */
  19  define('IN_PHPBB', true);
  20  define('IN_INSTALL', true);
  21  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
  22  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  23  
  24  function phpbb_end_update($cache, $config)
  25  {
  26      $cache->purge();
  27  
  28      $config->increment('assets_version', 1);
  29  
  30  ?>
  31                                  </p>
  32                              </div>
  33                          </div>
  34                  </div>
  35              </div>
  36          </div>
  37  
  38          <div id="page-footer">
  39              <div class="copyright">
  40                  Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited
  41              </div>
  42          </div>
  43      </div>
  44  </body>
  45  </html>
  46  
  47  <?php
  48  
  49      garbage_collection();
  50      exit_handler();
  51  }
  52  
  53  require($phpbb_root_path . 'includes/startup.' . $phpEx);
  54  require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
  55  
  56  $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
  57  $phpbb_class_loader->register();
  58  
  59  $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
  60  extract($phpbb_config_php_file->get_all());
  61  
  62  if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type))
  63  {
  64      die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update.");
  65  }
  66  
  67  // In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
  68  $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
  69  $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
  70  
  71  // Include files
  72  require($phpbb_root_path . 'includes/functions.' . $phpEx);
  73  require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
  74  
  75  require($phpbb_root_path . 'includes/constants.' . $phpEx);
  76  include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
  77  require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
  78  
  79  // Set PHP error handler to ours
  80  set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
  81  
  82  // Set up container (must be done here because extensions table may not exist)
  83  $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx);
  84  $phpbb_container_builder->set_use_extensions(false);
  85  $phpbb_container_builder->set_use_kernel_pass(false);
  86  $phpbb_container_builder->set_dump_container(false);
  87  $phpbb_container = $phpbb_container_builder->get_container();
  88  
  89  // set up caching
  90  $cache = $phpbb_container->get('cache');
  91  
  92  // Instantiate some basic classes
  93  $phpbb_dispatcher = $phpbb_container->get('dispatcher');
  94  $request    = $phpbb_container->get('request');
  95  $user        = $phpbb_container->get('user');
  96  $auth        = $phpbb_container->get('auth');
  97  $db            = $phpbb_container->get('dbal.conn');
  98  $phpbb_log    = $phpbb_container->get('log');
  99  
 100  // make sure request_var uses this request instance
 101  request_var('', 0, false, false, $request); // "dependency injection" for a function
 102  
 103  // Grab global variables, re-cache if necessary
 104  $config = $phpbb_container->get('config');
 105  set_config(null, null, null, $config);
 106  set_config_count(null, null, null, $config);
 107  
 108  if (!isset($config['version_update_from']))
 109  {
 110      $config->set('version_update_from', $config['version']);
 111  }
 112  
 113  $orig_version = $config['version_update_from'];
 114  
 115  $user->add_lang(array('common', 'acp/common', 'install', 'migrator'));
 116  
 117  // Add own hook handler, if present. :o
 118  if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
 119  {
 120      require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
 121      $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
 122  
 123      $phpbb_hook_finder = $phpbb_container->get('hook_finder');
 124      foreach ($phpbb_hook_finder->find() as $hook)
 125      {
 126          @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
 127      }
 128  }
 129  else
 130  {
 131      $phpbb_hook = false;
 132  }
 133  
 134  header('Content-type: text/html; charset=UTF-8');
 135  ?>
 136  <!DOCTYPE html>
 137  <html dir="<?php echo $user->lang['DIRECTION']; ?>" lang="<?php echo $user->lang['USER_LANG']; ?>">
 138  <head>
 139  <meta charset="utf-8">
 140  <meta http-equiv="X-UA-Compatible" content="IE=edge">
 141  
 142  <title><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></title>
 143  
 144  <link href="<?php echo htmlspecialchars($phpbb_admin_path); ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" />
 145  
 146  </head>
 147  
 148  <body>
 149      <div id="wrap">
 150          <div id="page-header">&nbsp;</div>
 151  
 152          <div id="page-body">
 153              <div id="acp">
 154                  <div class="panel">
 155                          <div id="content">
 156                              <div id="main" class="install-body">
 157  
 158                                  <h1><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></h1>
 159  
 160                                  <br />
 161  
 162                                  <p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->get_sql_layer(); ?></strong><br />
 163                                  <?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br />
 164  
 165  <?php
 166  
 167  define('IN_DB_UPDATE', true);
 168  
 169  /**
 170  * @todo mysql update?
 171  */
 172  
 173  // End startup code
 174  
 175  $migrator = $phpbb_container->get('migrator');
 176  $migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($user, new \phpbb\db\html_migrator_output_handler($user), $phpbb_root_path . 'store/migrations_' . time() . '.log'));
 177  
 178  $migrator->create_migrations_table();
 179  
 180  $phpbb_extension_manager = $phpbb_container->get('ext.manager');
 181  
 182  $migrations = $phpbb_extension_manager
 183      ->get_finder()
 184      ->core_path('phpbb/db/migration/data/')
 185      ->extension_directory('/migrations')
 186      ->get_classes();
 187  
 188  $migrator->set_migrations($migrations);
 189  
 190  // What is a safe limit of execution time? Half the max execution time should be safe.
 191  //  No more than 15 seconds so the user isn't sitting and waiting for a very long time
 192  $phpbb_ini = new \phpbb\php\ini();
 193  $safe_time_limit = min(15, ($phpbb_ini->get_int('max_execution_time') / 2));
 194  
 195  // While we're going to try limit this to half the max execution time,
 196  //  we want to try and take additional measures to prevent hitting the
 197  //  max execution time (if, say, one migration step takes much longer
 198  //  than the max execution time)
 199  @set_time_limit(0);
 200  
 201  while (!$migrator->finished())
 202  {
 203      try
 204      {
 205          $migrator->update();
 206      }
 207      catch (\phpbb\db\migration\exception $e)
 208      {
 209          echo $e->getLocalisedMessage($user);
 210  
 211          phpbb_end_update($cache, $config);
 212      }
 213  
 214      // Are we approaching the time limit? If so we want to pause the update and continue after refreshing
 215      if ((time() - $update_start_time) >= $safe_time_limit)
 216      {
 217          echo '<br />' . $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br /><br />';
 218          echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&amp;language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>';
 219  
 220          phpbb_end_update($cache, $config);
 221      }
 222  }
 223  
 224  if ($orig_version != $config['version'])
 225  {
 226      add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']);
 227  }
 228  
 229  echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '<br />';
 230  
 231  if ($request->variable('type', 0))
 232  {
 233      echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '<br /><br />';
 234      echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&amp;sub=update_db&amp;language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>';
 235  }
 236  else
 237  {
 238      echo '<div class="errorbox">' . $user->lang['UPDATE_FILES_NOTICE'] . '</div>';
 239      echo $user->lang['COMPLETE_LOGIN_TO_BOARD'];
 240  }
 241  
 242  $config->delete('version_update_from');
 243  
 244  phpbb_end_update($cache, $config);


Generated: Sun Feb 19 19:52:41 2017 Cross-referenced by PHPXref 0.7.1