If there is a sticky block and the same blockname is listed in defaultblocks_override you get duplicates

If there is a sticky block and the same blockname is listed in defaultblocks_override you get duplicates

by Diane Soini -
Number of replies: 3
If you have a block name in $CFG->defaultblocks_override and you have used the sticky block method to add that same kind of block to all the course pages, new courses that are created will have two of the same type of block even if the block has instance_allow_multiple() function defined and returning false.

I don't know if I should submit a Tracker ticket for this or if there is a fix for it.

It would be ideal to move away from the sticky block method for a lot of these blocks. But we can't do it because if we remove the sticky block the block gets removed throughout the site. We're sort of trapped.

So my questions:
1. Should I submit a tracker ticket?
2. Is there a fix for this I'm not aware of.
Average of ratings: -
In reply to Diane Soini

Re: If there is a sticky block and the same blockname is listed in defaultblocks_override you get duplicates

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
If you have the block as a sticky block, why not remove it from the $CFG, then only the instance created by the "sticky" will show up.
In reply to Richard Oelmann

Re: If there is a sticky block and the same blockname is listed in defaultblocks_override you get duplicates

by Diane Soini -

Removing it from the config is what we have done. But we have some that are in the config and some that are not, and it would be nice if things were more consistent. We will sometimes lose the sticky blocks and then have to put them back. I don't know if that happens when dashboards are reset or how they disappear.

It appears maybe the only solution is to write a one-off script to retroactively add blocks to already-created courses if we decide to stop using the sticky block method.

In reply to Diane Soini

Re: If there is a sticky block and the same blockname is listed in defaultblocks_override you get duplicates

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
"write a one-off script to retroactively add blocks to already-created courses" - I've certainly done it that way in the past. It's a pain, but it does work smile Just do it at a low usage time for your site as it can be quite intensive on the servers, particularly if there are a lot of courses to add the block to.