From f0fd318a4e0337ec47baf3d4b83372b99862dca3 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Tue, 8 Feb 2011 01:31:21 +0000 Subject: [PATCH] Followup r81583, break some of the long lines and centralize the regex. --- includes/parser/ParserOutput.php | 5 ++++- includes/parser/Tidy.php | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 80d53439d8..caac802f43 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -125,6 +125,8 @@ class ParserOutput extends CacheTime { private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. private $mAccessedOptions = null; # List of ParserOptions (stored in the keys) + const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#'; + function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(), $containsOldMagic = false, $titletext = '' ) { @@ -137,7 +139,8 @@ class ParserOutput extends CacheTime { function getText() { if ( $this->mEditSectionTokens ) { - return preg_replace_callback( '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#', array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText ); + return preg_replace_callback( ParserOutput::EDITSECTION_REGEX, + array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText ); } return $this->mText; } diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php index 2988f3e399..d2b58f6064 100644 --- a/includes/parser/Tidy.php +++ b/includes/parser/Tidy.php @@ -26,9 +26,11 @@ class MWTidyWrapper { public function getWrapped( $text ) { $this->mTokens = new ReplacementArray; - $this->mUniqPrefix = "\x7fUNIQ" . dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ); + $this->mUniqPrefix = "\x7fUNIQ" . + dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ); $this->mMarkerIndex = 0; - $wrappedtext = preg_replace_callback( '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#', array( &$this, 'replaceEditSectionLinksCallback' ), $text ); + $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, + array( &$this, 'replaceEditSectionLinksCallback' ), $text ); $wrappedtext = ''. -- 2.20.1