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

Use plugin slug for generator tag #1103

Merged
merged 4 commits into from
Apr 1, 2024
Merged

Conversation

felixarntz
Copy link
Member

Summary

Based on the discussion in #1102 (comment): Since plugin names can change over time, the original approach of using the plugin names for generator tags is not great. Therefore this PR proposes using the plugin slug, which is immutable. In the long run, this will be more maintainable as it won't result in tooling or queries requiring an update.

Relevant technical choices

  • Use the plugin slug instead of plugin name for all existing generator tags, including Performance Lab.
  • Update existing tests, and add a missing test for the Speculation Rules plugin's generator tag.
  • Add readme entries for the standalone plugins (for PL this will be auto-generated, while for the other standalone plugins we'll start with that after the next "set of releases").
  • Bump Optimization Detective to 0.1.1 to include this change.

@felixarntz felixarntz added [Type] Enhancement A suggestion for improvement of an existing feature Infrastructure Issues for the overall performance plugin infrastructure labels Mar 29, 2024
@felixarntz felixarntz added this to the performance-lab 3.0.0 milestone Mar 29, 2024
@felixarntz felixarntz changed the title Use plugin slugs in generator tags Use plugin slug for generator tag Mar 29, 2024
Copy link

github-actions bot commented Mar 29, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: joemcgill <joemcgill@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@adamsilverstein
Copy link
Member

+1 to making this change, makes sense for the long run. One issue worth noting that will arise from this change will be that any queries against a feature will need to take both old and new slugs into account to work properly.

@@ -54,6 +54,7 @@ function plsr_print_speculation_rules() {
* @since 1.1.0
*/
function plsr_render_generator_meta_tag() {
echo '<meta name="generator" content="Speculative Loading ' . esc_attr( SPECULATION_RULES_VERSION ) . '">' . "\n";
// Use the plugin slug as it is immutable.
echo '<meta name="generator" content="speculation-rules ' . esc_attr( SPECULATION_RULES_VERSION ) . '">' . "\n";
Copy link
Member

Choose a reason for hiding this comment

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

probably want to bump the plugin version as well, otherwise users won't get this update.

Copy link
Member Author

Choose a reason for hiding this comment

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

@adamsilverstein That version is already bumped (and not published), so this PR doesn't need to bump it again. :)

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

Should we take this opportunity to add generator tags to the auto-sizes plugin as well? We should also make sure that all plugins have tests in place to cover this behavior.

@felixarntz
Copy link
Member Author

@adamsilverstein

One issue worth noting that will arise from this change will be that any queries against a feature will need to take both old and new slugs into account to work properly.

Slugs never change, so that's the main reason for why this change is proposed. Only now this one time we would have to update tooling, to switch from the plugin names to plugin slugs.

@joemcgill

Should we take this opportunity to add generator tags to the auto-sizes plugin as well?

I was going to do that in a separate PR.

We should also make sure that all plugins have tests in place to cover this behavior.

+1, let me check that every plugin is covered by such a test.

@felixarntz
Copy link
Member Author

@joemcgill Tests for all generator tags and that they include the slugs are now present.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

Thanks @felixarntz. One follow-up question, but this is looking good.

@@ -19,6 +19,11 @@ public function tear_down() {
parent::tear_down();
}

public function test_hooks() {
Copy link
Member

Choose a reason for hiding this comment

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

Good idea. I don't think we are validating that hooks are always present for each of the plugins. Should this type of test be added everywhere, since I don't believe we can run tests against the output of wp_head to confirm that these are actually being printed without introducing side effects?

Copy link
Member Author

Choose a reason for hiding this comment

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

@joemcgill I generally like to have this kind of test as it helps prevent accidents with hooks added or removed, but I wouldn't want to mandate it. IMO it's a good practice, but I still think this is something we can leave up to the typical freedom of choice of the respective plugin developers / PR authors and PR reviewers.

I only added this here since the hook check previously was baked into the generator test method, which IMO it shouldn't be since it's a different kind of test.

@felixarntz felixarntz merged commit eb0b0f4 into trunk Apr 1, 2024
27 of 28 checks passed
@felixarntz felixarntz deleted the update/slugs-in-generator-tags branch April 1, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants