MDL-45041 Web Service: add_user_device doesn't store entries for different users using the same push key

This commit is contained in:
Juan Leyva 2014-07-25 10:35:24 +02:00
parent 40f0ad21a3
commit a1bacaf13d
4 changed files with 11 additions and 12 deletions

View File

@ -2959,7 +2959,6 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="pushid-userid" TYPE="unique" FIELDS="pushid, userid"/>
<KEY NAME="pushid-platform" TYPE="unique" FIELDS="pushid, platform"/>
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
</KEYS>
</TABLE>

View File

@ -3709,5 +3709,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014070101.00);
}
if ($oldversion < 2014072400.01) {
$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, 2014072400.01);
}
return true;
}

View File

@ -1119,16 +1119,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'];

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2014072400.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2014072400.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.