ApiQueryCategories: Supply limit for DB query
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 28 Aug 2019 20:34:30 +0000 (16:34 -0400)
committerMobrovac <mobrovac@wikimedia.org>
Mon, 2 Sep 2019 11:39:45 +0000 (11:39 +0000)
The limit is applied in PHP, but all matching rows are being fetched
from the database. We should only fetch the number of rows needed.

Bug: T231462
Change-Id: Ie64ea6f79a187942c476868c383a1349d110aa7c

includes/api/ApiQueryCategories.php

index 547a4e8..79347e6 100644 (file)
@@ -127,6 +127,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                                'cl_to' . $sort
                        ] );
                }
+               $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
                $res = $this->select( __METHOD__ );