aboutsummaryrefslogtreecommitdiffstats
path: root/includes/deferred
diff options
context:
space:
mode:
authorPppery <mapreader@olum.org>2025-03-19 22:59:18 -0400
committerReedy <reedy@wikimedia.org>2025-03-20 15:48:17 +0000
commitb9c99fc622fd633d196467c773eef4ca32bea85f (patch)
tree0217bc67a6227444d1e08a951c90c50938e4b045 /includes/deferred
parent46ac6adf8581ebdfd1a5225aaafe5684b140c25d (diff)
downloadmediawikicore-b9c99fc622fd633d196467c773eef4ca32bea85f.tar.gz
mediawikicore-b9c99fc622fd633d196467c773eef4ca32bea85f.zip
Fix GREATEST usage in site_stats
For the positive-delta case since the row can't be negative the `GREATEST` is useless, so delete it. For the negative-delta case do the GREATEST before the subtraction so that it doesn't try to temporarily go negative. Bug: T315573 Change-Id: I0a27a57835048ee6a06266d377ed8f3f52ddf435 (cherry picked from commit 4017d2b6d60c6eb5c02ca48c8d8eeb74a18ba262)
Diffstat (limited to 'includes/deferred')
-rw-r--r--includes/deferred/SiteStatsUpdate.php11
1 files changed, 4 insertions, 7 deletions
diff --git a/includes/deferred/SiteStatsUpdate.php b/includes/deferred/SiteStatsUpdate.php
index 28e1fee4a2ac..1f67b787fc16 100644
--- a/includes/deferred/SiteStatsUpdate.php
+++ b/includes/deferred/SiteStatsUpdate.php
@@ -138,16 +138,13 @@ class SiteStatsUpdate implements DeferrableUpdate, MergeableUpdate {
$delta = (int)$deltaByType[$type];
$initValues[$field] = $delta;
if ( $delta > 0 ) {
- $set[$field] = new RawSQLValue( $dbw->buildGreatest(
- [ $field => $dbw->addIdentifierQuotes( $field ) . '+' . abs( $delta ) ],
- 0
- ) );
+ $set[$field] = new RawSQLValue( $dbw->addIdentifierQuotes( $field ) . '+' . abs( $delta ) );
} elseif ( $delta < 0 ) {
$hasNegativeDelta = true;
$set[$field] = new RawSQLValue( $dbw->buildGreatest(
- [ 'new' => $dbw->addIdentifierQuotes( $field ) . '-' . abs( $delta ) ],
- 0
- ) );
+ [ 'new' => $dbw->addIdentifierQuotes( $field ) ],
+ abs( $delta )
+ ) . '-' . abs( $delta ) );
}
}