From 3fa588c637e6777dbe255e6488f3e4aaf8ce59b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dagef=C3=B6rde?= Date: Thu, 13 Jul 2017 15:36:57 +0200 Subject: [PATCH] MDL-59511 oauth2: Allow empty email in system account --- lib/classes/oauth2/api.php | 2 +- lib/db/install.xml | 2 +- lib/db/upgrade.php | 12 ++++++++++++ version.php | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/classes/oauth2/api.php b/lib/classes/oauth2/api.php index 966ea3ffa06..a27e60525fe 100644 --- a/lib/classes/oauth2/api.php +++ b/lib/classes/oauth2/api.php @@ -752,7 +752,7 @@ class api { $record->issuerid = $issuer->get('id'); $record->refreshtoken = $refreshtoken; $record->grantedscopes = $scopes; - $record->email = $userinfo['email']; + $record->email = isset($userinfo['email']) ? $userinfo['email'] : ''; $record->username = $userinfo['username']; $systemaccount = new system_account(0, $record); diff --git a/lib/db/install.xml b/lib/db/install.xml index e947ca7aa8b..b83f3183a54 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -3520,7 +3520,7 @@ - + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index ca24cd9e828..3120399a619 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2214,5 +2214,17 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2017072000.02); } + if ($oldversion < 2017072700.01) { + // Changing nullability of field email on table oauth2_system_account to null. + $table = new xmldb_table('oauth2_system_account'); + $field = new xmldb_field('email', XMLDB_TYPE_TEXT, null, null, null, null, null, 'grantedscopes'); + + // Launch change of nullability for field email. + $dbman->change_field_notnull($table, $field); + + // Main savepoint reached. + upgrade_main_savepoint(true, 2017072700.01); + } + return true; } diff --git a/version.php b/version.php index 7ae262ab3e4..cf1bb369b02 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2017072700.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2017072700.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.