Skip to content

Conversation

@spacedmonkey
Copy link
Member

Trac ticket: https://core.trac.wordpress.org/ticket/58528

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@spacedmonkey spacedmonkey self-assigned this Jun 15, 2023
Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Just a couple driveby nits

@spacedmonkey
Copy link
Member Author

CC @aristath

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.

@spacedmonkey This looks great so far. Only a bit of feedback below.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Great work @spacedmonkey, Left some feedback.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

@spacedmonkey A few last feedback, but almost good to go.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

@spacedmonkey Left some feedback.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @spacedmonkey for the update. It look good to me.

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.

Thanks @spacedmonkey, LGTM in terms of production code!

If you can add a few tests, that would be excellent 🎉

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @spacedmonkey, Great work. Approved with one nit-pick.

@spacedmonkey spacedmonkey force-pushed the fix/realpath-error-5 branch from cdbb241 to b4842ef Compare June 26, 2023 10:46
@spacedmonkey
Copy link
Member Author

@felixarntz @mukeshpanchal27 As requested, I have added unit tests. The unit tests have highlighted that the incorrectly value was being return. I moved the some the logic in register_block_style_handle around. This does two things, one skips the need to call wp_should_load_separate_core_block_assets, which resulted in a 1ms of load time. Two, calls generate_block_asset_handle and gets the correct style handle name early, so it can be used with wp_style_is.

This change now is even better of a performance improvement.

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.

@spacedmonkey Production code LGTM! For the tests, please use a data provider rather than a big foreach loop in the tests themselves.

* @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
*/
if ( ! WP_DEBUG ) {
$transient_name = 'wp_core_block_styles';
Copy link
Member

Choose a reason for hiding this comment

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

Would this be better named:

Suggested change
$transient_name = 'wp_core_block_styles';
$transient_name = 'wp_core_block_css_files';

update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() );
}

delete_transient( 'wp_core_block_styles' );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
delete_transient( 'wp_core_block_styles' );
delete_transient( 'wp_core_block_css_files' );

Copy link
Member

Choose a reason for hiding this comment

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

Also, per below, wouldn't site transients be more appropriate?

Suggested change
delete_transient( 'wp_core_block_styles' );
delete_site_transient( 'wp_core_block_css_files' );

Copy link
Member Author

Choose a reason for hiding this comment

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

@westonruter Using network options ( tranisents ) has a performance impact. I think network options are not autoloaded. So it result in a database query, slow things down. Maybe we could work this out later.

$files = get_transient( $transient_name );
if ( ! $files ) {
$files = glob( __DIR__ . '/**/**.css' );
set_transient( $transient_name, $files );
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this could be setting a site transient instead:

Suggested change
set_transient( $transient_name, $files );
set_site_transient( $transient_name, $files );

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Thanks @spacedmonkey, looks great! Good to commit IMO.

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.

@spacedmonkey One small tweak here is needed now that wp_get_development_mode() is available in trunk, see below. Can you please update the code as suggested to get rid of the todo comment?

It would be nice to add a simple test to ensure that the transient is used only when the development mode is not "core", so if you can implement that before the beta release, that would be awesome, though not a blocker IMO. For reference, it could be similar to e.g. 4a16702#diff-a2793e725e03902d8a665c105916351677858253a237e4d08bdc1c01f8c3d671R38-R61.

@spacedmonkey
Copy link
Member Author

Committed d8409a2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants