Commit 3aeefdf1 authored by Kevin Rickis's avatar Kevin Rickis Committed by Robert Lyon

Bug 1487464: SAML creating new email artefact on login

Problem is the dealing with the email artefact type happens after the check
for is_singular(), which 'email' artefact type is not.

behatnotneeded

Change-Id: I4d1ffbb2fb89cc705bf3e2e6211f22e24ca55b26
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent d6af8c86
...@@ -1667,10 +1667,6 @@ function artefact_instance_from_type($artefact_type, $user_id=null) { ...@@ -1667,10 +1667,6 @@ function artefact_instance_from_type($artefact_type, $user_id=null) {
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $artefact_type)); safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $artefact_type));
if (!call_static_method(generate_artefact_class_name($artefact_type), 'is_singular')) {
throw new ArtefactNotFoundException("This artefact type is not a 'singular' artefact type");
}
// email is special (as in the user can have more than one of them, but // email is special (as in the user can have more than one of them, but
// it's treated as a 0 or 1 artefact and the primary is returned // it's treated as a 0 or 1 artefact and the primary is returned
if ($artefact_type == 'email') { if ($artefact_type == 'email') {
...@@ -1685,8 +1681,11 @@ function artefact_instance_from_type($artefact_type, $user_id=null) { ...@@ -1685,8 +1681,11 @@ function artefact_instance_from_type($artefact_type, $user_id=null) {
return new $classname($id); return new $classname($id);
} }
else { else {
$sql = 'SELECT a.*, i.plugin if (!call_static_method(generate_artefact_class_name($artefact_type), 'is_singular')) {
FROM {artefact} a throw new ArtefactNotFoundException("This artefact type is not a 'singular' artefact type");
}
$sql = 'SELECT a.*, i.plugin
FROM {artefact} a
JOIN {artefact_installed_type} i ON a.artefacttype = i.name JOIN {artefact_installed_type} i ON a.artefacttype = i.name
WHERE a.artefacttype = ? AND a.owner = ?'; WHERE a.artefacttype = ? AND a.owner = ?';
if (!$data = get_record_sql($sql, array($artefact_type, $user_id))) { if (!$data = get_record_sql($sql, array($artefact_type, $user_id))) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment