How to reset All Likes in a page

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

説明

This user macro will reset all the likes in a page. Just embed it in a page temporarily (using one of the preview modes should be enough) and it should remove all likes on that page. 

オプション 1:   

Applicable for Confluence 6.x.

Create a user macro with the following steps:

  1. Go to  > General Configuration > User Macros.
  2. Choose Create a User Macro.
  3. Enter the Macro Name
  4. Add the following Parameter in Template:

    ## @noparams
    #set($containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager'))
    #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
    #set($containerManager=$getInstanceMethod.invoke(null,null))
    #set($containerContext=$containerManager.containerContext)
    #set($likeManager=$containerContext.getComponent('likeManager'))
    $likeManager.removeAllLikesOn($content)
  5. Save the Macro
  6. Add the macro in the page.

オプション 2:  

The above user macro stopped working for Confluence 7.x as the code has been deprecated. However you can reset the likes on the page from the database directly.

 Please note Atlassian support not support directly editing the DB, but if you wish to proceed you may use the below queries at your own risk. Please ensure to take a backup of your database before making any changes.

There is a table called likes where such information are stored. If you just need to remove the entry from that table for specific page.

To delete:

  • If you know the page ID you can simply remove that:
DELETE FROM likes 
WHERE contentid = <PAGEID>;
  • Or to choose the page title you could use following - remember to substitute  page title:
DELETE From likes
WHERE contentid = (SELECT contentid FROM content WHERE prevver is NULL and title='<Page Title>');

 If you have same title of the page in the different space this will not work and you need to check the exact page id (content id)

最終更新日 2020 年 8 月 18 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.