Skip to content

[HttpKernel] Deprecate usage of getRootDir() and kernel.root_dir #28810

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

Merged
merged 1 commit into from
Oct 16, 2018

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Oct 10, 2018

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #24293
License MIT
Doc PR n/a

* @param string $charset The charset
*/
public function __construct($fileLinkFormat, string $rootDir, string $charset)
public function __construct($fileLinkFormat, string $projectDir, string $charset)
Copy link
Member Author

Choose a reason for hiding this comment

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

We already inject kernel.project_dir in the container definition.

@fabpot fabpot force-pushed the root_dir-removal branch 2 times, most recently from 799ef32 to 086826e Compare October 10, 2018 16:10
@ogizanagi
Copy link
Contributor

You meant kernel.root_dir :)

- Remove internal usage of kernel.project_dir when possible
+ Remove internal usage of kernel.root_dir when possible

@fabpot fabpot changed the title Remove internal usage of kernel.project_dir when possible Remove internal usage of kernel.root_dir when possible Oct 10, 2018
@fabpot
Copy link
Member Author

fabpot commented Oct 10, 2018

indeed, fixed

protected $rootDir;
protected $projectDir;
Copy link
Member

Choose a reason for hiding this comment

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

should the new property be private instead ? I don't think it needs to be an extension point

Copy link
Member Author

Choose a reason for hiding this comment

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

of course, done

@@ -572,6 +572,9 @@ protected function getKernelParameters()
}

return array(
/**
* @deprecated since Symfony 3.3
Copy link
Member

Choose a reason for hiding this comment

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

version looks wrong (otherwise, it would already be gone in 4.0).

And for that one, being able to warn when using the parameter looks useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

version is the right one, it was deprecated in 3.3, but we did not add the deprecation notice and didn't find time/energy/way to make it before 4.0. I can change to 4.2, no big deal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to 4.2.

@fabpot fabpot force-pushed the root_dir-removal branch 4 times, most recently from d8188bc to 78416ad Compare October 10, 2018 17:29
@fabpot fabpot changed the title Remove internal usage of kernel.root_dir when possible [HttpKernel] Deprecate usage of getRootDir() and kernel.root_dir Oct 10, 2018
@fabpot
Copy link
Member Author

fabpot commented Oct 10, 2018

Ok, now with the deprecation of the getRootDir() method.

@@ -360,15 +369,15 @@ public function getStartTime()
*/
public function getCacheDir()
{
return $this->rootDir.'/cache/'.$this->environment;
return $this->getProjectDir().'/var/cache/'.$this->environment;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the default value in the Symfony Flex recipe.

}

/**
* {@inheritdoc}
*/
public function getLogDir()
{
return $this->rootDir.'/logs';
return $this->getProjectDir().'/var/log';
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the default value in the Symfony Flex recipe.

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

fixes #24293

@fabpot fabpot force-pushed the root_dir-removal branch 2 times, most recently from 11c7519 to efffda4 Compare October 11, 2018 11:46
@nicolas-grekas nicolas-grekas added this to the next milestone Oct 14, 2018
Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

UPGRADE files need to be updated

given the parameters are not deprecated in code (trigger error) i suggest a mention to manually search your code base

for UPGRADE-5.0 these should be listed as BC break (preferably put on top)

@ro0NL
Copy link
Contributor

ro0NL commented Oct 16, 2018

@fabpot can you clarify why deprecating Kernel::getRootDir() but not KernelInterface::getRootDir(), this looks odd.

Do you aim to rename KernelInterface::getRootDir() to getProjectDir() on the interface?

edit: wait.. in 5.0 KernelInterface::getRootDir() will return the project dir at implementation level i guess :) cool 👍

@fabpot
Copy link
Member Author

fabpot commented Oct 16, 2018

@ro0NL It's more pragmatic than that :) As we are using getRootDir() in our own code (translation commands), having @deprecatedmeans that there is no way to be deprecation-free... unless I'm missing something of course.

@chalasr
Copy link
Member

chalasr commented Oct 16, 2018

IIRC the debug component mutes deprecations from the same vendor so implementing getRootDir() should keep the core deprecation free. @nicolas-grekas am I wrong?

@ro0NL
Copy link
Contributor

ro0NL commented Oct 16, 2018

i was assuming the same yes :)

