54 $this->factory = MediaWikiServices::getInstance()->getMagicWordFactory();
63 public function add( $name ) {
65 $this->hash = $this->baseRegex = $this->regex =
null;
75 $this->hash = $this->baseRegex = $this->regex =
null;
83 if ( is_null( $this->hash ) ) {
84 $this->hash = [ 0 => [], 1 => [] ];
86 $magic = $this->factory->get(
$name );
87 $case = intval( $magic->isCaseSensitive() );
88 foreach ( $magic->getSynonyms()
as $syn ) {
90 $syn = $this->factory->getContentLanguage()->lc( $syn );
92 $this->hash[$case][$syn] =
$name;
104 if ( is_null( $this->baseRegex ) ) {
105 $this->baseRegex = [ 0 =>
'', 1 =>
'' ];
108 $magic = $this->factory->get(
$name );
109 $case = intval( $magic->isCaseSensitive() );
110 foreach ( $magic->getSynonyms()
as $i => $syn ) {
112 $it = strtr( $i,
'0123456789',
'abcdefghij' );
113 $groupName = $it .
'_' .
$name;
114 $group =
'(?P<' . $groupName .
'>' . preg_quote( $syn,
'/' ) .
')';
116 if ( isset( $allGroups[$groupName] ) ) {
118 __METHOD__ .
': duplicate internal name in magic word array: ' .
$name
121 $allGroups[$groupName] =
true;
122 if ( $this->baseRegex[$case] ===
'' ) {
123 $this->baseRegex[$case] = $group;
125 $this->baseRegex[$case] .=
'|' . $group;
138 if ( is_null( $this->regex ) ) {
140 $this->regex = [
'',
'' ];
141 if ( $this->baseRegex[0] !==
'' ) {
142 $this->regex[0] =
"/{$base[0]}/iuS";
144 if ( $this->baseRegex[1] !==
'' ) {
145 $this->regex[1] =
"/{$base[1]}/S";
157 return str_replace(
"\\$1",
"(.*?)", $this->
getRegex() );
167 $newRegex = [
'',
'' ];
168 if (
$base[0] !==
'' ) {
169 $newRegex[0] =
"/^(?:{$base[0]})/iuS";
171 if (
$base[1] !==
'' ) {
172 $newRegex[1] =
"/^(?:{$base[1]})/S";
184 $newRegex = [
'',
'' ];
185 if (
$base[0] !==
'' ) {
186 $newRegex[0] = str_replace(
"\\$1",
"(.*?)",
"/^(?:{$base[0]})$/iuS" );
188 if (
$base[1] !==
'' ) {
189 $newRegex[1] = str_replace(
"\\$1",
"(.*?)",
"/^(?:{$base[1]})$/S" );
214 while ( ( $key =
key( $m ) ) !==
null ) {
217 if ( $key === 0 ||
$value ===
'' ) {
220 $parts = explode(
'_', $key, 2 );
221 if ( count( $parts ) != 2 ) {
224 throw new MWException( __METHOD__ .
': bad parameter name' );
226 list( , $magicName ) = $parts;
227 $paramValue = next( $m );
228 return [ $magicName, $paramValue ];
231 throw new MWException( __METHOD__ .
': parameter not found' );
249 if ( preg_match(
$regex, $text, $m ) ) {
254 return [
false,
false ];
267 if ( isset(
$hash[1][$text] ) ) {
268 return $hash[1][$text];
270 $lc = $this->factory->getContentLanguage()->lc( $text );
271 return $hash[0][$lc] ??
false;
291 if (
$res ===
false ) {
292 LoggerFactory::getInstance(
'parser' )->warning(
'preg_match_all returned false', [
293 'code' => preg_last_error(),
300 $found[
$name] = $param;
304 if (
$res ===
null ) {
305 LoggerFactory::getInstance(
'parser' )->warning(
'preg_replace returned null', [
306 'code' => preg_last_error(),
332 if ( preg_match(
$regex, $text, $m ) ) {
334 if ( strlen( $m[0] ) >= strlen( $text ) ) {
337 $text = substr( $text, strlen( $m[0] ) );
within a display generated by the Derivative if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You alongside or as an addendum to the NOTICE text from the provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for or distribution of Your or for any such Derivative Works as a provided Your and distribution of the Work otherwise complies with the conditions stated in this License Submission of Contributions Unless You explicitly state any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this without any additional terms or conditions Notwithstanding the nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions Trademarks This License does not grant permission to use the trade names
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Class for handling an array of magic words.
matchVariableStartToEnd( $text)
Match some text, with parameter capture Returns an array with the magic word name in the first elemen...
add( $name)
Add a magic word by name.
getVariableRegex()
Get a regex for matching variables with parameters.
__construct( $names=[], MagicWordFactory $factory=null)
parseMatch( $m)
Parse a match array from preg_match Returns array(magic word ID, parameter value) If there is no para...
matchStartToEnd( $text)
Match some text, without parameter capture Returns the magic word name, or false if there was no capt...
getRegexStart()
Get a regex anchored to the start of the string that does not match parameters.
getBaseRegex()
Get the base regex.
matchStartAndRemove(&$text)
Return the ID of the magic word at the start of $text, and remove the prefix from $text.
getRegex()
Get an unanchored regex that does not match parameters.
getVariableStartToEndRegex()
Get an anchored regex for matching variables with parameters.
getHash()
Get a 2-d hashtable for this array.
MagicWordFactory $factory
matchAndRemove(&$text)
Returns an associative array, ID => param value, for all items that match Removes the matched items f...
addArray( $names)
Add a number of magic words by name.
A factory that stores information about MagicWords, and creates them on demand with caching.
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
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))