Addshore has submitted this change and it was merged.
Change subject: Add use declarations for core classes, fix style issues
......................................................................
Add use declarations for core classes, fix style issues
Change-Id: Idede243ccfe5d55c91d051418d981dc968390f0a
---
M lib/includes/Utils.php
1 file changed, 20 insertions(+), 12 deletions(-)
Approvals:
WikidataJenkins: Verified
Addshore: Looks good to me, approved
diff --git a/lib/includes/Utils.php b/lib/includes/Utils.php
index 3982d57..6bcc9db 100644
--- a/lib/includes/Utils.php
+++ b/lib/includes/Utils.php
@@ -2,8 +2,12 @@
namespace Wikibase;
+use FormatJson;
+use Http;
use Language;
+use MWException;
use SiteSQLStore;
+use Sites;
/**
* Utility functions for Wikibase.
@@ -30,14 +34,14 @@
static $languageCodes = null;
if ( is_null( $languageCodes ) ) {
- $languageCodes = array_keys(
\Language::fetchLanguageNames() );
+ $languageCodes = array_keys(
Language::fetchLanguageNames() );
}
return $languageCodes;
}
/**
- * @see \Language::fetchLanguageName()
+ * @see Language::fetchLanguageName()
*
* @since 0.1
*
@@ -48,16 +52,19 @@
*/
public static function fetchLanguageName( $languageCode, $inLanguage =
null ) {
$languageCode = str_replace( '_', '-', $languageCode );
+
if ( isset( $inLanguage ) ) {
$inLanguage = str_replace( '_', '-', $inLanguage );
- $languageName = \Language::fetchLanguageName(
$languageCode, $inLanguage );
+ $languageName = Language::fetchLanguageName(
$languageCode, $inLanguage );
}
else {
- $languageName = \Language::fetchLanguageName(
$languageCode );
+ $languageName = Language::fetchLanguageName(
$languageCode );
}
+
if ( $languageName == '' ) {
$languageName = $languageCode;
}
+
return $languageName;
}
@@ -65,13 +72,14 @@
* Inserts some sites into the sites table, if the sites table is
currently empty.
* Called when update.php is run. The initial sites are loaded from
https://meta.wikimedia.org.
*
- * @param \DatabaseUpdater $updater database updater. Not used. Present
to be compatible with DatabaseUpdater::addExtensionUpdate
+ * @param DatabaseUpdater $updater database updater. Not used. Present
to be
+ * compatible with DatabaseUpdater::addExtensionUpdate
*
- * @throws \MWException if an error occurs.
+ * @throws MWException if an error occurs.
* @since 0.1
*/
public static function insertDefaultSites( $updater = null ) {
- if ( \Sites::singleton()->getSites()->count() > 0 ) {
+ if ( Sites::singleton()->getSites()->count() > 0 ) {
return;
}
@@ -90,7 +98,7 @@
* @param String|bool $stripProtocol Causes any leading http or
https to be stripped from URLs, forcing
* the remote sites to be references in a
protocol-relative way.
*
- * @throws \MWException if an error occurs.
+ * @throws MWException if an error occurs.
* @since 0.1
*/
public static function insertSitesFrom( $url, $stripProtocol = false ) {
@@ -100,19 +108,19 @@
$url .= '?action=sitematrix&format=json';
//NOTE: the raiseException option needs change Iad3995a6 to be
merged, otherwise it is ignored.
- $json = \Http::get( $url, 'default', array( 'raiseException' =>
true ) );
+ $json = Http::get( $url, 'default', array( 'raiseException' =>
true ) );
if ( !$json ) {
- throw new \MWException( "Got no data from $url" );
+ throw new MWException( "Got no data from $url" );
}
- $languages = \FormatJson::decode(
+ $languages = FormatJson::decode(
$json,
true
);
if ( !is_array( $languages ) ) {
- throw new \MWException( "Failed to parse JSON from
$url" );
+ throw new MWException( "Failed to parse JSON from $url"
);
}
$groupMap = array(
--
To view, visit https://gerrit.wikimedia.org/r/119710
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idede243ccfe5d55c91d051418d981dc968390f0a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits