From d5a3727884dd799faff260486988364841f58690 Mon Sep 17 00:00:00 2001 From: Thomas Bartelt Date: Sun, 27 Sep 2026 10:16:49 +0200 Subject: [PATCH] fix(artikel): attribute_7 nur als Ziffernfolge in die SQL (Leerzeichen => HTTP 500); zieht Live-Haertung vom 25.08. (Grundpreis-Teiler) nach --- .../php/intelectra_item_additional.inc.php | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/web/intelectra_shop/php/intelectra_item_additional.inc.php b/web/intelectra_shop/php/intelectra_item_additional.inc.php index f83c13e..549732c 100644 --- a/web/intelectra_shop/php/intelectra_item_additional.inc.php +++ b/web/intelectra_shop/php/intelectra_item_additional.inc.php @@ -52,8 +52,12 @@ if (strlen($obj->number) >= 8 || !empty($obj->attribute_7)) { $ersatzteil_ids = array(); // Query 1A: Legacy Items (über attribute_7) - if (!empty($obj->attribute_7)) { - $sql1a = "SELECT id FROM krempl_passendwie WHERE navisionid = ".$this->db->real_escape_string($obj->attribute_7); + // 27.09.2026: navisionid ist bigint -- nur eine echte Ziffernfolge in die SQL. Artikel 832247 + // hatte ein einzelnes Leerzeichen in attribute_7 (truthy, aber "navisionid = " => SQL-Fehler, + // Artikelseite HTTP 500, 14x im fatal.log seit 22.09.). + $attr7 = trim((string)$obj->attribute_7); + if ($attr7 !== '' && ctype_digit($attr7)) { + $sql1a = "SELECT id FROM krempl_passendwie WHERE navisionid = ".$attr7; $result1a = $this->db->query($sql1a); if ($result1a) { while ($row = $result1a->fetch_assoc()) { @@ -229,11 +233,32 @@ $int = $this->createIntWithTableData($html); // base price calc -if ($obj->attribute_11 && $obj->attribute_15) { - $obj->sample_unit = $obj->attribute_15; - if (strstr($obj->sample_unit, '100')) { - $obj->sample_price = $obj->shop_price_1 / ($obj->attribute_11 * 10); +// +// 25.08.2026 gehaertet. Vorher wurde nur auf "truthy" geprueft -- und zwei Sorten +// gepflegter Werte sind truthy, ohne rechenbar zu sein: +// +// " " (Artikel 831966, beide Felder ein Leerzeichen) +// PHP 8: float / " " => TypeError => Artikelseite mit HTTP 500 tot. +// Unter PHP 7 lief das als Warnung durch -- ein Migrationsueberbleibsel. +// +// "2,5" (24 aktive Artikel, Komma statt Punkt) +// PHP 8 nimmt den fuehrenden Teil und rechnet mit 2 statt 2,5. Kein Fehler, +// aber ein um 25 % zu hoher Grundpreis -- und wegen error_reporting(0) in +// index.php sieht das niemand. +// +// Deshalb: Komma normalisieren, numerisch pruefen, und erst dann rechnen. Ist der +// Teiler unbrauchbar, bleibt sample_price schlicht ungesetzt -- besser kein Grundpreis +// als ein falscher (Preisangabenverordnung). +$grundpreis_teiler = str_replace(',', '.', trim((string)$obj->attribute_11)); +$grundpreis_einheit = trim((string)$obj->attribute_15); + +if (is_numeric($grundpreis_teiler) && (float)$grundpreis_teiler > 0 && $grundpreis_einheit !== '') { + $grundpreis_teiler = (float)$grundpreis_teiler; + $obj->sample_unit = $obj->attribute_15; + + if (strstr($grundpreis_einheit, '100')) { + $obj->sample_price = $obj->shop_price_1 / ($grundpreis_teiler * 10); } else { - $obj->sample_price = $obj->shop_price_1 / $obj->attribute_11; + $obj->sample_price = $obj->shop_price_1 / $grundpreis_teiler; } }