Skip to content

566 remove llmstxt when plugin is disabled#22269

Merged
leonidasmi merged 6 commits intofeature/llms-txtfrom
566-remove-llmstxt-when-plugin-is-disabled
May 19, 2025
Merged

566 remove llmstxt when plugin is disabled#22269
leonidasmi merged 6 commits intofeature/llms-txtfrom
566-remove-llmstxt-when-plugin-is-disabled

Conversation

@thijsoo
Copy link
Copy Markdown
Contributor

@thijsoo thijsoo commented May 15, 2025

Context

  • We want to clean up after ourselves when the plugin is disabled.

Summary

This PR can be summarized in the following changelog entry:

  • Adds a deactiviation hook to remove our generated llms.txt file

Relevant technical choices:

  • The cleanup relies on the command handler to check if it should remove the file.
  • We always want to unschedule the cron job since its made when the plugin is activated again, and won't do anything with the plugin disabled.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Make sure we own the file by disabling the feature in the settings and removing the llms.txt.
  • Than enable the setting and make sure a llms.txt is generated.
  • Deactivate the plugin and make sure the file is removed. Also make sure the cron is gone with the WP Crontrol plugin.
  • Activate the plugin again and make sure the cron is back. Wait 5 minutes and refresh a page, to create the file again.
  • Open the llms.txt file in an editor and change something (this makes it that we are no longer in control of the file)
  • Deactivate the plugin and make sure the file is there but the cron is gone.
  • Acticate the plugin and make sure the cron is back. Wait 5 minutes and refresh a page, to try and create the file again but confirm that the file wasn't changed.
  • Repeat the tests but this time deactivate/activate via the WP CLI.

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 May 15, 2025
…s-when-were-not-supposed-to' of github.com:Yoast/wordpress-seo into 566-remove-llmstxt-when-plugin-is-disabled
Base automatically changed from 557-make-sure-that-we-dont-deleteoverwrite-llmstxt-files-when-were-not-supposed-to to feature/llms-txt May 16, 2025 07:07
Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi left a comment

Choose a reason for hiding this comment

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

CR: 🚧

Also, I think we should now remove the parts where we unschedule crons and delete files when the feature is disabled, both in the activation hook and in the upgrade routine, what do you think?

So, the

		else {
			$cron_scheduler->unschedule_llms_txt_population();
			$file_remove_handler->handle();
		}

parts.

I even checked the test instructions of #22253 and confirmed that this change doesn't impact them

Comment thread src/llms-txt/user-interface/cleanup-llms-txt-on-deactivation.php Outdated
Comment thread src/llms-txt/user-interface/cleanup-llms-txt-on-deactivation.php Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented May 19, 2025

Pull Request Test Coverage Report for Build 8963354b6751b33207f91a206448399f874eb968

Details

  • 0 of 10 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.002%) to 52.328%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/llms-txt/user-interface/schedule-population-on-activation-integration.php 0 2 0.0%
src/llms-txt/user-interface/cleanup-llms-txt-on-deactivation.php 0 8 0.0%
Totals Coverage Status
Change from base Build 4bf04bd8b5c43c38503136a7cc3f082edbb34311: -0.002%
Covered Lines: 29150
Relevant Lines: 56855

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@leonidasmi leonidasmi left a comment

Choose a reason for hiding this comment

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

CR + Acceptance test: ✅

@leonidasmi leonidasmi merged commit 90633c6 into feature/llms-txt May 19, 2025
28 checks passed
@leonidasmi leonidasmi deleted the 566-remove-llmstxt-when-plugin-is-disabled branch May 19, 2025 09:55
@leonidasmi leonidasmi mentioned this pull request May 21, 2025
18 tasks
@igorschoester igorschoester added this to the feature/llms-txt milestone May 21, 2025
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.

4 participants