Yoast / Yoast/wordpress-seo

Prepare for WPVIP: create wrapper for user meta data

Open
#7,697 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

featurerequest VIP-compliance
Dominant language
JavaScript
Stars
2k
Forks
975
Avg merge
3d 13h
Merged PRs (30d)
36

Description

On VIP we cannot call the default user_meta functions directly, but we must use the user_attribute variation, see https://vip.wordpress.com/documentation/user_meta-vs-user_attributes/

Thus we need to create a wrapper which will allow to call the user_attribute version when available, otherwise use the user_meta as default.

The scope of the usages is the following (at the time of creating this issue):

FILE: ...gins/wordpress-seo/admin/ajax/class-yoast-dismissable-notice.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 67 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...ent/plugins/wordpress-seo/admin/ajax/class-yoast-onpage-ajax.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 36 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...ns/wordpress-seo/admin/ajax/class-yoast-plugin-conflict-ajax.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 51 | ERROR | get_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta)
 81 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: /Users/jip/Yoast/wp-content/plugins/wordpress-seo/admin/ajax.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 83 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...oast/wp-content/plugins/wordpress-seo/admin/class-admin-init.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 125 | ERROR | get_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta)
----------------------------------------------------------------------


FILE: ...content/plugins/wordpress-seo/admin/class-admin-user-profile.php
----------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
----------------------------------------------------------------------
 59 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 69 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 70 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 71 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 72 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 73 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 74 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...jip/Yoast/wp-content/plugins/wordpress-seo/admin/class-admin.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 652 | ERROR | update_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...tent/plugins/wordpress-seo/admin/class-product-upsell-notice.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 176 | ERROR | get_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta)
 183 | ERROR | update_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...st/wp-content/plugins/wordpress-seo/admin/class-yoast-alerts.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 88 | ERROR | delete_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_delete_user_meta)
----------------------------------------------------------------------


FILE: .../plugins/wordpress-seo/admin/class-yoast-notification-center.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
  97 | ERROR | get_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta)
 479 | ERROR | update_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: .../admin/config-ui/components/class-component-mailchimp-signup.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 56 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
 75 | ERROR | get_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta)
----------------------------------------------------------------------


FILE: ...ress-seo/admin/config-ui/fields/class-field-mailchimp-signup.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 55 | ERROR | get_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta)
----------------------------------------------------------------------


FILE: ...ins/wordpress-seo/admin/google_search_console/class-gsc-ajax.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 43 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...Yoast/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 14 | ERROR | update_user_meta() usage is highly discouraged, check VIP
    |       | documentation on "Working with wp_users"
    |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...ins/wordpress-seo/inc/sitemaps/class-author-sitemap-provider.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 253 | ERROR | update_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------


FILE: ...tent/plugins/wordpress-seo/inc/sitemaps/class-sitemaps-cache.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 198 | ERROR | update_user_meta() usage is highly discouraged, check VIP
     |       | documentation on "Working with wp_users"
     |       | (WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta)
----------------------------------------------------------------------

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the listed admin, config-ui, Google Search Console, sitemap, and notification files, beginning with their direct get_user_meta(), update_user_meta(), and delete_user_meta() calls. Consult the linked VIP user_meta versus user_attributes documentation before deciding the wrapper's location and interface. Done means every listed usage goes through the wrapper, using user_attribute when available and user_meta otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, database
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.