-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conflict with DI extra bundle #4292
Comments
I had the same issue, and I fixed it with this lines in config.yml jms_di_extra:
annotation_patterns:
- "JMS\\DiExtraBundle\\Annotation" |
@maarekj Thanks made the trick! Hope we find a better solution that SonataAdminBundle doesn't break main App. |
Can one of you use |
Hey, the only change related to JMSDIExtra is this one: 216933f#diff-d81fe8cfe0444cbcab9e87a76c5e9970R219 EDIT: here is the problem: if (isset($bundles['JMSDiExtraBundle'])) {
$container->prependExtensionConfig(
'jms_di_extra',
array(
'annotation_patterns' => array(
'Sonata\AdminBundle\Annotation',
),
)
);
} I think we should test if the default annotation_patterns is set. If not we should add Default annotation_patterns in JMS: |
If it is already set, our values should be merged with existing values, right? That sounds like a bug to me… |
Nop it's not a bug but a misunderstanding of the default value. For example, with this jms_di_extra configuration: jms_di_extra:
locations:
all_bundles: false
bundles: [AppBundle, ApiBundle]
directories: ["%kernel.root_dir%/../src"] When I called prependExtensionConfig my annotation_patterns if empty so the config for annotation_patterns will be only 'annotation_patterns' => array(
'Sonata\AdminBundle\Annotation',
), And now, the annotation_patterns config is not empty (contains It's the correct behavior of DepInjection configuration. |
Oh ok I get it, but I'm not sure I agree with your fix… because that would mean that any bundle that wants to prepend any configuration would have to do the same. |
Very similar problems : #2425 sonata-project/SonataPageBundle#776 Maybe @core23 is right and there should be a native way to do this. |
Maybe |
No problem, I don't say that my fix is ideal ;) |
If there is no native way I think your fix might be the best course of action… can you check if |
Seems the |
Actually in that case, [the first bundle wins](https://symfony.com/doc/3.1/bundles/prepend_extension.html#more-than-one-bundle-using- |
@greg0ire are you sure about? Because while writing and testing sonata-project/SonataUserBundle#829 and sonata-project/SonataClassificationBundle#271 I've found that actually the configuration is merged (controller paths from both bundles get merged and dumped). I'm going to test it right now. |
Are you talking about merging with default values, or merging with existing configuration? |
After some research, I confirm what I said later, the |
So I asked on the symfony slack, and I was told this by @xabbuh :
Here are the related docs, can you try something like that in the DI bundle? |
The change to the |
I can't check right now (in phone) but I would do the following. Please correct me if I'm wrong. In If key actualy exists it means that those values come from config.yml and not from defaults. Just prepend the sonata pattern, it's the developer responsibility to add any other pattern (including the default ones). This is a temporary fix but it's necessary because how symfony and jms do merging/prepending is not going to chance in the near future. |
@gremo that's exactly what @Nightbr proposed I think. I was just wondering if that would be something that would make more sense to fix in the DI bundle, but I'm starting to think there is no way to do that properly, b/c you could not guess if the value comes from Sonata and needs to be merged, or if it comes from the developer, in which case they probably want to get it overwritten. However, for the other problems you had with other bundles, since it's internal, we could go ahead and use what @xabbuh said (@stof says it should actually take place in the |
Ok then, lets see what @Nightbr says. I could be wrong but checking for keys (just the presence/absence) should be enought to guess if values come from the developer. Unfortunatly (or not) I'm on holidays until next week and I can't check :) |
@greg0ire hey, I will make the PR sonata-side next week, I'm on holidays right now too. |
Happy holiday then! |
Is it a good idea to prepend It has caused extreme slowness in dev mode on my projects. Just tried upgrading, and my dev mode runtime went from 0.8 seconds to 2.6. |
We didn't do it yet… |
216933f#diff-d81fe8cfe0444cbcab9e87a76c5e9970 This commit landed in 3.11, and fixed the prepending. |
Oh you're right, sorry! Are you positive that line causes the drop in performance? What if you comment the block? |
I think we don't need a deprecation with this because it has never worked. It has been introduced in 3.11.* and directly conflict with JMSDiExtra. We should remove this part and documenting the thing as @andreadelfino said. I can modify my PR if you want. |
You mean that no one currently is not configuring these annotations, and expecting it to work? Apparently 216933f fucks some things up for some people, but not for people who are using it exclusively with Sonata, right? |
Yep kind of ^^ At 3.10 => works fine but you have to specify manually the AdminAnnotation in your config.yml I think we just need to document this properly and remove the part where SonataAdminBundle try to (force) add the AdminAnnotation. |
So since 3.11, it's fair to say new users could have been successfully using this for Sonata. Removing the auto-config would be a BC-break, and should be treated as such (by throwing a deprecation notice telling people they need to do it manually). Otherwise you get people like @andreasferber, that are not very happy and come here to tell "please don't do this", "please don't do that". |
ok why not create a patch 3.11.n with the deprecation notice and remove this code in 3.12. Fair enough 👌 |
Deprecation notices are minor, and removals are major… so… your PR : 3.11.n, the deprecation => 3.12, the removal => 4.0.0 |
I don't know if we really should merge my PR... It's not a best practice to modify other bundle config on runtime... Wait and see others though on this subject. |
But we're already doing it, right? Might as well do it a bit better… |
If we don't, people will be stuck with this bug until 4.0, because we don't do BC-breaks (well, we try not to). |
Or we can right now remove the auto-config JMSDi code and finally the code works (without workaround) and I think it's not a BC-breaks. And If you want to use AdminAnnotation, you have to add it into your config.yml (we just need to document this a bit). |
So it boils down to : is this a BC-break? My thoughts:
@sonata-project/contributors WDYT? Should this be considered a BC-break or not? |
It's definitely a BC break for users using 3.10 or earlier and updating to 3.11 while using DiExtraBundle or later right now... |
agree with @andreasferber and it was my case and the primary reason I opened the issue. It creates a BC-breaks when updates from 3.10 to 3.11 it breaks all Symfony app with JMSDiExtra setup... |
@andreasferber : yes, it is, don't rub it in. What's the lesson we get from reading your sarcasm? That people do not like BC-breaks. Right now you are proposing to create a second BC-break… What I'm proposing is having the right solution in 3.12, but also keep the "bad but better" solution from #4312 around, but deprecated. |
What you guys don't understand is that the BC-break from 3.10 to 3.11 is done. Now it's the new behavior, and it might work for some people. You're trying to fix your use case, but what about people using the other use case, which, by the way, is the documented one? What about people that did not do the upgrade from 3.10 to 3.11 , but will update from 3.10 or lower to 3.12? They will feel just like you two. Don't do unto others what you don't want others to do unto you. |
The solution from #4312 doesn't work, see my comment there. |
Wait and see what other contributors think about this and take a decision. |
Since it appears right now that someone has to "bite the dust", the question is, what is the larger user base, the ones that just started using Sonata admin with version 3.11 to 3.13 and might be using the Admin annotation, or the ones that use Sonata admin for years and want to update their project to the latest version. Also please think about the impact it has: "Some users have to add a line to their config.yml when updating admin-bundle" vs. "some users are stuck with version 3.10 until 4.0 is eventually released". |
What? |
They would have to wait until 3.12… so… a few days? |
"keep the solution from #4312 around" would mean right now, that SonataAdminExtension would keep adding its own annotation_pattern without any way to completely disable it. See my first post, the error I'm getting happens as soon as the Admin annotation gets enabled in any way, even if I use 3.10 and add the pattern manually to |
…uration Preserve the default for the annotation_patterns option of DiExtraBundle, otherwise annotations provided by DiExtraBundle itself break if the project has no custom configuration for annotation_patterns.
In addition to fixing the general issue with JMSDiExtraBundle, my PR also adds a new config option to disable the whole stuff, which provides a workaround to avoid the performance hit (until JMSDiExtraBundle gets fixed) and helps people with a problem like mine. |
Hi !
I have an issue with the last release of SonataAdminBundle (3.11.*).
Environment
Sonata packages
$ composer show sonata-project/* sonata-project/admin-bundle 3.10.3 The missing Symfony Admin Generator sonata-project/block-bundle 3.3.0 Symfony SonataBlockBundle sonata-project/cache 1.0.7 Cache library sonata-project/core-bundle 3.2.0 Symfony SonataCoreBundle sonata-project/datagrid-bundle dev-master 9c6f293 Symfony SonataDatagridBundle sonata-project/doctrine-extensions 1.0.2 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 3.0.0 Symfony Sonata / Integrate Doctrine... sonata-project/easy-extends-bundle 2.1.10 Symfony SonataEasyExtendsBundle sonata-project/exporter 1.7.0 Lightweight Exporter library sonata-project/intl-bundle dev-master d2eab1c Symfony SonataIntlBundle sonata-project/media-bundle dev-master master
Symfony packages
PHP version
PHP version 5.6.29-0+deb8u1
Subject
With the last release of SonataAdmin, I have some issues with DI Extra Bundle see this issue schmittjoh/JMSDiExtraBundle#266
All services are not found with basic service annotation:
Also, it could be a conflict with my JMS configuration:
I tried to use
"jms/di-extra-bundle": "^1.7"
but the problem still persists...My workaround so far: rollback to SonataAdminBundle 3.10.* 😕
Steps to reproduce
Expected results
All services in AppBundle which uses DI annotation must be found as service.
Actual results
Services declared with DI annotation are not found.
Any idea ?
Thanks for your amazing work and your help !
If you need anything ask for it ! ;)
The text was updated successfully, but these errors were encountered: