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

Subscriptions: inform a clear error for pending confirmations #14326

Merged
merged 5 commits into from
Jan 27, 2020

Conversation

htdat
Copy link
Member

@htdat htdat commented Jan 11, 2020

Fixes #276

Heads-up: To test this PR, it requires to have a sandbox.

Changes proposed in this Pull Request:

As explained in this comment #276 (comment), what I am trying to do in this PR:

1, Apply patch D37557-code to introduce a new status=confirming. With this change, Jetpack is able to handle 2 different cases:

  • confirming: an email tries to subscribe a site for the first time.
  • pending: this email tries to subcribe the site again while the confirmation link (sent during the first try) has not been clicked.

2, Jetpack plugin code sends respective messages for two statuses in the front-end. A notice here is that I am changing the handling of pending status. You can see my comment above, it was not correctly handled.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

Fix a bug in a current feature.

Testing instructions:

Before trying two test cases below, make sure you've done two actions:

  1. Apply D37557-code in your sandbox.
  2. Configure JETPACK__SANDBOX_DOMAIN in your wp-config.php

Case 01 - Compatibility for the previous JP versions

  1. DO NOT apply this Jetpack PR in your testing site.
  2. Use a test email to subscribe your testing site
  3. See a successful message Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm Follow' to start subscribing.
  4. Try to use this email and subscribe again.
  5. Continue to see the successful message above.

Case 02 - Fix the bug in new releases

  1. APPLY this Jetpack PR in your testing site.
  2. In jetpack.php, change constant JETPACK__VERSION to 8.2. https://github.com/Automattic/jetpack/blob/master/jetpack.php#L18
  3. Go to JPDB of your site > Full Sync section > choose options, constants, functions, updates > Run Schedule Sync. Make sure the full-sync is finished.
  4. Refresh JPDB, the version of JP should be 8.2 now.
  5. Use a test email to subscribe your testing site.
  6. See a successful message Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm Follow' to start subscribing.
  7. Try to use this email and subscribe again.
  8. See an error message You subscribed this site before but you have not clicked the confirmation link yet. Please check your mailbox. Otherwise, you can manage your preferences at subscribe.wordpress.com.

Extra steps to restore your site version:

  • In jetpack.php, revert the previous value of JETPACK__VERSION.
  • Follow steps 3 and 4 but verify that your site version is back to the previous value.

Proposed changelog entry for your changes:

  • Subscriptions: inform a clear error for pending confirmations

@htdat htdat added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Status] In Progress Touches WP.com Files labels Jan 11, 2020
@htdat htdat requested a review from a team January 11, 2020 14:01
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello htdat! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D37554-code before merging this PR. Thank you!

@htdat
Copy link
Member Author

htdat commented Jan 11, 2020

Update: I have a patch on WP.com already but still need to create a PR (Diff) there, and update its description.

Update: Added WP.com patch already. Ready to get a review now!

@jetpackbot
Copy link

jetpackbot commented Jan 11, 2020

Warnings
⚠️

pre-commit hook was skipped for one or more commits

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

Generated by 🚫 dangerJS against 152aeb0

@htdat htdat self-assigned this Jan 12, 2020
@htdat htdat added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] In Progress labels Jan 12, 2020
modules/subscriptions.php Outdated Show resolved Hide resolved
@jeherve jeherve added this to the 8.2 milestone Jan 13, 2020
@htdat htdat force-pushed the fix/sub-pending-error branch from 24ed1c9 to c790bd4 Compare January 16, 2020 14:15
@matticbot
Copy link
Contributor

htdat, Your synced wpcom patch D37554-code has been updated.

@htdat
Copy link
Member Author

htdat commented Jan 16, 2020

Current PHPCS issue:

FILE: modules/subscriptions.php
-----------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 0 WARNINGS AFFECTING 6 LINES
-----------------------------------------------------------------------------------------------
 591 | ERROR | Line indented incorrectly; expected 4 tabs, found 3
 591 | ERROR | There must be no space before the colon in a CASE statement
 594 | ERROR | Line indented incorrectly; expected 4 tabs, found 3
 594 | ERROR | There must be no space before the colon in a CASE statement
 595 | ERROR | Line indented incorrectly; expected at least 5 tabs, found 4
 596 | ERROR | Terminating statement must be indented to the same level as the CASE body

