Liferay Portal 7.4 GA132 Knowledge Base articles are shown in wrong order in Admin view

Environment: Liferay Portal 7.4 GA132

Portlet: Knowledge Base

Package: com.liferay.knowledge.base.web.internal.display.context

Description:

KBAdminNavigationDisplayContext.java function KBArticleServiceUtil.getKBArticles( uses a parameter KBArticleTitleComparator.getInstance(true). This means every child article below the root level are sorted by their title, not by their priority.

The order of the articles should be based on priority value of the article. You can change the priority by dragging articles up/down on in their context. The articles are also shown in priority order when viewed in the public pages.

Comparison 1: KBAdminNavigationDisplayContext.java Admin view folders and root level articles are ordered by priority comparison KBObjectsPriorityComparator.getInstance(true).

Comparison 2: KBNavigationDisplayContext.java “Knowledge Base Display” portlet left side navigation bar articles are ordered by priority comparison KBArticlePriorityComparator.getInstance(true).

The situation causes the Admin view article navigation and “Knowledge base display” public website article navigation to have different orders. Changing the order of the articles causes further problems.

How to reproduce:

  1. Liferay Admin → Content & Data → Knowledge base
  2. Create a new article “Base article”
  3. Create 3 articles as child articles for the “Base article”:
    1. CCC Article 1
    2. BBB Article 2
    3. AAA Article 3
  4. Refresh the admin view

Expected outcome: The order of the articles stays the same, CCC Article 1 as fist and AAA Article 3 as last.

Outcome: AAA Article 1 is show first in the admin view and CCC Article 1 as last, caused by title sorting. Articles are shown in correct order in the public view.

Possible fix: replace KBArticleTitleComparator.getInstance(true) parameter with KBObjectsPriorityComparator.getInstance(true).

The knowledge base is one of the features that is in maintenance mode, so only critical bugs would be addressed.

I would suggest weaving in an update that takes into account the ordering you expect using a technique like the one I described here: Extending Liferay OSGi Modules Revisited - Liferay