Skip to content

Add validation to the response from license API#22386

Merged
pls78 merged 2 commits intotrunkfrom
22346-license-check-should-verify-response
Jul 30, 2025
Merged

Add validation to the response from license API#22386
pls78 merged 2 commits intotrunkfrom
22346-license-check-should-verify-response

Conversation

@thijsoo
Copy link
Copy Markdown
Contributor

@thijsoo thijsoo commented Jun 27, 2025

Context

  • We want to make sure our license check shows a proper error if the response is not the expected result.

Summary

This PR can be summarized in the following changelog entry:

  • Improves response validation of the Yoast license check. Props to aryanjasala.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Install this RC/PR on a site with a valid license and premium enabled.
  • On a site with a valid license make sure the plans page still shows that you have a valid install. And make sure our morphology feature works.
  • Install this PR/RC on a site that does not have a valid license but still has premium enabled.
  • Make sure the morphology feature does not work and the plans page shows that your plan is not active.

For devs:

  • open class-my-yoast-api-request.php and on line 70 between $response = $this->do_request( $this->url, $this->args ); and $response = $this->decode_response( $response ); add $response = '{"statusCode":200,"subscriptions": "ERROR","url": "ERROR"}';
  • Make sure the license check fails gracefully by showing something is wrong in the alert center.
  • Reset your transients with wp transient delete --all in the WP cli.
  • Change the line to {"statusCode":404,"subscriptions": "ERROR","url": "ERROR"} and test again.
  • Reset your transients with wp transient delete --all in the WP cli.
  • Change the line to {"statusCode":404,"something":"random"} and test again.
  • Reset your transients with wp transient delete --all in the WP cli.
  • Change the line to RROR"} and test again.
  • Be critical of other options and try those as well.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #

@thijsoo thijsoo added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jun 27, 2025
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 6227dd3809bccdf8057b56a581f2e6a2a45c2e0c

Details

  • 7 of 8 (87.5%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.5%) to 53.407%

Changes Missing Coverage Covered Lines Changed/Added Lines %
inc/class-my-yoast-api-request.php 7 8 87.5%
Totals Coverage Status
Change from base Build 389a00f7adb7173a200dff217287813c8e4f3f52: -0.5%
Covered Lines: 29987
Relevant Lines: 57022

💛 - Coveralls

@thijsoo thijsoo linked an issue Jun 27, 2025 that may be closed by this pull request
11 tasks
Copy link
Copy Markdown
Member

@pls78 pls78 left a comment

Choose a reason for hiding this comment

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

CR && Acc: ✅

@pls78 pls78 merged commit b16dde7 into trunk Jul 30, 2025
28 checks passed
@pls78 pls78 deleted the 22346-license-check-should-verify-response branch July 30, 2025 11:54
@leonidasmi leonidasmi added this to the 25.8 milestone Aug 12, 2025
@enricobattocchi enricobattocchi added changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog changelog: other Needs to be included in the 'Other' category in the changelog and removed changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog labels Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: other Needs to be included in the 'Other' category in the changelog community-patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

License check should verify response

5 participants