Password: Support INSERT ... ON DUPLICATE KEY UPDATE queries

pull/6911/head
Aleksander Machniak 5 years ago
parent 27bfd0884e
commit fcf5a12e30

@ -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",

@ -5,7 +5,7 @@
*
* Driver for passwords stored in SQL database
*
* @version 2.0
* @version 2.1
* @author Aleksander Machniak <alec@alec.pl>
*
* 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)
{

Loading…
Cancel
Save