Bump 1.25
[lhc/web/wiklou.git] / includes / parser / ParserOutput.php
index 75fc01f..5037ce1 100644 (file)
@@ -50,13 +50,13 @@ class ParserOutput extends CacheTime {
                $mTOCHTML = '',               # HTML of the TOC
                $mTimestamp,                  # Timestamp of the revision
                $mTOCEnabled = true;          # Whether TOC should be shown, can't override __NOTOC__
-               private $mIndexPolicy = '';       # 'index' or 'noindex'?  Any other value will result in no change.
-               private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
-               private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
-               private $mExtensionData = array(); # extra data used by extensions
-               private $mLimitReportData = array(); # Parser limit report data
-               private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
-               private $mPreventClickjacking = false; # Whether to emit X-Frame-Options: DENY
+       private $mIndexPolicy = '';       # 'index' or 'noindex'?  Any other value will result in no change.
+       private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
+       private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
+       private $mExtensionData = array(); # extra data used by extensions
+       private $mLimitReportData = array(); # Parser limit report data
+       private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
+       private $mPreventClickjacking = false; # Whether to emit X-Frame-Options: DENY
 
        const EDITSECTION_REGEX =
                '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
@@ -75,8 +75,27 @@ class ParserOutput extends CacheTime {
                wfProfileIn( __METHOD__ );
                $text = $this->mText;
                if ( $this->mEditSectionTokens ) {
-                       $text = preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
-                               array( &$this, 'replaceEditSectionLinksCallback' ), $text );
+                       $text = preg_replace_callback(
+                               ParserOutput::EDITSECTION_REGEX,
+                               function ( $m ) {
+                                       global $wgOut, $wgLang;
+                                       $editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) );
+                                       $editsectionSection = htmlspecialchars_decode( $m[2] );
+                                       $editsectionContent = isset( $m[4] ) ? $m[3] : null;
+
+                                       if ( !is_object( $editsectionPage ) ) {
+                                               throw new MWException( "Bad parser output text." );
+                                       }
+
+                                       $skin = $wgOut->getSkin();
+                                       return call_user_func_array(
+                                               array( $skin, 'doEditSectionLink' ),
+                                               array( $editsectionPage, $editsectionSection,
+                                                       $editsectionContent, $wgLang->getCode() )
+                                       );
+                               },
+                               $text
+                       );
                } else {
                        $text = preg_replace( ParserOutput::EDITSECTION_REGEX, '', $text );
                }
@@ -95,29 +114,6 @@ class ParserOutput extends CacheTime {
                return $text;
        }
 
-       /**
-        * callback used by getText to replace editsection tokens
-        * @private
-        * @param array $m
-        * @throws MWException
-        * @return mixed
-        */
-       public function replaceEditSectionLinksCallback( $m ) {
-               global $wgOut, $wgLang;
-               $args = array(
-                       htmlspecialchars_decode( $m[1] ),
-                       htmlspecialchars_decode( $m[2] ),
-                       isset( $m[4] ) ? $m[3] : null,
-               );
-               $args[0] = Title::newFromText( $args[0] );
-               if ( !is_object( $args[0] ) ) {
-                       throw new MWException( "Bad parser output text." );
-               }
-               $args[] = $wgLang->getCode();
-               $skin = $wgOut->getSkin();
-               return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args );
-       }
-
        public function &getLanguageLinks() {
                return $this->mLanguageLinks;
        }
@@ -737,10 +733,12 @@ class ParserOutput extends CacheTime {
                if ( !$clock || $clock === 'wall' ) {
                        $ret['wall'] = microtime( true );
                }
-               if ( ( !$clock || $clock === 'cpu' ) && function_exists( 'getrusage' ) ) {
-                       $ru = getrusage();
-                       $ret['cpu'] = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
-                       $ret['cpu'] += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
+               if ( !$clock || $clock === 'cpu' ) {
+                       $ru = wfGetRusage();
+                       if ( $ru ) {
+                               $ret['cpu'] = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
+                               $ret['cpu'] += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
+                       }
                }
                return $ret;
        }
@@ -809,6 +807,7 @@ class ParserOutput extends CacheTime {
 
        /**
         * Save space for for serialization by removing useless values
+        * @return array
         */
        public function __sleep() {
                return array_diff(