<commit_before><?php

namespace N98\Magento\Command\System\Setup;

use N98\Magento\Command\AbstractMagentoCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class RunCommand extends AbstractMagentoCommand
{
    protected function configure()
    {
        $this
            ->setName('sys:setup:run')
            ->setDescription('Runs all new setup scripts.');
        $help = <<<HELP
Runs all setup scripts (no need to call frontend).
This command is useful if you update your system with enabled maintenance mode.
HELP;
        $this->setHelp($help);
    }

    /**
     * @param \Symfony\Component\Console\Input\InputInterface   $input
     * @param \Symfony\Component\Console\Output\OutputInterface $output
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->getApplication()->setAutoExit(false);
        $this->detectMagento($output);
        if ($this->initMagento()) {

            try {
                $this->getApplication()->run(new StringInput('cache:flush'), new NullOutput());
                /**
                 * Put output in buffer. \Mage_Core_Model_Resource_Setup::_modifyResourceDb should print any error
                 * directly to stdout. Use execption which will be thrown to show error
                 */
                \ob_start();
                \Mage_Core_Model_Resource_Setup::applyAllUpdates();
                if (is_callable(array('\Mage_Core_Model_Resource_Setup', 'applyAllDataUpdates'))) {
                    \Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
                }
                \ob_end_clean();
                $output->writeln('<info>done</info>');
            } catch (\Exception $e) {
                \ob_end_clean();
                $this->printException($output, $e);
                $this->printStackTrace($output, $e->getTrace());
                $this->printFile($output, $e);<commit_msg>[BUGFIX] #315 sys:setup:run on enterprise requires admin session. (by <NAME> and <NAME>)<commit_after><?php

namespace N98\Magento\Command\System\Setup;

use N98\Magento\Command\AbstractMagentoCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class RunCommand extends AbstractMagentoCommand
{
    protected function configure()
    {
        $this
            ->setName('sys:setup:run')
            ->setDescription('Runs all new setup scripts.');
        $help = <<<HELP
Runs all setup scripts (no need to call frontend).
This command is useful if you update your system with enabled maintenance mode.
HELP;
        $this->setHelp($help);
    }

    /**
     * @param InputInterface   $input
     * @param OutputInterface $output
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->getApplication()->setAutoExit(false);
        $this->detectMagento($output);
        if ($this->initMagento()) {
            try {
                /**
                 * Get events before cache flush command is called.
                 */
                $reflectionApp = new \ReflectionObject(\Mage::app());
                $appEventReflectionProperty = $reflectionApp->getProperty('_events');
                $appEventReflectionProperty->setAccessible(true);
                $eventsBeforeCacheFlush = $appEventReflectionProperty->getValue(\Mage::app());

                $this->getApplication()->run(new StringInput('cache:flush'), new NullOutput());

                /**
                 * Restore initially loaded events which was reset during setup script run
                 */
                $appEventReflectionProperty->setValue(\Mage::app(), $eventsBeforeCacheFlush);

                /**
                 * Put output in buffer. \Mage_Core_Model_Resource_Setup::_modifyResourceDb should print any error
                 * directly to stdout. Use execption which will be thrown to show error
                 */
                \ob_start();
                \Mage_Core_Model_Resource_Setup::applyAllUpdates();
                if (is_callable(array('\Mage_Core_Model_Resource_Setup', 'applyAllDataUpdates'))) {
                    \Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
                }
                \ob_end_clean();
                $output->writeln('<info>done</info>');
            } catch (\Exception $e) {
                \ob_end_clean();
                $this->printException($output, $e);
                $this->printStackTrace($output, $e->getTrace());
                $this->printFile($output, $e);
{'fraction_non_alphanumeric': 0.11497975708502024, 'fraction_numerical': 0.002226720647773279, 'mean_word_length': 2.402892561983471, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5779015', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1275, 'n_words': 269}