MediaWiki  1.23.1
Preprocessor_Hash.php
Go to the documentation of this file.
1 <?php
30 class Preprocessor_Hash implements Preprocessor {
34  var $parser;
35 
36  const CACHE_VERSION = 1;
37 
38  function __construct( $parser ) {
39  $this->parser = $parser;
40  }
41 
45  function newFrame() {
46  return new PPFrame_Hash( $this );
47  }
48 
53  function newCustomFrame( $args ) {
54  return new PPCustomFrame_Hash( $this, $args );
55  }
56 
61  function newPartNodeArray( $values ) {
62  $list = array();
63 
64  foreach ( $values as $k => $val ) {
65  $partNode = new PPNode_Hash_Tree( 'part' );
66  $nameNode = new PPNode_Hash_Tree( 'name' );
67 
68  if ( is_int( $k ) ) {
69  $nameNode->addChild( new PPNode_Hash_Attr( 'index', $k ) );
70  $partNode->addChild( $nameNode );
71  } else {
72  $nameNode->addChild( new PPNode_Hash_Text( $k ) );
73  $partNode->addChild( $nameNode );
74  $partNode->addChild( new PPNode_Hash_Text( '=' ) );
75  }
76 
77  $valueNode = new PPNode_Hash_Tree( 'value' );
78  $valueNode->addChild( new PPNode_Hash_Text( $val ) );
79  $partNode->addChild( $valueNode );
80 
81  $list[] = $partNode;
82  }
83 
84  $node = new PPNode_Hash_Array( $list );
85  return $node;
86  }
87 
111  function preprocessToObj( $text, $flags = 0 ) {
112  wfProfileIn( __METHOD__ );
113 
114  // Check cache.
115  global $wgMemc, $wgPreprocessorCacheThreshold;
116 
117  $cacheable = $wgPreprocessorCacheThreshold !== false && strlen( $text ) > $wgPreprocessorCacheThreshold;
118  if ( $cacheable ) {
119  wfProfileIn( __METHOD__ . '-cacheable' );
120 
121  $cacheKey = wfMemcKey( 'preprocess-hash', md5( $text ), $flags );
122  $cacheValue = $wgMemc->get( $cacheKey );
123  if ( $cacheValue ) {
124  $version = substr( $cacheValue, 0, 8 );
125  if ( intval( $version ) == self::CACHE_VERSION ) {
126  $hash = unserialize( substr( $cacheValue, 8 ) );
127  // From the cache
128  wfDebugLog( "Preprocessor",
129  "Loaded preprocessor hash from memcached (key $cacheKey)" );
130  wfProfileOut( __METHOD__ . '-cacheable' );
131  wfProfileOut( __METHOD__ );
132  return $hash;
133  }
134  }
135  wfProfileIn( __METHOD__ . '-cache-miss' );
136  }
137 
138  $rules = array(
139  '{' => array(
140  'end' => '}',
141  'names' => array(
142  2 => 'template',
143  3 => 'tplarg',
144  ),
145  'min' => 2,
146  'max' => 3,
147  ),
148  '[' => array(
149  'end' => ']',
150  'names' => array( 2 => null ),
151  'min' => 2,
152  'max' => 2,
153  )
154  );
155 
156  $forInclusion = $flags & Parser::PTD_FOR_INCLUSION;
157 
158  $xmlishElements = $this->parser->getStripList();
159  $enableOnlyinclude = false;
160  if ( $forInclusion ) {
161  $ignoredTags = array( 'includeonly', '/includeonly' );
162  $ignoredElements = array( 'noinclude' );
163  $xmlishElements[] = 'noinclude';
164  if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
165  $enableOnlyinclude = true;
166  }
167  } else {
168  $ignoredTags = array( 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' );
169  $ignoredElements = array( 'includeonly' );
170  $xmlishElements[] = 'includeonly';
171  }
172  $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) );
173 
174  // Use "A" modifier (anchored) instead of "^", because ^ doesn't work with an offset
175  $elementsRegex = "~($xmlishRegex)(?:\s|\/>|>)|(!--)~iA";
176 
177  $stack = new PPDStack_Hash;
178 
179  $searchBase = "[{<\n";
180  $revText = strrev( $text ); // For fast reverse searches
181  $lengthText = strlen( $text );
182 
183  $i = 0; # Input pointer, starts out pointing to a pseudo-newline before the start
184  $accum =& $stack->getAccum(); # Current accumulator
185  $findEquals = false; # True to find equals signs in arguments
186  $findPipe = false; # True to take notice of pipe characters
187  $headingIndex = 1;
188  $inHeading = false; # True if $i is inside a possible heading
189  $noMoreGT = false; # True if there are no more greater-than (>) signs right of $i
190  $findOnlyinclude = $enableOnlyinclude; # True to ignore all input up to the next <onlyinclude>
191  $fakeLineStart = true; # Do a line-start run without outputting an LF character
192 
193  while ( true ) {
194  //$this->memCheck();
195 
196  if ( $findOnlyinclude ) {
197  // Ignore all input up to the next <onlyinclude>
198  $startPos = strpos( $text, '<onlyinclude>', $i );
199  if ( $startPos === false ) {
200  // Ignored section runs to the end
201  $accum->addNodeWithText( 'ignore', substr( $text, $i ) );
202  break;
203  }
204  $tagEndPos = $startPos + strlen( '<onlyinclude>' ); // past-the-end
205  $accum->addNodeWithText( 'ignore', substr( $text, $i, $tagEndPos - $i ) );
206  $i = $tagEndPos;
207  $findOnlyinclude = false;
208  }
209 
210  if ( $fakeLineStart ) {
211  $found = 'line-start';
212  $curChar = '';
213  } else {
214  # Find next opening brace, closing brace or pipe
215  $search = $searchBase;
216  if ( $stack->top === false ) {
217  $currentClosing = '';
218  } else {
219  $currentClosing = $stack->top->close;
220  $search .= $currentClosing;
221  }
222  if ( $findPipe ) {
223  $search .= '|';
224  }
225  if ( $findEquals ) {
226  // First equals will be for the template
227  $search .= '=';
228  }
229  $rule = null;
230  # Output literal section, advance input counter
231  $literalLength = strcspn( $text, $search, $i );
232  if ( $literalLength > 0 ) {
233  $accum->addLiteral( substr( $text, $i, $literalLength ) );
234  $i += $literalLength;
235  }
236  if ( $i >= $lengthText ) {
237  if ( $currentClosing == "\n" ) {
238  // Do a past-the-end run to finish off the heading
239  $curChar = '';
240  $found = 'line-end';
241  } else {
242  # All done
243  break;
244  }
245  } else {
246  $curChar = $text[$i];
247  if ( $curChar == '|' ) {
248  $found = 'pipe';
249  } elseif ( $curChar == '=' ) {
250  $found = 'equals';
251  } elseif ( $curChar == '<' ) {
252  $found = 'angle';
253  } elseif ( $curChar == "\n" ) {
254  if ( $inHeading ) {
255  $found = 'line-end';
256  } else {
257  $found = 'line-start';
258  }
259  } elseif ( $curChar == $currentClosing ) {
260  $found = 'close';
261  } elseif ( isset( $rules[$curChar] ) ) {
262  $found = 'open';
263  $rule = $rules[$curChar];
264  } else {
265  # Some versions of PHP have a strcspn which stops on null characters
266  # Ignore and continue
267  ++$i;
268  continue;
269  }
270  }
271  }
272 
273  if ( $found == 'angle' ) {
274  $matches = false;
275  // Handle </onlyinclude>
276  if ( $enableOnlyinclude && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>' ) {
277  $findOnlyinclude = true;
278  continue;
279  }
280 
281  // Determine element name
282  if ( !preg_match( $elementsRegex, $text, $matches, 0, $i + 1 ) ) {
283  // Element name missing or not listed
284  $accum->addLiteral( '<' );
285  ++$i;
286  continue;
287  }
288  // Handle comments
289  if ( isset( $matches[2] ) && $matches[2] == '!--' ) {
290 
291  // To avoid leaving blank lines, when a sequence of
292  // space-separated comments is both preceded and followed by
293  // a newline (ignoring spaces), then
294  // trim leading and trailing spaces and the trailing newline.
295 
296  // Find the end
297  $endPos = strpos( $text, '-->', $i + 4 );
298  if ( $endPos === false ) {
299  // Unclosed comment in input, runs to end
300  $inner = substr( $text, $i );
301  $accum->addNodeWithText( 'comment', $inner );
302  $i = $lengthText;
303  } else {
304  // Search backwards for leading whitespace
305  $wsStart = $i ? ( $i - strspn( $revText, " \t", $lengthText - $i ) ) : 0;
306 
307  // Search forwards for trailing whitespace
308  // $wsEnd will be the position of the last space (or the '>' if there's none)
309  $wsEnd = $endPos + 2 + strspn( $text, " \t", $endPos + 3 );
310 
311  // Keep looking forward as long as we're finding more
312  // comments.
313  $comments = array( array( $wsStart, $wsEnd ) );
314  while ( substr( $text, $wsEnd + 1, 4 ) == '<!--' ) {
315  $c = strpos( $text, '-->', $wsEnd + 4 );
316  if ( $c === false ) {
317  break;
318  }
319  $c = $c + 2 + strspn( $text, " \t", $c + 3 );
320  $comments[] = array( $wsEnd + 1, $c );
321  $wsEnd = $c;
322  }
323 
324  // Eat the line if possible
325  // TODO: This could theoretically be done if $wsStart == 0, i.e. for comments at
326  // the overall start. That's not how Sanitizer::removeHTMLcomments() did it, but
327  // it's a possible beneficial b/c break.
328  if ( $wsStart > 0 && substr( $text, $wsStart - 1, 1 ) == "\n"
329  && substr( $text, $wsEnd + 1, 1 ) == "\n"
330  ) {
331  // Remove leading whitespace from the end of the accumulator
332  // Sanity check first though
333  $wsLength = $i - $wsStart;
334  if ( $wsLength > 0
335  && $accum->lastNode instanceof PPNode_Hash_Text
336  && strspn( $accum->lastNode->value, " \t", -$wsLength ) === $wsLength
337  ) {
338  $accum->lastNode->value = substr( $accum->lastNode->value, 0, -$wsLength );
339  }
340 
341  // Dump all but the last comment to the accumulator
342  foreach ( $comments as $j => $com ) {
343  $startPos = $com[0];
344  $endPos = $com[1] + 1;
345  if ( $j == ( count( $comments ) - 1 ) ) {
346  break;
347  }
348  $inner = substr( $text, $startPos, $endPos - $startPos );
349  $accum->addNodeWithText( 'comment', $inner );
350  }
351 
352  // Do a line-start run next time to look for headings after the comment
353  $fakeLineStart = true;
354  } else {
355  // No line to eat, just take the comment itself
356  $startPos = $i;
357  $endPos += 2;
358  }
359 
360  if ( $stack->top ) {
361  $part = $stack->top->getCurrentPart();
362  if ( !( isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 ) ) {
363  $part->visualEnd = $wsStart;
364  }
365  // Else comments abutting, no change in visual end
366  $part->commentEnd = $endPos;
367  }
368  $i = $endPos + 1;
369  $inner = substr( $text, $startPos, $endPos - $startPos + 1 );
370  $accum->addNodeWithText( 'comment', $inner );
371  }
372  continue;
373  }
374  $name = $matches[1];
375  $lowerName = strtolower( $name );
376  $attrStart = $i + strlen( $name ) + 1;
377 
378  // Find end of tag
379  $tagEndPos = $noMoreGT ? false : strpos( $text, '>', $attrStart );
380  if ( $tagEndPos === false ) {
381  // Infinite backtrack
382  // Disable tag search to prevent worst-case O(N^2) performance
383  $noMoreGT = true;
384  $accum->addLiteral( '<' );
385  ++$i;
386  continue;
387  }
388 
389  // Handle ignored tags
390  if ( in_array( $lowerName, $ignoredTags ) ) {
391  $accum->addNodeWithText( 'ignore', substr( $text, $i, $tagEndPos - $i + 1 ) );
392  $i = $tagEndPos + 1;
393  continue;
394  }
395 
396  $tagStartPos = $i;
397  if ( $text[$tagEndPos - 1] == '/' ) {
398  // Short end tag
399  $attrEnd = $tagEndPos - 1;
400  $inner = null;
401  $i = $tagEndPos + 1;
402  $close = null;
403  } else {
404  $attrEnd = $tagEndPos;
405  // Find closing tag
406  if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
407  $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 )
408  ) {
409  $inner = substr( $text, $tagEndPos + 1, $matches[0][1] - $tagEndPos - 1 );
410  $i = $matches[0][1] + strlen( $matches[0][0] );
411  $close = $matches[0][0];
412  } else {
413  // No end tag -- let it run out to the end of the text.
414  $inner = substr( $text, $tagEndPos + 1 );
415  $i = $lengthText;
416  $close = null;
417  }
418  }
419  // <includeonly> and <noinclude> just become <ignore> tags
420  if ( in_array( $lowerName, $ignoredElements ) ) {
421  $accum->addNodeWithText( 'ignore', substr( $text, $tagStartPos, $i - $tagStartPos ) );
422  continue;
423  }
424 
425  if ( $attrEnd <= $attrStart ) {
426  $attr = '';
427  } else {
428  // Note that the attr element contains the whitespace between name and attribute,
429  // this is necessary for precise reconstruction during pre-save transform.
430  $attr = substr( $text, $attrStart, $attrEnd - $attrStart );
431  }
432 
433  $extNode = new PPNode_Hash_Tree( 'ext' );
434  $extNode->addChild( PPNode_Hash_Tree::newWithText( 'name', $name ) );
435  $extNode->addChild( PPNode_Hash_Tree::newWithText( 'attr', $attr ) );
436  if ( $inner !== null ) {
437  $extNode->addChild( PPNode_Hash_Tree::newWithText( 'inner', $inner ) );
438  }
439  if ( $close !== null ) {
440  $extNode->addChild( PPNode_Hash_Tree::newWithText( 'close', $close ) );
441  }
442  $accum->addNode( $extNode );
443  } elseif ( $found == 'line-start' ) {
444  // Is this the start of a heading?
445  // Line break belongs before the heading element in any case
446  if ( $fakeLineStart ) {
447  $fakeLineStart = false;
448  } else {
449  $accum->addLiteral( $curChar );
450  $i++;
451  }
452 
453  $count = strspn( $text, '=', $i, 6 );
454  if ( $count == 1 && $findEquals ) {
455  // DWIM: This looks kind of like a name/value separator
456  // Let's let the equals handler have it and break the potential heading
457  // This is heuristic, but AFAICT the methods for completely correct disambiguation are very complex.
458  } elseif ( $count > 0 ) {
459  $piece = array(
460  'open' => "\n",
461  'close' => "\n",
462  'parts' => array( new PPDPart_Hash( str_repeat( '=', $count ) ) ),
463  'startPos' => $i,
464  'count' => $count );
465  $stack->push( $piece );
466  $accum =& $stack->getAccum();
467  extract( $stack->getFlags() );
468  $i += $count;
469  }
470  } elseif ( $found == 'line-end' ) {
471  $piece = $stack->top;
472  // A heading must be open, otherwise \n wouldn't have been in the search list
473  assert( '$piece->open == "\n"' );
474  $part = $piece->getCurrentPart();
475  // Search back through the input to see if it has a proper close
476  // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient
477  $wsLength = strspn( $revText, " \t", $lengthText - $i );
478  $searchStart = $i - $wsLength;
479  if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) {
480  // Comment found at line end
481  // Search for equals signs before the comment
482  $searchStart = $part->visualEnd;
483  $searchStart -= strspn( $revText, " \t", $lengthText - $searchStart );
484  }
485  $count = $piece->count;
486  $equalsLength = strspn( $revText, '=', $lengthText - $searchStart );
487  if ( $equalsLength > 0 ) {
488  if ( $searchStart - $equalsLength == $piece->startPos ) {
489  // This is just a single string of equals signs on its own line
490  // Replicate the doHeadings behavior /={count}(.+)={count}/
491  // First find out how many equals signs there really are (don't stop at 6)
492  $count = $equalsLength;
493  if ( $count < 3 ) {
494  $count = 0;
495  } else {
496  $count = min( 6, intval( ( $count - 1 ) / 2 ) );
497  }
498  } else {
499  $count = min( $equalsLength, $count );
500  }
501  if ( $count > 0 ) {
502  // Normal match, output <h>
503  $element = new PPNode_Hash_Tree( 'possible-h' );
504  $element->addChild( new PPNode_Hash_Attr( 'level', $count ) );
505  $element->addChild( new PPNode_Hash_Attr( 'i', $headingIndex++ ) );
506  $element->lastChild->nextSibling = $accum->firstNode;
507  $element->lastChild = $accum->lastNode;
508  } else {
509  // Single equals sign on its own line, count=0
510  $element = $accum;
511  }
512  } else {
513  // No match, no <h>, just pass down the inner text
514  $element = $accum;
515  }
516  // Unwind the stack
517  $stack->pop();
518  $accum =& $stack->getAccum();
519  extract( $stack->getFlags() );
520 
521  // Append the result to the enclosing accumulator
522  if ( $element instanceof PPNode ) {
523  $accum->addNode( $element );
524  } else {
525  $accum->addAccum( $element );
526  }
527  // Note that we do NOT increment the input pointer.
528  // This is because the closing linebreak could be the opening linebreak of
529  // another heading. Infinite loops are avoided because the next iteration MUST
530  // hit the heading open case above, which unconditionally increments the
531  // input pointer.
532  } elseif ( $found == 'open' ) {
533  # count opening brace characters
534  $count = strspn( $text, $curChar, $i );
535 
536  # we need to add to stack only if opening brace count is enough for one of the rules
537  if ( $count >= $rule['min'] ) {
538  # Add it to the stack
539  $piece = array(
540  'open' => $curChar,
541  'close' => $rule['end'],
542  'count' => $count,
543  'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ),
544  );
545 
546  $stack->push( $piece );
547  $accum =& $stack->getAccum();
548  extract( $stack->getFlags() );
549  } else {
550  # Add literal brace(s)
551  $accum->addLiteral( str_repeat( $curChar, $count ) );
552  }
553  $i += $count;
554  } elseif ( $found == 'close' ) {
555  $piece = $stack->top;
556  # lets check if there are enough characters for closing brace
557  $maxCount = $piece->count;
558  $count = strspn( $text, $curChar, $i, $maxCount );
559 
560  # check for maximum matching characters (if there are 5 closing
561  # characters, we will probably need only 3 - depending on the rules)
562  $rule = $rules[$piece->open];
563  if ( $count > $rule['max'] ) {
564  # The specified maximum exists in the callback array, unless the caller
565  # has made an error
566  $matchingCount = $rule['max'];
567  } else {
568  # Count is less than the maximum
569  # Skip any gaps in the callback array to find the true largest match
570  # Need to use array_key_exists not isset because the callback can be null
571  $matchingCount = $count;
572  while ( $matchingCount > 0 && !array_key_exists( $matchingCount, $rule['names'] ) ) {
573  --$matchingCount;
574  }
575  }
576 
577  if ( $matchingCount <= 0 ) {
578  # No matching element found in callback array
579  # Output a literal closing brace and continue
580  $accum->addLiteral( str_repeat( $curChar, $count ) );
581  $i += $count;
582  continue;
583  }
584  $name = $rule['names'][$matchingCount];
585  if ( $name === null ) {
586  // No element, just literal text
587  $element = $piece->breakSyntax( $matchingCount );
588  $element->addLiteral( str_repeat( $rule['end'], $matchingCount ) );
589  } else {
590  # Create XML element
591  # Note: $parts is already XML, does not need to be encoded further
592  $parts = $piece->parts;
593  $titleAccum = $parts[0]->out;
594  unset( $parts[0] );
595 
596  $element = new PPNode_Hash_Tree( $name );
597 
598  # The invocation is at the start of the line if lineStart is set in
599  # the stack, and all opening brackets are used up.
600  if ( $maxCount == $matchingCount && !empty( $piece->lineStart ) ) {
601  $element->addChild( new PPNode_Hash_Attr( 'lineStart', 1 ) );
602  }
603  $titleNode = new PPNode_Hash_Tree( 'title' );
604  $titleNode->firstChild = $titleAccum->firstNode;
605  $titleNode->lastChild = $titleAccum->lastNode;
606  $element->addChild( $titleNode );
607  $argIndex = 1;
608  foreach ( $parts as $part ) {
609  if ( isset( $part->eqpos ) ) {
610  // Find equals
611  $lastNode = false;
612  for ( $node = $part->out->firstNode; $node; $node = $node->nextSibling ) {
613  if ( $node === $part->eqpos ) {
614  break;
615  }
616  $lastNode = $node;
617  }
618  if ( !$node ) {
619  if ( $cacheable ) {
620  wfProfileOut( __METHOD__ . '-cache-miss' );
621  wfProfileOut( __METHOD__ . '-cacheable' );
622  }
623  wfProfileOut( __METHOD__ );
624  throw new MWException( __METHOD__ . ': eqpos not found' );
625  }
626  if ( $node->name !== 'equals' ) {
627  if ( $cacheable ) {
628  wfProfileOut( __METHOD__ . '-cache-miss' );
629  wfProfileOut( __METHOD__ . '-cacheable' );
630  }
631  wfProfileOut( __METHOD__ );
632  throw new MWException( __METHOD__ . ': eqpos is not equals' );
633  }
634  $equalsNode = $node;
635 
636  // Construct name node
637  $nameNode = new PPNode_Hash_Tree( 'name' );
638  if ( $lastNode !== false ) {
639  $lastNode->nextSibling = false;
640  $nameNode->firstChild = $part->out->firstNode;
641  $nameNode->lastChild = $lastNode;
642  }
643 
644  // Construct value node
645  $valueNode = new PPNode_Hash_Tree( 'value' );
646  if ( $equalsNode->nextSibling !== false ) {
647  $valueNode->firstChild = $equalsNode->nextSibling;
648  $valueNode->lastChild = $part->out->lastNode;
649  }
650  $partNode = new PPNode_Hash_Tree( 'part' );
651  $partNode->addChild( $nameNode );
652  $partNode->addChild( $equalsNode->firstChild );
653  $partNode->addChild( $valueNode );
654  $element->addChild( $partNode );
655  } else {
656  $partNode = new PPNode_Hash_Tree( 'part' );
657  $nameNode = new PPNode_Hash_Tree( 'name' );
658  $nameNode->addChild( new PPNode_Hash_Attr( 'index', $argIndex++ ) );
659  $valueNode = new PPNode_Hash_Tree( 'value' );
660  $valueNode->firstChild = $part->out->firstNode;
661  $valueNode->lastChild = $part->out->lastNode;
662  $partNode->addChild( $nameNode );
663  $partNode->addChild( $valueNode );
664  $element->addChild( $partNode );
665  }
666  }
667  }
668 
669  # Advance input pointer
670  $i += $matchingCount;
671 
672  # Unwind the stack
673  $stack->pop();
674  $accum =& $stack->getAccum();
675 
676  # Re-add the old stack element if it still has unmatched opening characters remaining
677  if ( $matchingCount < $piece->count ) {
678  $piece->parts = array( new PPDPart_Hash );
679  $piece->count -= $matchingCount;
680  # do we still qualify for any callback with remaining count?
681  $min = $rules[$piece->open]['min'];
682  if ( $piece->count >= $min ) {
683  $stack->push( $piece );
684  $accum =& $stack->getAccum();
685  } else {
686  $accum->addLiteral( str_repeat( $piece->open, $piece->count ) );
687  }
688  }
689 
690  extract( $stack->getFlags() );
691 
692  # Add XML element to the enclosing accumulator
693  if ( $element instanceof PPNode ) {
694  $accum->addNode( $element );
695  } else {
696  $accum->addAccum( $element );
697  }
698  } elseif ( $found == 'pipe' ) {
699  $findEquals = true; // shortcut for getFlags()
700  $stack->addPart();
701  $accum =& $stack->getAccum();
702  ++$i;
703  } elseif ( $found == 'equals' ) {
704  $findEquals = false; // shortcut for getFlags()
705  $accum->addNodeWithText( 'equals', '=' );
706  $stack->getCurrentPart()->eqpos = $accum->lastNode;
707  ++$i;
708  }
709  }
710 
711  # Output any remaining unclosed brackets
712  foreach ( $stack->stack as $piece ) {
713  $stack->rootAccum->addAccum( $piece->breakSyntax() );
714  }
715 
716  # Enable top-level headings
717  for ( $node = $stack->rootAccum->firstNode; $node; $node = $node->nextSibling ) {
718  if ( isset( $node->name ) && $node->name === 'possible-h' ) {
719  $node->name = 'h';
720  }
721  }
722 
723  $rootNode = new PPNode_Hash_Tree( 'root' );
724  $rootNode->firstChild = $stack->rootAccum->firstNode;
725  $rootNode->lastChild = $stack->rootAccum->lastNode;
726 
727  // Cache
728  if ( $cacheable ) {
729  $cacheValue = sprintf( "%08d", self::CACHE_VERSION ) . serialize( $rootNode );
730  $wgMemc->set( $cacheKey, $cacheValue, 86400 );
731  wfProfileOut( __METHOD__ . '-cache-miss' );
732  wfProfileOut( __METHOD__ . '-cacheable' );
733  wfDebugLog( "Preprocessor", "Saved preprocessor Hash to memcached (key $cacheKey)" );
734  }
735 
736  wfProfileOut( __METHOD__ );
737  return $rootNode;
738  }
739 }
740 
745 class PPDStack_Hash extends PPDStack {
746  function __construct() {
747  $this->elementClass = 'PPDStackElement_Hash';
748  parent::__construct();
749  $this->rootAccum = new PPDAccum_Hash;
750  }
751 }
752 
757  function __construct( $data = array() ) {
758  $this->partClass = 'PPDPart_Hash';
759  parent::__construct( $data );
760  }
761 
767  function breakSyntax( $openingCount = false ) {
768  if ( $this->open == "\n" ) {
769  $accum = $this->parts[0]->out;
770  } else {
771  if ( $openingCount === false ) {
772  $openingCount = $this->count;
773  }
774  $accum = new PPDAccum_Hash;
775  $accum->addLiteral( str_repeat( $this->open, $openingCount ) );
776  $first = true;
777  foreach ( $this->parts as $part ) {
778  if ( $first ) {
779  $first = false;
780  } else {
781  $accum->addLiteral( '|' );
782  }
783  $accum->addAccum( $part->out );
784  }
785  }
786  return $accum;
787  }
788 }
789 
793 class PPDPart_Hash extends PPDPart {
794  function __construct( $out = '' ) {
795  $accum = new PPDAccum_Hash;
796  if ( $out !== '' ) {
797  $accum->addLiteral( $out );
798  }
799  parent::__construct( $accum );
800  }
801 }
802 
807  var $firstNode, $lastNode;
808 
809  function __construct() {
810  $this->firstNode = $this->lastNode = false;
811  }
812 
816  function addLiteral( $s ) {
817  if ( $this->lastNode === false ) {
818  $this->firstNode = $this->lastNode = new PPNode_Hash_Text( $s );
819  } elseif ( $this->lastNode instanceof PPNode_Hash_Text ) {
820  $this->lastNode->value .= $s;
821  } else {
822  $this->lastNode->nextSibling = new PPNode_Hash_Text( $s );
823  $this->lastNode = $this->lastNode->nextSibling;
824  }
825  }
826 
830  function addNode( PPNode $node ) {
831  if ( $this->lastNode === false ) {
832  $this->firstNode = $this->lastNode = $node;
833  } else {
834  $this->lastNode->nextSibling = $node;
835  $this->lastNode = $node;
836  }
837  }
838 
842  function addNodeWithText( $name, $value ) {
844  $this->addNode( $node );
845  }
846 
852  function addAccum( $accum ) {
853  if ( $accum->lastNode === false ) {
854  // nothing to add
855  } elseif ( $this->lastNode === false ) {
856  $this->firstNode = $accum->firstNode;
857  $this->lastNode = $accum->lastNode;
858  } else {
859  $this->lastNode->nextSibling = $accum->firstNode;
860  $this->lastNode = $accum->lastNode;
861  }
862  }
863 }
864 
869 class PPFrame_Hash implements PPFrame {
870 
874  var $parser;
875 
879  var $preprocessor;
880 
884  var $title;
885  var $titleCache;
886 
891  var $loopCheckHash;
892 
897  var $depth;
898 
903  function __construct( $preprocessor ) {
904  $this->preprocessor = $preprocessor;
905  $this->parser = $preprocessor->parser;
906  $this->title = $this->parser->mTitle;
907  $this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false );
908  $this->loopCheckHash = array();
909  $this->depth = 0;
910  }
911 
923  function newChild( $args = false, $title = false, $indexOffset = 0 ) {
924  $namedArgs = array();
925  $numberedArgs = array();
926  if ( $title === false ) {
928  }
929  if ( $args !== false ) {
930  if ( $args instanceof PPNode_Hash_Array ) {
931  $args = $args->value;
932  } elseif ( !is_array( $args ) ) {
933  throw new MWException( __METHOD__ . ': $args must be array or PPNode_Hash_Array' );
934  }
935  foreach ( $args as $arg ) {
936  $bits = $arg->splitArg();
937  if ( $bits['index'] !== '' ) {
938  // Numbered parameter
939  $index = $bits['index'] - $indexOffset;
940  $numberedArgs[$index] = $bits['value'];
941  unset( $namedArgs[$index] );
942  } else {
943  // Named parameter
944  $name = trim( $this->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
945  $namedArgs[$name] = $bits['value'];
946  unset( $numberedArgs[$name] );
947  }
948  }
949  }
950  return new PPTemplateFrame_Hash( $this->preprocessor, $this, $numberedArgs, $namedArgs, $title );
951  }
952 
959  function expand( $root, $flags = 0 ) {
960  static $expansionDepth = 0;
961  if ( is_string( $root ) ) {
962  return $root;
963  }
964 
965  if ( ++$this->parser->mPPNodeCount > $this->parser->mOptions->getMaxPPNodeCount() ) {
966  $this->parser->limitationWarn( 'node-count-exceeded',
967  $this->parser->mPPNodeCount,
968  $this->parser->mOptions->getMaxPPNodeCount()
969  );
970  return '<span class="error">Node-count limit exceeded</span>';
971  }
972  if ( $expansionDepth > $this->parser->mOptions->getMaxPPExpandDepth() ) {
973  $this->parser->limitationWarn( 'expansion-depth-exceeded',
974  $expansionDepth,
975  $this->parser->mOptions->getMaxPPExpandDepth()
976  );
977  return '<span class="error">Expansion depth limit exceeded</span>';
978  }
979  ++$expansionDepth;
980  if ( $expansionDepth > $this->parser->mHighestExpansionDepth ) {
981  $this->parser->mHighestExpansionDepth = $expansionDepth;
982  }
983 
984  $outStack = array( '', '' );
985  $iteratorStack = array( false, $root );
986  $indexStack = array( 0, 0 );
987 
988  while ( count( $iteratorStack ) > 1 ) {
989  $level = count( $outStack ) - 1;
990  $iteratorNode =& $iteratorStack[$level];
991  $out =& $outStack[$level];
992  $index =& $indexStack[$level];
993 
994  if ( is_array( $iteratorNode ) ) {
995  if ( $index >= count( $iteratorNode ) ) {
996  // All done with this iterator
997  $iteratorStack[$level] = false;
998  $contextNode = false;
999  } else {
1000  $contextNode = $iteratorNode[$index];
1001  $index++;
1002  }
1003  } elseif ( $iteratorNode instanceof PPNode_Hash_Array ) {
1004  if ( $index >= $iteratorNode->getLength() ) {
1005  // All done with this iterator
1006  $iteratorStack[$level] = false;
1007  $contextNode = false;
1008  } else {
1009  $contextNode = $iteratorNode->item( $index );
1010  $index++;
1011  }
1012  } else {
1013  // Copy to $contextNode and then delete from iterator stack,
1014  // because this is not an iterator but we do have to execute it once
1015  $contextNode = $iteratorStack[$level];
1016  $iteratorStack[$level] = false;
1017  }
1018 
1019  $newIterator = false;
1020 
1021  if ( $contextNode === false ) {
1022  // nothing to do
1023  } elseif ( is_string( $contextNode ) ) {
1024  $out .= $contextNode;
1025  } elseif ( is_array( $contextNode ) || $contextNode instanceof PPNode_Hash_Array ) {
1026  $newIterator = $contextNode;
1027  } elseif ( $contextNode instanceof PPNode_Hash_Attr ) {
1028  // No output
1029  } elseif ( $contextNode instanceof PPNode_Hash_Text ) {
1030  $out .= $contextNode->value;
1031  } elseif ( $contextNode instanceof PPNode_Hash_Tree ) {
1032  if ( $contextNode->name == 'template' ) {
1033  # Double-brace expansion
1034  $bits = $contextNode->splitTemplate();
1035  if ( $flags & PPFrame::NO_TEMPLATES ) {
1036  $newIterator = $this->virtualBracketedImplode( '{{', '|', '}}', $bits['title'], $bits['parts'] );
1037  } else {
1038  $ret = $this->parser->braceSubstitution( $bits, $this );
1039  if ( isset( $ret['object'] ) ) {
1040  $newIterator = $ret['object'];
1041  } else {
1042  $out .= $ret['text'];
1043  }
1044  }
1045  } elseif ( $contextNode->name == 'tplarg' ) {
1046  # Triple-brace expansion
1047  $bits = $contextNode->splitTemplate();
1048  if ( $flags & PPFrame::NO_ARGS ) {
1049  $newIterator = $this->virtualBracketedImplode( '{{{', '|', '}}}', $bits['title'], $bits['parts'] );
1050  } else {
1051  $ret = $this->parser->argSubstitution( $bits, $this );
1052  if ( isset( $ret['object'] ) ) {
1053  $newIterator = $ret['object'];
1054  } else {
1055  $out .= $ret['text'];
1056  }
1057  }
1058  } elseif ( $contextNode->name == 'comment' ) {
1059  # HTML-style comment
1060  # Remove it in HTML, pre+remove and STRIP_COMMENTS modes
1061  if ( $this->parser->ot['html']
1062  || ( $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() )
1064  ) {
1065  $out .= '';
1066  } elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) {
1067  # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
1068  # Not in RECOVER_COMMENTS mode (extractSections) though
1069  $out .= $this->parser->insertStripItem( $contextNode->firstChild->value );
1070  } else {
1071  # Recover the literal comment in RECOVER_COMMENTS and pre+no-remove
1072  $out .= $contextNode->firstChild->value;
1073  }
1074  } elseif ( $contextNode->name == 'ignore' ) {
1075  # Output suppression used by <includeonly> etc.
1076  # OT_WIKI will only respect <ignore> in substed templates.
1077  # The other output types respect it unless NO_IGNORE is set.
1078  # extractSections() sets NO_IGNORE and so never respects it.
1079  if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] ) || ( $flags & PPFrame::NO_IGNORE ) ) {
1080  $out .= $contextNode->firstChild->value;
1081  } else {
1082  //$out .= '';
1083  }
1084  } elseif ( $contextNode->name == 'ext' ) {
1085  # Extension tag
1086  $bits = $contextNode->splitExt() + array( 'attr' => null, 'inner' => null, 'close' => null );
1087  $out .= $this->parser->extensionSubstitution( $bits, $this );
1088  } elseif ( $contextNode->name == 'h' ) {
1089  # Heading
1090  if ( $this->parser->ot['html'] ) {
1091  # Expand immediately and insert heading index marker
1092  $s = '';
1093  for ( $node = $contextNode->firstChild; $node; $node = $node->nextSibling ) {
1094  $s .= $this->expand( $node, $flags );
1095  }
1096 
1097  $bits = $contextNode->splitHeading();
1098  $titleText = $this->title->getPrefixedDBkey();
1099  $this->parser->mHeadings[] = array( $titleText, $bits['i'] );
1100  $serial = count( $this->parser->mHeadings ) - 1;
1101  $marker = "{$this->parser->mUniqPrefix}-h-$serial-" . Parser::MARKER_SUFFIX;
1102  $s = substr( $s, 0, $bits['level'] ) . $marker . substr( $s, $bits['level'] );
1103  $this->parser->mStripState->addGeneral( $marker, '' );
1104  $out .= $s;
1105  } else {
1106  # Expand in virtual stack
1107  $newIterator = $contextNode->getChildren();
1108  }
1109  } else {
1110  # Generic recursive expansion
1111  $newIterator = $contextNode->getChildren();
1112  }
1113  } else {
1114  throw new MWException( __METHOD__ . ': Invalid parameter type' );
1115  }
1116 
1117  if ( $newIterator !== false ) {
1118  $outStack[] = '';
1119  $iteratorStack[] = $newIterator;
1120  $indexStack[] = 0;
1121  } elseif ( $iteratorStack[$level] === false ) {
1122  // Return accumulated value to parent
1123  // With tail recursion
1124  while ( $iteratorStack[$level] === false && $level > 0 ) {
1125  $outStack[$level - 1] .= $out;
1126  array_pop( $outStack );
1127  array_pop( $iteratorStack );
1128  array_pop( $indexStack );
1129  $level--;
1130  }
1131  }
1132  }
1133  --$expansionDepth;
1134  return $outStack[0];
1135  }
1136 
1142  function implodeWithFlags( $sep, $flags /*, ... */ ) {
1143  $args = array_slice( func_get_args(), 2 );
1144 
1145  $first = true;
1146  $s = '';
1147  foreach ( $args as $root ) {
1148  if ( $root instanceof PPNode_Hash_Array ) {
1149  $root = $root->value;
1150  }
1151  if ( !is_array( $root ) ) {
1152  $root = array( $root );
1153  }
1154  foreach ( $root as $node ) {
1155  if ( $first ) {
1156  $first = false;
1157  } else {
1158  $s .= $sep;
1159  }
1160  $s .= $this->expand( $node, $flags );
1161  }
1162  }
1163  return $s;
1164  }
1165 
1171  function implode( $sep /*, ... */ ) {
1172  $args = array_slice( func_get_args(), 1 );
1173 
1174  $first = true;
1175  $s = '';
1176  foreach ( $args as $root ) {
1177  if ( $root instanceof PPNode_Hash_Array ) {
1178  $root = $root->value;
1179  }
1180  if ( !is_array( $root ) ) {
1181  $root = array( $root );
1182  }
1183  foreach ( $root as $node ) {
1184  if ( $first ) {
1185  $first = false;
1186  } else {
1187  $s .= $sep;
1188  }
1189  $s .= $this->expand( $node );
1190  }
1191  }
1192  return $s;
1193  }
1194 
1201  function virtualImplode( $sep /*, ... */ ) {
1202  $args = array_slice( func_get_args(), 1 );
1203  $out = array();
1204  $first = true;
1205 
1206  foreach ( $args as $root ) {
1207  if ( $root instanceof PPNode_Hash_Array ) {
1208  $root = $root->value;
1209  }
1210  if ( !is_array( $root ) ) {
1211  $root = array( $root );
1212  }
1213  foreach ( $root as $node ) {
1214  if ( $first ) {
1215  $first = false;
1216  } else {
1217  $out[] = $sep;
1218  }
1219  $out[] = $node;
1220  }
1221  }
1222  return new PPNode_Hash_Array( $out );
1223  }
1224 
1230  function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
1231  $args = array_slice( func_get_args(), 3 );
1232  $out = array( $start );
1233  $first = true;
1234 
1235  foreach ( $args as $root ) {
1236  if ( $root instanceof PPNode_Hash_Array ) {
1237  $root = $root->value;
1238  }
1239  if ( !is_array( $root ) ) {
1240  $root = array( $root );
1241  }
1242  foreach ( $root as $node ) {
1243  if ( $first ) {
1244  $first = false;
1245  } else {
1246  $out[] = $sep;
1247  }
1248  $out[] = $node;
1249  }
1250  }
1251  $out[] = $end;
1252  return new PPNode_Hash_Array( $out );
1253  }
1254 
1255  function __toString() {
1256  return 'frame{}';
1257  }
1258 
1263  function getPDBK( $level = false ) {
1264  if ( $level === false ) {
1265  return $this->title->getPrefixedDBkey();
1266  } else {
1267  return isset( $this->titleCache[$level] ) ? $this->titleCache[$level] : false;
1268  }
1269  }
1274  function getArguments() {
1275  return array();
1276  }
1281  function getNumberedArguments() {
1282  return array();
1283  }
1288  function getNamedArguments() {
1289  return array();
1290  }
1291 
1297  function isEmpty() {
1298  return true;
1299  }
1300 
1305  function getArgument( $name ) {
1306  return false;
1307  }
1308 
1316  function loopCheck( $title ) {
1317  return !isset( $this->loopCheckHash[$title->getPrefixedDBkey()] );
1318  }
1319 
1325  function isTemplate() {
1326  return false;
1327  }
1328 
1334  function getTitle() {
1335  return $this->title;
1336  }
1337 }
1338 
1343 class PPTemplateFrame_Hash extends PPFrame_Hash {
1346 
1354  function __construct( $preprocessor, $parent = false, $numberedArgs = array(), $namedArgs = array(), $title = false ) {
1355  parent::__construct( $preprocessor );
1356 
1357  $this->parent = $parent;
1358  $this->numberedArgs = $numberedArgs;
1359  $this->namedArgs = $namedArgs;
1360  $this->title = $title;
1361  $pdbk = $title ? $title->getPrefixedDBkey() : false;
1362  $this->titleCache = $parent->titleCache;
1363  $this->titleCache[] = $pdbk;
1364  $this->loopCheckHash = /*clone*/ $parent->loopCheckHash;
1365  if ( $pdbk !== false ) {
1366  $this->loopCheckHash[$pdbk] = true;
1367  }
1368  $this->depth = $parent->depth + 1;
1369  $this->numberedExpansionCache = $this->namedExpansionCache = array();
1370  }
1371 
1372  function __toString() {
1373  $s = 'tplframe{';
1374  $first = true;
1375  $args = $this->numberedArgs + $this->namedArgs;
1376  foreach ( $args as $name => $value ) {
1377  if ( $first ) {
1378  $first = false;
1379  } else {
1380  $s .= ', ';
1381  }
1382  $s .= "\"$name\":\"" .
1383  str_replace( '"', '\\"', $value->__toString() ) . '"';
1384  }
1385  $s .= '}';
1386  return $s;
1387  }
1388 
1394  function isEmpty() {
1395  return !count( $this->numberedArgs ) && !count( $this->namedArgs );
1396  }
1401  function getArguments() {
1402  $arguments = array();
1403  foreach ( array_merge(
1404  array_keys( $this->numberedArgs ),
1405  array_keys( $this->namedArgs ) ) as $key ) {
1406  $arguments[$key] = $this->getArgument( $key );
1407  }
1408  return $arguments;
1409  }
1414  function getNumberedArguments() {
1415  $arguments = array();
1416  foreach ( array_keys( $this->numberedArgs ) as $key ) {
1417  $arguments[$key] = $this->getArgument( $key );
1418  }
1419  return $arguments;
1420  }
1425  function getNamedArguments() {
1426  $arguments = array();
1427  foreach ( array_keys( $this->namedArgs ) as $key ) {
1428  $arguments[$key] = $this->getArgument( $key );
1429  }
1430  return $arguments;
1431  }
1432 
1437  function getNumberedArgument( $index ) {
1438  if ( !isset( $this->numberedArgs[$index] ) ) {
1439  return false;
1440  }
1441  if ( !isset( $this->numberedExpansionCache[$index] ) ) {
1442  # No trimming for unnamed arguments
1443  $this->numberedExpansionCache[$index] = $this->parent->expand( $this->numberedArgs[$index], PPFrame::STRIP_COMMENTS );
1444  }
1445  return $this->numberedExpansionCache[$index];
1446  }
1447 
1452  function getNamedArgument( $name ) {
1453  if ( !isset( $this->namedArgs[$name] ) ) {
1454  return false;
1455  }
1456  if ( !isset( $this->namedExpansionCache[$name] ) ) {
1457  # Trim named arguments post-expand, for backwards compatibility
1458  $this->namedExpansionCache[$name] = trim(
1459  $this->parent->expand( $this->namedArgs[$name], PPFrame::STRIP_COMMENTS ) );
1460  }
1461  return $this->namedExpansionCache[$name];
1462  }
1463 
1468  function getArgument( $name ) {
1469  $text = $this->getNumberedArgument( $name );
1470  if ( $text === false ) {
1471  $text = $this->getNamedArgument( $name );
1472  }
1473  return $text;
1474  }
1475 
1481  function isTemplate() {
1482  return true;
1483  }
1484 }
1485 
1490 class PPCustomFrame_Hash extends PPFrame_Hash {
1491  var $args;
1492 
1493  function __construct( $preprocessor, $args ) {
1494  parent::__construct( $preprocessor );
1495  $this->args = $args;
1496  }
1497 
1498  function __toString() {
1499  $s = 'cstmframe{';
1500  $first = true;
1501  foreach ( $this->args as $name => $value ) {
1502  if ( $first ) {
1503  $first = false;
1504  } else {
1505  $s .= ', ';
1506  }
1507  $s .= "\"$name\":\"" .
1508  str_replace( '"', '\\"', $value->__toString() ) . '"';
1509  }
1510  $s .= '}';
1511  return $s;
1512  }
1517  function isEmpty() {
1518  return !count( $this->args );
1519  }
1520 
1525  function getArgument( $index ) {
1526  if ( !isset( $this->args[$index] ) ) {
1527  return false;
1528  }
1529  return $this->args[$index];
1530  }
1531 
1532  function getArguments() {
1533  return $this->args;
1534  }
1535 }
1540 class PPNode_Hash_Tree implements PPNode {
1542 
1543  function __construct( $name ) {
1544  $this->name = $name;
1545  $this->firstChild = $this->lastChild = $this->nextSibling = false;
1546  }
1547 
1548  function __toString() {
1549  $inner = '';
1550  $attribs = '';
1551  for ( $node = $this->firstChild; $node; $node = $node->nextSibling ) {
1552  if ( $node instanceof PPNode_Hash_Attr ) {
1553  $attribs .= ' ' . $node->name . '="' . htmlspecialchars( $node->value ) . '"';
1554  } else {
1555  $inner .= $node->__toString();
1556  }
1557  }
1558  if ( $inner === '' ) {
1559  return "<{$this->name}$attribs/>";
1560  } else {
1561  return "<{$this->name}$attribs>$inner</{$this->name}>";
1562  }
1563  }
1564 
1570  static function newWithText( $name, $text ) {
1571  $obj = new self( $name );
1572  $obj->addChild( new PPNode_Hash_Text( $text ) );
1573  return $obj;
1574  }
1575 
1576  function addChild( $node ) {
1577  if ( $this->lastChild === false ) {
1578  $this->firstChild = $this->lastChild = $node;
1579  } else {
1580  $this->lastChild->nextSibling = $node;
1581  $this->lastChild = $node;
1582  }
1583  }
1588  function getChildren() {
1589  $children = array();
1590  for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
1591  $children[] = $child;
1592  }
1593  return new PPNode_Hash_Array( $children );
1594  }
1595 
1596  function getFirstChild() {
1597  return $this->firstChild;
1598  }
1599 
1600  function getNextSibling() {
1601  return $this->nextSibling;
1602  }
1603 
1604  function getChildrenOfType( $name ) {
1605  $children = array();
1606  for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
1607  if ( isset( $child->name ) && $child->name === $name ) {
1608  $children[] = $child;
1609  }
1610  }
1611  return $children;
1612  }
1617  function getLength() {
1618  return false;
1619  }
1620 
1625  function item( $i ) {
1626  return false;
1627  }
1632  function getName() {
1633  return $this->name;
1634  }
1635 
1645  function splitArg() {
1646  $bits = array();
1647  for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
1648  if ( !isset( $child->name ) ) {
1649  continue;
1650  }
1651  if ( $child->name === 'name' ) {
1652  $bits['name'] = $child;
1653  if ( $child->firstChild instanceof PPNode_Hash_Attr
1654  && $child->firstChild->name === 'index'
1655  ) {
1656  $bits['index'] = $child->firstChild->value;
1657  }
1658  } elseif ( $child->name === 'value' ) {
1659  $bits['value'] = $child;
1660  }
1661  }
1662 
1663  if ( !isset( $bits['name'] ) ) {
1664  throw new MWException( 'Invalid brace node passed to ' . __METHOD__ );
1665  }
1666  if ( !isset( $bits['index'] ) ) {
1667  $bits['index'] = '';
1668  }
1669  return $bits;
1670  }
1671 
1679  function splitExt() {
1680  $bits = array();
1681  for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
1682  if ( !isset( $child->name ) ) {
1683  continue;
1684  }
1685  if ( $child->name == 'name' ) {
1686  $bits['name'] = $child;
1687  } elseif ( $child->name == 'attr' ) {
1688  $bits['attr'] = $child;
1689  } elseif ( $child->name == 'inner' ) {
1690  $bits['inner'] = $child;
1691  } elseif ( $child->name == 'close' ) {
1692  $bits['close'] = $child;
1693  }
1694  }
1695  if ( !isset( $bits['name'] ) ) {
1696  throw new MWException( 'Invalid ext node passed to ' . __METHOD__ );
1697  }
1698  return $bits;
1699  }
1700 
1707  function splitHeading() {
1708  if ( $this->name !== 'h' ) {
1709  throw new MWException( 'Invalid h node passed to ' . __METHOD__ );
1710  }
1711  $bits = array();
1712  for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
1713  if ( !isset( $child->name ) ) {
1714  continue;
1715  }
1716  if ( $child->name == 'i' ) {
1717  $bits['i'] = $child->value;
1718  } elseif ( $child->name == 'level' ) {
1719  $bits['level'] = $child->value;
1720  }
1721  }
1722  if ( !isset( $bits['i'] ) ) {
1723  throw new MWException( 'Invalid h node passed to ' . __METHOD__ );
1724  }
1725  return $bits;
1726  }
1727 
1734  function splitTemplate() {
1735  $parts = array();
1736  $bits = array( 'lineStart' => '' );
1737  for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) {
1738  if ( !isset( $child->name ) ) {
1739  continue;
1740  }
1741  if ( $child->name == 'title' ) {
1742  $bits['title'] = $child;
1743  }
1744  if ( $child->name == 'part' ) {
1745  $parts[] = $child;
1746  }
1747  if ( $child->name == 'lineStart' ) {
1748  $bits['lineStart'] = '1';
1749  }
1750  }
1751  if ( !isset( $bits['title'] ) ) {
1752  throw new MWException( 'Invalid node passed to ' . __METHOD__ );
1753  }
1754  $bits['parts'] = new PPNode_Hash_Array( $parts );
1755  return $bits;
1756  }
1757 }
1762 class PPNode_Hash_Text implements PPNode {
1763  var $value, $nextSibling;
1764 
1765  function __construct( $value ) {
1766  if ( is_object( $value ) ) {
1767  throw new MWException( __CLASS__ . ' given object instead of string' );
1768  }
1769  $this->value = $value;
1770  }
1771 
1772  function __toString() {
1773  return htmlspecialchars( $this->value );
1774  }
1775 
1776  function getNextSibling() {
1778  }
1780  function getChildren() { return false; }
1781  function getFirstChild() { return false; }
1782  function getChildrenOfType( $name ) { return false; }
1783  function getLength() { return false; }
1784  function item( $i ) { return false; }
1785  function getName() { return '#text'; }
1786  function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
1787  function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
1788  function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
1789 }
1794 class PPNode_Hash_Array implements PPNode {
1795  var $value, $nextSibling;
1796 
1797  function __construct( $value ) {
1798  $this->value = $value;
1799  }
1800 
1801  function __toString() {
1802  return var_export( $this, true );
1803  }
1804 
1805  function getLength() {
1806  return count( $this->value );
1807  }
1808 
1809  function item( $i ) {
1810  return $this->value[$i];
1811  }
1812 
1813  function getName() { return '#nodelist'; }
1814 
1815  function getNextSibling() {
1817  }
1819  function getChildren() { return false; }
1820  function getFirstChild() { return false; }
1821  function getChildrenOfType( $name ) { return false; }
1822  function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
1823  function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
1824  function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
1825 }
1830 class PPNode_Hash_Attr implements PPNode {
1831  var $name, $value, $nextSibling;
1832 
1833  function __construct( $name, $value ) {
1834  $this->name = $name;
1835  $this->value = $value;
1836  }
1837 
1838  function __toString() {
1839  return "<@{$this->name}>" . htmlspecialchars( $this->value ) . "</@{$this->name}>";
1840  }
1841 
1842  function getName() {
1843  return $this->name;
1844  }
1845 
1846  function getNextSibling() {
1848  }
1850  function getChildren() { return false; }
1851  function getFirstChild() { return false; }
1852  function getChildrenOfType( $name ) { return false; }
1853  function getLength() { return false; }
1854  function item( $i ) { return false; }
1855  function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
1856  function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
1857  function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
1858 }
PPNode_Hash_Tree\$lastChild
$lastChild
Definition: Preprocessor_Hash.php:1537
PPFrame_Hash\getArguments
getArguments()
Definition: Preprocessor_Hash.php:1270
PPNode_Hash_Tree\getLength
getLength()
Definition: Preprocessor_Hash.php:1613
PPDAccum_Hash\addAccum
addAccum( $accum)
Append a PPAccum_Hash Takes over ownership of the nodes in the source argument.
Definition: Preprocessor_Hash.php:851
PPFrame\STRIP_COMMENTS
const STRIP_COMMENTS
Definition: Preprocessor.php:75
PPDPart
Definition: Preprocessor_DOM.php:899
PPNode_Hash_Tree\getChildrenOfType
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
Definition: Preprocessor_Hash.php:1600
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
PPCustomFrame_Hash\__toString
__toString()
Definition: Preprocessor_Hash.php:1494
PPFrame_Hash\$depth
$depth
Recursion depth of this frame, top = 0 Note that this is NOT the same as expansion depth in expand()
Definition: Preprocessor_Hash.php:893
PPNode_Hash_Tree\item
item( $i)
Definition: Preprocessor_Hash.php:1621
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PPTemplateFrame_Hash\__construct
__construct( $preprocessor, $parent=false, $numberedArgs=array(), $namedArgs=array(), $title=false)
Definition: Preprocessor_Hash.php:1350
PPFrame_Hash\getPDBK
getPDBK( $level=false)
Definition: Preprocessor_Hash.php:1259
PPDPart_Hash
Definition: Preprocessor_Hash.php:792
PPFrame_Hash\getNumberedArguments
getNumberedArguments()
Definition: Preprocessor_Hash.php:1277
PPNode_Hash_Array\splitHeading
splitHeading()
Split an "<h>" node.
Definition: Preprocessor_Hash.php:1820
PPFrame_Hash\expand
expand( $root, $flags=0)
Definition: Preprocessor_Hash.php:955
PPNode_Hash_Tree\getFirstChild
getFirstChild()
Get the first child of a tree node.
Definition: Preprocessor_Hash.php:1592
PPNode_Hash_Tree\__construct
__construct( $name)
Definition: Preprocessor_Hash.php:1539
is
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
PPTemplateFrame_Hash\$parent
$parent
Definition: Preprocessor_Hash.php:1340
PPFrame\NO_ARGS
const NO_ARGS
Definition: Preprocessor.php:73
PPNode_Hash_Attr\$name
$name
Definition: Preprocessor_Hash.php:1827
PPTemplateFrame_Hash\$numberedArgs
$numberedArgs
Definition: Preprocessor_Hash.php:1340
Preprocessor
Definition: Preprocessor.php:27
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
Title\getPrefixedDBkey
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:1357
PPTemplateFrame_Hash\$numberedExpansionCache
$numberedExpansionCache
Definition: Preprocessor_Hash.php:1341
Preprocessor_Hash\__construct
__construct( $parser)
Create a new preprocessor object based on an initialised Parser object.
Definition: Preprocessor_Hash.php:37
PPFrame_Hash
An expansion frame, used as a context to expand the result of preprocessToObj()
Definition: Preprocessor_Hash.php:868
PPFrame\NO_IGNORE
const NO_IGNORE
Definition: Preprocessor.php:76
character
</p > ! end ! test Bare pipe character(bug 52363) !! wikitext|!! html< p >|</p > !! end !! test Bare pipe character from a template(bug 52363) !! wikitext
Definition: parserTests.txt:918
PPNode_Hash_Text\splitHeading
splitHeading()
Split an "<h>" node.
Definition: Preprocessor_Hash.php:1784
PPNode_Hash_Tree\splitHeading
splitHeading()
Split an "<h>" node.
Definition: Preprocessor_Hash.php:1703
PPNode_Hash_Attr\splitExt
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
Definition: Preprocessor_Hash.php:1852
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1040
PPCustomFrame_Hash\isEmpty
isEmpty()
Definition: Preprocessor_Hash.php:1513
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
PPNode_Hash_Text\__construct
__construct( $value)
Definition: Preprocessor_Hash.php:1761
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1530
PPNode_Hash_Text\getChildrenOfType
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
Definition: Preprocessor_Hash.php:1778
PPNode_Hash_Tree\splitExt
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
Definition: Preprocessor_Hash.php:1675
PPFrame_Hash\getNamedArguments
getNamedArguments()
Definition: Preprocessor_Hash.php:1284
PPNode_Hash_Text\getLength
getLength()
Returns the length of the array, or false if this is not an array-type node.
Definition: Preprocessor_Hash.php:1779
Preprocessor_Hash\newFrame
newFrame()
Definition: Preprocessor_Hash.php:44
PPFrame_Hash\__construct
__construct( $preprocessor)
Construct a new preprocessor frame.
Definition: Preprocessor_Hash.php:899
PPTemplateFrame_Hash\getNumberedArgument
getNumberedArgument( $index)
Definition: Preprocessor_Hash.php:1433
$s
$s
Definition: mergeMessageFileList.php:156
PPDStackElement
Definition: Preprocessor_DOM.php:825
PPFrame_Hash\$loopCheckHash
$loopCheckHash
Hashtable listing templates which are disallowed for expansion in this frame, having been encountered...
Definition: Preprocessor_Hash.php:887
Preprocessor_Hash
Differences from DOM schema:
Definition: Preprocessor_Hash.php:30
PPTemplateFrame_Hash\isEmpty
isEmpty()
Returns true if there are no arguments in this frame.
Definition: Preprocessor_Hash.php:1390
Makefile.open
open
Definition: Makefile.py:14
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
PPNode_Hash_Array\splitExt
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
Definition: Preprocessor_Hash.php:1819
PPTemplateFrame_Hash\$namedArgs
$namedArgs
Definition: Preprocessor_Hash.php:1340
PPFrame\RECOVER_COMMENTS
const RECOVER_COMMENTS
Definition: Preprocessor.php:77
PPFrame\NO_TEMPLATES
const NO_TEMPLATES
Definition: Preprocessor.php:74
PPNode_Hash_Array\splitArg
splitArg()
Split a "<part>" node into an associative array containing: name PPNode name index String index value...
Definition: Preprocessor_Hash.php:1818
Preprocessor_Hash\newCustomFrame
newCustomFrame( $args)
Definition: Preprocessor_Hash.php:52
PPFrame_Hash\$titleCache
$titleCache
Definition: Preprocessor_Hash.php:881
PPNode_Hash_Array\getFirstChild
getFirstChild()
Get the first child of a tree node.
Definition: Preprocessor_Hash.php:1816
PPNode_Hash_Attr\item
item( $i)
Returns an item of an array-type node.
Definition: Preprocessor_Hash.php:1850
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
PPNode_Hash_Attr\getFirstChild
getFirstChild()
Get the first child of a tree node.
Definition: Preprocessor_Hash.php:1847
PPNode_Hash_Attr\splitHeading
splitHeading()
Split an "<h>" node.
Definition: Preprocessor_Hash.php:1853
PPNode_Hash_Tree\$name
$name
Definition: Preprocessor_Hash.php:1537
PPNode_Hash_Attr\__construct
__construct( $name, $value)
Definition: Preprocessor_Hash.php:1829
PPFrame_Hash\virtualBracketedImplode
virtualBracketedImplode( $start, $sep, $end)
Virtual implode with brackets.
Definition: Preprocessor_Hash.php:1226
PPNode_Hash_Attr\getChildrenOfType
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
Definition: Preprocessor_Hash.php:1848
PPDAccum_Hash
Definition: Preprocessor_Hash.php:805
MWException
MediaWiki exception.
Definition: MWException.php:26
wfMemcKey
wfMemcKey()
Get a cache key.
Definition: GlobalFunctions.php:3571
PPNode_Hash_Array\getChildrenOfType
getChildrenOfType( $name)
Get all children of this tree node which have a given name.
Definition: Preprocessor_Hash.php:1817
$out
$out
Definition: UtfNormalGenerate.php:167
PPDStackElement\$count
$count
Definition: Preprocessor_DOM.php:826
PPNode_Hash_Text\$nextSibling
$nextSibling
Definition: Preprocessor_Hash.php:1759
PPTemplateFrame_Hash\getArguments
getArguments()
Definition: Preprocessor_Hash.php:1397
PPNode_Hash_Tree\getNextSibling
getNextSibling()
Get the next sibling of any node.
Definition: Preprocessor_Hash.php:1596
PPNode_Hash_Text\getNextSibling
getNextSibling()
Get the next sibling of any node.
Definition: Preprocessor_Hash.php:1772
PPNode_Hash_Text\__toString
__toString()
Definition: Preprocessor_Hash.php:1768
PPNode_Hash_Array\getLength
getLength()
Returns the length of the array, or false if this is not an array-type node.
Definition: Preprocessor_Hash.php:1801
Preprocessor_Hash\newPartNodeArray
newPartNodeArray( $values)
Definition: Preprocessor_Hash.php:60
PPNode_Hash_Tree\splitTemplate
splitTemplate()
Split a "<template>" or "<tplarg>" node.
Definition: Preprocessor_Hash.php:1730
there
has been added to your &Future changes to this page and its associated Talk page will be listed there
Definition: All_system_messages.txt:357
PPNode_Hash_Tree\__toString
__toString()
Definition: Preprocessor_Hash.php:1544
PPFrame_Hash\__toString
__toString()
Definition: Preprocessor_Hash.php:1251
PPDStackElement_Hash
Definition: Preprocessor_Hash.php:755
PPCustomFrame_Hash\__construct
__construct( $preprocessor, $args)
Definition: Preprocessor_Hash.php:1489
PPTemplateFrame_Hash\getNamedArgument
getNamedArgument( $name)
Definition: Preprocessor_Hash.php:1448
PPNode
There are three types of nodes:
Definition: Preprocessor.php:183
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
Preprocessor_Hash\CACHE_VERSION
const CACHE_VERSION
Definition: Preprocessor_Hash.php:35
Preprocessor_Hash\$parser
Parser $parser
Definition: Preprocessor_Hash.php:33
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
PPDStackElement_Hash\__construct
__construct( $data=array())
Definition: Preprocessor_Hash.php:756
PPFrame_Hash\isEmpty
isEmpty()
Returns true if there are no arguments in this frame.
Definition: Preprocessor_Hash.php:1293
PPNode_Hash_Attr\$value
$value
Definition: Preprocessor_Hash.php:1827
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
PPFrame_Hash\getArgument
getArgument( $name)
Definition: Preprocessor_Hash.php:1301
PPTemplateFrame_Hash\getNamedArguments
getNamedArguments()
Definition: Preprocessor_Hash.php:1421
PPNode_Hash_Attr\getLength
getLength()
Returns the length of the array, or false if this is not an array-type node.
Definition: Preprocessor_Hash.php:1849
PPNode_Hash_Array\$nextSibling
$nextSibling
Definition: Preprocessor_Hash.php:1791
PPNode_Hash_Tree\$firstChild
$firstChild
Definition: Preprocessor_Hash.php:1537
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:188
PPDPart_Hash\__construct
__construct( $out='')
Definition: Preprocessor_Hash.php:793
PPNode_Hash_Text\splitExt
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
Definition: Preprocessor_Hash.php:1783
PPNode_Hash_Text\$value
$value
Definition: Preprocessor_Hash.php:1759
PPDAccum_Hash\addLiteral
addLiteral( $s)
Append a string literal.
Definition: Preprocessor_Hash.php:815
PPNode_Hash_Array
Definition: Preprocessor_Hash.php:1790
PPTemplateFrame_Hash
Expansion frame with template arguments.
Definition: Preprocessor_Hash.php:1339
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
PPNode_Hash_Text\getFirstChild
getFirstChild()
Get the first child of a tree node.
Definition: Preprocessor_Hash.php:1777
$matches
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
Definition: NoLocalSettings.php:33
PPNode_Hash_Tree\getName
getName()
Definition: Preprocessor_Hash.php:1628
$value
$value
Definition: styleTest.css.php:45
PPFrame_Hash\getTitle
getTitle()
Get a title of frame.
Definition: Preprocessor_Hash.php:1330
PPFrame_Hash\$preprocessor
Preprocessor $preprocessor
Definition: Preprocessor_Hash.php:876
Preprocessor_Hash\preprocessToObj
preprocessToObj( $text, $flags=0)
Preprocess some wikitext and return the document tree.
Definition: Preprocessor_Hash.php:110
PPDStack
Stack class to help Preprocessor::preprocessToObj()
Definition: Preprocessor_DOM.php:737
PPFrame
Definition: Preprocessor.php:72
PPNode_Hash_Tree\getChildren
getChildren()
Definition: Preprocessor_Hash.php:1584
PPNode_Hash_Array\__construct
__construct( $value)
Definition: Preprocessor_Hash.php:1793
up
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set up
Definition: hooks.txt:1679
PPNode_Hash_Tree\addChild
addChild( $node)
Definition: Preprocessor_Hash.php:1572
PPNode_Hash_Attr\$nextSibling
$nextSibling
Definition: Preprocessor_Hash.php:1827
PPNode_Hash_Text\getName
getName()
Get the name of this node.
Definition: Preprocessor_Hash.php:1781
$version
$version
Definition: parserTests.php:86
PPDAccum_Hash\$firstNode
$firstNode
Definition: Preprocessor_Hash.php:806
PPNode_Hash_Text\getChildren
getChildren()
Get an array-type node containing the children of this node.
Definition: Preprocessor_Hash.php:1776
PPNode_Hash_Array\item
item( $i)
Returns an item of an array-type node.
Definition: Preprocessor_Hash.php:1805
PPFrame_Hash\implodeWithFlags
implodeWithFlags( $sep, $flags)
Definition: Preprocessor_Hash.php:1138
PPDPart\$out
$out
Definition: Preprocessor_DOM.php:900
PPCustomFrame_Hash\$args
$args
Definition: Preprocessor_Hash.php:1487
PPDAccum_Hash\addNode
addNode(PPNode $node)
Append a PPNode.
Definition: Preprocessor_Hash.php:829
PPNode_Hash_Array\getChildren
getChildren()
Get an array-type node containing the children of this node.
Definition: Preprocessor_Hash.php:1815
PPNode_Hash_Attr\getChildren
getChildren()
Get an array-type node containing the children of this node.
Definition: Preprocessor_Hash.php:1846
PPFrame_Hash\implode
implode( $sep)
Implode with no flags specified This previously called implodeWithFlags but has now been inlined to r...
Definition: Preprocessor_Hash.php:1167
$hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Definition: hooks.txt:2697
PPNode_Hash_Array\getName
getName()
Get the name of this node.
Definition: Preprocessor_Hash.php:1809
start
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to start
Definition: skin.txt:62
PPNode_Hash_Attr\getNextSibling
getNextSibling()
Get the next sibling of any node.
Definition: Preprocessor_Hash.php:1842
PPNode_Hash_Tree\$nextSibling
$nextSibling
Definition: Preprocessor_Hash.php:1537
$count
$count
Definition: UtfNormalTest2.php:96
PPNode_Hash_Attr
Definition: Preprocessor_Hash.php:1826
PPFrame_Hash\newChild
newChild( $args=false, $title=false, $indexOffset=0)
Create a new child frame $args is optionally a multi-root PPNode or array containing the template arg...
Definition: Preprocessor_Hash.php:919
$args
if( $line===false) $args
Definition: cdb.php:62
PPTemplateFrame_Hash\$namedExpansionCache
$namedExpansionCache
Definition: Preprocessor_Hash.php:1341
Title
Represents a title within MediaWiki.
Definition: Title.php:35
PPNode_Hash_Text
Definition: Preprocessor_Hash.php:1758
PPCustomFrame_Hash\getArgument
getArgument( $index)
Definition: Preprocessor_Hash.php:1521
PPNode_Hash_Text\item
item( $i)
Returns an item of an array-type node.
Definition: Preprocessor_Hash.php:1780
PPNode_Hash_Attr\getName
getName()
Get the name of this node.
Definition: Preprocessor_Hash.php:1838
PPDStack_Hash
Stack class to help Preprocessor::preprocessToObj()
Definition: Preprocessor_Hash.php:744
PPNode_Hash_Array\$value
$value
Definition: Preprocessor_Hash.php:1791
in
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
Definition: maintenance.txt:1
PPFrame_Hash\$parser
Parser $parser
Definition: Preprocessor_Hash.php:872
are
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are
Definition: contenthandler.txt:5
PPNode_Hash_Attr\splitArg
splitArg()
Split a "<part>" node into an associative array containing: name PPNode name index String index value...
Definition: Preprocessor_Hash.php:1851
PPDAccum_Hash\addNodeWithText
addNodeWithText( $name, $value)
Append a tree node with text contents.
Definition: Preprocessor_Hash.php:841
PPFrame_Hash\virtualImplode
virtualImplode( $sep)
Makes an object that, when expand()ed, will be the same as one obtained with implode()
Definition: Preprocessor_Hash.php:1197
PPDStackElement_Hash\breakSyntax
breakSyntax( $openingCount=false)
Get the accumulator that would result if the close is not found.
Definition: Preprocessor_Hash.php:766
PPNode_Hash_Array\getNextSibling
getNextSibling()
Get the next sibling of any node.
Definition: Preprocessor_Hash.php:1811
PPNode_Hash_Array\__toString
__toString()
Definition: Preprocessor_Hash.php:1797
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
PPDAccum_Hash\$lastNode
$lastNode
Definition: Preprocessor_Hash.php:806
PPCustomFrame_Hash\getArguments
getArguments()
Definition: Preprocessor_Hash.php:1528
PPCustomFrame_Hash
Expansion frame with custom arguments.
Definition: Preprocessor_Hash.php:1486
PPFrame_Hash\loopCheck
loopCheck( $title)
Returns true if the infinite loop check is OK, false if a loop is detected.
Definition: Preprocessor_Hash.php:1312
PPTemplateFrame_Hash\isTemplate
isTemplate()
Return true if the frame is a template frame.
Definition: Preprocessor_Hash.php:1477
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
PPTemplateFrame_Hash\getArgument
getArgument( $name)
Definition: Preprocessor_Hash.php:1464
PPNode_Hash_Tree\newWithText
static newWithText( $name, $text)
Definition: Preprocessor_Hash.php:1566
PPFrame_Hash\isTemplate
isTemplate()
Return true if the frame is a template frame.
Definition: Preprocessor_Hash.php:1321
PPNode_Hash_Text\splitArg
splitArg()
Split a "<part>" node into an associative array containing: name PPNode name index String index value...
Definition: Preprocessor_Hash.php:1782
PPNode_Hash_Tree
Definition: Preprocessor_Hash.php:1536
PPFrame_Hash\$title
Title $title
Definition: Preprocessor_Hash.php:880
PPDStack_Hash\__construct
__construct()
Definition: Preprocessor_Hash.php:745
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1530
PPTemplateFrame_Hash\__toString
__toString()
Definition: Preprocessor_Hash.php:1368
PPNode_Hash_Attr\__toString
__toString()
Definition: Preprocessor_Hash.php:1834
PPTemplateFrame_Hash\getNumberedArguments
getNumberedArguments()
Definition: Preprocessor_Hash.php:1410
PPDAccum_Hash\__construct
__construct()
Definition: Preprocessor_Hash.php:808
line
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for so if you want to use a style that puts opening braces on the next line
Definition: design.txt:79
PPNode_Hash_Tree\splitArg
splitArg()
Split a "<part>" node into an associative array containing:
Definition: Preprocessor_Hash.php:1641