Skip to content

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

@westonruter

Description

@westonruter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done 😃

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions