Skip to content

Conversation

@roykho
Copy link
Contributor

@roykho roykho commented Dec 4, 2020

All Submissions:

Changes proposed in this Pull Request:

Ref: p7bje6-2HA-p2

Closes #27424

How to test the changes in this Pull Request:

UPDATE:
This PR no longer requires anything from WC Admin.

  1. Trigger a WooCommerce Database Update Required notice. One way to do this is set your database version to an older version than what is installed. For example got to wp_options table search for woocommerce_db_version and set it to 4.4.0.
  2. Ensure you're able to click on the Update WooCommerce database button without errors and you're able to see the process started to run.
  3. After it is done, you should see another banner/notice WooCommerce database update done. When you see this open another browser or incognito mode and login as the same admin user so you have two concurrent sessions going.
  4. For the second user navigate to WooCommerce->Home. Ensure you also see the same banner/notice WooCommerce database update done.
  5. Go back to your first user session and now click on the Thanks! dismissal button.
  6. Ensure the banner goes away after clicking. If it doesn't work the first time, try one more time after refresh and it should now go away. You shouldn't have to reload the page more than twice for it to go away.
  7. Navigate to other WooCommerce pages and ensure that banner/notice does not reappear anywhere in either sessions.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Fix - Admin notices sometimes were persisting even after dismissing.

@roykho roykho requested review from a team and Konamiman and removed request for a team December 4, 2020 22:06
@Konamiman
Copy link
Contributor

I tried the test steps but when I click the "Update WooCommerce database" button I get a "The link you followed has expired" error... am I doing something wrong?

@roykho
Copy link
Contributor Author

roykho commented Dec 9, 2020

@Konamiman - are you triggering a new notice? As in this is not a notice that was already in the database unactioned before this PR?

@Konamiman
Copy link
Contributor

@roykho Yes, I'm following the testing steps from the PR description: manually modify the db version in the options table, then load the admin page in the site and click "Update database", that's all.

@roykho
Copy link
Contributor Author

roykho commented Dec 10, 2020

@Konamiman - I know you're following the steps however since I can't see, I have to make sure on a few keys steps. Have you have WC Admin activated as separate plugin and checked out this PR woocommerce/woocommerce-admin#5827 ?

@Konamiman
Copy link
Contributor

Sorry, totally my fault, I hadn't seen that prerrequisite line 🤦🏻‍♂️

I've now been able to trigger the db update, however after it finishes and I click "Thanks" I get the "expired link" error again. Same if I retry, and the third time the banner has disappeared (including the banner in the other session).

@roykho
Copy link
Contributor Author

roykho commented Dec 10, 2020

Hmmm I've not seen the "expired link" error in my testing. Only that sometimes the banner doesn't disappear right away on first click and that is normal. But it should definitely disappear after second click after a page refresh.

@roykho
Copy link
Contributor Author

roykho commented Dec 10, 2020

Hey @jonathansadowski - sorry to wrangle you in here but I need a second tester to see if y'all are both having the issues testing this PR as described by @Konamiman Thanks!

@jonathansadowski
Copy link
Contributor

@roykho I'm having the same issue as @Konamiman

When I try and dismiss this notice:

image

I see this error:

image

Clicking on "please try again" displays the notice again.

Clicking on the notice dismissal shows "please try again" again.

Clicking on it the last time does dismiss the notice.

@roykho
Copy link
Contributor Author

roykho commented Dec 11, 2020

@jonathansadowski - Thanks for testing. Would you happen to know the URL link to the dismissal button? I want to see if it is formatted correctly.

@jonathansadowski
Copy link
Contributor

Thanks for testing. Would you happen to know the URL link to the dismissal button? I want to see if it is formatted correctly.

@roykho, sorry for the delay in responding.

After I load the dashboard in the incognito window, the link in the main window is to: /wp-admin/admin.php?page=wc-admin&do_update_woocommerce=true&wc-hide-notice=update&_wc_notice_nonce=A

The error message's try again link is: /wp-admin/admin.php?page=wc-admin&do_update_woocommerce=true&wc_db_update_nonce=B (with a different nonce than before)

When I see the dialog again after the try again link fails, that button's nonce is again /wp-admin/admin.php?page=wc-admin&do_update_woocommerce=true&wc-hide-notice=update&_wc_notice_nonce=A (with the same nonce as the dialog before, but different than the try again link)

The error message that the link has expired again links to: /wp-admin/admin.php?page=wc-admin&do_update_woocommerce=true&wc_db_update_nonce=B (same nonce as the previous try-again link)

