Closed (fixed)
Project:
Drupal core
Version:
10.1.x-dev
Component:
block.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Jun 2019 at 14:50 UTC
Updated:
10 Mar 2023 at 14:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
grimreaperAssigning the issue to myself, I will delegate it to beginners in my company to mentor them.
Comment #3
grimreaperComment #4
grimreaperTagging.
Comment #5
ithom commentedHello here is a patch for this issue.
Thanks for the review.
Comment #7
ithom commentedHello,
Here is the fixed patch for the issue.
Thanks for the review.
Comment #8
joachim commentedThis patch looks like it's only tests so far. I'm not seeing anything that implements the change the issue summary talks about.
Comment #10
grimreaperComment #11
grimreaperWith this new patch, we also have "Alter the autogenerated machine name in the form to add a block to prefix automatically by the theme machine name (this issue)".
Comment #13
rachel_norfolkretagging
Comment #14
grimreaperFixing tests.
Comment #15
grimreaperComment #17
nod_In Umami profile the blocks are prefixed with the theme name:
umami_brandingfor exempleComment #18
nod_This is the actual change made by the patch, the rest is updating tests. There is an issue when a theme is not preselected when adding the block.
If you go to
/en/admin/structure/block/add/local_tasks_block/, the machine name has the default theme in the name but when you use the select to change the theme (and region) the machine name is not updated.To be the least problematic we could do:
That would avoid changing the signature of a public method as an added bonus.
Comment #19
pavnish commented@nod_ I am working on it.
Comment #20
pavnish commented@nod_ Hi i am very happy to working with you.I have changed the patch as suggest by you in #18
Could you please review .
Thanks
Pavnish
Comment #22
pavnish commentedChecking failed test cases
Comment #23
pavnish commentedComment #24
pavnish commentedComment #25
nod_Comment #26
hardik_patel_12 commentedComment #27
ramya balasubramanian commentedComment #28
ridhimaabrol24 commentedFixing PHP lint error.
Comment #30
nod_This needs to be removed, the parameter doesn't exists anymore
This is not necessary, the test works fine as-is.
Comment #31
ridhimaabrol24 commentedComment #32
ridhimaabrol24 commentedHi @nod_
Thanks for the feedback. implemented the feedback. Kindly review.
Thanks
Comment #33
nod_Looks good to me
Comment #34
catchThe issue title makes this look like more of a change than it actually is. Looks sensible to me and reduces the chance for collisions.
However, this fails cspell:
Comment #35
nod_I didn't see how that config was used, I removed it and the few tests I ran still worked, let's see what testbot says.
Comment #37
nod_can't replicate the failures locally... adding back the config and renamed it.
Comment #38
nod_so... load bearing config file huh.
Comment #39
alexpottI'm pretty sure it used to work this way and we undid it for reasons. So yeah this leads me to #2043527: Theme name is included in block machine name but should be stored as a key instead where we kinda of did the opposite of this. But that was a bit different because this is about the id and not the dot structure of the config name. I think this change is okay but I've pinged @tim.plunkett to gather other thoughts.
Another good thing is that block_theme_initialize() supports this way of naming blocks so that makes sense.
Why have we changed this config - we're only changing a suggestion - we don;'t have to have a theme name here and many existing sites won't so let's not make it look like it is enforced.
Same with all these. I don't think we should be changing them if we don't have to.
Why do we need this?
Comment #40
grimreaperHello,
First, thanks to everyone contributing to this issue. Since comment 15, I don't have time to push it forward. So huge thanks.
In reply of comment 39, points 1 and 2, this is because a rule for the Coder module had been prepared in the related issue #3061184: Add a rule on block machine name. So to have Core ready for this new rule.
I initially wanted a new rule in Coder, and discussed of that with @Klausi at DDD Transylvania 2019, so he told me to have Core ready. For existing websites, it won't break existing blocks and admin can remove the suggested theme name when placing a new block. Also regarding Coder, PHPCS can be customized with phpcs.xml config file to disable this new rule.
For handling existing websites, I don't know if it is possible to have a rule in Coder not enabled by default. So people can add it in their phpcs.xml config file (opt-in instead of opt-out).
Comment 39, point 3: It was for a Views test and only being renamed in my patch comment 15. But maybe on 9.1.x it is no more relevant.
Regards,
Comment #42
grimreaperRereading comment 39 and comment 40.
And review points of comment 39 had been replied in comment 40.
So back to RTBC.
Comment #43
rachel_norfolkJust doing a little tag tidying. Nice work everyone!!
Comment #44
alexpottI think adding the theme name to the suggestion is fine and makes sense. But I also think that this is just a suggestion and should not in anyway be mandated by a coder rule. Therefore I think we should do the changes recommended in #39 as we shouldn't be making unnecessary test changes to comply with a Coder rule that core is unlikely to ever adopt.
Comment #47
drupaldope commentedI just made a copy of a subtheme.
I was very surprised to see the site messed up because CSS and JQuery could not be applied anymore.
What I observed:
the blocks were created in the first subtheme, and the name of the original subtheme was not included in the original machine name, so the blocks' ID were similar to #block-blockname
when I copied the theme, all blocks had new names such as #block-themename-blockname
this is very confusing and creates a lot of unnecessary work when copying themes.
if including the name of the theme in the block ID becomes the standard, then I would suggest to also make it a standard when a block is created in the original theme.
and maybe admin users should be warned about it when creating a block, that they are not allowed to name the block as they want and that they can't give it an ID that remains stable from one theme to another.
Comment #49
smustgrave commentedSounds like a possible duplicate of https://www.drupal.org/project/drupal/issues/2858897
Comment #50
WebbehCleaning out old tags from 2019-2021. Per #49, linking #2858897: Block name collision on theme creation as a similar issue.
Comment #51
smustgrave commentedCould almost say this one is a blocker for https://www.drupal.org/project/drupal/issues/2858897
Sounds like it needs reroll but also address the issues in #39
Comment #52
ravi.shankar commentedWorking on this issue.
Comment #53
sandeepsingh199 commentedre-rolled the #32 patch for 9.5.x.
Comment #54
WebbehUn-assigning this task.
Updating the IS to note the work that needs to be done, as #53 inadvertently moved to Needs Review (NR).
This still needs work (NW), see #3061266-39: Prefix block machine name suggestions with the theme machine name:
Comment #55
Ankit.Gupta commentedReroll the patch #53 with Drupal 9.5.x
Comment #56
Webbeh#55, please see the status change and justification from #54. As you did not mention any fix to the feedback in #54, moving back to Needs Work.
Comment #58
smustgrave commentedFollowing the suggestion in #54. So going back to patch #37 and making the changes mentioned in #39
Hiding patches #53 and #55
#37 was a while ago that the intediff didn't full generate.
Comment #59
smustgrave commentedFixed some test failures
Comment #61
smustgrave commentedComment #62
WebbehBig thanks to @smustgrave for following the issue comments and moving us forward. Per #58 into #61, updating the IS to update where we're at.
Comment #64
larowlanThis looks good to me.
Re #47 I don't think this changes things - theming using the block ID is probably not a good idea, you should be using a class added by the template.
Comment #66
longwaveCommitted and pushed to 10.1.x, thanks!
Comment #67
nod_