Commit Graph

73 Commits

Author SHA1 Message Date
Christopher Allford 6ad091a9b7 Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
Peter Fabian 309c48ab0e Deprecated old cache function and replaced it with a new one. 2019-11-28 14:03:57 +01:00
Gerhard 6870d756d1 Merge branch 'avoid-unnecessary-session-saving' of git://github.com/AmazeCom/woocommerce into AmazeCom-avoid-unnecessary-session-saving 2019-09-30 13:54:58 +02:00
Gerhard Potgieter 043fd478bc
Merge pull request #23687 from rekkitatu/master
Delete guest cart session if user logs in, solves #23686
2019-07-15 09:54:39 +02:00
Tatu ed7f98a584
Coding standards fix 2019-07-12 23:18:29 +03:00
Tatu d9254cedb2
Prevent conflict with multiple logged in users
Previous code would delete the session of previously logged in user in the rare case that multiple users would be logged in on the same browser. Added check to see if there is user account exists with the old_session_key and if not then the old session is from a guest user which can be deleted from database during logging in. Also returned old_session_key as optional parameter to prevent issues.
2019-07-12 22:53:01 +03:00
Tatu c52e7bd75a
Dropped redundant persistent cart check code
Changing the not equal check between current_user_id and old_session_key to loose type allowed leaving out persistent cart related check.
2019-07-11 23:40:56 +03:00
Kris Shannon 3945694e37 Force string comparison for customer_id
In 203dba5 a check against the current user id was introduced.

This check is always failing because of a type mismatch causing an unnecessary insert/update query against the database.
2019-06-27 18:40:39 +10:00
Jonathan Moore d8470aa45a
implementing review from @claudiosanches 2019-06-18 21:20:39 +01:00
Jonathan Moore 9e8debd7ba
Avoid attempting to cache expired sessions
get_session() attempts to cache a session even if it is already expired.
The code used passes negative expiry seconds to wp_cache_add if the session expired in the past:
wp_cache_add( $this->get_cache_prefix() . $customer_id, $value, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() );

