Possible unneccesary mysql write from Mage_Persistent module #2173
Replies: 7 comments
-
The observer gets executed
My opinion: the persistent session (aka "persistent cart") has a defined lifetime (aka expiration time). note, the persistent session is only saved on logout. to ensure a most recent "updated_at" value of the session, it may be saved regardless of changes. This ensures, that the lifetime countdown start from logout - and not at a "last changed" time. I would move
into the IF-block, where
is called. |
Beta Was this translation helpful? Give feedback.
-
this is the problem I currently see: it is not only happening on logout, its happening on every request as soon as you are logged in. The current logic says: |
Beta Was this translation helpful? Give feedback.
-
Hah, you're right. the linebreak confused me. ;) The comment above the IF gives us a hint. // Quote Id could be changed only by logged in customer Reads like some dev liked to avoid the save for guests, but saving on logout. |
Beta Was this translation helpful? Give feedback.
-
its probably more that the logout is the possible last action a "logged in" customer does, but the check would at this point in time already say "logged out" |
Beta Was this translation helpful? Give feedback.
-
IMHO it should read:
Maybe I miss something. I assume the save is not needed on every request, but this throws another question: how to handle cookie-expiration (e.g. close browser or visitor inactivity) properly? This is what the persistence modules should take care of - and it will stop working, because only on logout the persistent session gets saved?
Needs some xdebug session to verify. |
Beta Was this translation helpful? Give feedback.
-
@infabo maybe check/debug which values the calls have during logout, may help to understand the if. And yes, not saving it on every request, makes expiration a bit harder. I had hoped to at least find a few people who are actively using this feature and can better estimate what is needed. |
Beta Was this translation helpful? Give feedback.
-
The only way to have the last updated timestamp of a quote is to update it at every request. Then you can make it expire in X hours, or, better, have a followup email for abandoned cart etc. |
Beta Was this translation helpful? Give feedback.
-
The event 'controller_front_send_response_after' is triggered on every page, and it seems always executing this observer https://github.com/OpenMage/magento-lts/blob/1.9.3.x/app/code/core/Mage/Persistent/Model/Observer/Session.php#L129 for logged in users.
Iam not sure about this area, actually Iam not sure what the persistent module is actually doing. But it seems it is looking for a change in the quote ID here, and I believe this change is not happening on the Category or Product page, which are both affected from this observer.
Also it saves it, even if it has not changed.
Is there anyone with more knowledge in this area who can give advice if this is something which can be improved?
Beta Was this translation helpful? Give feedback.
All reactions