Page MenuHomePhabricator

Section edit links for transcluded templates are not affected by <noinclude> or <includeonly>
Closed, ResolvedPublic


Author: Kevin_b_er

As can be whitnessed on

Basically, there are two transcluded templates on the page. Subpage 1 and
subpage 2. Subpage 1 has its 2nd section surrounded by <noinclude>, and subpage
2 and its 1st section surrounded by <noinclude>.

Attempting to use the section edit links for the first template's 1st section is
easy and understandable. But if you attempt to edit the 2nd section that
appears, you are taken to an edit page for a completely different section of the

The attempt to produce a section edit link relies on only counting what ends up
on the transcluded page, but the edit link it produces relies upon the natural
layout of the page in question.

Its all messed up really. Subpage 3 edits just fine, but try actually going to
subpage 3, you'll find that the includeonly has made it so that the only section

To summarize: Section edit links are generated based upon displayed content, but
going to said section edit links leads to a section that does not take into
account noinclude or includeonly tags. Therefor, section edit links should be
generated based upon content as if there were no <includeonly> or <noinclude>

This got annoying with Wikipedia's Request for Checkuser as we wanted a requests
related to a username to be on one page, and transcluded to the main page, but
edit links started acting 'strange'.

This bug may be related to 4926, and is still currently a problem as of 1.7alpha

Version: 1.12.x
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:19 PM
bzimport set Reference to bz6563.
bzimport added a subscriber: Unknown Object (MLST).

folengo wrote:

I agree with Kevin.

For all practical matters, this bug prevents transclusion of selected sections
of pages that contain several sections.

"< noinclude > " and "< includeonly >" are useless when you try to use them to
select some sections among many.

To understand what this means, try, for example, editing "section 3" of
[[:fr:Utilisateur:Teofilo/test1]] .
Instead of "text 3" as expected, you will find "text 1" in the edit box.

Similarly, try editing "section 5" of [[:fr:Utilisateur:Teofilo/test2]] .
Instead of editing "text 5", as expected, you will find "text 3" in the edit box.

ssanbeg wrote:

I don't think template transclusion was intended to do that; it would be
somewhat complicated to fix, since there are three distinct types (noinclude,
includeonly, and onlyinclude) of tags that should be accounted for.

That's part of what the labeled section transclusion
( was
intended to address, so this extension can handle that case.

But we're still waiting to hear if that can be installed on the official
projects. Since that marks the sections by name, instead of behavior, it is
simpler to do in the extension, but it's not simple to port that functionality
into the core code.

The distinction between using the built-in tags like <noinclude> and the LST extension is that in the former case
the content of the transcluded page itself determines which portions are transcluded, and this does not change
unless the transcluded page does. In the latter case the transcludING page decides which portions are transcluded,
and this is subject to change in both places: the transcludING page might choose to transclude a different
selection, the transcludED page might offer a different selection.

What appears to be happening here is that different code for counting sections is being used in different places,
and the use of <includeonly> tags and the like causes the two different methods to come up with different answers.
Hope this clears up your confusion.

ssanbeg wrote:

<includeonly> tags have the same behavior in both. It's when using the
extension tags that the extension counts the number of sections that are skipped
in the beginning, so that transcluded links can be offset.

includeonly and sections currently don't work well together, and I don't know of
a solution to that, at least not without a substantial rewrite to one or both of
the section edit & includeonly handling. I'm not sure that this is intended to
be done with the built in transclusion anyway, or if they'd want to rework the
core code that much, when it can be done in an extension.

wikipedia wrote:

This error is also witnessed on WP:ERRORS (enwp)

bugzilla wrote:

*** Bug 10170 has been marked as a duplicate of this bug. ***

marking the severity as major as I believe that it's a major issue. A pretty simple solution to the problem could be to introduce some meta directive to recount the sections, so for example this could work:

ssanbeg wrote:

(In reply to comment #7)

marking the severity as major as I believe that it's a major issue. A pretty
simple solution to the problem could be to introduce some meta directive to
recount the sections, so for example this could work:

It may be easier to see if the labeled section transclusion should be installed, or if enhancements should be made to that. Since the extension counts sections automatically, it's less likely to cause weird behavior if someone edits the transcluded page later on.

Although there may be various ways to hack some kind of workaround into the core code, I don't know if that's the place for it; and since the extension is already running on some projects, that may be more useful in the long run.

I' think I've just encountered this problem, or something similar, while finding vandalism. This edit:
caused all section links beyond "P-r of authors section" (which was most of the article) to point to the wrong place. (There is an item "<includeonly></includeonly>" in the edit toolbar. Interestingly includeonly causes this problem while noinclude does not, as can be shown by:

ayg wrote:

r29292 looks to fix this, but Tim isn't sure if it will stick.