Finally, the link in the incognito window (which I didn't click) is: /wp-admin/admin.php?page=wc-admin&wc-hide-notice=update&_wc_notice_nonce=C (with a different nonce than any of the previous)

@roykho
Copy link
Contributor Author

roykho commented Jan 5, 2021

Ok I think I found the culprit. The query arg do_update_woocommerce sometimes persists in the query when you stay on the same page and just clicked refresh to get the "Thanks for updating" notice to show. In my testing, I clicked away from that page hence that query arg isn't there and hence I couldn't reproduce the issue y'all are seeing. So I pushed up a change to remove this query arg when showing the "Thanks for updating" notice.

Could y'all please give this another go? @Konamiman @jonathansadowski

@jonathansadowski
Copy link
Contributor

I ran into an interesting issue while testing this. I'm a bit puzzled as to how it could be related to this PR, but let me describe how I've been able to reproduce it:

  1. Started with a brand-new WordPress site with this branch checked out, built, and activated. I skipped the on-boarding wizard.
  2. Built and activated the branch from Add a nonce check function when preparing note response woocommerce-admin#5827.
  3. Went to WooCommerce dashboard (where I left the task list was entirely uncompleted).
  4. Open the network inspector and have it monitoring requests.
  5. Updated the woocommerce_db_version option to 4.4.0 as described in the original test plan. I used wp option update woocommerce_db_version 4.4.0.
  6. Reloaded the page, and clicked on Update WooCommerce database.
  7. Reload the page after the update starts. Afterward, I noticed hundreds of requests in the network inspector — they appear to be trying to update the task list. None of them had a response.
    image

Switching from this branch to master (and reloading the Dashboard), back to this branch seemed to resolve the issue for me.

I repeated the above steps, again starting on a brand new site, except on the master branch of WC / main branch of WCA, and wasn't able to reproduce the same issue.

Not sure of this is some symptom of how I'm testing this, or some weird obscure thing, so I figure I'd drop it here with the steps I used to recreate it. @Konamiman, could you see if you're able to reproduce the issue I ran into?

@Konamiman
Copy link
Contributor

Hi @roykho, after your update it seems to work as expected for me (I had to reload a couple of times for the notice to disappear but that's expected according to your description). I'll now check what @jonathansadowski has found.

@Konamiman
Copy link
Contributor

Hi @jonathansadowski, I haven't been able to reproduce the hundreds of network requests issue locally.

Konamiman
Konamiman previously approved these changes Jan 11, 2021
Copy link
Contributor

@Konamiman Konamiman left a comment

Choose a reason for hiding this comment

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

I'm approving since the main issue addressed by the PR seems to be fixed. If what @jonathansadowski found rutns out to be a real issue I think it could be addressed in a separate PR.

@roykho
Copy link
Contributor Author

roykho commented Jan 11, 2021

Hi @Konamiman - thanks for testing and approving. Could you please also approve this one here that is linked woocommerce/woocommerce-admin#5827

@jonathansadowski
Copy link
Contributor

I'm a little concerned because of the nature of the issue I ran into, but if it doesn't worry you, and nobody else can reproduce it, I'm happy to create a new issue if I still run into it after this is merged.

@roykho
Copy link
Contributor Author

roykho commented Jan 20, 2021

Hi @jonathansadowski @Konamiman - sorry to rope y'all in on this again. So after speaking with Isotope, we found a suitable hook to use from WC Admin to achieve the same results. This means we don't need to make any changes over on WC Admin side. So basically I just ported the code I've added from there to here. It works the same way as before. Could y'all please review again?

Copy link
Contributor

@jonathansadowski jonathansadowski left a comment

Choose a reason for hiding this comment

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

This is working for me... plus, the issue that I was experiencing before with the repeating requests isn't happening with this update. Nice work. 👍

Copy link
Contributor

@xknown xknown left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the feedback. The changes look fine, although I didn't really test the whole workflow.

Copy link
Contributor

@claudiosanches claudiosanches left a comment

Choose a reason for hiding this comment

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

Works great!

@claudiosanches claudiosanches added this to the 5.1.0 milestone Jan 22, 2021
@claudiosanches claudiosanches merged commit a07eea8 into master Jan 22, 2021
@claudiosanches claudiosanches deleted the fix/issue-27424 branch January 22, 2021 14:16
@woocommercebot woocommercebot added release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Jan 22, 2021
@zhongruige zhongruige added testing instructions added and removed release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: add changelog Mark all PRs that have not had their changelog entries added. [auto]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notifications won't go away after clicking their button

8 participants