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

URL Metric ETag should now be required since a transitional period has now elapsed #1819

Open
westonruter opened this issue Jan 23, 2025 · 0 comments
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@westonruter
Copy link
Member

Feature Description

For #1466 we introduced the etag property for the URL Metric (#1705, #1722). At the time, we made it optional so as to avoid invaliding all existing URL Metrics. See #1466 (comment). However, now that URL Metrics have been collected for a few months, we can safely now make etag a required property of the URL Metric.

For example, this method can now return non-empty-string instead of non-empty-string|null:

/**
* Gets ETag.
*
* @since 0.9.0
*
* @return non-empty-string|null ETag.
*/
public function get_etag(): ?string {
// Since the ETag is optional for now, return null for old URL Metrics that do not have one.
return $this->data['etag'] ?? null;
}

Similarly here:

And here:

'etag' => array(
'description' => __( 'The ETag for the URL Metric.', 'optimization-detective' ),
'type' => 'string',
'pattern' => '^[0-9a-f]{32}\z',
'minLength' => 32,
'maxLength' => 32,
'required' => false, // To be made required in a future release.
'readonly' => true, // Omit from REST API.
),

And this condition can be removed:

// The ETag is not populated yet, so this is stale. Eventually this will be required.
if ( $url_metric->get_etag() === null ) {
return false;
}

There's probably a few other impacted bits of code.

@westonruter westonruter added [Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature labels Jan 23, 2025
@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2024 Jan 23, 2025
@westonruter westonruter moved this from Not Started/Backlog 📆 to To Do 🔧 in WP Performance 2024 Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Optimization Detective Issues for the Optimization Detective plugin [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: To Do 🔧
Development

No branches or pull requests

1 participant