Since this bug appeared while implementing the lead paragraph moving there is concern the number of errors may escalate upon rolling this out everywhere.
[[ https://logstash.wikimedia.org/app/kibana#/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-7d,mode:quick,to:now))&_a=(columns:!(_source),index:'logstash-*',interval:auto,query:(query_string:(analyze_wildcard:!t,query:'(message:MobileFrontend%20OR%20message:Popups%20OR%20message:TextExtracts%20OR%20message:PageImages%20OR%20message:RelatedArticles%20OR%20message:QuickSurveys%20OR%20message:Cards%20%20OR%20message:WikidataPageBanner)%20AND%20message:%22Invalid%20State%20Error%22%20AND%20wiki:enwiki')),sort:!('@timestamp',desc)) | logstash ]] is complaining:
```
Warning: Invalid State Error in /srv/mediawiki/php-1.29.0-wmf.3/extensions/MobileFrontend/includes/MobileFormatter.php on line 667
Warning: Invalid State Error in /srv/mediawiki/php-1.29.0-wmf.3/extensions/MobileFrontend/includes/MobileFormatter.php on line 673
```
This seems to relate to code in MobileFormatter::makeHeadingsEditable where we call setAttribute
Stack trace:
```
0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.29.0-wmf.18/extensions/MobileFrontend/includes/MobileFormatter.php(672): DOMElement->setAttribute(string, string)
#2 /srv/mediawiki/php-1.29.0-wmf.18/extensions/MobileFrontend/includes/MobileFormatter.php(178): MobileFormatter->makeHeadingsEditable(array)
#3 /srv/mediawiki/php-1.29.0-wmf.18/extensions/MobileFrontend/includes/MobileFrontend.body.php(72): MobileFormatter->filterContent(boolean, boolean, boolean, boolean)
#4 /srv/mediawiki/php-1.29.0-wmf.18/extensions/MobileFrontend/includes/MobileFrontend.hooks.php(197): ExtMobileFrontend::DOMParse(OutputPage, string)
#5 /srv/mediawiki/php-1.29.0-wmf.18/includes/Hooks.php(186): MobileFrontendHooks::onOutputPageBeforeHTML(OutputPage, string)
#6 /srv/mediawiki/php-1.29.0-wmf.18/includes/OutputPage.php(1874): Hooks::run(string, array)
#7 /srv/mediawiki/php-1.29.0-wmf.18/includes/OutputPage.php(1892): OutputPage->addParserOutputText(ParserOutput)
#8 /srv/mediawiki/php-1.29.0-wmf.18/includes/page/Article.php(537): OutputPage->addParserOutput(ParserOutput)
#9 /srv/mediawiki/php-1.29.0-wmf.18/includes/actions/ViewAction.php(71): Article->view()
#10 /srv/mediawiki/php-1.29.0-wmf.18/includes/MediaWiki.php(497): ViewAction->show()
#11 /srv/mediawiki/php-1.29.0-wmf.18/includes/MediaWiki.php(291): MediaWiki->performAction(Article, Title)
#12 /srv/mediawiki/php-1.29.0-wmf.18/includes/MediaWiki.php(860): MediaWiki->performRequest()
#13 /srv/mediawiki/php-1.29.0-wmf.18/includes/MediaWiki.php(521): MediaWiki->main()
#14 /srv/mediawiki/php-1.29.0-wmf.18/index.php(43): MediaWiki->run()
#15 /srv/mediawiki/w/index.php(3): include(string)
#16 {main}
```
Frequency: ~20 per day
{F4881392}
{F4881393}
== (Expected) Outcomes
[x] We log the title of the article that's being parsed in an easily found error message.
* e.g. prefix it with T151838.
[] The nature of the error is well understood and the error itself is fixed.
== Example Articles
https://en.wikipedia.org/wiki/Schopenhauer
https://en.wikipedia.org/wiki/Bahri_dynasty
https://es.wikipedia.org/wiki/Altos_Hornos_de_M%C3%A9xico
== Replication instructions
Ensure lazy loaded references is enabled in beta mode
```
$wgMFLazyLoadReferences = array(
'useMobileViewApi' => true,
'base' => false,
'beta' => true,
);
$wgMFRemovableClasses = [
'base' => [ '.navbox', '.nomobile' ],
'beta' => [ '.navbox', '.nomobile' ],
'HTML' => [],
];
Check out [[ https://gerrit.wikimedia.org/r/#/c/349131/ | the magic patch ]] to load content directly from Wikipedia
Navigate to http://localhost:8888/w/index.php/Arthur_Schopenhauer?mobileaction=beta to see the error
```
== QA
This task can't be QA'd directly and can skip the **Needs QA** column.