From a63c25803686ff3085f6dbeb0a961aae1bbe5c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 3 Jun 2022 03:21:43 +0200 Subject: [PATCH] ApiParse: When querying TOC sections, also return whether it should be hidden The table of contents is supposed to be hidden when the page has less than 4 headings, but it can be overridden by several magic words. The API provided no way to find out if it should be shown or hidden for skins that don't use the built-in table of contents. Using getTOCHTML() to check this is weird, but the TOC code is currently enduring a rewrite, and this is how it's done in OutputPage. Bug: T294950 Bug: T310083 Change-Id: I6cf76c870124c162dc1bcbc2f7e9ca0c5fdcd10e --- includes/api/ApiParse.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 4480e28d4a3..e3bd790f637 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -571,6 +571,7 @@ class ApiParse extends ApiBase { } if ( isset( $prop['sections'] ) ) { $result_array['sections'] = $p_result->getSections(); + $result_array['hidetoc'] = !$p_result->getTOCHTML(); } if ( isset( $prop['parsewarnings'] ) ) { $result_array['parsewarnings'] = $p_result->getWarnings();