diff --git a/plugins/password/composer.json b/plugins/password/composer.json index 028ef373a..1e7fb6f84 100644 --- a/plugins/password/composer.json +++ b/plugins/password/composer.json @@ -3,7 +3,7 @@ "type": "roundcube-plugin", "description": "Password Change for Roundcube. Plugin adds a possibility to change user password using many methods (drivers) via Settings/Password tab.", "license": "GPLv3+", - "version": "5.0", + "version": "5.1", "authors": [ { "name": "Aleksander Machniak", diff --git a/plugins/password/drivers/sql.php b/plugins/password/drivers/sql.php index ca7e0d983..d68edda02 100644 --- a/plugins/password/drivers/sql.php +++ b/plugins/password/drivers/sql.php @@ -5,7 +5,7 @@ * * Driver for passwords stored in SQL database * - * @version 2.0 + * @version 2.1 * @author Aleksander Machniak * * Copyright (C) The Roundcube Dev Team @@ -23,9 +23,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ - class rcube_sql_password { + /** + * Update current user password + * + * @param string $curpass Current password + * @param string $passwd New password + * + * @return int Result + */ function save($curpass, $passwd) { $rcmail = rcmail::get_instance(); @@ -159,11 +166,11 @@ class rcube_sql_password } } else { - // This is the good case: 1 row updated - if ($db->affected_rows($res) == 1) + // Note: Don't be tempted to check affected_rows = 1. For some queries + // (e.g. INSERT ... ON DUPLICATE KEY UPDATE) the result can be 2. + if ($db->affected_rows($res) > 0) { return PASSWORD_SUCCESS; - // @TODO: Some queries don't affect any rows - // Should we assume a success if there was no error? + } } } @@ -172,6 +179,10 @@ class rcube_sql_password /** * Parse DSN string and replace host variables + * + * @param string $dsn DSN string + * + * @return string DSN string */ protected static function parse_dsn($dsn) {