Problem/Motivation
Currently much of the logic is hardcoded to do search and replace in nodes. However, on sites using Layout Builder overrides extensively, much of their content is made up of blocks (reuseable or not) placed on nodes.
Proposed resolution
Add a BlockContent scanner plugin.
Remaining tasks
Write tests?
User interface changes
none
API changes
Plugins need to key their search() returns by entity_type:$id instead of just $id.
Data model changes
none
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | interdiff.txt | 530 bytes | dcam |
| #17 | 3203383-17.patch | 13.5 KB | dcam |
| #8 | interdiff-7-8.txt | 592 bytes | mariacha1 |
| #8 | support-blocks-3203383-8.diff | 13.25 KB | mariacha1 |
| #7 | support-blocks-3203383-7.diff | 12.67 KB | mariacha1 |
Issue fork scanner-3203383
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 #3
chrisfromredfinI apologize, my VSCode auto-formats to Drupal coding standards, so there's a bunch of changes in that realm. To that end:
Comment #4
chrisfromredfinComment #5
chrisfromredfinComment #6
damienmckennaLooks like it needs a reroll.
Comment #7
mariacha1 commentedHere's a re-roll of the patch which ignores the code standard stuff and the work from https://www.drupal.org/project/scanner/issues/3196119#comment-14028687
I'm realizing I don't know how to make a merge request based off another person's merge request! So just going with the old-fashioned patch method.
Comment #8
mariacha1 commentedReroll misses a fix to the Paragraph plugin that applies the parent's entitytype to the id key. Here's that bit as well.
Comment #9
mariacha1 commentedOne more bug I found: The undo function was trying to reset a node revision instead of the block revision.
Comment #10
philosurfer commented#9 fails to patch the twig file, might need to be re-rolled.
Comment #11
a.griff commentedPatch fixed from the latest updates. Should apply again.
Comment #12
gedvan commented#11 does not include #8 and #9 fixes. Here's a new one.
However, if the block is non-reusable (inline), the result's view/edit links point to an "access denied" page. In this case, it should point to the node containing the block. I'll try to implement this and submit a new patch.
Comment #13
dcam commentedThis needs an
accessCheck()on the entity query in order to be compatible with Drupal 10. See #3372857: Fix access check on query (Drupal 10 compatibility) which adds it for a Node query.We're using this patch on a site that just got upgraded to D10 and scanner stopped working as a result of the lack of access checks in the scanner plugins.
Comment #14
dcam commentedI added the accessCheck().
Comment #15
dcam commentedSorry, I messed up when creating the patch in #14.
Comment #16
dcam commentedThe same change needs to be made to the replace() function. I'll try to come back to it again tonight.
Comment #17
dcam commentedI added the access check to the
replace()function.Comment #19
anybodyI think to speed up the fix here, it would be great to:
Then I think this should be close to RTBC! Could someone do that?
Comment #20
smustgrave commentedLets update for 2.0.x and add some test coverage please.
Comment #22
knyshuk.vova commentedanybody, It's a good idea.
I also suggest resolving the issue with complex IDs {entityType}:{id} and the template first. This will prevent unnecessary work with MR rerolling. We have few issues with changes to the same conflicting files. Like this one 3196119
MR3 removes
$query->accessCheck(FALSE);, it was added correctly in #17 patchComment #23
joespinelli7 commentedHi all! Is #17 patch working to replace text within Layout builder blocks?
Comment #24
damienmckennaLet's focus this on blocks.
Comment #26
damienmckennaThis will need a rewrite after the refactoring work is done - stay tuned for beta2.
Comment #30
smustgrave commentedWe've simplified things so it was a lot easier to add a new entity. Thanks!