Ideas

Update Migration Helper so that Obsidian Block Chopping doesn't break plugin migrations

Note You are not authorized to edit this feature.

Update Migration Helper so that Obsidian Block Chopping doesn't break plugin migrations

Core

When a plugin includes a migration to add a core block, and that block get's "chopped" with a new obsidian block, the plugin's migration will fail to run (it gets an exception for missing block guid). This requires plugin developers to release a new version of their plugin anytime a new version of Rock is released. This especially affects a theme plugin that has migration to add a lot of public pages using a lot of core blocks. 

wouldn't it be an easy update to the AddBlock() migration helper method to add try/catch and if an exception occurs, check the block guid against a dictionary of chopped blocks. 

For example:

try

{
...[existing logic]
}
catch (Exception ex)
{
var blockReplacements = new Dictionary<string, string> {
// blocks chopped in v18.0.13
{ "476FBA19-005C-4FF4-996B-CA1B165E5BC8", "FF88B243-4580-4BE0-97B1-BA9895C3FB8F" }, // Email Preference Entry ( Communication )
{ "13165D92-9CCD-4071-8484-3956169CB640", "535500a7-967f-4da3-8fca-cb844203cb3d" }, // File Asset Manager
{ "CABD2BFB-DFFF-42CD-BF1A-14F3BEE583DD", "0252E237-0684-4426-9E5C-D454A13E152A" }, // Registration Entry
// blocks chopped in v18.0.11
{ "0926B82C-CBA2-4943-962E-F788C8A80037", "000ca534-6164-485e-b405-ba0fa6ae92f9" }, // Binary File Type List ( Core )
{ "508DA252-F94C-4641-8579-458D8FCE14B2", "b52e7cae-c5cc-41cb-a5ec-1cf027074a2c" }, // Metric Value Detail ( Reporting )
{ "56ABBD0F-8F62-4094-88B3-161E71F21419", "c3544f53-8e2d-43d6-b165-8fefc541a4eb" }, // Communication List ( Communication )
{ "ACF84335-34A1-4DD6-B242-20119B8D0967", "6bc7da76-1a19-4685-b50a-dfd7eaa5ce33" }, // Schedule Category Exclusion List ( Core )
{ "C7FCE3B7-704B-43C0-AF96-5A70EB7F70D9", "35D5EF65-0B0D-4E99-82B5-3F5FC2E0344F" }, // Connection Opportunity Signup ( Connection )
{ "CEDC742C-0AB3-487D-ABC2-77A0A443AEBF", "2B63C6ED-20D5-467E-9A6A-C608E1D953E5" }, // Communication Detail ( Communication )
{ "D9302E4A-C498-4CD7-8D3B-0E9DA9802DD5", "66f5882f-163c-4616-9b39-2f063611db22" }, // Bulk Import ( Bulk Import )
{ "DA102F02-6DBB-42E6-BFEE-360E137B1411", "740f7de3-d5f5-4eeb-beee-99c3bfb23b52" }, // Merge Template List ( Core )
{ "DF0F5743-2BFF-40C0-8BEE-39F1DE7B4C22", "3f997da7-ac42-41c9-97f1-2069bb9d9e5c" }, // Prayer Comment List ( Core )
// blocks chopped in v18.0.10
{ "3131C55A-8753-435F-85F3-DF777EFBD1C8", "8adb5c0d-9a4f-4396-ab0f-deb552c094e1" }, // Benevolence Request List ( Finance )
{ "41AE0574-BE1E-4656-B45D-2CB734D1BE30", "6e9672e6-ee42-4aac-b0a9-b041c3b8368c" }, // Nameless Person List ( CRM )
{ "63ADDB5A-75D6-4E86-A031-98B3451C49A3", "6c824483-6624-460b-9dd8-e127b25ca65d" }, // Web Farm Node Log List ( WebFarm )
{ "78A31D91-61F6-42C3-BB7D-676EDC72F35F", "1c3d7f3d-e8c7-4f27-871c-7ec20483b416" }, // Block Type List ( CMS )
{ "7F9CEA6F-DCE5-4F60-A551-924965289F1D", "6554ADE3-2FC8-482B-BA63-2C3EABC11D32" }, // Group Schedule Toolbox ( Group Scheduling )
{ "95F38562-6CEF-4798-8A4F-05EBCDFB07E0", "6bba1fc0-ac56-4e58-9e99-eb20da7aa415" }, // Web Farm Node Detail ( WebFarm )
{ "A3E648CC-0F19-455F-AF1D-B70A8205802D", "6c329001-9c04-4090-bed0-12e3f6b88fb6" }, // Block Type Detail ( CMS )
{ "C4191011-0391-43DF-9A9D-BE4987C679A4", "e1dce349-2f5b-46ed-9f3d-8812af857f69" }, // Bank Account List ( Finance )
{ "C93D614A-6EBC-49A1-A80D-F3677D2B86A0", "52df00e5-bc19-43f2-8533-a386db53c74f" }, // Campus List ( Core )
{ "CE9F1E41-33E6-4FED-AA08-BD9DCA061498", "e20b2fe2-2708-4e9a-b9fb-b370e8b0e702" }, // Saved Account List ( Finance )
// blocks chopped in v18.0.8
{ "250FF1C3-B2AE-4AFD-BEFA-29C45BEB30D2", "770d3039-3f07-4d6f-a64e-c164acce93e1" }, // Signal Type List ( Core )
{ "B3F280BD-13F4-4195-A68A-AC4A64F574A5", "633a75a7-7186-4cfd-ab80-6f2237f0bdd8" }, // AI Provider List ( Core )
{ "88820905-1B5A-4B82-8E56-F9A0736A0E98", "13f49f94-d9bc-434a-bb20-a6ba87bbe81f" }, // AI Provider Detail ( Core )
{ "D3B7C96B-DF1F-40AF-B09F-AB468E0E726D", "120552e2-5c36-4220-9a73-fbbbd75b0964" }, // Audit List ( Core )
// blocks chopped in v18.0
{ "1D7B8095-9E5B-4A9A-A519-69E1746140DD", "e44cac85-346f-41a4-884b-a6fb5fc64de1" }, // Page Short Link Click List ( CMS )
{ "4C4A46CD-1622-4642-A655-11585C5D3D31", "eddfcaff-70aa-4791-b051-6567b37518c4" }, // Achievement Type Detail ( Achievements )
{ "7E4663CD-2176-48D6-9CC2-2DBC9B880C23", "fbe75c18-7f71-4d23-a546-7a17cf944ba6" }, // Achievement Attempt Detail ( Engagement )
{ "9C1236AE-4FF0-480C-A7DF-0E5277CA75FB", "b294c1b9-8368-422c-8054-9672c7f41477" }, // Achievement Attempt List ( Achievements )
{ "C26C7979-81C1-4A20-A167-35415CD7FED3", "09FD3746-48D1-4B94-AAA9-6896443AA43E" }, // Lava Shortcode List ( CMS )
{ "D2F918CF-F63C-4643-A02A-FD3DE7C5CFFD", "4acfbf3f-3d49-4ae3-b468-529f79da9898" }, // Achievement Type List ( Streaks )
{ "D6D87CCC-DB6D-4138-A4B5-30F0707A5300", "d25ff675-07c8-4e2d-a3fa-38ba3468b4ae" }, // Page Short Link List ( CMS )
};

if (blockTypeGuid.HasValue && blockReplacements.ContainsKey( blockTypeGuid.Value.ToString().ToUpper() ))
{
blockTypeGuid = blockReplacements[blockTypeGuid.Value.ToString().ToUpper()].AsGuidOrNull();
AddBlock( skipIfAlreadyExists, pageGuid, layoutGuid, siteGuid, blockTypeGuid, name, zone, preHtml, postHtml, order, guid );
}
else
{
throw ex;
}
}

Photo of David TurnerSubmitted by David Turner, 9 Embers  ·   ·  Core
Login to add a comment...

Submission Success Tips

Cultivate your ideas for maximum impact with these helpful submission tips that will increase the chances of your brilliant concepts becoming reality.

  • Clear Title: Craft a straightforward and descriptive title that instantly conveys the essence of your idea.
  • Concise Description: Provide an idea description that is succinct, ensuring it effectively communicates the concept without unnecessary verbosity.
  • Provide Additional Details: With a concise description complete, now provide any other details that are needed to better understand the requirements.
  • Thorough Ministry Need Review: Provide a comprehensive overview of the ministry need your idea addresses, emphasizing its significance.
  • Cover the WHY: Clearly articulate the rationale behind your idea, explaining why it's essential and how it aligns with the organization's goals and mission. Oftentimes a clear "why" sheds light into other possible options.