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

Merge Optimization Detective into trunk #1079

Merged
merged 427 commits into from Mar 22, 2024

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Mar 22, 2024

Since Optimization Detective has been approved by the Plugin Review team, it is ready to be committed to WordPress.org. Therefore, it should be merged into trunk and the feature branch should be retired.

Blocked by:

westonruter and others added 30 commits December 14, 2023 10:31
Rely on server-side breadcrumbs for detection and optimization
…ge-loading-optimization

* origin/trunk: (149 commits)
  Manually fix remaining phpcs issues
  Run php-format
  Discontinue excluding all WordPress-Extra from tests so phpcbf can format
  Add @joemcgill to images and measurement focuses.
  Update codeowners, removing inactive contributors.
  Introduce perflab-plugin-management.js
  Load migration script in settings page
  Update function name
  Apply suggestions from code review
  Address slow query feedbacks
  Revise migration pointer un-dismissal to work for all admins
  Rename variable.
  improve code
  Require Node v20
  un-dismiss the migration pointer
  Minor update to return doc.
  Move inline script in to JS
  Fix PHP Documentation Standards
  Remove duplicate admin notice call
  Address review feedback
  ...
… merge/trunk-into-image-loading-optimization

* 'trunk' of https://github.com/WordPress/performance:
  Remove scheduler from globals since not yet used
  Fix or ignore eslint rules
  Remove modules/images/webp-uploads/fallback.js from ignorePatterns
  Run format-js on JS files
  Cherry pick fixes to JS linting from feature/image-loading-optimization
  Prevent sending header during test
…-optimization

Merge trunk into feature/image-loading-optimization
…om/WordPress/performance into add/ilo-tests

* 'feature/image-loading-optimization' of https://github.com/WordPress/performance: (155 commits)
  Remove scheduler from globals since not yet used
  Fix or ignore eslint rules
  Remove modules/images/webp-uploads/fallback.js from ignorePatterns
  Run format-js on JS files
  Cherry pick fixes to JS linting from feature/image-loading-optimization
  Prevent sending header during test
  Manually fix remaining phpcs issues
  Run php-format
  Discontinue excluding all WordPress-Extra from tests so phpcbf can format
  Add @joemcgill to images and measurement focuses.
  Update codeowners, removing inactive contributors.
  Introduce perflab-plugin-management.js
  Load migration script in settings page
  Update function name
  Apply suggestions from code review
  Address slow query feedbacks
  Revise migration pointer un-dismissal to work for all admins
  Rename variable.
  improve code
  Require Node v20
  ...
… add/ilo-tests

* 'trunk' of https://github.com/WordPress/performance:
  Re-run composer update with PHP 8.1
  Run composer update
  Fix PHPStan errors in tests
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
thelovekesh and others added 18 commits March 22, 2024 10:13
Update Optimization Detective plugin build process

Co-authored-by: thelovekesh <thelovekesh@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
…-readme

Update readme and phpdoc for initial Optimization Detective release

Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
@westonruter westonruter marked this pull request as ready for review March 22, 2024 21:43
Copy link

github-actions bot commented Mar 22, 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: westonruter <westonruter@git.wordpress.org>
Co-authored-by: thelovekesh <thelovekesh@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>

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

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@westonruter Almost looks good, a few points of feedback. Please take a look, though we could also consider addressing some of them afterwards.

@@ -32,6 +33,7 @@ build-cs/composer.lock

node_modules/
vendor/
plugins/optimization-detective/detection/web-vitals*
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be a good idea to use build directories within the individual standalone plugins for things like this. If we want to exclude built resources, it shouldn't be necessary to add exclusions for every individual one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. Let's do that in another PR to trunk.