They're all around here

switch ( $response[0]['status'] ) {
case 'error' :
$r[] = new Jetpack_Error( 'not_subscribed' );
continue 2;
case 'disabled' :
$r[] = new Jetpack_Error( 'disabled' );
continue 2;
case 'active' :
$r[] = new Jetpack_Error( 'active' );
continue 2;
case 'confirming' :
$r[] = true;
continue 2;
case 'pending' :
$r[] = new Jetpack_Error( 'pending' );
continue 2;
default :
$r[] = new Jetpack_Error( 'unknown_status', (string) $response[0]['status'] );
continue 2;
}

I do not fix this PHPCS error so reviewers can easily to see the logic. After this is tested OK, I willl fix this PHPCS error.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This looks good to me, I only have one minor remark.

I am not a native speaker though, so I am not sure I am the best person to approve the new phrase. "Otherwise.." seems to make the phrase a bit long to me, and I would phrase it a bit differently, but I'll let a native weigh in on that.

modules/subscriptions/views.php Outdated Show resolved Hide resolved
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jan 17, 2020
@jeherve
Copy link
Member

jeherve commented Jan 17, 2020

I do not fix this PHPCS error so reviewers can easily to see the logic. After this is tested OK, I willl fix this PHPCS error.

Don't hesitate to address those now, and then add single comments to your own PR if you think it can make it easier for folks to review. Folks can also view the changes commit per commit if they need to break things down.

Co-Authored-By: Jeremy Herve <jeremy@jeremy.hu>
@matticbot
Copy link
Contributor

htdat, Your synced wpcom patch D37554-code has been updated.

@htdat htdat added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 20, 2020
@htdat
Copy link
Member Author

htdat commented Jan 20, 2020

Don't hesitate to address those now,

Gotcha! My last commit fixed the PHPCS errors.

and then add single comments to your own PR if you think it can make it easier for folks to review. Folks can also view the changes commit per commit if they need to break things down.

Make sense! I will do this next time.

jeherve
jeherve previously approved these changes Jan 22, 2020
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This works well for me now. I'll let @kraftbj take a look as well, for functionality and for the wording. 👍

@htdat htdat requested a review from kraftbj January 23, 2020 07:55
@matticbot
Copy link
Contributor

htdat, Your synced wpcom patch D37554-code has been updated.

Copy link
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

I tweaked the language (we use inbox elsewhere), but otherwise, let's do it.

@kraftbj kraftbj added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jan 24, 2020
@jeherve jeherve merged commit 67ca6cf into master Jan 27, 2020
@jeherve jeherve deleted the fix/sub-pending-error branch January 27, 2020 09:57
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jan 27, 2020
@jeherve jeherve added the [Status] Needs Testing We need to add this change to the testing call for this month's release label Jan 27, 2020
@jeherve
Copy link
Member

jeherve commented Jan 27, 2020

r202136-wpcom and r202137-wpcom

@jeherve jeherve added [Status] Has Changelog and removed [Status] Needs Changelog [Status] Needs Testing We need to add this change to the testing call for this month's release labels Jan 27, 2020
jeherve added a commit that referenced this pull request Jan 27, 2020
jeherve added a commit that referenced this pull request Jan 28, 2020
* [not verified] Remove empty readme section

* Initial changelog for 8.2

* Changelog: add #14220

* Changelog: add #14252

* Changelog: add #14291

* Changelog: add #14309

* Changelog: add #14304

* Changelog: add general connection log.

* Changelog: add #14275

* Changelog: add #14313

* Changelog: add #14213

* Changelog: add #14357

* Add sync testing instructions

* Add 8.1.1 changelog back

See eeaafab and 61757eb

* Changelog: add #14371

* Changelog: add #14386

* Changelog: add #14471

* Changelog: add #14325

* Changelog: add #14194

* Changelog: add #14340

* Changelog: add #14418

* Changelog: add #14417

* Changelog: add #14075

* Changelog: add #14467

* Changelog: add #14307

* Changelog: add #14326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blog subscriptions should inform of pending confirmations
5 participants