From 00b74a0e4b1ee133a2c657c59150bd5aad0c7939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 16 Sep 2022 12:34:51 +0200 Subject: Use buildComparison() instead of raw SQL in more API modules (easy cases) See ec79aa394312d62b598ad29601e2c80eaaf0dd19 about the new method. These changes all follow the same simple patterns. More complex cases are handled in I6231b6beae13474d4986929367a9adc6bb76b0db. This commit was created by running the following terrible Ruby script I devised: https://phabricator.wikimedia.org/P34833, then manually reviewing the results: checking that the output makes sense in general, that the affected variables are not used elsewhere in the file, and that no comparison conditions have been lost. A few incorrect changes were undone or corrected. Change-Id: I8ed363bd6b80a9481d44434a526f078cce20220f --- includes/api/ApiQueryLinks.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'includes/api/ApiQueryLinks.php') diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 98d00d817a39..0a5335d97ff8 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -150,19 +150,18 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { } if ( $params['continue'] !== null ) { + $db = $this->getDB(); $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 3 ); - $op = $params['dir'] == 'descending' ? '<' : '>'; + $op = $params['dir'] == 'descending' ? '<=' : '>='; $plfrom = (int)$cont[0]; $plns = (int)$cont[1]; - $pltitle = $this->getDB()->addQuotes( $cont[2] ); - $this->addWhere( - "{$this->prefix}_from $op $plfrom OR " . - "({$this->prefix}_from = $plfrom AND " . - "($nsField $op $plns OR " . - "($nsField = $plns AND " . - "$titleField $op= $pltitle)))" - ); + $pltitle = $cont[2]; + $this->addWhere( $db->buildComparison( $op, [ + "{$this->prefix}_from" => $plfrom, + $nsField => $plns, + $titleField => $pltitle, + ] ) ); } $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); -- cgit v1.2.3