From 5577d92bf54efeb8c5196053de5888bfe1eb574e Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Fri, 25 Sep 2015 00:15:14 -0400 Subject: [PATCH] User::incEditCountImmediate(): Add explicit IS NOT NULL check Within the UPDATE query, if user_editcount IS NULL, user_editcount+1 will also be NULL, and the change becomes a no-op. So in MySQL, the number of affected rows would be zero, which is the number of rows that actually changed. However, other DBMSs (e.g. PostgreSQL, SQLite) do count no-op changes, meaning the code would not initialize user_editcount if it were NULL. Explicitly checking for NULL should ensure consistent behavior across database types. Also, if the CLIENT_FOUND_ROWS flag is set when connecting to MySQL, the server returns "Rows matched:" instead of "Changed:" as the affected row count. This change would be necessary if MediaWiki, like Drupal, is changed to use that flag . Change-Id: Idac160bae56adc5c5d17f8558c55d87000019741 --- includes/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/User.php b/includes/User.php index 029f5cf292..3dcd4804f8 100644 --- a/includes/User.php +++ b/includes/User.php @@ -4852,7 +4852,7 @@ class User implements IDBAccessObject { $dbw->update( 'user', array( 'user_editcount=user_editcount+1' ), - array( 'user_id' => $this->getId() ), + array( 'user_id' => $this->getId(), 'user_editcount IS NOT NULL' ), __METHOD__ ); // Lazy initialization check... -- 2.20.1