What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hey! I found this piece of code and i am wondering whats the reason for setting the permissions to n

UPPB2H525
UPPB2H525 Posts: 51 🧑🏻‍🚀 - Cadet

Hey!
I found this piece of code and i am wondering whats the reason for setting the permissions to null and then load a new customer transfer to get the permissions again.

https://github.com/spryker/shared-cart/blob/master/src/Spryker/Zed/SharedCart/Business/QuoteResponseExpander/CustomerPermissionQuoteResponseExpander.php#L59

I did some simple tests and the returned permissions are still equal:


Can anyone tell me why this was done? With many permissions it becomes quite slow.

Comments

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    As per our development, when there were permissions already in the transfer they got duplicated. Also when you remove permissons they remained in transfer.

  • UPPB2H525
    UPPB2H525 Posts: 51 🧑🏻‍🚀 - Cadet
    edited October 2019

    Hey, thanks for your answer, but i do not understand it.
    This code runs while adding an item to the (persistent) cart. Permissions should not change while adding items to the cart. So my questions are:
    1. why is it neccessary to expand the responseQuoteTransfer with permissions again?
    2. why is it neccessary to set the permissions to null, call the customer facade (and let run further expanders...) to get the same permissions again?

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice
    For each action with a cart, we update the list of carts available to the customer in the session, including the shared carts. There will be no access to the carts without updating the permissions.
    
  • UPPB2H525
    UPPB2H525 Posts: 51 🧑🏻‍🚀 - Cadet

    Ok thanks a lot!

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 🧑🏻‍🚀 - Cadet

    @UPPB2H525 In general, the idea is that Zed always loads the latest state from the database, it won’t thrust to what Yves “thinks” is actual. Exactly because “Permissions *should* not change” although they might - someone decided to change them, while the session of the current customer might also be quite old.

  • Andriy Netseplyayev
    Andriy Netseplyayev Domain Lead Solution Architecture Sprykee Posts: 519 🧑🏻‍🚀 - Cadet
    edited October 2019

    However, you can decide for your project that that’s rather an edge case (change of the permissions) and performance here is more important and override the logic, I would totally go for it if that brings a good improvement.

  • UPPB2H525
    UPPB2H525 Posts: 51 🧑🏻‍🚀 - Cadet

    Hey @UKJSE6T47! Thanks for this information, sounds good and will check side impacts in our project!