Depending on the caching layers used this will give errors in the logs such as:
ERR invalid expire time in setex in /var/www/html/wp-content/plugins/redis-cache/includes/predis/src/Client.php:370
as reported on: https://wordpress.org/support/topic/error-when-trying-to-get-a-get-a-cache-not-available/
2019-06-03 22:11:46 +01:00
Tatu 968a0561bb
Add additional check for cart persistence 2019-05-14 12:47:06 +03:00
Tatu 44c6d0b36c
Compatibility for persistent cart disabled case
If woocommerce_persistent_cart_enabled filter was set to false the cart would be emptied while logged in. This fixes also that case. Now the guest session is removed from the woocommerce_sessions table after successful login whether the persistent cart is set enabled or disabled and the guest session cart is carried over to logged in user session.
2019-05-14 11:24:21 +03:00
Tatu 71e94e9c08
Add mention of $old_session_key parameter 2019-05-13 15:20:39 +03:00
Tatu bfad881f32
Removes the $old_session_key default value
Fix for the issue #23686
2019-05-13 14:27:28 +03:00
Tatu 4266cc9eaa
Update class-wc-session-handler.php 2019-05-13 12:27:01 +03:00
Tatu 4a725f3f3e
Delete guest session after user logs in
Logging in to the user account makes a copy of the guest session and possible cart content. This causes conflicts in situations where there are only single quantities of products left and real time product availability checks are in place. While this kind of single quantity items are at time in two carts for the same visitor the checking of product availability fails. Deleting the same visitors guest cart solves this issue.
2019-05-13 02:14:52 +03:00
Mike Jolley ccc5805632 Use secure and http cookies 2019-03-15 11:34:10 +00:00
Mike Jolley 203dba5a1f After logging in, migrate session data 2019-03-12 16:36:15 +00:00
Mike Jolley cab45fafb3
Merge pull request #22650 from woocommerce/update/20995
Registration success notices
2019-02-08 13:04:36 +00:00
Mike Jolley c88a92144b Only update session cookie if the value changes 2019-02-05 13:02:20 +00:00
Mike Jolley eed91070b1 Allow notice to persist after customer ID change 2019-02-04 15:48:59 +00:00
John Blackbourn 71def7b5f0 Revert "Add support for clearing a session and associated cart contents when switching between accounts using the User Switching plugin. See #21989."
This reverts commit b0b36ae4b8.
2018-11-21 18:50:59 +01:00
John Blackbourn b0b36ae4b8 Add support for clearing a session and associated cart contents when switching between accounts using the User Switching plugin. See #21989. 2018-11-20 18:58:42 +01:00
John Blackbourn 179aa0853d Add a public method for forgetting a session without clearing it. 2018-11-20 18:58:14 +01:00
Rodrigo Primo 734a9370be Change query to save session data
Use `INSERT ... ON DUPLICATE KEY UPDATE` instead of `REPLACE` in the query that saves session data. Doing this to prevent deadlocks in this table. For more information see https://github.com/woocommerce/woocommerce/issues/20912#issuecomment-420888726
2018-09-26 14:46:28 -03:00
Rodrigo Primo 3f82ecee8c Remove unnecessary uses of @codingStandardsIgnoreLine 2018-07-31 16:10:51 -03:00
Claudio Sanches 8a31755b8c Fixed includes/class-wc-session-handler.php PHPCS violations 2018-03-21 00:18:01 -03:00
Mike Jolley 42b1ab50c0 Ensure customer id is not empty in cookie 2018-01-23 13:36:53 +00:00
Mike Jolley 4eaf1afb88 Cleanup session callback. 2017-12-15 15:14:05 +00:00
Mike Jolley 15089fc432 Added init method and phpcs changes. 2017-12-15 15:13:24 +00:00
Boro Sitnikovski 6c29d886ca Use protected instead of private methods to allow easy override 2017-12-04 15:10:35 +01:00
Mike Jolley d3666738d8 Merge branch 'pr/15069' 2017-05-23 18:56:58 +01:00
Rasmus Bengtsson 185934fad9 Fix phpdoc to include params and correct types 2017-05-15 13:50:52 +02:00
Ninos Ego 89113cf6b2 Added filter for cookie name 2017-05-10 21:46:43 +02:00
Mike Jolley bbf8e750ce Tidy up includes 2017-02-16 11:46:01 +00:00
Aristeides Stathopoulos 0516e96843 PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket 2016-09-02 04:33:57 +03:00
Aristeides Stathopoulos f2730eea02 WordPress.WhiteSpace.ControlStructureSpacing.BlankLineAfterEnd 2016-08-27 08:57:05 +03:00
Aristeides Stathopoulos ec8a0b288b PHPCS: WordPress.Arrays.ArrayDeclaration.NoCommaAfterLast 2016-08-27 05:08:49 +03:00
Aristeides Stathopoulos b063bcfe4c last item in a multiline-array should end in a comma 2016-08-27 04:46:45 +03:00
Mike Jolley 66c61eebc8 Define full path for includes
Closes #11087
2016-07-27 11:58:43 +01:00
Mike Jolley 874d2e3e0a Check cookie is a string 2016-03-16 10:04:53 +00:00
Mike Jolley 32acec8477 Load session handler and abstract together 2016-03-10 09:31:25 +00:00
Gerhard Potgieter 62e19162e6 Use $wpdb->replace instead of doing a select and then deciding to do an update or insert. Fixes #10389 2016-02-23 14:48:48 +02:00
Mike Jolley 6c8709f4b5 Return false if cookie_hash is not set. 2016-01-18 10:34:06 +00:00
Mike Jolley 2714ec0aeb Keep cookie/session alive after order.
@claudiosmweb this ok with you?

Closes #10045
2016-01-11 10:28:38 +00:00
Mike Jolley b474dcb879 Use WC_Cache_Helper for session class prefixes 2015-11-13 23:12:44 +00:00
Mike Jolley cb0e61bd4e Set prefix_num first time 2015-11-05 15:21:06 +00:00
Claudio Sanches ee30b5b308 Fixed php docs standards 2015-11-03 11:31:20 -02:00
Mike Jolley 12fe4e7a52 Use delimiter in hashing function 2015-10-23 12:02:29 +01:00
Mike Jolley b81fc128ac Use hash_equals when comparing hashes
PHP 5.6+ but WP has a fallback inside.
2015-10-23 12:00:56 +01:00