X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fparser%2FParserOutput.php;h=7bf848fb90929254258ad9b7c2e0cb7bdd78cda3;hb=96491f80d3481190605006c71a8421857adda58e;hp=d2ef5e303918e1593f577c3d52d1cee50ff47ccc;hpb=2fdcd7bfdd95a3b1515b9a94289d67eb60add484;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index d2ef5e3039..7bf848fb90 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -193,6 +193,9 @@ class ParserOutput extends CacheTime { */ private $mLimitReportData = []; + /** @var array Parser limit report data for JSON */ + private $mLimitReportJSData = []; + /** * @var array $mParseStartTime Timestamps for getTimeSinceStart(). */ @@ -215,7 +218,7 @@ class ParserOutput extends CacheTime { private $mMaxAdaptiveExpiry = INF; const EDITSECTION_REGEX = - '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#'; + '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#s'; // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL) // Current values imply that m=3933.333333 and b=-333.333333 @@ -411,6 +414,10 @@ class ParserOutput extends CacheTime { return $this->mLimitReportData; } + public function getLimitReportJSData() { + return $this->mLimitReportJSData; + } + public function getTOCEnabled() { return $this->mTOCEnabled; } @@ -823,7 +830,6 @@ class ParserOutput extends CacheTime { * @code * $parser->getOutput()->my_ext_foo = '...'; * @endcode - * */ public function setProperty( $name, $value ) { $this->mProperties[$name] = $value; @@ -1011,6 +1017,26 @@ class ParserOutput extends CacheTime { */ public function setLimitReportData( $key, $value ) { $this->mLimitReportData[$key] = $value; + + if ( is_array( $value ) ) { + if ( array_keys( $value ) === [ 0, 1 ] + && is_numeric( $value[0] ) + && is_numeric( $value[1] ) + ) { + $data = [ 'value' => $value[0], 'limit' => $value[1] ]; + } else { + $data = $value; + } + } else { + $data = $value; + } + + if ( strpos( $key, '-' ) ) { + list( $ns, $name ) = explode( '-', $key, 2 ); + $this->mLimitReportJSData[$ns][$name] = $data; + } else { + $this->mLimitReportJSData[$key] = $data; + } } /**