Compare commits

...

2 Commits

Author SHA1 Message Date
4056296dab ver. 0.317: klucz API — przycisk generowania + fix zapisu
- fix: api_key brakowało w whiteliście saveSettings() — wartość tracona przy zapisie
- feat: przycisk "Generuj" losowy 32-znakowy klucz, usunięto "(ordersPRO)" z nazwy
- fix: api.php routing przeniesiony przed global settings + Throwable error handling
- fix: ApiRouter catch Throwable zamiast Exception

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 23:30:41 +01:00
7158f4d369 build: update package v0.316
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:01:50 +01:00
9 changed files with 99 additions and 16 deletions

45
api.php
View File

@@ -47,6 +47,43 @@ if ( !$isApiRequest )
}
}
// --- API routing (ordersPRO) ---
if ( $isApiRequest )
{
if ( !headers_sent() )
header( 'Content-Type: application/json; charset=utf-8' );
try
{
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => $database[ 'name' ],
'server' => $database[ 'host' ],
'username' => $database[ 'user' ],
'password' => $database[ 'password' ],
'charset' => 'utf8'
] );
$settingsRepo = new \Domain\Settings\SettingsRepository( $mdb );
$router = new \api\ApiRouter( $mdb, $settingsRepo );
$router->handle();
}
catch ( \Throwable $e )
{
if ( !headers_sent() )
header( 'Content-Type: application/json; charset=utf-8' );
http_response_code( 500 );
echo json_encode( [
'status' => 'error',
'code' => 'INTERNAL_ERROR',
'message' => 'Internal server error'
], JSON_UNESCAPED_UNICODE );
}
exit;
}
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => $database[ 'name' ],
@@ -59,14 +96,6 @@ $mdb = new medoo( [
$settingsRepo = new \Domain\Settings\SettingsRepository( $mdb );
$settings = $settingsRepo->allSettings();
// --- API routing (ordersPRO) ---
if ( $isApiRequest )
{
$router = new \api\ApiRouter( $mdb, $settingsRepo );
$router->handle();
exit;
}
// --- Ekomi CSV export ---
if ( \Shared\Helpers\Helpers::get( 'ekomi_csv' ) )
{

View File

@@ -71,6 +71,7 @@ class SettingsRepository
'infinitescroll' => $this->isEnabled($values['infinitescroll'] ?? null) ? 1 : 0,
'own_gtm_js' => $values['own_gtm_js'] ?? '',
'own_gtm_html' => $values['own_gtm_html'] ?? '',
'api_key' => $values['api_key'] ?? '',
];
$warehouseMessageZero = $values['warehouse_message_zero'] ?? [];

View File

@@ -471,8 +471,7 @@ class SettingsController
'label' => 'Htaccess cache',
'tab' => 'system',
]),
FormField::text('api_key', [
'label' => 'Klucz API (ordersPRO)',
FormField::custom('api_key', $this->renderApiKeyField($data['api_key'] ?? ''), [
'tab' => 'system',
]),
@@ -560,4 +559,23 @@ class SettingsController
return $data;
}
private function renderApiKeyField(string $value): string
{
$escaped = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
$js = "var c='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',"
. "k='';for(var i=0;i<32;i++){k+=c.charAt(Math.floor(Math.random()*c.length));}"
. "document.getElementById('api_key').value=k;";
return '<div class="form-group row">'
. '<label class="col-lg-4 control-label">Klucz API:</label>'
. '<div class="col-lg-8">'
. '<div class="input-group">'
. '<input type="text" id="api_key" class="form-control" name="api_key" value="' . $escaped . '" />'
. '<span class="input-group-addon btn btn-info" onclick="' . htmlspecialchars($js, ENT_QUOTES, 'UTF-8') . '">Generuj</span>'
. '</div>'
. '</div>'
. '</div>';
}
}

View File

@@ -46,7 +46,7 @@ class ApiRouter
}
$controller->$action();
} catch (\Exception $e) {
} catch (\Throwable $e) {
self::sendError('INTERNAL_ERROR', 'Internal server error', 500);
}
}

View File

