Fix missing mbstring: replace mb_strtolower with strtolower
Production server (PHP 8.4) doesn't have mbstring extension, causing 500 error on saatavuus endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
20
api.php
20
api.php
@@ -1,20 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
// Virheraportointi (debug)
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
set_error_handler(function($errno, $errstr, $errfile, $errline) {
|
|
||||||
http_response_code(500);
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode(['php_error' => $errstr, 'file' => basename($errfile), 'line' => $errline]);
|
|
||||||
exit;
|
|
||||||
});
|
|
||||||
set_exception_handler(function($e) {
|
|
||||||
http_response_code(500);
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode(['php_exception' => $e->getMessage(), 'file' => basename($e->getFile()), 'line' => $e->getLine()]);
|
|
||||||
exit;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Turvalliset session-asetukset
|
// Turvalliset session-asetukset
|
||||||
ini_set('session.cookie_httponly', 1);
|
ini_set('session.cookie_httponly', 1);
|
||||||
ini_set('session.cookie_secure', 1);
|
ini_set('session.cookie_secure', 1);
|
||||||
@@ -117,7 +101,7 @@ function saveConfig(array $config): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalizeAddress(string $addr): string {
|
function normalizeAddress(string $addr): string {
|
||||||
$addr = mb_strtolower(trim($addr));
|
$addr = strtolower(trim($addr));
|
||||||
$addr = preg_replace('/\s+/', ' ', $addr);
|
$addr = preg_replace('/\s+/', ' ', $addr);
|
||||||
return $addr;
|
return $addr;
|
||||||
}
|
}
|
||||||
@@ -318,7 +302,7 @@ switch ($action) {
|
|||||||
foreach ($c['liittymat'] ?? [] as $l) {
|
foreach ($c['liittymat'] ?? [] as $l) {
|
||||||
$addr = normalizeAddress($l['asennusosoite'] ?? '');
|
$addr = normalizeAddress($l['asennusosoite'] ?? '');
|
||||||
$zip = trim($l['postinumero'] ?? '');
|
$zip = trim($l['postinumero'] ?? '');
|
||||||
$city = mb_strtolower(trim($l['kaupunki'] ?? ''));
|
$city = strtolower(trim($l['kaupunki'] ?? ''));
|
||||||
$hit = false;
|
$hit = false;
|
||||||
|
|
||||||
// Postinumero-haku
|
// Postinumero-haku
|
||||||
|
|||||||
Reference in New Issue
Block a user