ApiQueryBase: Fix addWhereFld for PHP 7.2
[lhc/web/wiklou.git] / includes / OutputPage.php
index 4635f99..92963fd 100644 (file)
@@ -1573,10 +1573,14 @@ class OutputPage extends ContextSource {
         * Get/set the ParserOptions object to use for wikitext parsing
         *
         * @param ParserOptions|null $options Either the ParserOption to use or null to only get the
-        *   current ParserOption object
+        *   current ParserOption object. This parameter is deprecated since 1.31.
         * @return ParserOptions
         */
        public function parserOptions( $options = null ) {
+               if ( $options !== null ) {
+                       wfDeprecated( __METHOD__ . ' with non-null $options', '1.31' );
+               }
+
                if ( $options !== null && !empty( $options->isBogus ) ) {
                        // Someone is trying to set a bogus pre-$wgUser PO. Check if it has
                        // been changed somehow, and keep it if so.
@@ -1779,7 +1783,9 @@ class OutputPage extends ContextSource {
 
                $popts->setTidy( $oldTidy );
 
-               $this->addParserOutput( $parserOutput );
+               $this->addParserOutput( $parserOutput, [
+                       'enableSectionEditLinks' => false,
+               ] );
        }
 
        /**
@@ -1864,9 +1870,10 @@ class OutputPage extends ContextSource {
         *
         * @since 1.24
         * @param ParserOutput $parserOutput
+        * @param array $poOptions Options to ParserOutput::getText()
         */
-       public function addParserOutputContent( $parserOutput ) {
-               $this->addParserOutputText( $parserOutput );
+       public function addParserOutputContent( $parserOutput, $poOptions = [] ) {
+               $this->addParserOutputText( $parserOutput, $poOptions );
 
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
@@ -1880,9 +1887,10 @@ class OutputPage extends ContextSource {
         *
         * @since 1.24
         * @param ParserOutput $parserOutput
+        * @param array $poOptions Options to ParserOutput::getText()
         */
-       public function addParserOutputText( $parserOutput ) {
-               $text = $parserOutput->getText();
+       public function addParserOutputText( $parserOutput, $poOptions = [] ) {
+               $text = $parserOutput->getText( $poOptions );
                // Avoid PHP 7.1 warning of passing $this by reference
                $outputPage = $this;
                Hooks::runWithoutAbort( 'OutputPageBeforeHTML', [ &$outputPage, &$text ] );
@@ -1893,16 +1901,22 @@ class OutputPage extends ContextSource {
         * Add everything from a ParserOutput object.
         *
         * @param ParserOutput $parserOutput
+        * @param array $poOptions Options to ParserOutput::getText()
         */
-       function addParserOutput( $parserOutput ) {
+       function addParserOutput( $parserOutput, $poOptions = [] ) {
                $this->addParserOutputMetadata( $parserOutput );
 
                // Touch section edit links only if not previously disabled
                if ( $parserOutput->getEditSectionTokens() ) {
                        $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
                }
+               if ( !$this->mEnableSectionEditLinks
+                       && !array_key_exists( 'enableSectionEditLinks', $poOptions )
+               ) {
+                       $poOptions['enableSectionEditLinks'] = false;
+               }
 
-               $this->addParserOutputText( $parserOutput );
+               $this->addParserOutputText( $parserOutput, $poOptions );
        }
 
        /**
@@ -1953,7 +1967,9 @@ class OutputPage extends ContextSource {
                        $popts->setTargetLanguage( $oldLang );
                }
 
-               return $parserOutput->getText();
+               return $parserOutput->getText( [
+                       'enableSectionEditLinks' => false,
+               ] );
        }
 
        /**
@@ -3953,6 +3969,7 @@ class OutputPage extends ContextSource {
         * Enables/disables section edit links, doesn't override __NOEDITSECTION__
         * @param bool $flag
         * @since 1.23
+        * @deprecated since 1.31, use $poOptions to addParserOutput() instead.
         */
        public function enableSectionEditLinks( $flag = true ) {
                $this->mEnableSectionEditLinks = $flag;
@@ -3961,6 +3978,7 @@ class OutputPage extends ContextSource {
        /**
         * @return bool
         * @since 1.23
+        * @deprecated since 1.31, use $poOptions to addParserOutput() instead.
         */
        public function sectionEditLinksEnabled() {
                return $this->mEnableSectionEditLinks;