[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/console/command/db/ -> revert.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\InputArgument;
  17  use Symfony\Component\Console\Input\InputInterface;
  18  use Symfony\Component\Console\Output\OutputInterface;
  19  use Symfony\Component\Console\Style\SymfonyStyle;
  20  
  21  class revert extends \phpbb\console\command\db\migrate
  22  {
  23  	protected function configure()
  24      {
  25          $this
  26              ->setName('db:revert')
  27              ->setDescription($this->language->lang('CLI_DESCRIPTION_DB_REVERT'))
  28              ->addArgument(
  29                  'name',
  30                  InputArgument::REQUIRED,
  31                  $this->language->lang('CLI_MIGRATION_NAME')
  32              )
  33          ;
  34      }
  35  
  36  	protected function execute(InputInterface $input, OutputInterface $output)
  37      {
  38          $io = new SymfonyStyle($input, $output);
  39  
  40          $name = str_replace('/', '\\', $input->getArgument('name'));
  41  
  42          $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));
  43  
  44          $this->cache->purge();
  45  
  46          if (!in_array($name, $this->load_migrations()))
  47          {
  48              $io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
  49              return 1;
  50          }
  51          else if ($this->migrator->migration_state($name) === false)
  52          {
  53              $io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
  54              return 1;
  55          }
  56  
  57          try
  58          {
  59              while ($this->migrator->migration_state($name) !== false)
  60              {
  61                  $this->migrator->revert($name);
  62              }
  63          }
  64          catch (\phpbb\db\migration\exception $e)
  65          {
  66              $io->error($e->getLocalisedMessage($this->user));
  67              $this->finalise_update();
  68              return 1;
  69          }
  70  
  71          $this->finalise_update();
  72          $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
  73      }
  74  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1