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
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | patternkit-remove-derivatives-3511525-14.patch | 58.78 KB | slucero |
| #13 | PLATCMS-1067.pdf | 2.97 MB | minsharm |
Issue fork patternkit-3511525
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
Comment #2
firewaller commentedSpecifically, 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...
Comment #3
firewaller commentedComment #5
sluceroI'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:
Comment #7
sluceroI'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: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_blocksservice parameter is not set or is explicitly set to FALSE,/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}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.ymlfile, typically found insites/default/services.yml:Comment #9
sluceroComment #12
sluceroComment #13
minsharm commentedRetested 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.
Comment #14
sluceroReady for merging into the 9.1.2 release. Attaching a patch of the current MR state for easy reference.
Comment #16
sluceroMerged for inclusion in the 9.1.2 release, and the related change record has been published.