-
Notifications
You must be signed in to change notification settings - Fork 110
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
Fix storage of URL Metric when plain non-pretty permalinks are enabled #1574
Changes from 4 commits
bc478e4
b515f87
942b397
b833e1b
1cf24f1
5960ff3
ef9f3ae
5549091
adc0c2e
eaed94f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,6 +16,8 @@ | |||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @since 0.4.0 | ||||||||||||||||||||||||||||||||||||||||||
* @access private | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @property-read OD_URL_Metric_Group_Collection $url_metrics_group_collection | ||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||
final class OD_Tag_Visitor_Context { | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
@@ -28,12 +30,12 @@ final class OD_Tag_Visitor_Context { | |||||||||||||||||||||||||||||||||||||||||
public $processor; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||
* URL metrics group collection. | ||||||||||||||||||||||||||||||||||||||||||
* URL metric group collection. | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @var OD_URL_Metrics_Group_Collection | ||||||||||||||||||||||||||||||||||||||||||
* @var OD_URL_Metric_Group_Collection | ||||||||||||||||||||||||||||||||||||||||||
* @readonly | ||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||
public $url_metrics_group_collection; | ||||||||||||||||||||||||||||||||||||||||||
public $url_metric_group_collection; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||
* Link collection. | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -46,13 +48,47 @@ final class OD_Tag_Visitor_Context { | |||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||
* Constructor. | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @param OD_HTML_Tag_Processor $processor HTML tag processor. | ||||||||||||||||||||||||||||||||||||||||||
* @param OD_URL_Metrics_Group_Collection $url_metrics_group_collection URL metrics group collection. | ||||||||||||||||||||||||||||||||||||||||||
* @param OD_Link_Collection $link_collection Link collection. | ||||||||||||||||||||||||||||||||||||||||||
* @param OD_HTML_Tag_Processor $processor HTML tag processor. | ||||||||||||||||||||||||||||||||||||||||||
* @param OD_URL_Metric_Group_Collection $url_metric_group_collection URL metric group collection. | ||||||||||||||||||||||||||||||||||||||||||
* @param OD_Link_Collection $link_collection Link collection. | ||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||
public function __construct( OD_HTML_Tag_Processor $processor, OD_URL_Metric_Group_Collection $url_metric_group_collection, OD_Link_Collection $link_collection ) { | ||||||||||||||||||||||||||||||||||||||||||
$this->processor = $processor; | ||||||||||||||||||||||||||||||||||||||||||
$this->url_metric_group_collection = $url_metric_group_collection; | ||||||||||||||||||||||||||||||||||||||||||
$this->link_collection = $link_collection; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||
* Gets magic properties. | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @param string $name Property name. | ||||||||||||||||||||||||||||||||||||||||||
* @return OD_URL_Metric_Group_Collection URL metric group collection. | ||||||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||||||
* @throws Error When property is unknown. | ||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||
public function __construct( OD_HTML_Tag_Processor $processor, OD_URL_Metrics_Group_Collection $url_metrics_group_collection, OD_Link_Collection $link_collection ) { | ||||||||||||||||||||||||||||||||||||||||||
$this->processor = $processor; | ||||||||||||||||||||||||||||||||||||||||||
$this->url_metrics_group_collection = $url_metrics_group_collection; | ||||||||||||||||||||||||||||||||||||||||||
$this->link_collection = $link_collection; | ||||||||||||||||||||||||||||||||||||||||||
public function __get( string $name ): OD_URL_Metric_Group_Collection { | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed to account for someone updating Optimization Detective but not right away updating Image Prioritizer or Embed Optimizer. They are using the performance/plugins/image-prioritizer/class-image-prioritizer-img-tag-visitor.php Lines 69 to 88 in 5952d55
The All of this code could be removed later once there is no longer this risk. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 5960ff3 |
||||||||||||||||||||||||||||||||||||||||||
if ( 'url_metrics_group_collection' === $name ) { | ||||||||||||||||||||||||||||||||||||||||||
_doing_it_wrong( | ||||||||||||||||||||||||||||||||||||||||||
__CLASS__ . '::$url_metrics_group_collection', | ||||||||||||||||||||||||||||||||||||||||||
esc_html( | ||||||||||||||||||||||||||||||||||||||||||
sprintf( | ||||||||||||||||||||||||||||||||||||||||||
/* translators: %s is class member variable name */ | ||||||||||||||||||||||||||||||||||||||||||
__( 'Use %s instead.', 'optimization-detective' ), | ||||||||||||||||||||||||||||||||||||||||||
__CLASS__ . '::$url_metric_group_collection' | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||
'optimization-detective n.e.x.t' | ||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||
return $this->url_metric_group_collection; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
throw new Error( | ||||||||||||||||||||||||||||||||||||||||||
esc_html( | ||||||||||||||||||||||||||||||||||||||||||
sprintf( | ||||||||||||||||||||||||||||||||||||||||||
/* translators: %s is class member variable name */ | ||||||||||||||||||||||||||||||||||||||||||
__( 'Unknown property %s.', 'optimization-detective' ), | ||||||||||||||||||||||||||||||||||||||||||
__CLASS__ . '::$' . $name | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's worth adding this, given it's only for backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed for static analysis. In 5960ff3 I've added a note that it is deprecated.