Kaldari has uploaded a new change for review. ( 
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
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/77/365177/1

diff --git a/api/ApiQueryProjectPages.php b/api/ApiQueryProjectPages.php
index b903cb4..4c4969d 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',

-- 
To view, visit https://gerrit.wikimedia.org/r/365177
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c878f173b7f9ec353750b70ed1b19df019a47d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageAssessments
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to