in 5.0 KernelInterface::getRootDir() will return the project dir at implementation level

should we actually consider this? Does it make sense? We could benefit from it, as we cant add getProjectDir() to the interface. But this means another big step in 5.0 (basically favoring Kernel::getRootDir() again instead of getProjectDir() 😂) Not sure it's worth it actually =/

But then we need to decide what's the purpose of KernelInterface::getRootDir() in 5.0

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Oct 16, 2018

IIRC the debug component mutes deprecations from the same vendor

I don't think so - that would prevent detecting when we use our own internal deprecated code actually.

5.0 KernelInterface::getRootDir() will return the project dir

no way, as you spotted :) in fact, getProjectDir() is used externally only once in the core, in AboutCommand. This means there is no need to have it on the interface to me.

we are using getRootDir() in our own code (translation commands),

how will this be implemented in 5.0?
do we want to deprecate using these folders?

@fabpot
Copy link
Member Author

fabpot commented Oct 16, 2018

The getRootDir usages are for legacy directories that are not relevant in Symfony 4, that we need/can remove in 5.0.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Oct 16, 2018

This means we need to trigger a deprecation whenever these dirs contain anything that we load currently, right?
Anyone willing to give it a try?

@fabpot
Copy link
Member Author

fabpot commented Oct 16, 2018

It was not possible in 3.4, but we can definitely do it in 4.2.

@yceruto
Copy link
Member

yceruto commented Oct 16, 2018

We talking about these directories %kernel.root_dir%/Resources/views and %kernel.root_dir%/Resources/translations right? I can take TwigBundle by now, maybe translations commands too.

@chalasr
Copy link
Member

chalasr commented Oct 16, 2018

@yceruto I already started the work for translation commands locally :)

fabpot added a commit that referenced this pull request Oct 16, 2018
…() (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[HttpKernel] fix deprecating KernelInterface::getRootDir()

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Follow up of #28810.
Did I get it right?

Commits
-------

819f525 [HttpKernel] fix deprecating KernelInterface::getRootDir()
fabpot added a commit that referenced this pull request Oct 21, 2018
…directories (yceruto)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[TwigBundle] Deprecating support for legacy templates directories

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#10500

go ahead with #28810 (comment)

- [x] Fix tests

Commits
-------

8b390f3 Deprecating support for legacy templates directories
fabpot added a commit that referenced this pull request Oct 27, 2018
…lations directory (yceruto)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[FrameworkBundle] Deprecating support for legacy translations directory

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #28810 (comment)
| License       | MIT
| Doc PR        | TODO

Commits
-------

acdece7 Deprecating support for legacy translations directory
Tobion added a commit that referenced this pull request Oct 31, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

[HttpKernel] Fix BC break in Kernel name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Fix a BC break introduced by  #28810 where the name of the kernel where change form the name of the folder containing the kernel class to the name of the folder containing the project.

This introduced a bug with deployment processes where the cache warmup is done before moving the application to a folder with a different name and removing the possibility to compile the container (either by moving to a read-only filesystem or by removing the config directory).

Commits
-------

872a772 Fix BC break in Kernel name
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
@fabpot fabpot deleted the root_dir-removal branch January 14, 2019 11:01
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Apr 5, 2019
…sys)

This PR was submitted for the master branch but it was merged into the 4.2 branch instead (closes #11299).

Discussion
----------

[Flex] Tell that `var/logs/` directory was renamed

Ref: symfony/symfony#28810 (comment)

Commits
-------

2fcd9bc [Flex] Tell that `var/logs/` directory was renamed
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Nov 30, 2019
…adzki)

This PR was submitted for the 5.0 branch but it was squashed and merged into the 4.3 branch instead (closes #12719).

Discussion
----------

[minor] remove usage of Kernel::$rootDir from docs

As per symfony/symfony#28810 $rootDir has been removed in 5.0 - use getProjectDir in docs instead - small change to be consistent

Commits
-------

9da96e1 [minor] remove usage of Kernel::$rootDir from docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants