MediaWiki  master
mwdoc-filter.php
Go to the documentation of this file.
1 <?php
41 // Warning: Converting this to a Maintenance script may reduce performance.
42 if ( PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg' ) {
43  die( "This filter can only be run from the command line.\n" );
44 }
45 
46 $source = file_get_contents( $argv[1] );
47 $tokens = token_get_all( $source );
48 
49 $buffer = $bufferType = null;
50 foreach ( $tokens as $token ) {
51  if ( is_string( $token ) ) {
52  if ( $buffer !== null && $token === ';' ) {
53  // If we still have a buffer and the statement has ended,
54  // flush it and move on.
55  echo $buffer;
56  $buffer = $bufferType = null;
57  }
58  echo $token;
59  continue;
60  }
61  list( $id, $content ) = $token;
62  switch ( $id ) {
63  case T_DOC_COMMENT:
64  // Escape slashes so that references to namespaces are not
65  // wrongly interpreted as a Doxygen "\command".
66  $content = addcslashes( $content, '\\' );
67  // Look for instances of "@var Type" not followed by $name.
68  if ( preg_match( '#@var\s+([^\s]+)\s+([^\$]+)#s', $content ) ) {
69  $buffer = preg_replace_callback(
70  // Strip the "@var Type" part and remember the type
71  '#(@var\s+)([^\s]+)#s',
72  function ( $matches ) use ( &$bufferType ) {
73  $bufferType = $matches[2];
74  return '';
75  },
76  $content
77  );
78  } else {
79  echo $content;
80  }
81  break;
82 
83  case T_VARIABLE:
84  if ( $buffer !== null ) {
85  echo $buffer;
86  echo "$bufferType $content";
87  $buffer = $bufferType = null;
88  } else {
89  echo $content;
90  }
91  break;
92 
93  default:
94  if ( $buffer !== null ) {
95  $buffer .= $content;
96  } else {
97  echo $content;
98  }
99  break;
100  }
101 }
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$source
$tokens
$buffer
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$content
Definition: pageupdater.txt:72
$matches