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

Fix BC after drop twig/extensions #6145

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

wbloszyk
Copy link
Member

@wbloszyk wbloszyk commented Jun 16, 2020

Subject

This issue resolve problem with missing TextExtension after drop CoreBundle and upgrate sonata-project/twig-extensions to 1.x when sonata_admin.options.legacy_twig_text_extension is set to true. It is resolve by copy truncate function to new DeprecatedTextExtension class.

I am targeting this branch, because this change repsect BC.

Changelog

### Deprecated
- Deprecated `sonata_admin.options.legacy_twig_text_extension` configuration

@wbloszyk wbloszyk force-pushed the fix_text_extension branch from 0fb5608 to 79d3cbd Compare June 16, 2020 15:05
@wbloszyk
Copy link
Member Author

@VincentLanglet Can you check this is working for you? Also better add next parameter like here or @iternal class based on AbstractExtension to provide StringExtension::twigTruncateFilter() ?

@VincentLanglet VincentLanglet requested a review from a team June 16, 2020 18:26
@VincentLanglet
Copy link
Member

@VincentLanglet Can you check this is working for you?

I forgot... Where did we talk about this issue ?
I need to find the context to reproduce the issue and try the fix.

Changelog here is not needed. This PR fix issue which can not be install in stable version.

Changelog is always needed when you fix something.

@wbloszyk
Copy link
Member Author

wbloszyk commented Jun 16, 2020

Even if it not possible to install in stable? It is little strange, something like say: hey i fix unexisting bug.

You can find here:
#6140

@VincentLanglet
Copy link
Member

VincentLanglet commented Jun 16, 2020

Even if it not possible to install in stable? It is little strange, something like say: hey i fix unexisting bug.

In this PR, you

  • Fix something, it maybe can't actually occur, but could in the futur. Or it could have impact that we didn't see. It always better to log them.
  • Add deprecation. This has an impact on the user and should be log to.

The more verbose are commit, Pr, Changelog, Upgrade note, the more this project will be easy to maintain.

Even if it not possible to install in stable

Then how do you want that I test this ?
Merging into master and running tests ?

@wbloszyk wbloszyk force-pushed the fix_text_extension branch 2 times, most recently from bcd10b2 to 3c57f96 Compare June 17, 2020 08:41
@wbloszyk wbloszyk changed the title Fix missing TextExtension from twig-extension 1.x Fix BC after drop twig/extensions Jun 17, 2020
@wbloszyk wbloszyk force-pushed the fix_text_extension branch from 3c57f96 to 5587412 Compare June 17, 2020 08:59
@wbloszyk
Copy link
Member Author

wbloszyk commented Jun 17, 2020

@core23 @VincentLanglet @jordisala1991 RTM. Can you check it?

@wbloszyk wbloszyk force-pushed the fix_text_extension branch from 5587412 to bc82182 Compare June 18, 2020 09:23
src/DependencyInjection/SonataAdminExtension.php Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@wbloszyk
Copy link
Member Author

@VincentLanglet @jordisala1991 @core23 @greg0ire
I need:

  • merge this PR,
  • then merge 3.x branch to master,
  • drop some deprecations from master,

After that i can rebase #5461
After merge encore webpack and decide what we do with x-editable i will finish #5989

@VincentLanglet VincentLanglet requested a review from a team June 19, 2020 09:51
@@ -29,18 +29,28 @@
* @internal
*
* @see https://github.com/symfony/symfony/pull/35649
* @deprecated since sonata-project/admin-bundle 3.69, to be removed in 4.0.
Copy link
Member

Choose a reason for hiding this comment

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

You should usually use sonata-project/admin-bundle 3.x because you can't be sure that he release will not be created before this merge.

Copy link
Member Author

@wbloszyk wbloszyk Jun 19, 2020

Choose a reason for hiding this comment

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

@wbloszyk wbloszyk force-pushed the fix_text_extension branch from edca82a to eef1af1 Compare June 19, 2020 10:01
@wbloszyk wbloszyk requested a review from VincentLanglet June 19, 2020 10:01
This commit replace using TextExtension from `twig/extensions` by
copy truncate function to `DeprecatedTextExtension` method.

Update src/DependencyInjection/Configuration.php

Co-authored-by: Vincent Langlet <[email protected]>
@wbloszyk wbloszyk force-pushed the fix_text_extension branch from eef1af1 to a94e623 Compare June 19, 2020 10:10
@jordisala1991 jordisala1991 requested a review from a team June 19, 2020 10:49
@wbloszyk
Copy link
Member Author

@VincentLanglet Can we merge it? Ask becouse #6140 (comment)

@VincentLanglet
Copy link
Member

@VincentLanglet Can we merge it? Ask becouse #6140 (comment)

I see no reason for not merging this. :)

@VincentLanglet VincentLanglet merged commit be445e1 into sonata-project:3.x Jun 19, 2020
@@ -176,6 +170,7 @@ public function getConfigTreeBuilder()
// NEXT_MAJOR : remove this option
->booleanNode('legacy_twig_text_extension')
->info('Use text filters from "twig/extensions" instead of those provided by "twig/string-extra".')
->setDeprecated('The child node "%node%" at path "%path%" is deprecated since sonata-project/admin-bundle 3.x and will be remove in 4.0.')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
->setDeprecated('The child node "%node%" at path "%path%" is deprecated since sonata-project/admin-bundle 3.x and will be remove in 4.0.')
->setDeprecated('The child node "%node%" at path "%path%" is deprecated since sonata-project/admin-bundle 3.x and will be removed in version 4.0.')

Copy link
Member Author

Choose a reason for hiding this comment

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

I think version is unnecessary here.

Comment on lines +186 to +187
'Using `true` as value for "sonata_admin.options.legacy_twig_text_extension" option is deprecated since sonata-project/admin-bundle 3.64 and will be remove in 4.0'.
'You should set it to `false` before upgrade process.'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'Using `true` as value for "sonata_admin.options.legacy_twig_text_extension" option is deprecated since sonata-project/admin-bundle 3.64 and will be remove in 4.0'.
'You should set it to `false` before upgrade process.'
'Using `true` as value for "sonata_admin.options.legacy_twig_text_extension" option is deprecated since sonata-project/admin-bundle 3.64 and will be removed in version 4.0.'.
' Remove it or set its value to `false`.'

Copy link
Member Author

Choose a reason for hiding this comment

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

At first it should be set to flase, then can be delete in upgrade process becouse by default is it true. Remove it is bad idea

*/
final class DeprecatedTextExtension extends AbstractExtension
{
public function twigTruncateFilter(Environment $env, ?string $value, int $length = 30, bool $preserve = false, $separator = '...')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function twigTruncateFilter(Environment $env, ?string $value, int $length = 30, bool $preserve = false, $separator = '...')
public function twigTruncateFilter(Environment $env, ?string $value, int $length = 30, bool $preserve = false, $separator = '...'): string

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree

@phansys
Copy link
Member

phansys commented Jun 19, 2020

@wbloszyk, I've left some suggestions just after the PR was merged. Please, take a look.

@wbloszyk
Copy link
Member Author

wbloszyk commented Jun 19, 2020

@phansys Thanks for suggestions. I think this should be change in some bigger pedantic PR.

@wbloszyk wbloszyk deleted the fix_text_extension branch June 19, 2020 15:11
@greg0ire greg0ire added minor and removed patch labels Jun 19, 2020
@greg0ire
Copy link
Contributor

There is a deprecation, this is minor.

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

Successfully merging this pull request may close these issues.

6 participants