From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- includes/api/ApiQueryBase.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'includes/api/ApiQueryBase.php') diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index a15754ce..c66e21b7 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -123,6 +123,7 @@ abstract class ApiQueryBase extends ApiBase { */ public function selectNamedDB( $name, $db, $groups ) { $this->mDb = $this->getQuery()->getNamedDB( $name, $db, $groups ); + return $this->mDb; } /** @@ -503,7 +504,7 @@ abstract class ApiQueryBase extends ApiBase { * capitalization settings. * * @param string $titlePart Title part - * @param int $defaultNamespace Namespace of the title + * @param int $namespace Namespace of the title * @return string DBkey (no namespace prefix) */ public function titlePartToKey( $titlePart, $namespace = NS_MAIN ) { @@ -524,6 +525,24 @@ abstract class ApiQueryBase extends ApiBase { return substr( $t->getDbKey(), 0, -1 ); } + /** + * Convert an input title or title prefix into a namespace constant and dbkey. + * + * @since 1.26 + * @param string $titlePart Title part + * @param int $defaultNamespace Default namespace if none is given + * @return array (int, string) Namespace number and DBkey + */ + public function prefixedTitlePartToKey( $titlePart, $defaultNamespace = NS_MAIN ) { + $t = Title::newFromText( $titlePart . 'x', $defaultNamespace ); + if ( !$t || $t->hasFragment() || $t->isExternal() ) { + // Invalid title (e.g. bad chars) or contained a '#'. + $this->dieUsageMsg( array( 'invalidtitle', $titlePart ) ); + } + + return array( $t->getNamespace(), substr( $t->getDbKey(), 0, -1 ) ); + } + /** * Gets the personalised direction parameter description * -- cgit v1.2.3-54-g00ecf