Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] remove dead conditions in Translation Commands #42362

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 0 commits into from

Conversation

acran
Copy link
Contributor

@acran acran commented Aug 3, 2021

Q A
Branch? 5.3
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

This is just a trivial removal of unused code I stumbled upon while debugging #42361. In the original code:

$transPaths = [$path.'/translations'];
$codePaths = [$path.'/templates'];

if (!is_dir($transPaths[0]) && !isset($transPaths[1])) {
		throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
}

The second part of the condition isset($transPaths[1]) will always evaluate to true, since $targetPath is just set 3 lines above but only has a single element.

This check was originally to support legacy paths which was removed in b6eb1f4:

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

I agree with this change. I updated the pull request description so it is using the template. (Fabbot is happy now).

Im not sure if we should target an earlier branch or not.

@acran
Copy link
Contributor Author

acran commented Aug 4, 2021

@Nyholm 5.3 is the oldest still supported branch containing this code; 4.4 still has the legacy paths supported

@Nyholm
Copy link
Member

Nyholm commented Aug 4, 2021

Cool. Thank you for checking for me.

@fabpot
Copy link
Member

fabpot commented Aug 4, 2021

As this is not a bug fix, I will merge this PR in 5.4.

@fabpot
Copy link
Member

fabpot commented Aug 4, 2021

Something went very wrong here. @acran Can you push your code again? Sorry for that.

@acran
Copy link
Contributor Author

acran commented Aug 4, 2021

@fabpot do you mean in a new PR on top of 5.4? Or into this PR again?

I pushed it into my fork again. But ... did you somehow manage to force-push into my fork of the repo without access? o0

@fabpot
Copy link
Member

fabpot commented Aug 5, 2021

@acran I think you will need to create a new PR on 5.4.

fabpot added a commit that referenced this pull request Aug 6, 2021
…Commands (acran)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle] remove dead conditions in Translation Commands

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This is just a trivial removal of unused code I stumbled upon while debugging #42361. In the [original code](https://github.com/symfony/symfony/blob/e617a9b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php#L165-L170):

~~~php
$transPaths = [$path.'/translations'];
$codePaths = [$path.'/templates'];

if (!is_dir($transPaths[0]) && !isset($transPaths[1])) {
		throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
}
~~~

The second part of the condition `isset($transPaths[1])` will **always** evaluate to true, since `$targetPath` is just set 3 lines above but only has a single element.

This check was originally to support legacy paths which was removed in b6eb1f4:
* in [`TranslationDebugCommand.php`](b6eb1f4#diff-67afa5b8860d0df4e44f1e1fc89f444b7ac77de515b698a6824dd5403a0acdbcL187-L194)
* in [`TranslationUpdateCommand.php `](b6eb1f4#diff-a01c7858e84f1868a427634740511da7c8c73e56772baa78bdcd98200d7125c0L180-L187)

Rebased from 5.3 to 5.4, see #42362
/cc `@fabpot`

Commits
-------

22db5ad [FrameworkBundle] remove dead conditions in Translation Commands
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.

4 participants