Skip to content

Symfony 5 parameter fix #295

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

Closed
wants to merge 2 commits into from
Closed

Symfony 5 parameter fix #295

wants to merge 2 commits into from

Conversation

michaljusiega
Copy link

@greg0ire
Copy link
Member

greg0ire commented Jan 2, 2020

The parameter was introduced in symfony/symfony#22315 , and available since 3.4.0 , so I think this should target 2.1.x instead of master.

@michaljusiega michaljusiega changed the base branch from master to 2.1.x January 2, 2020 07:03
@michaljusiega
Copy link
Author

Changed. I think I changed it well.

@greg0ire
Copy link
Member

greg0ire commented Jan 2, 2020

Changing the base branch is the first step, and you did it correctly. The second step is to get rid of commits that are on master and which you did not author

  1. Fetch all new commits: git fetch --all. ⬇️
  2. Rebase on what you fetched interactively: ✂️
    1. git rebase -i origin/2.1.x, assuming origin is a git remote that points to this repository, and not your fork. If you're not sure what your remotes are, run git remote -vvv, there should be your fork and the holy/reference/base/origin repository.
    2. A window will show up with many lines, remove every line but the last one, which should correspond to your commit.
    3. If you run into a conflict: 💥
      1. fix it with git mergetool. 😷
      2. continue on your merry way with git rebase --continue. ⏩
  3. Force push to overwrite all this : git push --force. ⬆️

@michaljusiega
Copy link
Author

It's too hard for me :< Sorry, I give up :/

@greg0ire
Copy link
Member

greg0ire commented Jan 2, 2020

Don't worry, I will do it for you

@greg0ire
Copy link
Member

greg0ire commented Jan 2, 2020

All is well now, although a bit confusing because you used your master branch for this 😅

@michaljusiega
Copy link
Author

Thank you.

@michaljusiega
Copy link
Author

Can We finish this PR ?

Copy link
Contributor

@dmaicher dmaicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -41,7 +41,7 @@ public function getConfigTreeBuilder() : TreeBuilder

$rootNode
->children()
->scalarNode('dir_name')->defaultValue('%kernel.root_dir%/DoctrineMigrations')->cannotBeEmpty()->end()
->scalarNode('dir_name')->defaultValue('%doctrine.migrations.dir%')->cannotBeEmpty()->end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to stick with the naming of the other parameters I would name this one %doctrine_migrations.default_dir_name%

@@ -45,7 +45,7 @@ public static function configureMigrations(ContainerInterface $container, Config
$configuration->setMigrationsDirectory($dir);
} else {
// class Kernel has method getKernelParameters with some of the important path parameters
$pathPlaceholderArray = ['kernel.root_dir', 'kernel.cache_dir', 'kernel.logs_dir'];
$pathPlaceholderArray = ['kernel.project_dir', 'kernel.cache_dir', 'kernel.logs_dir'];
Copy link
Contributor

@dmaicher dmaicher Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be a BC break? The code below seems to replace/resolve parameter placeholders with kernel parameters. So now this will not work anymore if my Symfony 3.4 project relies on %kernel.root_dir% to be replaced here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think for now we can just add kernel.project_dir to the array but also keep kernel.root_dir. There is a check below that ensures the kernel parameter exists.

if ($container->hasParameter('kernel.root_dir')) {
$container->setParameter('doctrine.migrations.dir', '%kernel.root_dir%/DoctrineMigrations');
} else {
$container->setParameter('doctrine.migrations.dir', '%kernel.project_dir%/src/Migrations');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response.

As far as I can see this would still be a BC break for someone having an application that uses the old directory layout (i.e. they only updated their dependencies, but didn't adapt the directory structure established with Symfony Flex).

I think the only safe upgrade path is to deprecate not configuring this option and making it a mandatory one in the next major release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed @xabbuh is right 😢 This will break for people with the old directory structure that just move to Symfony 5 without adapting to the new structure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only safe upgrade path is to deprecate not configuring this option and making it a mandatory one in the next major release.

I'll defer this to @goetas, since the next major release will change the config format anyways. We may just want to ignore this for now and fix it properly in 3.0.

@goetas goetas self-assigned this Jan 23, 2020
@michaljusiega
Copy link
Author

So what about this PR ? I can't bump to SF5 due to kernel.root_dir which does not exist.

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 this pull request may close these issues.

8 participants