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

Limit cookie dedupe logic to only WooCommerce Cart cookies #43504

Merged
merged 4 commits into from Jan 11, 2024

Conversation

senadir
Copy link
Member

@senadir senadir commented Jan 11, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Builds from #42828 but only limit the logic to WooCommerce cookies.

Closes #43463

How to test the changes in this Pull Request:

Like #42828 use this updated snippet

add_action(
	'template_redirect',
	function() {
		if ( is_front_page() ) {
			return;
		}

		if ( is_page() ) {
			$products = wc_get_products(
				array(
					'posts_per_page' => 5,
					'status'         => 'publish',
					'type'           => 'simple',
				)
			);
			wc_empty_cart();
			foreach ( $products as $product ) {
				WC()->cart->add_to_cart( $product->get_id(), 1 );
			}
			header( 'Set-Cookie: my_cookie=value;path=/', false );
			header( 'Set-Cookie: my_cookie=value;path=/wp-admin', false );
			wp_redirect( get_site_url() );
			exit;
		}
	},
	20
);
  1. Open the network tab in the browser inspector and make sure you're recording and that "Preserve log" is checked.
  2. Visit any page that isn't the home page.
  3. You will see 2 requests, open the 302 one.
  4. See that Woo cookies aren't duplicated but other cookies are there fine.
image

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 11, 2024
@woocommercebot woocommercebot requested a review from a team January 11, 2024 12:35
@senadir senadir self-assigned this Jan 11, 2024
Copy link
Contributor

github-actions bot commented Jan 11, 2024

Hi @mikejolley, @woocommerce/rubik

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@senadir senadir added type: bug The issue is a confirmed bug. focus: inbox team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues labels Jan 11, 2024
Copy link
Contributor

github-actions bot commented Jan 11, 2024

Test Results Summary

Commit SHA: 0aec6a6

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 38s
E2E Tests147818106027933m 55s

⚠️ Warning

Please address the following issues prior to merging this pull request:
  • FAILED/BROKEN TESTS. There were failed and/or broken API and E2E tests.

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

Copy link
Member

@mikejolley mikejolley left a comment

Choose a reason for hiding this comment

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

Tested with and without the new code after the latest commit; seems to work as intended. The session cookie was only created once.

@senadir senadir merged commit 77d0a6a into trunk Jan 11, 2024
35 checks passed
@senadir senadir deleted the fix/only-dedub-cookies-with-same-path branch January 11, 2024 14:53
@github-actions github-actions bot added this to the 8.6.0 milestone Jan 11, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 11, 2024
github-actions bot pushed a commit that referenced this pull request Jan 11, 2024
* limit check to only Woo cookies

* limit logic to woo cookies only

* add changelog

* no need for set-cookie prefix
alopezari pushed a commit that referenced this pull request Jan 11, 2024
* Limit cookie dedupe logic to only WooCommerce Cart cookies (#43504)

* limit check to only Woo cookies

* limit logic to woo cookies only

* add changelog

* no need for set-cookie prefix

* Prep for cherry pick 43504

---------

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
@rodelgc rodelgc added status: analysis complete Indicates if a PR has been analysed by Solaris needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. needs: internal testing Indicates if the PR requires further testing conducted by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Jan 12, 2024
@alopezari alopezari modified the milestones: 8.6.0, 8.5.0 Jan 12, 2024
github-actions bot pushed a commit that referenced this pull request Jan 12, 2024
* limit check to only Woo cookies

* limit logic to woo cookies only

* add changelog

* no need for set-cookie prefix
alopezari pushed a commit that referenced this pull request Jan 12, 2024
* Limit cookie dedupe logic to only WooCommerce Cart cookies (#43504)

* limit check to only Woo cookies

* limit logic to woo cookies only

* add changelog

* no need for set-cookie prefix

* Prep for cherry pick 43504

---------

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: inbox needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wordpress auth cookies are removed by WooCommerce 8.5.0
4 participants