jenkins-bot has submitted this change and it was merged.
Change subject: Improve ApiQueryProofread error handling
......................................................................
Improve ApiQueryProofread error handling
Change-Id: I00c2070dbe71efa19b0330d6237f31ffe23105a0
---
M ApiQueryProofread.php
1 file changed, 17 insertions(+), 6 deletions(-)
Approvals:
Phe: Looks good to me, but someone else must approve
Tpt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ApiQueryProofread.php b/ApiQueryProofread.php
index e465d52..19e1f89 100644
--- a/ApiQueryProofread.php
+++ b/ApiQueryProofread.php
@@ -54,28 +54,39 @@
$qualityLevels = array_flip( $qualityCategories );
// <Reedy> johnduhart, it'd seem sane rather than duplicating
the functionality
- $params = new FauxRequest(array(
+ $params = new FauxRequest( array(
'action' => 'query',
'prop' => 'categories',
'pageids' => implode( '|', $pageIds ),
'clcategories' => implode( '|', $qualityCategories ),
'cllimit' => 'max'
- ));
+ ) );
$api = new ApiMain($params);
$api->execute();
$data = $api->getResultData();
unset( $api );
+ if ( array_key_exists( 'error', $data ) ) {
+ $this->dieUsageMsg( $data['error'] );
+ }
+
$result = $this->getResult();
foreach ( $data['query']['pages'] as $pageid => $data) {
- $title = $data['categories'][0]['title'];
- if ( !isset( $qualityLevels[ $title ] ) ) {
+ if ( !array_key_exists( 'categories', $data ) ) {
continue;
}
+ $title = $data['categories'][0]['title'];
+ if ( !array_key_exists( $title, $qualityLevels ) ) {
+ continue;
+ }
$pageQuality = $qualityLevels[ $title ];
- $val = array( 'quality' => $pageQuality,
'quality_text' => $qualityText[ $pageQuality ] );
+
+ $val = array(
+ 'quality' => $pageQuality,
+ 'quality_text' => $qualityText[ $pageQuality ]
+ );
$result->addValue( array( 'query', 'pages', $pageid ),
'proofread', $val );
}
}
@@ -94,7 +105,7 @@
public function getExamples() {
return array(
-
'api.php?action=query&generator=allpages&gapnamespace=104&prop=proofread'
+
'api.php?action=query&generator=allpages&gapnamespace=250&prop=proofread'
);
}
--
To view, visit https://gerrit.wikimedia.org/r/93155
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I00c2070dbe71efa19b0330d6237f31ffe23105a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <[email protected]>
Gerrit-Reviewer: Phe <[email protected]>
Gerrit-Reviewer: Rtdwivedi <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits