Page MenuHomePhabricator

Remex does not use \DOMElement::setIdAttribute('id') by default
Open, Needs TriagePublic

Description

PHP requires you to call $el->setIdAttribute('id') after creating *each* \DOMElement in order for DOMDocument::getElementById() to execute efficiently.

Event Timeline

cscott created this task.Mon, Sep 9, 8:28 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMon, Sep 9, 8:28 PM
cscott renamed this task from Remex does not use \DOMDocument::setIdAttribute('id') by default to Remex does not use \DOMElement::setIdAttribute('id') by default.Mon, Sep 9, 8:38 PM
cscott updated the task description. (Show Details)

Change 535289 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/services/parsoid@master] Use DOMElement::setIdAttribute() where necessary for efficiency

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

Change 535291 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/libs/RemexHtml@master] Call the non-standard \DOMElement::setIdAttribute() method by default

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

cscott added a comment.Mon, Sep 9, 9:36 PM

This is a workaround for https://bugs.php.net/bug.php?id=77686 and other issues related to inconsistent indexing behavior. See also the implementation of DOMCompat::getElementById in 10dedbbeb626aa614b5931c07035675e01590259 and the implementation of getElementById in Zest, for example in d118dcc45b803917e5e34d60712b893b3892d5ac, and the discussion in T215000#4993172 and T215000#4994273 and the PHP documentation in https://www.php.net/manual/en/domdocument.getelementbyid.php and https://www.php.net/manual/en/domelement.setidattribute.php

Change 535289 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Use DOMElement::setIdAttribute() where necessary for efficiency

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

Change 535291 merged by jenkins-bot:
[mediawiki/libs/RemexHtml@master] Call the non-standard \DOMElement::setIdAttribute() method by default

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