- Allow extensions to hook into WebRequest::getPathInfo and add to or alter the way titles are extracted from paths
- Add a $variant argument to the GetLocalURL hook; It's always had $query, but never had $variant. As a result extensions using GetLocalURL never new if getLocalURL and have the possibility of trying to change the url in cases where they shouldn't and as a result breaking links on wiki with language variants.
- Add GetLocalURL::Internal hook for non-interwiki links. These kinds of links internally use a ugly hack for action=render and an extension using GetLocalURL can be buggy in render mode if they don't re-implement the same ugly hack that MW does. This ::Internal hook runs before the hack does so extension authors don't need to be exposed to our ugly hacky code.
- Add GetLocalURL::Article hook specifically for url tweaks to pretty urls (ie: Only when we would apply $wgArticlePath); This hook avoids the need for extensions that only want to tweak pretty url output. This hook avoids the need to make a bunch of tests for things like !$title->isExternal(), $query == '', and $variant === false which getLocalURL does and could potentially change in the future making wider GetLocalURL hooks change in function requiring extension updates.
as with templates.
* Installer now issues a warning if mod_security is present.
* (bug 29455) Add support for a filter callback function in jQuery byteLimit plugin.
+* Extensions can now participate in the extraction of titles from url paths
+* Added two new GetLocalURL hooks to better serve extensions working on a limited
+ type of titles.
=== Bug fixes in 1.19 ===
* $wgUploadNavigationUrl should be used for file redlinks if
indexed by page_id.
&$colours: (output) array of CSS classes, indexed by prefixed DB keys
-'GetLocalURL': modify local URLs as output into page links
+'GetLocalURL': modify local URLs as output into page links. Note that if you
+ are working with internal urls (non-interwiki) then it may be preferable
+ to work with the GetLocalURL::Internal or GetLocalURL::Article hooks as
+ GetLocalURL can be buggy for internal urls on render if you do not
+ re-implement the horrible hack that Title::getLocalURL uses
+ in your own extension.
$title: Title object of page
-$url: string value as output (out parameter, can modify)
+&$url: string value as output (out parameter, can modify)
+$query: query options passed to Title::getLocalURL()
+$variant: variant options passed to Title::getLocalURL()
+
+'GetLocalURL::Internal': modify local URLs to internal pages.
+$title: Title object of page
+&$url: string value as output (out parameter, can modify)
$query: query options passed to Title::getLocalURL()
+$variant: variant options passed to Title::getLocalURL()
+
+'GetLocalURL::Article': modify local URLs specifically pointing to article paths
+ without any fancy queries or variants.
+$title: Title object of page
+&$url: string value as output (out parameter, can modify)
'GetMetadataVersion': modify the image metadata version currently in use. This is
used when requesting image metadata from a ForiegnApiRepo. Media handlers
$redirect: whether the page is a redirect
$skin: Skin object
+'WebRequestGetPathInfoRequestURI': while extracting path info from REQUEST_URI.
+ Allows an extension to extend the extraction of titles from paths.
+ Implementing hooks should follow the pattern used in core:
+ * Use the `$matches = WebRequest::extractTitle` pattern
+ * Ensure that you test `if ( !$matches ) {` before you try extracting a title
+ from the path so that you don't override an already found match.
+$path: The request path to extract a title from.
+&$matches: The array to apply matches to.
+
'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions
dumps
One, and only one hook should set this, and return false.
$url = str_replace( '$1', $dbkey, $url );
} else {
$url = str_replace( '$1', $dbkey, $wgArticlePath );
+ wfRunHooks( 'GetLocalURL::Article', array( &$this, &$url ) );
}
} else {
global $wgActionPaths;
$url = "{$wgScript}?title={$dbkey}&{$query}";
}
}
+
+ wfRunHooks( 'GetLocalURL::Internal', array( &$this, &$url, $query, $variant ) );
// @todo FIXME: This causes breakage in various places when we
// actually expected a local URL and end up with dupe prefixes.
$url = $wgServer . $url;
}
}
- wfRunHooks( 'GetLocalURL', array( &$this, &$url, $query ) );
+ wfRunHooks( 'GetLocalURL', array( &$this, &$url, $query, $variant ) );
return $url;
}
}
$matches = self::extractTitle( $path, $variantPaths, 'variant' );
}
+
+ wfRunHooks( 'WebRequestGetPathInfoRequestURI', array( $path, &$matches ) );
}
} elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
// Mangled PATH_INFO
}
/**
- * Internal URL rewriting function; tries to extract page title and,
+ * URL rewriting function; tries to extract page title and,
* optionally, one other fixed parameter value from a URL path.
*
* @param $path string: the URL path given from the client
* passed on as the value of this URL parameter
* @return array of URL variables to interpolate; empty if no match
*/
- private static function extractTitle( $path, $bases, $key = false ) {
+ static function extractTitle( $path, $bases, $key = false ) {
foreach( (array)$bases as $keyValue => $base ) {
// Find the part after $wgArticlePath
$base = str_replace( '$1', '', $base );