Caused by T255586
Steps to Reproduce
- Navigate to the wiki’s main page, or create any page that contains HTML content, for example:
<div class="testing-task-phab-400401"> </div>
- Access the mobile view by visiting /w/index.php?title=Main_Page&mobileaction=toggle_view_mobile
- The error occurs during page rendering
Actual Results
A TypeError is thrown with the following message:
TypeError: MobileFrontend\Transforms\RemovableClassesTransform::apply(): Argument #1 ($node) must be of type DOMElement, Dom\HTMLElement given, called in extensions/MobileFrontend/includes/MobileFormatter.php on line 32
Full stack trace:
from extensions/MobileFrontend/includes/Transforms/RemovableClassesTransform.php(23)
#0 extensions/MobileFrontend/includes/MobileFormatter.php(32): MobileFrontend\Transforms\RemovableClassesTransform->apply()
#1 extensions/MobileFrontend/includes/ExtMobileFrontend.php(173): MobileFormatter->applyTransforms()
#2 extensions/MobileFrontend/includes/ExtMobileFrontend.php(75): ExtMobileFrontend::domParseMobile()
#3 extensions/MobileFrontend/includes/MobileFrontendHooks.php(357): ExtMobileFrontend::domParseWithContentProvider()
#4 includes/HookContainer/HookContainer.php(155): MobileFrontendHooks->onOutputPageBeforeHTML()
#5 includes/HookContainer/HookRunner.php(2783): MediaWiki\HookContainer\HookContainer->run()
#6 includes/Output/OutputPage.php(2633): MediaWiki\HookContainer\HookRunner->onOutputPageBeforeHTML()
#7 includes/Output/OutputPage.php(2661): MediaWiki\Output\OutputPage->addParserOutputText()
#8 includes/page/Article.php(931): MediaWiki\Output\OutputPage->addParserOutput()
#9 includes/page/Article.php(739): MediaWiki\Page\Article->doOutputFromParserCache()
#10 includes/page/Article.php(551): MediaWiki\Page\Article->generateContentOutput()
#11 includes/actions/ViewAction.php(84): MediaWiki\Page\Article->view()
#12 includes/actions/ActionEntryPoint.php(728): MediaWiki\Actions\ViewAction->show()
#13 includes/actions/ActionEntryPoint.php(505): MediaWiki\Actions\ActionEntryPoint->performAction()
#14 includes/actions/ActionEntryPoint.php(143): MediaWiki\Actions\ActionEntryPoint->performRequest()
#15 includes/MediaWikiEntryPoint.php(198): MediaWiki\Actions\ActionEntryPoint->execute()
#16 index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#17 {main}Expected Results
The mobile view should load normally without any TypeError, displaying the main page in mobile format.
Environment
- MediaWiki version: master (a336ef72a24bca53702f4b1fa9e76fbb46a16428)
- PHP version: 8.4.11
- MobileFrontend extension version: master (0b6bf3797333ebbb7641db42d6a29078a1f5724a)
- Browser: Chrome v139
Analysis
The error occurs because RemovableClassesTransform::apply() expects a DOMElement but receives a Dom\HTMLElement instead. This suggests a type compatibility issue, possibly related to recent changes in MediaWiki's DOM handling or PHP 8.4 compatibility.
The issue appears to be in the type of declaration mismatch between what's being passed from MobileFormatter and what RemovableClassesTransform expects to receive.