Parser: Call firstCallInit() in getTags/getFunctionHooks
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 14 Aug 2018 05:49:53 +0000 (22:49 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 14 Aug 2018 21:16:42 +0000 (14:16 -0700)
So callers don't need to do this manually. Pointed out by Tim in T201799.

Depends-On: Ia6c36d5a650095e35093bf47e275e081e89b3daf
Change-Id: Ida62767f3ca53f99609cae01d3a20051bb92ccab

includes/api/ApiQuerySiteinfo.php
includes/parser/Parser.php
tests/phpunit/includes/api/ApiQuerySiteinfoTest.php

index c26bb62..eaa3bc1 100644 (file)
@@ -784,7 +784,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function appendExtensionTags( $property ) {
                global $wgParser;
-               $wgParser->firstCallInit();
                $tags = array_map(
                        function ( $item ) {
                                return "<$item>";
@@ -799,7 +798,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function appendFunctionHooks( $property ) {
                global $wgParser;
-               $wgParser->firstCallInit();
                $hooks = $wgParser->getFunctionHooks();
                ApiResult::setArrayType( $hooks, 'BCarray' );
                ApiResult::setIndexedTagName( $hooks, 'h' );
index b1e3928..1fc2f92 100644 (file)
@@ -4926,6 +4926,7 @@ class Parser {
         * @return array
         */
        public function getFunctionHooks() {
+               $this->firstCallInit();
                return array_keys( $this->mFunctionHooks );
        }
 
@@ -5482,6 +5483,7 @@ class Parser {
         * @return array
         */
        public function getTags() {
+               $this->firstCallInit();
                return array_merge(
                        array_keys( $this->mTransparentTagHooks ),
                        array_keys( $this->mTagHooks ),
index 7b93571..fe2058f 100644 (file)
@@ -571,7 +571,6 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
        public function testExtensionTags() {
                global $wgParser;
 
-               $wgParser->firstCallInit();
                $expected = array_map(
                        function ( $tag ) {
                                return "<$tag>";
@@ -585,7 +584,6 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
        public function testFunctionHooks() {
                global $wgParser;
 
-               $wgParser->firstCallInit();
                $this->assertSame( $wgParser->getFunctionHooks(), $this->doQuery( 'functionhooks' ) );
        }