diff --git a/README.md b/README.md index 7278bef..5625b6e 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych. ## Instalacja -W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.42.2). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.42.3). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.42.3.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.42.3.sql new file mode 100644 index 0000000..efdd806 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.42.3.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.42.3. diff --git a/administrator/components/com_testquestions/src/Model/ResultModel.php b/administrator/components/com_testquestions/src/Model/ResultModel.php index 3786fc3..69efeea 100644 --- a/administrator/components/com_testquestions/src/Model/ResultModel.php +++ b/administrator/components/com_testquestions/src/Model/ResultModel.php @@ -94,22 +94,29 @@ class ResultModel extends BaseDatabaseModel $provider = trim((string) $params->get('ai_provider', 'openai')); $apiKey = trim((string) $params->get('ai_api_key', '')); - // Pole typu password może zwrócić zamaskowaną wartość zamiast pustej. - // W takim przypadku odczytaj rzeczywiste parametry bezpośrednio z rekordu rozszerzenia. - if ($apiKey === '' || preg_match('/^\*+$/', $apiKey)) { - $db = Factory::getContainer()->get('DatabaseDriver'); - $storedParams = (string) $db->setQuery( - $db->getQuery(true) - ->select($db->quoteName('params')) - ->from($db->quoteName('#__extensions')) - ->where($db->quoteName('type') . ' = ' . $db->quote('component')) - ->where($db->quoteName('element') . ' = ' . $db->quote('com_testquestions')) - )->loadResult(); - $storedParams = json_decode($storedParams, true); + // Odczytaj zapisane parametry bezpośrednio z bazy. Dzięki temu nie użyjemy + // nieaktualnej wartości z pamięci ComponentHelper, a maska pola hasła + // (np. ********) nie zostanie potraktowana jako prawdziwy klucz. + $db = Factory::getContainer()->get('DatabaseDriver'); + $storedParams = (string) $db->setQuery( + $db->getQuery(true) + ->select($db->quoteName('params')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('type') . ' = ' . $db->quote('component')) + ->where($db->quoteName('element') . ' = ' . $db->quote('com_testquestions')) + )->loadResult(); + $storedParams = json_decode($storedParams, true); - if (is_array($storedParams)) { - $provider = trim((string) ($storedParams['ai_provider'] ?? $provider)); - $apiKey = trim((string) ($storedParams['ai_api_key'] ?? '')); + if (is_array($storedParams)) { + $storedProvider = trim((string) ($storedParams['ai_provider'] ?? '')); + $storedApiKey = trim((string) ($storedParams['ai_api_key'] ?? '')); + + if ($storedProvider !== '') { + $provider = $storedProvider; + } + + if ($storedApiKey !== '' && !preg_match('/^\*+$/', $storedApiKey)) { + $apiKey = $storedApiKey; } } diff --git a/com_testquestions.xml b/com_testquestions.xml index ec98edd..9cc09e8 100644 --- a/com_testquestions.xml +++ b/com_testquestions.xml @@ -4,7 +4,7 @@ 2026-10-14 Komponent GNU General Public License version 2 or later - 1.42.2 + 1.42.3 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions