Project

General

Profile

Actions

Bug #17267

closed

Link Library showing duplicate, flattened categories using the "link-library-cats" shortcode

Added by Raffi Khatchadourian over 1 year ago. Updated over 1 year ago.

Status:
Resolved
Priority name:
Normal
Assignee:
-
Category name:
WordPress Plugins
Target version:
Start date:
2022-11-18
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

Was there an update to the Link Library plug-in lately? I am seeing duplicate categories at https://khatchad.commons.gc.cuny.edu/research/background/#Overview. I haven't seen this behavior before. It would seem that the categories are being repeated when they area under other categories. In other words, subcategories appear both at the top-level and under their parent category.


Related issues

Has duplicate CUNY Academic Commons - Bug #17266: Link Library showing duplicate, flattened categories using the "link-library-cats shortcodeDuplicate2022-11-18

Actions
Actions #1

Updated by Boone Gorges over 1 year ago

Hi Raffi - We've updated link-library a number of times over the last few months. I've looked back over these changes and they're mostly small and have nothing to do with the way that the category tree is traversed. As a test, I tried rolling the plugin version back to what it was at several moments in the recent past (3 months ago, 12 months ago) to see if the behavior would change. But it did not: in each case, items like 'Static Analysis' were listed both as child categories and as top-level items.

I took a few minutes to look through the plugin to understand what might be happening. The plugin uses WP's `get_terms()` function to fetch a list of categories https://plugins.trac.wordpress.org/browser/link-library/tags/7.4/render-link-library-cats-sc.php?marks=179#L170. `get_terms()` does not return a tree, but a flat array of categories with parent information. It is thus up to the renderer (in this case, link-library) to build a tree. I believe that, in order to work properly, the plugin would need to build the tree before rendering; it's only after walking through the entire array of term objects that you could say whether a given item has a 'parent' and thus should be excluded from level 0 rendering. But the plugin doesn't appear to do this: it just runs through a `foreach` loop of the returned categories, calling itself recursively when the item has children but not excluding it from future rendering when an item appears in a parent's sublist. As such, I don't see evidence that it even tries to exclude children during level-0 rendering.

On a lark, I tried modifying the plugin so that the initial category query fetched only items with parent=0. But something about this seemed to cause the page to trigger out-of-memory errors, so I rolled it back.

I'm afraid we'll have to monitor your post on wordpress.org https://wordpress.org/support/topic/duplicate-flattened-categories-using-link-library-cats/ to see if the author replies.

Actions #2

Updated by Raffi Khatchadourian over 1 year ago

Thanks, Boone. I wonder if the functionality of get_terms() changed at some point. I could swear this was working in the past.

Actions #3

Updated by Boone Gorges over 1 year ago

  • Has duplicate Bug #17266: Link Library showing duplicate, flattened categories using the "link-library-cats shortcode added
Actions #4

Updated by Raffi Khatchadourian over 1 year ago

Looks like there's a fix. Can we update to version 7.4.7? See https://wordpress.org/support/topic/duplicate-flattened-categories-using-link-library-cats/#post-16298959. Thanks.

Actions #5

Updated by Boone Gorges over 1 year ago

  • Target version set to 2.0.14

Glad to hear it's fixed. The update should be part of the 2.0.14 release on Dec 27.

Actions #6

Updated by Raffi Khatchadourian over 1 year ago

Boone Gorges wrote in #note-5:

Glad to hear it's fixed. The update should be part of the 2.0.14 release on Dec 27.

Spoke to soon. Looks like it's not completely fixed :(. See https://wordpress.org/support/topic/duplicate-flattened-categories-using-link-library-cats/#post-16302625

Actions #7

Updated by Raffi Khatchadourian over 1 year ago

Actually, the problem they're discussing now may be a user error.

Actions #8

Updated by Raffi Khatchadourian over 1 year ago

Boone Gorges wrote in #note-5:

Glad to hear it's fixed. The update should be part of the 2.0.14 release on Dec 27.

Thanks again, Boone. How do I verify the current version of CAC? Is there a status website or something?

Actions #9

Updated by Boone Gorges over 1 year ago

  • Category name set to WordPress Plugins
  • Status changed from New to Resolved

There's no direct way for you to see the current version of CAC. You can follow https://dev.commons.gc.cuny.edu/, where I create a new post once the release is complete. Or you can wait for this ticket to be marked as resolved.

link-library 7.4.19 is included in this release, see https://github.com/cuny-academic-commons/cac/commit/de25af34532ec8adbf6591c2b1c9fd05ef11adb5

Actions #11

Updated by Boone Gorges over 1 year ago

Excellent!

Actions

Also available in: Atom PDF