Comment on lines -46 to +57
/*
* This settings section technically includes a field, however it is directly rendered as part of the section
* callback due to requiring custom markup.
*/
add_settings_section(
'output-buffering',
__( 'Output Buffering', 'performance-lab' ),
'perflab_render_server_timing_page_output_buffering_section',
PERFLAB_SERVER_TIMING_SCREEN
);
if ( ! has_filter( 'template_include', 'od_buffer_output' ) ) {
/*
* This settings section technically includes a field, however it is directly rendered as part of the section
* callback due to requiring custom markup.
*/
add_settings_section(
'output-buffering',
__( 'Output Buffering', 'performance-lab' ),
'perflab_render_server_timing_page_output_buffering_section',
PERFLAB_SERVER_TIMING_SCREEN
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this change really needed? Is it harmful to have both output buffers active?

I'm asking since I don't like the idea of excluding PL specific logic because of another standalone plugin. There are lots of WordPress plugins that have output buffers, so it's a bit random we would cater for the one from Optimization Detective here just because it's also our plugin. What would be the problem of having the Server-Timing output buffering active in combination with the one from Optimization Detective?

Copy link
Member Author

Choose a reason for hiding this comment

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

The thinking was that if Optimization Detective introduces an official way to do output buffering (for Core-43258), that this can be reused.

Copy link
Member Author

Choose a reason for hiding this comment

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

And that if a PL standalone plugin is already doing output buffering, it's kinda unnecessary to do yet more output buffering on top.

Copy link
Member Author

Choose a reason for hiding this comment

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

In other words, it's the Performance Lab plugin taking advantage of the capabilities of one of its own feature plugins.

Copy link
Member

Choose a reason for hiding this comment

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

If there was a standard way to do this, that would be great indeed. However, I'm not sure there's good value in connecting the plugins in this way. It comes with its own set of questions, such as:

  • Which of the two plugins should be the "source of truth" for output buffering when both are active?
  • If PL uses OD's output buffering capabilities, how do we deal with the somewhat confusing implications of that for the Server-Timing screen? It's strange to just hide the control without any explanation.

I'm not sure it's worth discussing those questions given the two plugins could just work independently. And again, it's somewhat arbitrary anyway. If any other plugin can have its own output buffering, I don't think it's important that these two plugins don't both add their own.

For those reasons I'd prefer to either remove this integration to simplify things, or alternatively to polish it. Could be done in a follow up PR though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since it doesn't impact the Optimization Detective plugin's codebase, let's do in another PR.

@@ -93,7 +95,7 @@ static function () {
);
?>
</p>
<?php if ( ! perflab_server_timing_use_output_buffer() ) : ?>
<?php if ( ! perflab_server_timing_use_output_buffer() && ! has_filter( 'template_include', 'od_buffer_output' ) ) : ?>
Copy link
Member

Choose a reason for hiding this comment

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

See above.

Comment on lines +228 to +242
// Skip doing anything with output buffering if it is already enabled via Optimization Detective.
if ( has_filter( 'template_include', 'od_buffer_output' ) ) {
// It feels better if this could rather be replaced with add_action( 'shutdown', [ $this, 'send_header' ] )
// However, this does not work because the buffer is sent before the shutdown callback is executed.
add_filter(
'od_template_output_buffer',
function ( $buffer ) {
$this->send_header();
return $buffer;
},
PHP_INT_MAX
);
return $passthrough;
}

Copy link
Member

Choose a reason for hiding this comment

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

See above.

phpcs.xml.dist Show resolved Hide resolved
@@ -23,6 +23,7 @@ nbproject/

build
.wp-env.override.json
*.asset.php
Copy link
Member

Choose a reason for hiding this comment

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

See my other comment below, if we used a build directory, we wouldn't need to explicitly exclude this from here and a few other places.

<file>.</file>
<exclude-pattern>./build/*</exclude-pattern>
<exclude-pattern>./node_modules/*</exclude-pattern>
<exclude-pattern>./plugins/*</exclude-pattern>
<exclude-pattern>./vendor/*</exclude-pattern>
<exclude-pattern>*.asset.php</exclude-pattern>
Copy link
Member

Choose a reason for hiding this comment

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

See above.

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 adamsilverstein self-requested a review March 22, 2024 22:35
Copy link
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

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

Looks good, maybe we can address additional feedback in separate PR?

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Good to merge, though let's address the two points from my previous review separately.

@westonruter westonruter merged commit 747956b into trunk Mar 22, 2024
37 checks passed
@westonruter
Copy link
Member Author

let's address the two points from my previous review separately.

See #1082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Plugin] Optimization Detective Issues for the Optimization Detective plugin skip changelog PRs that should not be mentioned in changelogs [Type] Feature A new feature within an existing module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants