Page MenuHomePhabricator

Parsoid section IDs don't correspond to PHP section IDs when headings are transcluded
Closed, ResolvedPublic

Description

On https://en.wikipedia.org/w/index.php?title=User:ESanders_(WMF)/sandbox&oldid=877762681, the bottom heading ("Heading 2") has a section id of 2 in PHP (see section edit URL), but in Parsoid it has a section ID of 5 (https://en.wikipedia.org/api/rest_v1/page/html/User%3AESanders_(WMF)%2Fsandbox?redirect=false)

The DOM spec claims "The data-mw-section-id attribute will either be "0" or greater and correspond exactly to a PHP section ID (as used for action=edit for example)"

Related Objects

Event Timeline

Change 483490 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/services/parsoid@master] WIP DRAFT HACK HACK HACK: transcluded sections don't get PHP section numbers

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

Change 483490 merged by jenkins-bot:
[mediawiki/services/parsoid@master] PHP section numbers are assigned during tokenization

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

Arlolra assigned this task to cscott.
Arlolra subscribed.

https://en.wikipedia.org/api/rest_v1/page/html/User:ESanders_(WMF)%2Fsandbox/877762681 now has,

<section data-mw-section-id="0" id="mwAQ"><p id="mwAg">Lede</p>

</section><section data-mw-section-id="1" id="mwAw"><h2 id="Heading_1">Heading 1</h2>
<p id="mwBA">Section 1</p>

</section><section data-mw-section-id="-1" id="mwBQ"><h2 about="#mwt1" typeof="mw:Transclusion" id="Transcluded_section" data-mw='{"parts":[{"template":{"target":{"wt":":User:ESanders (WMF)/sandbox/section","href":"./User:ESanders_(WMF)/sandbox/section"},"params":{},"i":0}}]}'>Transcluded section</h2><span about="#mwt1">
</span><p about="#mwt1">Content</p>
</section><section data-mw-section-id="-1" id="mwBg"><h2 about="#mwt2" typeof="mw:Transclusion" id="Transcluded_section_2" data-mw='{"parts":[{"template":{"target":{"wt":":User:ESanders (WMF)/sandbox/section","href":"./User:ESanders_(WMF)/sandbox/section"},"params":{},"i":0}}]}'>Transcluded section</h2><span about="#mwt2">
</span><p about="#mwt2">Content</p>
</section><section data-mw-section-id="-1" id="mwBw"><h2 about="#mwt3" typeof="mw:Transclusion" id="Transcluded_section_3" data-mw='{"parts":[{"template":{"target":{"wt":":User:ESanders (WMF)/sandbox/section","href":"./User:ESanders_(WMF)/sandbox/section"},"params":{},"i":0}}]}'>Transcluded section</h2><span about="#mwt3">
</span><p about="#mwt3">Content</p>

</section><section data-mw-section-id="2" id="mwCA"><h2 id="Heading_2">Heading 2</h2>
<p id="mwCQ">Section 2</p></section>