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

Clear term metadata on Site Kit reset #10061

Open
1 task
nfmohit opened this issue Jan 18, 2025 · 7 comments
Open
1 task

Clear term metadata on Site Kit reset #10061

nfmohit opened this issue Jan 18, 2025 · 7 comments
Labels
Module: RRM Reader Revenue Manager module related issues P0 High priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@nfmohit
Copy link
Collaborator

nfmohit commented Jan 18, 2025

Feature Description

With Reader Revenue Manager Phase 2, Site Kit starts using WordPress term metadata to store term-level configuration. While the Site Kit reset mechanism clears non-persistent SK data in different WP database tables, it doesn't clear term metadata.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • When resetting Site Kit, any non-persistent term meta added by Site Kit should be cleared, similar to other WordPress options and post meta.

Implementation Brief

  • Update includes/Core/Util/Reset.php:
    • Create a new method delete_term_meta, modelled on the delete_post_meta function, querying and deleting rows from termmeta.
    • Update the all method to call the new delete_term_meta method for site and network mode conditions.

Test Coverage

  • Add tests in tests/phpunit/integration/Core/Util/ResetTest.php to confirm all data in the term meta are cleared as expected.

QA Brief

  1. Install and activate Smart Custom Fields plugin.

  2. Add a new custom field using plugin's settings page and with following details provided in screenshot. Notice that name field starts with googlesitekit_, this is important because only settings with this prefix will be removed on reset.

Image
  1. Create a category "Test". Add the custom field value in term and save. Ensure that custom field value is saved properly and is being reflected in term edit screen.

  2. Open your database admin tool and check thewp_termmetatable and find the key that has been created.

  3. Activate the Site Kit plugin with bare minimum modules.

  4. Go to Site Kit > Settings, reset Site Kit.

  5. After resetting Site Kit, confirm that all database records in wp_termmeta have been removed with the prefix googlesitekit_.

Changelog entry

  • Add mechanism to clear term meta on Site Kit reset.
@nfmohit nfmohit added P0 High priority Type: Enhancement Improvement of an existing feature Team M Issues for Squad 2 labels Jan 18, 2025
@nfmohit nfmohit self-assigned this Jan 18, 2025
@nfmohit nfmohit added the Module: RRM Reader Revenue Manager module related issues label Jan 18, 2025
@nfmohit nfmohit assigned nfmohit and unassigned nfmohit Jan 20, 2025
@ankitrox ankitrox assigned ankitrox and unassigned ankitrox Jan 24, 2025
@benbowler benbowler self-assigned this Jan 24, 2025
@benbowler
Copy link
Collaborator

Waiting on #9961 and #9962 before I can confidently define the best way to reset term and post level data.

@nfmohit
Copy link
Collaborator Author

nfmohit commented Jan 29, 2025

Hi @benbowler. Just FYI, this issue isn't specific/dependent on Reader Revenue Manager. I was anticipating the implementation would just include mechanism to clear term metadata within wp_termmeta in includes/Core/Util/Reset.php, similar to how it clears post metadata within wp_postmeta. What do you think?

@benbowler
Copy link
Collaborator

@nfmohit I see, that makes sense, IB updated.

@benbowler benbowler removed their assignment Jan 29, 2025
@nfmohit nfmohit self-assigned this Jan 29, 2025
@nfmohit
Copy link
Collaborator Author

nfmohit commented Jan 29, 2025

IB ✅

Thanks @benbowler!

@nfmohit nfmohit removed their assignment Jan 29, 2025
@ankitrox ankitrox self-assigned this Jan 30, 2025
@ankitrox ankitrox removed their assignment Jan 31, 2025
@nfmohit nfmohit assigned nfmohit and unassigned nfmohit Jan 31, 2025
@mohitwp mohitwp self-assigned this Feb 3, 2025
@mohitwp
Copy link
Collaborator

mohitwp commented Feb 3, 2025

QA Update ⚠

  • Tested on dev environment.
  • Tested when rrmModuleV2 feature flag is enabled.
  • Tested when rrmModuleV2 feature flag is not enabled.
  • I followed the steps mentioned under QAB but custom field value is not changing after resetting the Site Kit. It shows the same value after resetting.

Smart Custom field

Image

Custom field value before resetting the plugin

Image

Custom field value after resetting the plugin

Image

Recording.1766.mp4

@benbowler
Copy link
Collaborator

Hey @mohitwp, what makes this not very clear for testing is the "Default" field for the custom field you create in the Smart Custom Fields plugin. I suggest the following changes to the QA steps:

After step 2. open your database admin tool and check the wp_termmeta table and find the key that has been created.

Instead of step 6., after resetting Site Kit, confirm that all database records in wp_termmeta have been removed with the prefix googlesitekit_.

@mohitwp
Copy link
Collaborator

mohitwp commented Feb 3, 2025

QA Update ✅

  • Tested on dev environment.
  • Tested when rrmModuleV2 feature flag is enabled.
  • Tested when rrmModuleV2 feature flag is not enabled.
  • Verified that after resetting Site Kit, all database records in wp_termmeta have been removed with the prefix googlesitekit_.
    Note : cc @wpdarren I updated the QAB of this ticket as per Ben comment.
Recording.1767.mp4
Recording.1769.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: RRM Reader Revenue Manager module related issues P0 High priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants