jenkins-bot has submitted this change and it was merged.
Change subject: Drop dead try-catch from populateInterwiki
......................................................................
Drop dead try-catch from populateInterwiki
An rtrim() can't throw an exception. I re-arranged the code without
changing semantics (as far as I can tell, please double-check).
Additionally I cleaned up some other bits in the same file:
* Added missing PHPDocs.
* Added array type hint.
* Made an if more specific (note that $data can be anything, e.g. a
string).
Change-Id: Ic68328ea87ef19f1329e9c88bb29ad40c2d061e3
---
M client/maintenance/populateInterwiki.php
1 file changed, 14 insertions(+), 11 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/maintenance/populateInterwiki.php
b/client/maintenance/populateInterwiki.php
index 0c63025..8ae618a 100644
--- a/client/maintenance/populateInterwiki.php
+++ b/client/maintenance/populateInterwiki.php
@@ -62,36 +62,39 @@
}
}
+ /**
+ * @return array[]|bool The 'interwikimap' sub-array or false on
failure.
+ */
protected function fetchLinks() {
- $params = array(
+ $url = wfArrayToCgi( array(
'action' => 'query',
'meta' => 'siteinfo',
'siprop' => 'interwikimap',
'sifilteriw' => 'local',
'format' => 'json'
- );
+ ) );
if ( !empty( $this->source ) ) {
- try {
- $baseUrl = rtrim( $this->source, '?' ) . '?';
- } catch( Exception $e ) {
- $this->error( "Error: Invalid api source" );
- }
+ $url = rtrim( $this->source, '?' ) . '?' . $url;
}
-
- $url = $baseUrl . wfArrayToCgi( $params );
$json = Http::get( $url );
$data = FormatJson::decode( $json, true );
- if ( $data ) {
+ if ( is_array( $data ) ) {
return $data['query']['interwikimap'];
} else {
return false;
}
}
- protected function doPopulate( $data, $force ) {
+ /**
+ * @param array[] $data
+ * @param bool $force
+ *
+ * @return bool
+ */
+ protected function doPopulate( array $data, $force ) {
$dbw = wfGetDB( DB_MASTER );
if ( !$force ) {
--
To view, visit https://gerrit.wikimedia.org/r/188337
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic68328ea87ef19f1329e9c88bb29ad40c2d061e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits