diff options
author | Bartosz Dziewoński <matma.rex@gmail.com> | 2022-09-16 12:34:51 +0200 |
---|---|---|
committer | Bartosz Dziewoński <matma.rex@gmail.com> | 2022-09-29 16:04:23 +0000 |
commit | 00b74a0e4b1ee133a2c657c59150bd5aad0c7939 (patch) | |
tree | b033e8334c45e78b35a269824e397b8478a1bc80 /includes/api/ApiQueryLinks.php | |
parent | 872970a21ccdb7e9deb1f88311d9e58d6e87458b (diff) | |
download | mediawikicore-00b74a0e4b1ee133a2c657c59150bd5aad0c7939.tar.gz mediawikicore-00b74a0e4b1ee133a2c657c59150bd5aad0c7939.zip |
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
Diffstat (limited to 'includes/api/ApiQueryLinks.php')
-rw-r--r-- | includes/api/ApiQueryLinks.php | 17 |
1 files changed, 8 insertions, 9 deletions
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' : '' ); |