Issue Summary
Contributors Summary Macro fails to render after renaming a user, if the system still has old "~favourites" style labels present.
When trying to load the macro on a page, you will get:
Error rendering macro 'contributors-summary'
No user could be found with the username old_user_id
And com.atlassian.confluence.labels.Label.<init> stack is logged in support logs.
Steps to Reproduce
The system needs to have old favourites labels with "~username:favourite" name, and content labelled by them.
- Create a page and add Contributors Summary Macro macro to it.
- Take one of the existing users and rename their account (irrelevant of directory type)
- Try to load a page with Contributors Summary Macro in it
Expected Results
- Macro Renders and loads as expected
Actual Results
- Instead of a macro, the following error is displayed:
Error rendering macro 'contributors-summary
Below exception is thrown in the atlassian-confluence.log file:
Workaround
Workaround 1
You can try creating and then disabling a user account with an old username, this would allow for the macro to render
Workaround 2
You can delete old favourites label from the content and delete the label itself
If you are unsure how to deal with the database, contact your DBA. Make sure to have the database backed up completely before going further. These SQL commands were tested in some environments and they worked as intended, however, it might not work in specific cases and newer versions of confluence as new constraints as changes may be done to the confluence database structure. As such, a database backup is mandatory in case something goes wrong and you need to revert.
- Check if there are legacy favourites labels still present in the system
You should see one of the labels containing a username for the non-existent user
SELECT * FROM LABEL
WHERE NAME LIKE '~%'
AND OWNER IS NULL;
- Check if any content is still tagged with old favourites labels
SELECT
l.labelid, l.name AS label, l.owner,
cl.contentid, cl.lastmoddate,
c.contenttype, c.title
FROM LABEL l
JOIN CONTENT_LABEL cl
ON l.LABELID = cl.LABELID
JOIN CONTENT c
ON cl.CONTENTID = c.CONTENTID
WHERE l.NAME LIKE '~%'
AND l.OWNER IS NULL;
If you see any output, it means there are pages still labelled as old user favourites, those pages would not appear under users favourites as those are linked to a label that maps to nobody and using old favourites system, on newer Confluence versions favourites label has no username in the name field and is simply called "favourite" and maps to the user by the owner key value.
- Shutdown Confluence
- Take complete Confluence DB and File system backups and test on staging system first
- Run the following queries to delete old favourites labels from label_content table:
DELETE FROM CONTENT_LABEL
WHERE labelid IN (
SELECT labelid
FROM LABEL WHERE name LIKE '~%'
AND owner IS NULL);
- Then this query to delete old labels themselves:
DELETE FROM LABEL WHERE name LIKE '~%'
AND owner IS NULL;
- Proceed with Rebuild the Content Indexes From Scratch on Confluence Server
- Test if the macro is rendered correctly