jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/365177 )
Change subject: Fix DB timeout from API queries without project specified ...................................................................... Fix DB timeout from API queries without project specified Bug: T170638 Change-Id: I2c878f173b7f9ec353750b70ed1b19df019a47d9 --- M api/ApiQueryProjectPages.php M i18n/en.json 2 files changed, 8 insertions(+), 7 deletions(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/api/ApiQueryProjectPages.php b/api/ApiQueryProjectPages.php index b903cb4..dc0c4e5 100644 --- a/api/ApiQueryProjectPages.php +++ b/api/ApiQueryProjectPages.php @@ -42,8 +42,8 @@ $this->buildDbQuery( $params, $resultPageSet ); - // If matching projects were found, or no specific projects were requested, run the query. - if ( $this->projectIds || !$params['projects'] ) { + // If matching projects were found, run the query. + if ( $this->projectIds ) { $db_res = $this->select( __METHOD__ ); // Otherwise, just set the result to an empty array (still works with foreach). } else { @@ -157,8 +157,8 @@ $this->handleQueryContinuation( $params['continue'] ); } - // If more than 1 project is requested (or all projects), order by project first. - if ( count( $this->projectIds ) !== 1 ) { + // If more than 1 project is requested, order by project first. + if ( count( $this->projectIds ) > 1 ) { $this->addOption( 'ORDER BY', 'pa_project_id, pa_page_id' ); } else { $this->addOption( 'ORDER BY', 'pa_page_id' ); @@ -205,7 +205,8 @@ ApiBase::PARAM_TYPE => 'boolean', ], 'projects' => [ - ApiBase::PARAM_ISMULTI => true + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_REQUIRED => true, ], 'limit' => [ ApiBase::PARAM_DFLT => '10', @@ -222,7 +223,7 @@ public function getExamplesMessages() { return [ - 'action=query&list=projectpages' + 'action=query&list=projectpages&wppprojects=Medicine|Anatomy' => 'apihelp-query+projectpages-example-simple-1', 'action=query&list=projectpages&wppprojects=Medicine&wppassessments=true' => 'apihelp-query+projectpages-example-simple-2', diff --git a/i18n/en.json b/i18n/en.json index d5594e3..209877e 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -18,7 +18,7 @@ "apihelp-query+projectpages-param-assessments": "Also return assessments for the pages returned.", "apihelp-query+projectpages-param-projects": "The projects to list pages for. If this parameter is omitted, all projects will be included.", "apihelp-query+projectpages-param-limit": "The maximum number of pages to return.", - "apihelp-query+projectpages-example-simple-1": "Get first 10 pages associated with any WikiProject.", + "apihelp-query+projectpages-example-simple-1": "Get first 10 pages associated with WikiProject <kbd>Medicine</kbd> or WikiProject <kbd>Anatomy</kbd>.", "apihelp-query+projectpages-example-simple-2": "Get first 10 pages associated with WikiProject <kbd>Medicine</kbd>, including assessment data.", "apihelp-query+projectpages-example-generator": "Get page info for first 10 pages associated with WikiProject <kbd>Textile Arts</kbd>.", "apihelp-query+projects-description": "List all the projects.", -- To view, visit https://gerrit.wikimedia.org/r/365177 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2c878f173b7f9ec353750b70ed1b19df019a47d9 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/PageAssessments Gerrit-Branch: master Gerrit-Owner: Kaldari <rkald...@wikimedia.org> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits