Compare commits

...

5 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
1d613d8226 fix: build-update.ps1 obsługa SQL-only paczek (0 plików)
Skrypt failował przy Set-Location do temp dir który nie istniał
gdy paczka nie miała plików (tylko migracja SQL).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:00:57 +01:00
174a85a707 ver. 0.316: migracja brakującej kolumny type w pp_shop_products_custom_fields
Kolumna type była używana w kodzie od v0.277 ale nigdy nie miała
migracji ALTER TABLE. Instancje ze starszą bazą dostawały
PDOException: Column not found przy zapisie produktu.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:00:03 +01:00
835386a887 build: update package v0.315
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 17:52:58 +01:00
13 changed files with 146 additions and 17 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

@@ -262,6 +262,10 @@ if (Test-Path $tempDir) {
Remove-Item -Recurse -Force $tempDir
}
if (-not (Test-Path $tempDir)) {
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
}
foreach ($f in $filesToPack) {
$destPath = Join-Path $tempDir $f
$destDir = Split-Path $destPath -Parent
@@ -295,7 +299,16 @@ if (Test-Path $zipPath) {
# Pakuj zawartosc temp dir (bez folderu temp/)
$originalLocation = Get-Location
Set-Location $tempDir
Compress-Archive -Path '*' -DestinationPath "../../$zipPath" -Force
$tempItems = Get-ChildItem -Force
if ($tempItems) {
Compress-Archive -Path '*' -DestinationPath "../../$zipPath" -Force
} else {
# SQL-only update: create minimal ZIP with empty placeholder
$placeholderPath = "_sql_only_update.txt"
Set-Content -Path $placeholderPath -Value "SQL-only update $versionNumber"
Compress-Archive -Path $placeholderPath -DestinationPath "../../$zipPath" -Force
Remove-Item $placeholderPath -Force
}
Set-Location $originalLocation
Write-Ok "Utworzono ZIP: $zipPath"

View File

@@ -4,6 +4,21 @@ 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
---
## ver. 0.315 (2026-02-23) - Fix listowania atrybutów w admin
- **FIX**: `AttributeRepository::listForAdmin()` — zapytanie COUNT dostawało parametr `:default_lang_id` którego nie miało w SQL, powodując `PDOException: SQLSTATE[HY093]: Invalid parameter number`. Parametr potrzebny tylko w głównym SELECT, nie w COUNT

1
migrations/0.316.sql Normal file
View File

@@ -0,0 +1 @@
ALTER TABLE `pp_shop_products_custom_fields` ADD COLUMN `type` VARCHAR(30) NOT NULL DEFAULT '' AFTER `name`;

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

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"changelog": "FIX - PDOException w listowaniu atrybutow admin (SQLSTATE HY093)",
"version": "0.315",
"files": {
"added": [
],
"deleted": [
],
"modified": [
"autoload/Domain/Attribute/AttributeRepository.php"
]
},
"checksum_zip": "sha256:cfe6eb7dfad896c4ea885c2f9a52c6a389d4e38379a0bf64f5d429910d87e55f",
"sql": [
],
"date": "2026-02-23",
"directories_deleted": [
]
}

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,14 +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 = 315;
$current_ver = 317;
for ($i = 1; $i <= $current_ver; $i++)
{