Skip to content

Gutenberg Backport: Use static closures whenever $this is not used to avoid memory leaks#4629

Closed
westonruter wants to merge 4 commits intoWordPress:trunkfrom
westonruter:trac-58323-2
Closed

Gutenberg Backport: Use static closures whenever $this is not used to avoid memory leaks#4629
westonruter wants to merge 4 commits intoWordPress:trunkfrom
westonruter:trac-58323-2

Conversation

@westonruter
Copy link
Copy Markdown
Member

@westonruter westonruter commented Jun 16, 2023

This backports the changes from WordPress/gutenberg#50723

See WordPress/gutenberg#51077

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


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.

$show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
if ( ! $show_prefix ) {
$filter_title = function( $title, $original_title ) {
$filter_title = static function( $title, $original_title ) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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


$more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';
$filter_excerpt_more = function( $more ) use ( $more_text ) {
$filter_excerpt_more = static function( $more ) use ( $more_text ) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that WordPress/gutenberg#50723 had another static addition in this file:

https://github.com/WordPress/gutenberg/blob/e3194a1d1d9869560260a3bba0939a28a52e737f/packages/block-library/src/post-excerpt/index.php#L80-L95

I guess it will come in another backport or the change in core wasn't "for-ported" to Gutenberg?

@spacedmonkey
Copy link
Copy Markdown
Member

@westonruter All the updates to the blocks php are unneeded. When the blocks are synced as part of the release, this will happen automatically.

…into trac-58323-2

* 'trunk' of https://github.com/WordPress/wordpress-develop: (106 commits)
  Twenty Nineteen: Ensure Separator block supports theme colors in editor.
  Tools: Fix unresolvable conflicts computation in package sync script.
  Twenty Twenty: Fix left margin in Latest Posts & Latest Comments blocks.
  Script Loader: Add support for HTML 5 "async" and "defer" attributes.
  Code Modernization: Use `str_contains()` in a few more places.
  Code Modernization: Use `str_contains()` in a few more places.
  Editor: rename reusable blocks to patterns.
  Editor: fix site editor layout bug.
  Editor: add support for block-level link hover colors.
  Upgrade/Install: Update 'show details' button change.
  Administration: Fix visual regression in media search input.
  Editor: Add no-js fallback for site editor.
  Upgrade/Install: Add aria-describedby for input descriptions.
  Administration: Consistent positioning and size of search form.
  Quick/Bulk Edit: Don't set publish date when editing drafts.
  Code Modernization: Use `str_contains()` in a few more places.
  Code Modernization: Use `str_starts_with()` and `str_ends_with()` in a few more places.
  Code Modernization: Use `str_starts_with()` and `str_ends_with()` in a few more places.
  Editor: Improve accessibility of new custom field UI.
  Coding Standards: Use Yoda condition in `str_ends_with()`.
  ...
@westonruter westonruter requested a review from spacedmonkey June 26, 2023 16:11
Copy link
Copy Markdown
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 @westonruter, LGTM!

@westonruter
Copy link
Copy Markdown
Member Author

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

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

3 participants