# at least one character of a host name (embeds EXT_LINK_URL_CLASS)
const EXT_LINK_ADDR = '(?:[0-9.]+|\\[(?i:[0-9a-f:.]+)\\]|[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}])';
# RegExp to make image URLs (embeds IPv6 part of EXT_LINK_ADDR)
- // @codingStandardsIgnoreStart Generic.Files.LineLength
+ // phpcs:ignore Generic.Files.LineLength
const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)((?:\\[(?i:[0-9a-f:.]+)\\])?[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]+)
\\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sxu';
- // @codingStandardsIgnoreEnd
# Regular expression for a non-newline space
const SPACE_NOT_NL = '(?:\t| |&\#0*160;|&\#[Xx]0*[Aa]0;|\p{Zs})';
$this->mPreprocessorClass = $conf['preprocessorClass'];
} elseif ( defined( 'HPHP_VERSION' ) ) {
# Preprocessor_Hash is much faster than Preprocessor_DOM under HipHop
- $this->mPreprocessorClass = 'Preprocessor_Hash';
+ $this->mPreprocessorClass = Preprocessor_Hash::class;
} elseif ( extension_loaded( 'domxml' ) ) {
# PECL extension that conflicts with the core DOM extension (T15770)
wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" );
- $this->mPreprocessorClass = 'Preprocessor_Hash';
+ $this->mPreprocessorClass = Preprocessor_Hash::class;
} elseif ( extension_loaded( 'dom' ) ) {
- $this->mPreprocessorClass = 'Preprocessor_DOM';
+ $this->mPreprocessorClass = Preprocessor_DOM::class;
} else {
- $this->mPreprocessorClass = 'Preprocessor_Hash';
+ $this->mPreprocessorClass = Preprocessor_Hash::class;
}
wfDebug( __CLASS__ . ": using preprocessor: {$this->mPreprocessorClass}\n" );
}
$useSubpages = $this->areSubpagesAllowed();
- // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
# Loop for each link
for ( ; $line !== false && $line !== null; $a->next(), $line = $a->current() ) {
- // @codingStandardsIgnoreEnd
-
# Check for excessive memory usage
if ( $holders->isBig() ) {
# Too big
}
// Extract any forwarded flags
+ if ( isset( $result['title'] ) ) {
+ $title = $result['title'];
+ }
if ( isset( $result['found'] ) ) {
$found = $result['found'];
}
$deps = [];
# Loop to fetch the article, with up to 1 redirect
- // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
+ // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) {
- // @codingStandardsIgnoreEnd
# Give extensions a chance to select the revision instead
$id = false; # Assume current
Hooks::run( 'BeforeParserFetchTemplateAndtitle',
# Inhibit editsection links if requested in the page
if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
- $maybeShowEditLink = $showEditLink = false;
+ $maybeShowEditLink = false;
} else {
- $maybeShowEditLink = true; /* Actual presence will depend on ParserOptions option */
- $showEditLink = $this->mOptions->getEditSection();
- }
- if ( $showEditLink ) {
- $this->mOutput->setEditSectionTokens( true );
+ $maybeShowEditLink = true; /* Actual presence will depend on post-cache transforms */
}
# Get all headlines for numbering them and adding funky stuff like [edit]
$anchor = $safeHeadline;
$fallbackAnchor = $fallbackHeadline;
if ( isset( $refers[$arrayKey] ) ) {
- // @codingStandardsIgnoreStart
+ // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall,Generic.Formatting.DisallowMultipleStatements
for ( $i = 2; isset( $refers["${arrayKey}_$i"] ); ++$i );
- // @codingStandardsIgnoreEnd
$anchor .= "_$i";
$linkAnchor .= "_$i";
$refers["${arrayKey}_$i"] = true;
$refers[$arrayKey] = true;
}
if ( $fallbackHeadline !== false && isset( $refers[$fallbackArrayKey] ) ) {
- // @codingStandardsIgnoreStart
+ // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall,Generic.Formatting.DisallowMultipleStatements
for ( $i = 2; isset( $refers["${fallbackArrayKey}_$i"] ); ++$i );
- // @codingStandardsIgnoreEnd
$fallbackAnchor .= "_$i";
$refers["${fallbackArrayKey}_$i"] = true;
} else {
* $this : caller
* $section : the section number
* &$sectionContent : ref to the content of the section
- * $showEditLinks : boolean describing whether this section has an edit link
+ * $maybeShowEditLinks : boolean describing whether this section has an edit link
*/
- Hooks::run( 'ParserSectionCreate', [ $this, $i, &$sections[$i], $showEditLink ] );
+ Hooks::run( 'ParserSectionCreate', [ $this, $i, &$sections[$i], $maybeShowEditLink ] );
$i++;
}
# Special case; width and height come in one variable together
if ( $type === 'handler' && $paramName === 'width' ) {
- $parsedWidthParam = $this->parseWidthParam( $value );
+ $parsedWidthParam = self::parseWidthParam( $value );
if ( isset( $parsedWidthParam['width'] ) ) {
$width = $parsedWidthParam['width'];
if ( $handler->validateParam( 'width', $width ) ) {
global $wgFragmentMode;
if ( isset( $wgFragmentMode[1] ) && $wgFragmentMode[1] === 'legacy' ) {
// ForAttribute() and ForLink() are the same for legacy encoding
- $id = Sanitizer::escapeIdForAttribute( $text, Sanitizer::ID_FALLBACK );
+ $id = Sanitizer::escapeIdForAttribute( $sectionName, Sanitizer::ID_FALLBACK );
} else {
- $id = Sanitizer::escapeIdForLink( $text );
+ $id = Sanitizer::escapeIdForLink( $sectionName );
}
return "#$id";
* Parsed a width param of imagelink like 300px or 200x300px
*
* @param string $value
+ * @param bool $parseHeight
*
* @return array
* @since 1.20
*/
- public function parseWidthParam( $value ) {
+ public static function parseWidthParam( $value, $parseHeight = true ) {
$parsedWidthParam = [];
if ( $value === '' ) {
return $parsedWidthParam;
$m = [];
# (T15500) In both cases (width/height and width only),
# permit trailing "px" for backward compatibility.
- if ( preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
+ if ( $parseHeight && preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
$width = intval( $m[1] );
$height = intval( $m[2] );
$parsedWidthParam['width'] = $width;