Bulk remove old macros from all wiki pages

I'm planning for an upgrade to Confluence 4 and have decided to sunset some plugins which are no longer useful to us (and have turned from open source to commercial...but that's another story).

The impetus for stripping out these old markup tags is because Confluence attempts to wrap these in wiki markup blocks. Worst case is users will have to copy and paste from the wiki block into the outside block.

Does anyone have any tricks or tips on how to best remove them en-masse? The solution that I'm thinking of involves database search/replace with regex pattern replace. I think this will be much easier to do before the upgrade and conversion into XHTML.


1 answer

1 accepted

One technique would be to create user macros for each macro offered by the plugin you're withdrawing. The user macro would be given the same name as a withdrawn macro. If the original macro was wrapping text or other content then you'll need to output that from the user macro. $body should do the trick. If there was no content wrapped by the macro then the macro doesn't need to do anything. You'll find an option when you define a user macro to prevent the macro appearing in the macro browser, except for admin users. This will help ensure that the users don't carry on using the macros by mistake.

You might say that this approach doesn't fully address the issue because the pages haven't been cleaned up. However the page authors could tackle this over time as pages are edited and updated in the normal run of things. You could track progress of this with careful use of the Confluence search and so remove the user macros when they're no longer required (see http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/).

A database search/replace is certainly possible, but riskier I think. Let us know which solution you go for. It's an interesting challenge you've got there.

That's a great tip on using a user macro. I think I'll try that out instead of the DB search/replace method since it's less destructive.

One flaw with this for anyone referencing it post 5.8.x, there is a bug with some macros being placed inside a user macro, so you could end up with an even greater mess if you make this change. https://jira.atlassian.com/browse/CONF-38074

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

755 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you