From: Kevin Israel Date: Fri, 25 Sep 2015 04:15:14 +0000 (-0400) Subject: User::incEditCountImmediate(): Add explicit IS NOT NULL check X-Git-Tag: 1.31.0-rc.0~9669 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=5577d92bf54efeb8c5196053de5888bfe1eb574e;p=lhc%2Fweb%2Fwiklou.git 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 --- 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...