return $value;
}
+
+ /**
+ * @internal For use by Title and WebRequest only.
+ * @param array $actionPaths
+ * @param string $articlePath
+ * @return string[]|false
+ */
+ public static function getActionPaths( array $actionPaths, $articlePath ) {
+ if ( !$actionPaths ) {
+ return false;
+ }
+ // Processing of urls for this feature requires that 'view' is set.
+ // By default, set it to the pretty article path.
+ if ( !isset( $actionPaths['view'] ) ) {
+ $actionPaths['view'] = $articlePath;
+ }
+ return $actionPaths;
+ }
}
}
}
-if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
- // 'view' is assumed the default action path everywhere in the code
- // but is rarely filled in $wgActionPaths
- $wgActionPaths['view'] = $wgArticlePath;
-}
-
if ( $wgResourceBasePath === null ) {
$wgResourceBasePath = $wgScriptPath;
}
$url = false;
$matches = [];
- if ( !empty( $wgActionPaths )
+ $articlePaths = PathRouter::getActionPaths( $wgActionPaths, $wgArticlePath );
+
+ if ( $articlePaths
&& preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches )
) {
$action = urldecode( $matches[2] );
- if ( isset( $wgActionPaths[$action] ) ) {
+ if ( isset( $articlePaths[$action] ) ) {
$query = $matches[1];
if ( isset( $matches[4] ) ) {
$query .= $matches[4];
}
- $url = str_replace( '$1', $dbkey, $wgActionPaths[$action] );
+ $url = str_replace( '$1', $dbkey, $articlePaths[$action] );
if ( $query != '' ) {
$url = wfAppendQuery( $url, $query );
}
}
global $wgActionPaths;
- if ( $wgActionPaths ) {
- $router->add( $wgActionPaths, [ 'action' => '$key' ] );
+ $articlePaths = PathRouter::getActionPaths( $wgActionPaths, $wgArticlePath );
+ if ( $articlePaths ) {
+ $router->add( $articlePaths, [ 'action' => '$key' ] );
}
global $wgVariantArticlePath;