Page MenuHomePhabricator

Restrict section edit links to specific section levels
Open, LowPublic

Description

Author: v

Description:
I noticed that using section edit links the pages can get really messy when using deep sectioning. So i made a
small patch to MediaWiki 1.5.0 (i checked that CVS didn't have this feature yet either) to disable section links
according to a set level. With this patch you set $wgEditSectionLevel to section level that you wish to have
section edit links and everything under that level. Makes some pages much clearer to read.

I wasn't sure where i should submit this patch to get reviewed and maybe added to MediaWiki so i submitted it here.
Couldn't come to the IRC channel because i'm at work right now.

Here is the patch:

--- includes/Parser.php.orig  2005-09-18 04:21:39.000000000 +0300
+++ includes/Parser.php  2005-10-24 11:14:39.000000000 +0300
@@ -2644,10 +2644,13 @@
                if ( empty( $head[$headlineCount] ) ) {
                    $head[$headlineCount] = '';
                }
-               if( $istemplate )
-                   $head[$headlineCount] .= $sk->editSectionLinkForOther($templatetitle, $templatesection);
-               else
-                   $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1);
+               global $wgEditSectionLevel;
+               if ( $wgEditSectionLevel == 0 || $level <= $wgEditSectionLevel ) {
+                   if( $istemplate )
+                       $head[$headlineCount] .= $sk->editSectionLinkForOther($templatetitle, $templatesection);
+                   else
+                       $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1);
+               }
            }

            # give headline the correct <h#> tag

Details

Reference
bz3787

Revisions and Commits

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 8:54 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz3787.
bzimport added a subscriber: Unknown Object (MLST).

v wrote:

Sorry, should have included the patch as an attachment.

v wrote:

The same patch as in description.

attachment editsectionlevel.patch ignored as obsolete

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

Adding the "need-review" keyword for patches that need review by developers. Väinö Järvelä, thank you for your patch, and sorry it's taken so long for a response on this!

Do you still run into the problem that occasioned this bug report and fix, or has it been resolved in subsequent versions of MediaWiki?

Created attachment 10462
Modernized patch

Here's how it should look on modern MW, bar parser tests. The question here is whether this feature has enough demand to warrant its inclusion? Comments are welcome, probably worth a wikitech-l discussion.

Attached:

Max: Could you put that patch into Gerrit?

epriestley closed this task as Resolved by committing Unknown Object (Diffusion Commit).Mar 4 2015, 8:16 AM
epriestley added a commit: Unknown Object (Diffusion Commit).
matmarex subscribed.

(That was a Phabricator bug, this is not fixed.)