Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config:export] broken in 1.9.4 #4198

Closed
erilot opened this issue Nov 15, 2019 · 4 comments · Fixed by #4246
Closed

[config:export] broken in 1.9.4 #4198

erilot opened this issue Nov 15, 2019 · 4 comments · Fixed by #4246

Comments

@erilot
Copy link

erilot commented Nov 15, 2019

[config:export] broken in 1.9.4

Problem

After upgrading to console 1.9.4, config:export incorrectly calculates the directory path for the export files, creates those incorrect directories, and doesn't export any files. No error is thrown.

May be related to #4195.

I am using a web docroot on Ubuntu 18.04 local development environment (Lando/Pantheon recipe), and

  • Drupal 8.7.10
  • PHP 7.2
  • Console 1.9.4

What I expect to see: execute drupal ce, accept the default directory (/app/config). All config files are exported to /config. (Note with a web docroot this is parallel to the web directory containing the drupal site). This worked as expected until upgrading to 1.9.4.

What happens instead:
image

Which creates an /app/app/config directory with no files in it:
image

Replacing the default with /config generates an /app//config directory structure with no files in it.

Replacing the default with / destroys the site. Do not recommend.

How to reproduce

  • Upgrade drupal/console to 1.9.4
  • Attempt a config:export

Workaround

Revert to 1.9.3, which works as expected

@scothubbard
Copy link

The issue lies in the src/Command/Config/ExportCommand.php file, this is lines 95 to 118...

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $drupal_root = $this->drupalFinder->getComposerRoot();
        $directory = $drupal_root.'/'.$input->getOption('directory');
        $tar = $input->getOption('tar');
        $removeUuid = $input->getOption('remove-uuid');
        $removeHash = $input->getOption('remove-config-hash');
        $drupal_root = $this->drupalFinder->getComposerRoot();

        if (!$directory) {
            $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
        }

        $fileSystem = new Filesystem();
        try {
            $fileSystem->mkdir($drupal_root."/".$directory);
        } catch (IOExceptionInterface $e) {
            $this->getIo()->error(
                sprintf(
                    $this->trans('commands.config.export.messages.error'),
                    $e->getPath()
                )
            );
        }

You'll see that the $drupal_root is being added by default to the directory passed in to the function at line 98, which precludes specifying a full system path (in other words, you can now only pass a relative path to the export function).

The $drupal_root variable is then also being added again at line 110, so even with a relative path it will still be wrong.

Also, the $drupal_root variable itself is being defined twice (lines 97 & 102).

I believe these lines should look more like this...

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $drupal_root = $this->drupalFinder->getComposerRoot();
        $directory = $drupal_root.'/'.$input->getOption('directory');
        $tar = $input->getOption('tar');
        $removeUuid = $input->getOption('remove-uuid');
        $removeHash = $input->getOption('remove-config-hash');

        // if the directory passed in to the function exists, use it explicity
        if (is_dir($input->getOption('directory'))) {
          $directory = $input->getOption('directory');
        }

        if (!$directory) {
            $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
        }

        $fileSystem = new Filesystem();
        try {
            $fileSystem->mkdir($directory);
        } catch (IOExceptionInterface $e) {
            $this->getIo()->error(
                sprintf(
                    $this->trans('commands.config.export.messages.error'),
                    $e->getPath()
                )
            );
        }

I'm happy to be corrected though!

@tivie
Copy link

tivie commented Jan 23, 2020

same issue. Downgrading to 1.9.3 as suggested by @erilot works.

@sylvainar
Copy link

Could be linked to #4195

@LOBsTerr
Copy link
Member

Thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants