Go to the documentation of this file.
92 if (
$path[0] !==
'/' ) {
98 if ( strpos(
$path,
'$1' ) ===
false ) {
99 if ( substr(
$path, -1 ) !==
'/' ) {
108 if ( !isset(
$params[
'title'] ) && strpos(
$path,
'$1' ) !==
false ) {
118 foreach (
$params as $paramName => $paramData ) {
119 if ( is_string( $paramData ) ) {
120 if ( preg_match(
'/\$(\d+|key)/u', $paramData ) ) {
121 $paramArrKey =
'pattern';
125 $paramArrKey =
'value';
128 $paramArrKey => $paramData
135 foreach (
$options as $optionName => $optionData ) {
136 if ( preg_match(
'/^\$\d+$/u', $optionName ) && !is_array( $optionData ) ) {
137 $options[$optionName] = [ $optionData ];
148 $this->patterns[] = $pattern;
159 if ( is_array(
$path ) ) {
160 foreach (
$path as $key => $onePath ) {
186 foreach ( $this->patterns
as $key => $pattern ) {
187 $weights[$key] = $pattern->weight;
189 array_multisort( $weights, SORT_DESC, SORT_NUMERIC, $this->patterns );
197 # Start with a weight of 0
201 $path = explode(
'/', $pattern->path );
203 # For each level of the path
205 if ( preg_match(
'/^\$(\d+|key)$/u', $piece ) ) {
206 # For a piece that is only a $1 variable add 1 points of weight
208 } elseif ( preg_match(
'/\$(\d+|key)/u', $piece ) ) {
209 # For a piece that simply contains a $1 variable add 2 points of weight
212 # For a solid piece add a full 3 points of weight
217 foreach ( $pattern->options
as $key => $option ) {
218 if ( preg_match(
'/^\$\d+$/u', $key ) ) {
219 # Add 0.5 for restrictions to values
220 # This way given two separate "/$2/$1" patterns the
221 # one with a limited set of $2 values will dominate
222 # the one that'll match more loosely
265 foreach ( $this->patterns
as $pattern ) {
281 $regexp = preg_quote( $pattern->path,
'#' );
283 $regexp = preg_replace(
'#\\\\\$1#u',
'(?P<par1>.*)', $regexp );
285 $regexp = preg_replace(
'#\\\\\$(\d+)#u',
'(?P<par$1>.+?)', $regexp );
286 $regexp =
"#^{$regexp}$#";
292 if ( preg_match( $regexp,
$path, $m ) ) {
295 foreach ( $pattern->options
as $key => $option ) {
296 if ( preg_match(
'/^\$\d+$/u', $key ) ) {
297 $n = intval( substr( $key, 1 ) );
298 $value = rawurldecode( $m[
"par{$n}"] );
299 if ( !in_array(
$value, $option ) ) {
308 foreach ( $m
as $matchKey => $matchValue ) {
309 if ( preg_match(
'/^par\d+$/u', $matchKey ) ) {
310 $n = intval( substr( $matchKey, 3 ) );
311 $data[
'$' . $n] = rawurldecode( $matchValue );
315 if ( isset( $pattern->key ) ) {
316 $data[
'$key'] = $pattern->key;
320 foreach ( $pattern->params
as $paramName => $paramData ) {
324 if ( preg_match(
'/^data:/u', $paramName ) ) {
326 $key = substr( $paramName, 5 );
332 if ( isset( $paramData[
'value'] ) ) {
334 $value = $paramData[
'value'];
335 } elseif ( isset( $paramData[
'pattern'] ) ) {
338 $paramData[
'pattern'] );
354 if ( isset( $pattern->options[
'callback'] ) ) {
355 call_user_func_array( $pattern->options[
'callback'], [ &
$matches,
$data ] );
376 $replacer =
function ( $m )
use ( $pathMatches, $key, &$error ) {
377 if ( $m[1] ==
"key" ) {
378 if ( is_null( $key ) ) {
387 if ( !isset( $pathMatches[
"par$d"] ) ) {
393 return rawurldecode( $pathMatches[
"par$d"] );
397 $value = preg_replace_callback(
'/\$(\d+|key)/u', $replacer,
$value );
add( $path, $params=[], $options=[])
Add a new path pattern to the path router.
internalParse( $path)
Match a path against each defined pattern.
doAdd( $path, $params, $options, $key=null)
Protected helper to do the actual bulk work of adding a single pattern.
addStrict( $path, $params=[], $options=[])
Add a new path pattern to the path router with the strict option on.
wfRemoveDotSegments( $urlPath)
Remove all dot-segments in the provided URL path.
parse( $path)
Parse a path and return the query matches for the path.
static makeWeight( $pattern)
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
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
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))
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 & $options
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
sortByWeight()
Protected helper to re-sort our patterns so that the most specific (most heavily weighted) patterns a...
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 $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 object
static expandParamValue( $pathMatches, $key, $value)
Replace $key etc.
static extractTitle( $path, $pattern)