r81678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81677‎ | r81678 | r81679 >
Date:01:31, 8 February 2011
Author:dantman
Status:ok
Tags:
Comment:
Followup r81583, break some of the long lines and centralize the regex.
Modified paths:
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)
  • /trunk/phase3/includes/parser/Tidy.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Tidy.php
@@ -26,9 +26,11 @@
2727
2828 public function getWrapped( $text ) {
2929 $this->mTokens = new ReplacementArray;
30 - $this->mUniqPrefix = "\x7fUNIQ" . dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
 30+ $this->mUniqPrefix = "\x7fUNIQ" .
 31+ dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
3132 $this->mMarkerIndex = 0;
32 - $wrappedtext = preg_replace_callback( '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#', array( &$this, 'replaceEditSectionLinksCallback' ), $text );
 33+ $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
 34+ array( &$this, 'replaceEditSectionLinksCallback' ), $text );
3335
3436 $wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.
3537 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'.
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -125,6 +125,8 @@
126126 private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
127127 private $mAccessedOptions = null; # List of ParserOptions (stored in the keys)
128128
 129+ const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
 130+
129131 function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
130132 $containsOldMagic = false, $titletext = '' )
131133 {
@@ -137,7 +139,8 @@
138140
139141 function getText() {
140142 if ( $this->mEditSectionTokens ) {
141 - return preg_replace_callback( '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#', array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText );
 143+ return preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
 144+ array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText );
142145 }
143146 return $this->mText;
144147 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81583Switch <editsection> to <mw:editsection> and start hiding these editsection t...dantman01:38, 6 February 2011

Status & tagging log