MDL-84394 ai: ensure provider instance config correctly encoded.

This commit is contained in:
Paul Holden 2025-01-31 10:18:11 +00:00
parent 07881a5772
commit 750077f3cd
No known key found for this signature in database
GPG key ID: A81A96D6045F6164
2 changed files with 1 additions and 3 deletions

View file

@ -380,7 +380,7 @@ class manager {
$provider = new $classname(
enabled: $enabled,
name: $name,
config: $config ? json_encode($config) : '',
config: json_encode($config ?? []),
);
$id = $this->db->insert_record('ai_providers', $provider->to_record());

View file

@ -41,11 +41,9 @@ final class provider_test extends \advanced_testcase {
// Create the provider instance.
$this->manager = \core\di::get(\core_ai\manager::class);
$config = ['data' => 'goeshere'];
$this->provider = $this->manager->create_provider_instance(
classname: '\aiprovider_openai\provider',
name: 'dummy',
config: $config,
);
}