@@ -4,6 +4,15 @@ Logi zmian z migracji na Domain-Driven Architecture. Najnowsze na gorze.
---
## ver. 0.317 (2026-02-23) - Klucz API: przycisk generowania + fix zapisu
- **FIX**: `SettingsRepository::saveSettings()` — pole `api_key` brakowało w whiteliście zapisywanych pól, przez co wartość była tracona przy każdym zapisie (TRUNCATE + insert)
- **NEW**: Pole "Klucz API" w ustawieniach — przycisk "Generuj" do losowego 32-znakowego klucza alfanumerycznego, usunięto "(ordersPRO)" z nazwy
- **FIX**: `api.php` — routing API przeniesiony przed ładowanie globalnych settings (wczesne wyjście), obsługa błędów przez `\Throwable`
- **FIX**: `ApiRouter` — catch `\Throwable` zamiast `\Exception` dla pełniejszego łapania błędów
---
## ver. 0.316 (2026-02-23) - Migracja brakującej kolumny type w custom fields
- **FIX**: Dodanie brakującej kolumny `type` w tabeli `pp_shop_products_custom_fields` — kolumna była używana w kodzie od v0.277 ale nigdy nie miała migracji ALTER TABLE, przez co instancje ze starszą bazą dostawały `PDOException: Column not found: 1054 Unknown column 'type'` przy zapisie produktu

BIN
updates/0.30/ver_0.316.zip Normal file

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"changelog": "FIX - migracja brakujacej kolumny type w pp_shop_products_custom_fields",
"version": "0.316",
"files": {
"added": [
],
"deleted": [
],
"modified": [
]
},
"checksum_zip": "sha256:654a3683c0add19d0cb2f87db6f6a45cd4ce08799dd3692c6adacc07666f13b1",
"sql": [
"ALTER TABLE `pp_shop_products_custom_fields` ADD COLUMN `type` VARCHAR(30) NOT NULL DEFAULT \u0027\u0027 AFTER `name`;"
],
"date": "2026-02-23",
"directories_deleted": [
]
}

View File

@@ -1,17 +1,20 @@
<b>ver. 0.316 - 23.02.2026</b><br />
FIX - migracja brakujacej kolumny type w pp_shop_products_custom_fields
<hr>
<b>ver. 0.315 - 23.02.2026</b><br />
FIX - PDOException w listowaniu atrybutow admin (SQLSTATE HY093)
<hr>
<b>ver. 0.314 - 23.02.2026</b><br />
FIX - naprawa globalnej wyszukiwarki admin (Content-Type, Cache-Control, POST, try/catch), NEW - title strony z numerem zamĂłwienia
FIX - naprawa globalnej wyszukiwarki admin (Content-Type, Cache-Control, POST, try/catch), NEW - title strony z numerem zamĂłwienia
<hr>
<b>ver. 0.313 - 23.02.2026</b><br />
FIX - sync płatności Apilo (int cast na apilo_order_id PPxxxxxx dawał 0) + logowanie decyzji sync do pp_log
FIX - sync pÄąââ¬ĹˇatnoÄąââ¬Ĺźci Apilo (int cast na apilo_order_id PPxxxxxx dawaĹ‚ 0) + logowanie decyzji sync do pp_log
<hr>
<b>ver. 0.312 - 23.02.2026</b><br />
FIX - krytyczne bugi integracji Apilo: curl_getinfo po curl_close, nieskoĹ„czona pÄ™tla wysyÄąââ¬Ĺˇki, ceny 0.00 PLN, walidacja cen
FIX - krytyczne bugi integracji Apilo: curl_getinfo po curl_close, nieskoĹ„czona pÄ‚ââ¬ĹľÄ˘ââ¬ĹľĂ˜tla wysyĄąĢ€ški, ceny 0.00 PLN, walidacja cen
<hr>
<b>ver. 0.311 - 23.02.2026</b><br />
FIX - race condition callback pĄąĢ€šatnoĄąĢ€şci Apilo, persistence filtrĂłw tabel admin, poprawki cen zamÄ‚Ĺââ¬ĹˇwieĄąĢ€ž
FIX - race condition callback pÄ‚ââ¬ĹľÄ„ââ¬Â¦Ă„‚Ă˜Ä˘ââ¬ĹˇĂ¬ÄąĂ‡atnoÄ‚ââ¬ĹľÄ„ââ¬Â¦Ă„‚Ă˜Ä˘ââ¬ĹˇĂ¬ÄąĹşci Apilo, persistence filtrĂłw tabel admin, poprawki cen zamÄĢ€šĄąĢ€šwieÄ‚ââ¬ĹľÄ„ââ¬Â¦Ă„‚Ă˜Ä˘ââ¬ĹˇĂ¬ÄąÄľ
<hr>
<b>ver. 0.310 - 23.02.2026</b><br />
NEW - Zakladka Logi w sekcji Integracje (podglad pp_log z paginacja, sortowaniem, filtrami)

View File

@@ -1,5 +1,5 @@
<?
$current_ver = 316;
$current_ver = 317;
for ($i = 1; $i <= $current_ver; $i++)
{