*/
private $mLimitReportData = [];
+ /** @var array Parser limit report data for JSON */
+ private $mLimitReportJSData = [];
+
/**
* @var array $mParseStartTime Timestamps for getTimeSinceStart().
*/
*/
private $mFlags = [];
- /** @var integer|null Assumed rev ID for {{REVISIONID}} if no revision is set */
+ /** @var int|null Assumed rev ID for {{REVISIONID}} if no revision is set */
private $mSpeculativeRevId;
- /** @var integer Upper bound of expiry based on parse duration */
+ /** @var int Upper bound of expiry based on parse duration */
private $mMaxAdaptiveExpiry = INF;
const EDITSECTION_REGEX =
- '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
+ '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s';
// finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL)
// Current values imply that m=3933.333333 and b=-333.333333
$text = $this->mText;
if ( $this->mEditSectionTokens ) {
$text = preg_replace_callback(
- ParserOutput::EDITSECTION_REGEX,
+ self::EDITSECTION_REGEX,
function ( $m ) {
global $wgOut, $wgLang;
$editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) );
$text
);
} else {
- $text = preg_replace( ParserOutput::EDITSECTION_REGEX, '', $text );
+ $text = preg_replace( self::EDITSECTION_REGEX, '', $text );
}
// If you have an old cached version of this class - sorry, you can't disable the TOC
}
/**
- * @param integer $id
+ * @param int $id
* @since 1.28
*/
public function setSpeculativeRevIdUsed( $id ) {
return $this->mLimitReportData;
}
+ public function getLimitReportJSData() {
+ return $this->mLimitReportJSData;
+ }
+
public function getTOCEnabled() {
return $this->mTOCEnabled;
}
# We don't register links pointing to our own server, unless... :-)
global $wgServer, $wgRegisterInternalExternals;
+ # Replace unnecessary URL escape codes with the referenced character
+ # This prevents spammers from hiding links from the filters
+ $url = parser::normalizeLinkUrl( $url );
+
$registerExternalLink = true;
if ( !$wgRegisterInternalExternals ) {
$registerExternalLink = !self::isLinkInternal( $wgServer, $url );
* to SpecialTrackingCategories::$coreTrackingCategories, and extensions
* should add to "TrackingCategories" in their extension.json.
*
+ * @todo Migrate some code to TrackingCategories
+ *
* @param string $msg Message key
* @param Title $title title of the page which is being tracked
* @return bool Whether the addition was successful
* @since 1.25
*/
public function addTrackingCategory( $msg, $title ) {
- if ( $title->getNamespace() === NS_SPECIAL ) {
+ if ( $title->isSpecialPage() ) {
wfDebug( __METHOD__ . ": Not adding tracking category $msg to special page!\n" );
return false;
}
- // Important to parse with correct title (bug 31469)
+ // Important to parse with correct title (T33469)
$cat = wfMessage( $msg )
->title( $title )
->inContentLanguage()
*/
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;
+ }
}
/**
/**
* Lower the runtime adaptive TTL to at most this value
*
- * @param integer $ttl
+ * @param int $ttl
* @since 1.28
*/
public function updateRuntimeAdaptiveExpiry( $ttl ) {