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

Fixing double carts #454

Closed
wants to merge 5 commits into from
Closed

Conversation

mamazu
Copy link
Member

@mamazu mamazu commented Jun 22, 2019

In the last pull request #401 the cart provider was overridden however this fix is much more specific in that it replaces the cart context only in a specific point (the cart blamer) The cart blamer is used on login so it is also the point where the cart creation shouldn't occur. For a more indepth view on if this is the right part of where the override should happen, the Sylius Core team would need to give feedback. This however should prevent the Sylius frontend from crashing when using the ShopApi

@mamazu mamazu requested a review from a team as a code owner June 22, 2019 19:41
src/DependencyInjection/Compiler/CartContextPass.php Outdated Show resolved Hide resolved
src/DependencyInjection/Compiler/CartContextPass.php Outdated Show resolved Hide resolved
src/DependencyInjection/Compiler/CartContextPass.php Outdated Show resolved Hide resolved
src/DependencyInjection/Compiler/CartContextPass.php Outdated Show resolved Hide resolved
src/DependencyInjection/Compiler/CartContextPass.php Outdated Show resolved Hide resolved
@@ -71,8 +71,13 @@
</service>

<!-- Removing the create cart context from composite context (see: https://github.com/Sylius/Sylius/issues/10192) -->
<service id="sylius.context.cart.new" class="Sylius\Component\Order\Context\CartContext">
<argument type="service" id="sylius.factory.order" />
<service id="sylius.shop_api_plugin.context.cart" class="Sylius\Component\Order\Context\CompositeCartContext" />
Copy link
Member

Choose a reason for hiding this comment

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

It should work without these services. May you test it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we need it. The compiler pass doesn't create the service but only uses it.

Copy link
Member

Choose a reason for hiding this comment

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

But the service is created by another compiler pass, shouldn't it be available?

Copy link
Member Author

Choose a reason for hiding this comment

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

No compiler pass creates it. The compiler pass I wrote just uses this and adds the other context.

Copy link
Member

Choose a reason for hiding this comment

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

I meant \Sylius\Bundle\OrderBundle\DependencyInjection\Compiler\RegisterCartContextsPass

Copy link
Member Author

Choose a reason for hiding this comment

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

It could be that I could use this class to create the service as well. I just took the logic of the PrioritizedCompositeServicePass and applied it here. This requires the service to exist though.

@@ -71,8 +71,13 @@
</service>

<!-- Removing the create cart context from composite context (see: https://github.com/Sylius/Sylius/issues/10192) -->
<service id="sylius.context.cart.new" class="Sylius\Component\Order\Context\CartContext">
<argument type="service" id="sylius.factory.order" />
<service id="sylius.shop_api_plugin.context.cart" class="Sylius\Component\Order\Context\CompositeCartContext" />
Copy link
Member

Choose a reason for hiding this comment

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

But the service is created by another compiler pass, shouldn't it be available?

src/Resources/config/services.xml Outdated Show resolved Hide resolved
@lchrusciel
Copy link
Member

Fixed in #490, thanks to Max for your work anyway :)

@lchrusciel lchrusciel closed this Jul 25, 2019
@mamazu mamazu deleted the new_cart_provider_ branch July 31, 2019 18:13
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.

2 participants