From 4f3ed071d46be79b362c01b5f5fff41f85b78d05 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Fri, 25 Jul 2014 10:42:27 +0200 Subject: [PATCH] MDL-45041 Web Service: add_user_device doesn't store entries for different users using the same push key --- lib/db/install.xml | 1 - lib/db/upgrade.php | 10 ++++++++++ user/externallib.php | 10 ---------- version.php | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index ec46f1df119..5ead98106bd 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -3064,7 +3064,6 @@ - diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f2caa411b42..dbc25dcc614 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2993,5 +2993,15 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2013111803.05); } + if ($oldversion < 2013111804.03) { + $table = new xmldb_table('user_devices'); + $oldindex = new xmldb_index('pushid-platform', XMLDB_KEY_UNIQUE, array('pushid', 'platform')); + if ($dbman->index_exists($table, $oldindex)) { + $key = new xmldb_key('pushid-platform', XMLDB_KEY_UNIQUE, array('pushid', 'platform')); + $dbman->drop_key($table, $key); + } + upgrade_main_savepoint(true, 2013111804.03); + } + return true; } diff --git a/user/externallib.php b/user/externallib.php index 1cbd067ddee..1bc740885a0 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -1052,16 +1052,6 @@ class core_user_external extends external_api { return $warnings; } - // The same key can't exists for the same platform. - if ($DB->get_record('user_devices', array('pushid' => $params['pushid'], 'platform' => $params['platform']))) { - $warnings['warning'][] = array( - 'item' => $params['pushid'], - 'warningcode' => 'existingkeyforplatform', - 'message' => 'This key is already stored for other device using the same platform' - ); - return $warnings; - } - $userdevice = new stdclass; $userdevice->userid = $USER->id; $userdevice->appid = $params['appid']; diff --git a/version.php b/version.php index a345abe7ec4..247e3b10ec4 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2013111804.02; // 20131118 = branching date YYYYMMDD - do not modify! +$version = 2013111804.03; // 20131118 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes.