From 4c92f40ba5071027dee719c3cdd63198be7b8c89 Mon Sep 17 00:00:00 2001 From: Chris Pittman Date: Fri, 26 Jan 2024 07:34:06 -0600 Subject: [PATCH] fix: truncate platform names to match db column size fixes #25 --- src/PlatformCreator.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PlatformCreator.php b/src/PlatformCreator.php index 175ad5a..cef5717 100644 --- a/src/PlatformCreator.php +++ b/src/PlatformCreator.php @@ -25,7 +25,11 @@ public static function createLTI1p2Platform( if ($platform->created !== null) { throw new \RuntimeException("Platform with this key already exists. Refusing to overwrite."); } - $platform->name = $name; + if (strlen($name) > 50) { + $platform->name = substr($name, 0, 50); + } else { + $platform->name = $name; + } $platform->secret = $secret; $platform->enabled = true; $platform->save(); @@ -45,7 +49,11 @@ public static function createLTI1p3Platform( ): void { $platform = LTI\Platform::fromPlatformId($platform_id, $client_id, $deployment_id, $dataConnector); - $platform->name = $platform_id; + if (strlen($platform_id) > 50) { + $platform->name = substr($platform_id, 0, 50); + } else { + $platform->name = $platform_id; + } $platform->authorizationServerId = $authorization_server_id; $platform->jku = $jku; $platform->authenticationUrl = $authentication_url;