[ Index ]

PHP Cross Reference of phpBB-3.3.3-deutsch

title

Body

[close]

/phpbb/console/command/db/ -> migrate.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  namespace phpbb\console\command\db;
  14  
  15  use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
  16  use Symfony\Component\Console\Input\InputInterface;
  17  use Symfony\Component\Console\Output\OutputInterface;
  18  use Symfony\Component\Console\Style\SymfonyStyle;
  19  
  20  class migrate extends \phpbb\console\command\db\migration_command
  21  {
  22      /** @var \phpbb\log\log */
  23      protected $log;
  24  
  25      /** @var string phpBB root path */
  26      protected $phpbb_root_path;
  27  
  28      /** @var  \phpbb\filesystem\filesystem_interface */
  29      protected $filesystem;
  30  
  31      /** @var \phpbb\language\language */
  32      protected $language;
  33  
  34  	public function __construct(\phpbb\user $user, \phpbb\language\language $language, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path)
  35      {
  36          $this->language = $language;
  37          $this->log = $log;
  38          $this->filesystem = $filesystem;
  39          $this->phpbb_root_path = $phpbb_root_path;
  40          parent::__construct($user, $migrator, $extension_manager, $config, $cache);
  41          $this->language->add_lang(array('common', 'install', 'migrator'));
  42      }
  43  
  44  	protected function configure()
  45      {
  46          $this
  47              ->setName('db:migrate')
  48              ->setDescription($this->language->lang('CLI_DESCRIPTION_DB_MIGRATE'))
  49          ;
  50      }
  51  
  52  	protected function execute(InputInterface $input, OutputInterface $output)
  53      {
  54          $io = new SymfonyStyle($input, $output);
  55  
  56          $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
  57  
  58          $this->migrator->create_migrations_table();
  59  
  60          $this->cache->purge();
  61  
  62          $this->load_migrations();
  63          $orig_version = $this->config['version'];
  64          while (!$this->migrator->finished())
  65          {
  66              try
  67              {
  68                  $this->migrator->update();
  69              }
  70              catch (\phpbb\db\migration\exception $e)
  71              {
  72                  $io->error($e->getLocalisedMessage($this->user));
  73                  $this->finalise_update();
  74                  return 1;
  75              }
  76          }
  77  
  78          if ($orig_version != $this->config['version'])
  79          {
  80              $this->log->add('admin', ANONYMOUS, '', 'LOG_UPDATE_DATABASE', time(), array($orig_version, $this->config['version']));
  81          }
  82  
  83          $this->finalise_update();
  84          $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
  85      }
  86  }


Generated: Sun Feb 14 20:08:31 2021 Cross-referenced by PHPXref 0.7.1