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

Refactor meta fields #21576

Open
wants to merge 19 commits into
base: trunk
Choose a base branch
from
Open

Refactor meta fields #21576

wants to merge 19 commits into from

Conversation

vraja-pro
Copy link
Contributor

@vraja-pro vraja-pro commented Aug 29, 2024

Context

  • We want to remove outdated properties and code from the wpseo meta class.
  • The translation moved to client side and all fields are of type string, so the meta fields should be striped of the old properties.
  • Since the type of values was changed to string, the sanitisation should also change accordingly. Sanitization for values that are not string should be dropped for the metabox and elementor classes and also remove duplication of sanitisation.

Summary

This PR can be summarized in the following changelog entry:

  • Remove outdated properties from the wpseo meta class for meta fields.

Relevant technical choices:

  • The hidden fields will always be rendered as hidden fields at Meta_Fields_Presenter so the type is not relevant anymore.
  • There is no fields of type checkbox or multi-select, that is why I removed the checks in the save_postdata and the sanitise callback function sanitize_post_meta.
  • I removed sanitisation from the save_postdata since this sanitisation is done by the sanitize_post_meta method again.
  • Updated the tests since advanced robots settings will always be a string since we moved to hidden fields.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Edit a post and save the following:
    • Focus keyphrase
    • Canonical url: Check you can save only valid url (starts with http).
    • social appearance: Save image, title and description.
    • Advanced settings: save all values in the tab.
    • Schema tab: save all values in the tab.
    • Search appearance: Save title and description.
    • Analysis: change the analysis scores and save ( SEO analysis, readability and inclusive language score).
    • Change corner stone switch.

For exceptional case and safety checks:
Inspect the hidden fields and change the values manually according to input id:

  • For the analysis scores ( linkdex, content_score, inclusive_language_score) add values that are not numbers and see it doesn't save.
  • For social appearance, change the image fields to string that is not a valid image url (doesn't start with http or ftp ), check it saves empty string.
  • For cornerstone change the values to false or true, check it saves 0 and 1 accordingly. Change to some other string, check it saves 0.
  • For advanced settings and schema tab (meta-robots-noindex,meta-robots-nofollow, schema_page_type, schema_article_type) change to a value that is not one of the options and check it saves empty string.

Repeat check with elementor.

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 #

@vraja-pro vraja-pro added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Aug 29, 2024
@coveralls
Copy link

coveralls commented Aug 29, 2024

Pull Request Test Coverage Report for Build 75edcb2fecfa3fb2ac2d3c213e36fe94b549f8c8

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 22 of 29 (75.86%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on refactor-meta-fields at 51.681%

Changes Missing Coverage Covered Lines Changed/Added Lines %
inc/class-wpseo-meta.php 18 21 85.71%
src/integrations/third-party/elementor.php 0 4 0.0%
Totals Coverage Status
Change from base Build 5f2b5e8300331714120546bcf52ecbeefa41904a: 51.7%
Covered Lines: 16345
Relevant Lines: 31627

💛 - Coveralls

@vraja-pro vraja-pro linked an issue Aug 29, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Declutter the way we sanitize post metadata
2 participants