User::incEditCountImmediate(): Add explicit IS NOT NULL check
authorKevin Israel <pleasestand@live.com>
Fri, 25 Sep 2015 04:15:14 +0000 (00:15 -0400)
committerUmherirrender <umherirrender_de.wp@web.de>
Tue, 29 Sep 2015 18:52:31 +0000 (18:52 +0000)
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 <https://www.drupal.org/node/805858>.

Change-Id: Idac160bae56adc5c5d17f8558c55d87000019741

includes/User.php

index 029f5cf..3dcd480 100644 (file)
@@ -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...