Page MenuHomePhabricator

Avoid duplicate section entries in AdminLinks page
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
Gesinn-it-ilm
Oct 22 2025, 10:12 AM
Referenced Files
Restricted File
Oct 22 2025, 10:12 AM
Restricted File
Oct 22 2025, 10:12 AM

Description

Steps to replicate the issue:

  • MediaWiki 1.39+

Extensions Involved:

  • PageForms (5.9.1)
  • SemanticMediaWiki (5.0.1)

Steps:

  • Install and enable both PageForms and SemanticMediaWiki.
  • Open Special:AdminLinks page.
  • Notice that both extensions register their own Datenstruktur / Data structure section.
  • When both hooks (PFHooks::addToAdminLinks and SMW\MediaWiki\Hooks\AdminLinks) run, multiple sections with the same header (e.g. Datenstruktur) are displayed.
  • Each duplicated section contains overlapping links (like Kategorien, etc.), often appearing multiple times.

What happens?:

  • Duplicate Admin Links sections (Datenstruktur / Data structure) appear when both PageForms and SemanticMediaWiki are installed.
  • Some links (e.g. Kategorien) are shown twice within the same section.
  • The section order may also become inconsistent due to multiple inserts.

What should have happened instead?:

  • Sections with the same header should be merged into one unified section.
  • Duplicate links (same label or target) should be displayed only once.

Screenshots:
How it looks like:

{F66779530}

How it should look like:

{F66779535}

Proposed fix:

  • Update the ALTree::addSection() method to detect and merge sections that have the same header (case-insensitive).

When merging sections:

  • Existing rows from both sections are combined, preserving their internal order.
  • Duplicate links are removed to prevent repeated entries.
  • The logic ensures that adding new sections via hooks (e.g. PFHooks and SMWHooks) no longer creates duplicates, but cleanly merges content into a single unified section.
  • Final output in Special:AdminLinks now properly lists each section only once, maintaining alphabetical consistency.

Fix implemented in fork:
https://github.com/gesinn-it-ilm/mediawiki-extensions-AdminLinks/commit/8a9ba967890edf8e89b7a8a7d97625c57972de3a

Event Timeline

Okay, I think I see the issue: Page Forms only creates a "Data structure" section if one does not exist (see here), but in the SMW code, it creates one no matter what. Maybe I had assumed that the SMW code would always be called be first, if both were installed; I'm not sure. Anyway, one relatively easy solution would be to have the SMW code first check before adding a section, like the PF code does. Your code does what might be the better solution, - assuming that no one will ever want to have two sections with the same name, which I think is a reasonable assumption. It seems a little needlessly complicated, though: the lines from 44-63 seems like they could be handled with a single section of code, without the "if" statement.

[Edited because I hadn't thought enough about it the first time around.]

@Yaron_Koren

Thanks a lot for your feedback — that makes perfect sense.
I simplified the logic as you suggested, by removing the unnecessary if branching between lines 44–63.
Now the merging code handles all cases in a single unified block.

Here is the link where you can check that commit - https://github.com/gesinn-it-ilm/mediawiki-extensions-AdminLinks/commit/c52da7bd0242a980a149fb9cbf052822b4318aa9

Okay, this looks good! Could you create a patch for it?

@Yaron_Koren Yes, of course. I will prepare it today.

@Yaron_Koren

I just noticed that I need Gerrit account, which I don't have.
We don't use Gerrit account to the organizational effort involved, but I will be happy to send you a diff from GitHub.

You are very welcome to use a Developer Account to submit the proposed code changes as a Git branch directly into Gerrit which makes it easier to review and provide feedback. If you don't want to set up Git/Gerrit, you can also use the Gerrit Patch Uploader. Thanks!

Change #1201034 had a related patch set uploaded (by Aklapper; author: Marko Ilic):

[mediawiki/extensions/AdminLinks@master] Avoid duplicate section entries in AdminLinks page

https://gerrit.wikimedia.org/r/1201034

Change #1201034 merged by jenkins-bot:

[mediawiki/extensions/AdminLinks@master] Avoid duplicate section entries in AdminLinks page

https://gerrit.wikimedia.org/r/1201034

Yaron_Koren claimed this task.