From 6f5b761fe7880a6fe48a1c4e0ebc92efd54bd050 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Wed, 15 Nov 2023 14:15:25 -0600 Subject: [PATCH] fix(core): let makeSections xpath query cope with multiple classes (#733) * Let makeSections xpath query cope with multiple classes As-of https://gerrit.wikimedia.org/r/c/mediawiki/core/+/939783 in mediawiki-core, this class attribute is going to contain multiple classes. This would break the section-creation. This change to the query is backwards-compatible, so this should just inoculate the skin against future updates. * Shorten line for mediawiki-lint compatibility * fix: update html selector for parser output Related: T350627 --------- Co-authored-by: alistair3149 --- includes/Partials/BodyContent.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/Partials/BodyContent.php b/includes/Partials/BodyContent.php index ab55615f..bb4bdacb 100644 --- a/includes/Partials/BodyContent.php +++ b/includes/Partials/BodyContent.php @@ -132,7 +132,10 @@ final class BodyContent extends Partial { */ private function makeSections( DOMDocument $doc, array $headingWrappers ) { $xpath = new DOMXpath( $doc ); - $containers = $xpath->query( '//div[@class="mw-parser-output"][1]' ); + $containers = $xpath->query( + // Equivalent of CSS attribute `~=` to support multiple classes + '//div[contains(concat(" ",normalize-space(@class)," ")," mw-parser-output ")][1]' + ); // Return if no parser output is found if ( !$containers->length || $containers->item( 0 ) === null ) {