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:
|
* etag?: non-empty-string, |
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.
Feature Description
For #1466 we introduced the
etagproperty 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 makeetaga required property of the URL Metric.For example, this method can now return
non-empty-stringinstead ofnon-empty-string|null:performance/plugins/optimization-detective/class-od-url-metric.php
Lines 432 to 442 in d44b4c1
Similarly here:
performance/plugins/optimization-detective/class-od-url-metric.php
Line 42 in d44b4c1
And here:
performance/plugins/optimization-detective/class-od-url-metric.php
Lines 214 to 222 in d44b4c1
And this condition can be removed:
performance/plugins/optimization-detective/class-od-url-metric-group.php
Lines 289 to 292 in d44b4c1
There's probably a few other impacted bits of code.