Problem/Motivation

Due to the code run on page load + on node save, with the amount of Patterns block in our current db, it can cause some sluggish and timeouts.

Proposed resolution

Add a new service parameter, enable_reusable_blocks, and related checks throughout the codebase with defaults to disable reusable blocks unless a site explicitly opts into enabling them through the use of the service parameter. This will make it easier to move toward removal altogether as part of #3516918: Remove Reusable Block Support.

Assuming the new enable_reusable_blocks service parameter is not set or is explicitly set to FALSE,

  • Reusable block derivatives will not load in order do address the originally reported performance issue
  • The following routes and related pages are no longer accessible or shown in menus:
    • /admin/structure/block/patternkit
    • /patternkit_block/{patternkit_block}
    • /patternkit_block/{patternkit_block}/edit
    • /patternkit_block/{patternkit_block}/delete
    • /patternkit_block/add
    • /patternkit_block/add/{pattern_id}
  • Existing reusable blocks originally created through the layout builder interface and placed in layouts should continue to render as expected
  • Existing reusable blocks originally created through the Block Structure > Patternkit Library interface and placed in layouts will not render
  • A status warning has been added to the requirements page if reusable blocks existing within the database

If the new service parameter is enabled, existing functionality should be maintained, but the status warning added to the requirements page will still be reported.

The new service parameter by be enabled on a site by adding the following to the site's services.yml file, typically found in sites/default/services.yml:

parameters:
  patternkit.config:
    enable_reusable_blocks: true

Issue fork patternkit-3511525

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

firewaller created an issue. See original summary.

firewaller’s picture

Specifically, commenting out the code here so `$patternkit_blocks` is always an empty array: https://git.drupalcode.org/project/patternkit/-/blob/9.1.x/src/Plugin/De...

firewaller’s picture

Status: Active » Needs review
StatusFileSize
new957 bytes

slucero made their first commit to this issue’s fork.

slucero’s picture

I've pushed up some work that adds a new configuration option to disable loading these derivatives and further disables the implementation of reusable blocks altogether. To help move toward disabling support for these altogether, the option is currently getting set to FALSE by default and outputs a warning during the update hook if there are any reusable blocks present in the system.

Remaining work includes:

  • Determine a migration path and implementation plan for sites currently using reusable blocks
  • Add automated test coverage for each option
  • General functional testing to make sure everything continues to work as intended

slucero changed the visibility of the branch 3511525-disable-reusable-blocks to hidden.

slucero’s picture

I've uploaded a new branch, 3511525-disable-reusable-blocks--parameter, that supersedes the previous one with an alternative direction of implementing the config for enabling reusable blocks as a service parameter instead of config value. I've redirected to this direction instead for the following reasons:

  • A service parameter obscures the functionality more effectively than a new setting in the configuration form requiring continued usage of the functionality to be very intentional.
  • Using a service parameter that's not heavily exposed also makes the process easier for phasing out the functionality altogether in a future release.

This new service parameter and related checks throughout the codebase default to disabling reusable blocks unless a site explicitly opts into enabling them through the use of the service parameter. This will make it easier to move toward removal altogether as part of #3516918: Remove Reusable Block Support.

Included in this branch are the following changes:

Assuming the new enable_reusable_blocks service parameter is not set or is explicitly set to FALSE,

  • Reusable block derivatives will not load in order do address the originally reported performance issue
  • The following routes and related pages are no longer accessible or shown in menus:
    • /admin/structure/block/patternkit
    • /patternkit_block/{patternkit_block}
    • /patternkit_block/{patternkit_block}/edit
    • /patternkit_block/{patternkit_block}/delete
    • /patternkit_block/add
    • /patternkit_block/add/{pattern_id}
  • Existing reusable blocks originally created through the layout builder interface and placed in layouts should continue to render as expected
  • Existing reusable blocks originally created through the Block Structure > Patternkit Library interface and placed in layouts will not render
  • A status warning has been added to the requirements page if reusable blocks existing within the database

If the new service parameter is enabled, existing functionality should be maintained, but the status warning added to the requirements page will still be reported.

The new service parameter by be enabled on a site by adding the following to the site's services.yml file, typically found in sites/default/services.yml:

parameters:
  patternkit.config:
    enable_reusable_blocks: true

slucero’s picture

Issue summary: View changes

slucero credited bladwin.

slucero credited johnle.

slucero’s picture

minsharm’s picture

StatusFileSize
new2.97 MB

Retested the issue on both D10 and D11 with enable_reusable_blocks = TRUE as well as with FALSE.

Results look good to me.

Attaching screenshots as well.

slucero’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new58.78 KB

Ready for merging into the 9.1.2 release. Attaching a patch of the current MR state for easy reference.

  • slucero committed a25b3170 on 9.1.x
    Issue #3511525 by slucero, firewaller, minsharm, bladwin, johnle: Remove...
slucero’s picture

Status: Reviewed & tested by the community » Fixed

Merged for inclusion in the 9.1.2 release, and the related change record has been published.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.