dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Let deduplicateRootJob() accept JobSpecification for consistency"
[lhc/web/wiklou.git]
/
includes
/
parser
/
StripState.php
diff --git
a/includes/parser/StripState.php
b/includes/parser/StripState.php
index
5d1743e
..
b11dc8c
100644
(file)
--- a/
includes/parser/StripState.php
+++ b/
includes/parser/StripState.php
@@
-37,15
+37,20
@@
class StripState {
const UNSTRIP_RECURSION_LIMIT = 20;
/**
const UNSTRIP_RECURSION_LIMIT = 20;
/**
- * @param string $prefix
+ * @param string|null $prefix
+ * @since 1.26 The prefix argument should be omitted, as the strip marker
+ * prefix string is now a constant.
*/
*/
- public function __construct( $prefix ) {
- $this->prefix = $prefix;
+ public function __construct( $prefix = null ) {
+ if ( $prefix !== null ) {
+ wfDeprecated( __METHOD__ . ' with called with $prefix argument' .
+ ' (call with no arguments instead)', '1.26' );
+ }
$this->data = array(
'nowiki' => array(),
'general' => array()
);
$this->data = array(
'nowiki' => array(),
'general' => array()
);
- $this->regex =
"/{$this->prefix}
([^\x7f]+)" . Parser::MARKER_SUFFIX . '/';
+ $this->regex =
'/' . Parser::MARKER_PREFIX . "
([^\x7f]+)" . Parser::MARKER_SUFFIX . '/';
$this->circularRefGuard = array();
}
$this->circularRefGuard = array();
}
@@
-117,12
+122,10
@@
class StripState {
return $text;
}
return $text;
}
- wfProfileIn( __METHOD__ );
$oldType = $this->tempType;
$this->tempType = $type;
$text = preg_replace_callback( $this->regex, array( $this, 'unstripCallback' ), $text );
$this->tempType = $oldType;
$oldType = $this->tempType;
$this->tempType = $type;
$text = preg_replace_callback( $this->regex, array( $this, 'unstripCallback' ), $text );
$this->tempType = $oldType;
- wfProfileOut( __METHOD__ );
return $text;
}
return $text;
}
@@
-146,7
+149,11
@@
class StripState {
}
$this->circularRefGuard[$marker] = true;
$this->recursionLevel++;
}
$this->circularRefGuard[$marker] = true;
$this->recursionLevel++;
- $ret = $this->unstripType( $this->tempType, $this->data[$this->tempType][$marker] );
+ $value = $this->data[$this->tempType][$marker];
+ if ( $value instanceof Closure ) {
+ $value = $value();
+ }
+ $ret = $this->unstripType( $this->tempType, $value );
$this->recursionLevel--;
unset( $this->circularRefGuard[$marker] );
return $ret;
$this->recursionLevel--;
unset( $this->circularRefGuard[$marker] );
return $ret;
@@
-164,10
+171,10
@@
class StripState {
* @return StripState
*/
public function getSubState( $text ) {
* @return StripState
*/
public function getSubState( $text ) {
- $subState = new StripState(
$this->prefix
);
+ $subState = new StripState();
$pos = 0;
while ( true ) {
$pos = 0;
while ( true ) {
- $startPos = strpos( $text,
$this->prefix
, $pos );
+ $startPos = strpos( $text,
Parser::MARKER_PREFIX
, $pos );
$endPos = strpos( $text, Parser::MARKER_SUFFIX, $pos );
if ( $startPos === false || $endPos === false ) {
break;
$endPos = strpos( $text, Parser::MARKER_SUFFIX, $pos );
if ( $startPos === false || $endPos === false ) {
break;
@@
-200,7
+207,7
@@
class StripState {
* @return array
*/
public function merge( $otherState, $texts ) {
* @return array
*/
public function merge( $otherState, $texts ) {
- $mergePrefix =
Parser::getRandomString(
);
+ $mergePrefix =
wfRandomString( 16
);
foreach ( $otherState->data as $type => $items ) {
foreach ( $items as $key => $value ) {
foreach ( $otherState->data as $type => $items ) {
foreach ( $items as $key => $value ) {
@@
-220,7
+227,7
@@
class StripState {
*/
protected function mergeCallback( $m ) {
$key = $m[1];
*/
protected function mergeCallback( $m ) {
$key = $m[1];
- return
"{$this->prefix}{$this->tempMergePrefix}-$key"
. Parser::MARKER_SUFFIX;
+ return
Parser::MARKER_PREFIX . $this->tempMergePrefix . '-' . $key
. Parser::MARKER_SUFFIX;
}
/**
}
/**