Es gibt eine Funktion in meinem Skript, die plötzlich einen 502 Bad Gateway Fehler verursacht, wenn sie durch PHPStorm läuft. Ich hatte noch nie zuvor ähnliche Skripte. Wenn ich es auszeichne, habe ich überhaupt keine Fehler. Wie ist das möglich?Funktion in PHP Skript verursacht einen 502 Bad Gateway Fehler
Das Skript nimmt Informationen von einem Excel und konvertiert sie in einen anderen.
public static function WJ_JewelsToExcel($array, $fileName) {
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$rowCount = 2;
foreach ($array as $row) {
$sku = $row[0];
$gender = $row[1];
$jewelType = $row[2];
$jewelType2 = $row[3];
$metalType = $row[4];
$metalColor = $row[5];
$gemType = $row[6];
$gemColor = $row[7];
$description = $row[9];
$brand = $row[10];
$msrp = $row[11];
$price = $row[12];
$qty = $row[13];
$url = $row[14];
$name = $brand . ' ' . $sku;
$finalGender = "";
if ($gender == "Female") {
$finalGender = "Women's";
} elseif ($gender == "Male") {
$finalGender = "Men's";
} else {
$finalGender = "Child";
}
for($categoryRow = 0 ; $categoryRow < 2 ; $categoryRow++){
if($categoryRow == 0){
$objPHPExcel->getActiveSheet()->setCellValue('A' . $rowCount, $sku);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $rowCount, "Jewels");
$objPHPExcel->getActiveSheet()->setCellValue('D' . $rowCount, "simple");
$objPHPExcel->getActiveSheet()->setCellValue('E' . $rowCount, "Jewelry/" . $finalGender . "/" . $jewelType);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $rowCount, "Default Category");
$objPHPExcel->getActiveSheet()->setCellValue('G' . $rowCount, "base");
$objPHPExcel->getActiveSheet()->setCellValue('K' . $rowCount, $brand);
$objPHPExcel->getActiveSheet()->setCellValue('W' . $rowCount, $description);
$objPHPExcel->getActiveSheet()->setCellValue('AA' . $rowCount, "No");
$objPHPExcel->getActiveSheet()->setCellValue('AC' . $rowCount, $gemColor);
$objPHPExcel->getActiveSheet()->setCellValue('AD' . $rowCount, $gemType);
switch ($finalGender){
case "Women's": $objPHPExcel->getActiveSheet()->setCellValue('AE' . $rowCount, "Women");break;
case "Men's": $objPHPExcel->getActiveSheet()->setCellValue('AE' . $rowCount, "Men");break;
default: $objPHPExcel->getActiveSheet()->setCellValue('AE' . $rowCount, "Child");
}
$objPHPExcel->getActiveSheet()->setCellValue('AG' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('AK' . $rowCount, $jewelType2);
$objPHPExcel->getActiveSheet()->setCellValue('AN' . $rowCount, $metalColor);
$objPHPExcel->getActiveSheet()->setCellValue('AO' . $rowCount, $metalType);
$objPHPExcel->getActiveSheet()->setCellValue('AU' . $rowCount, $msrp);
$objPHPExcel->getActiveSheet()->setCellValue('AV' . $rowCount, "Use config");
$objPHPExcel->getActiveSheet()->setCellValue('AW' . $rowCount, "Use config");
$objPHPExcel->getActiveSheet()->setCellValue('AX' . $rowCount, $name);
$objPHPExcel->getActiveSheet()->setCellValue('BB' . $rowCount, "Product Info Column");
$objPHPExcel->getActiveSheet()->setCellValue('BD' . $rowCount, $price);
$objPHPExcel->getActiveSheet()->setCellValue('BE' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('BH' . $rowCount, $description);
$objPHPExcel->getActiveSheet()->setCellValue('BN' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('BO' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('BU' . $rowCount, "4");
$objPHPExcel->getActiveSheet()->setCellValue('BY' . $rowCount, $qty);
$objPHPExcel->getActiveSheet()->setCellValue('BZ' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CA' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CB' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CC' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CD' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CE' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CF' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CG' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CH' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CI' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CK' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CL' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CM' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CN' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CO' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CP' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CQ' . $rowCount, "1");
$objPHPExcel->getActiveSheet()->setCellValue('CR' . $rowCount, "0");
$objPHPExcel->getActiveSheet()->setCellValue('CS' . $rowCount, "0");
}
if($categoryRow == 1){
$objPHPExcel->getActiveSheet()->setCellValue('E' . $rowCount, "Brands/" . $brand);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $rowCount, "Default Category");
}
$rowCount++;
}
}
$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
$objWriter->save('D:\Websites\Utilities\PHPUtils\Export\\' . $fileName);
}
Oben ist das Skript, das den Fehler verursacht, und es wird von einem Haupt aufgerufen.
PHP & Interpreter sind korrekt konfiguriert.
Entfernen Sie das statische Schlüsselwort aus der Funktionssignatur. –
Und es dynamisch nennen? Hat nicht funktioniert. – TanguyB
Ohh ok. Bedeutet, dass diese Funktion innerhalb einer Klasse ist. Ich nahm draußen an. Nebenbei fügen Sie diese Skripte kurz vor dem Aufruf der Funktion 'error_reporting (E_ALL & ~ E_DEPRECATED & ~ E_STRICT); ini_set ('display_errors', 'On'); ini_set ('xdebug.force_display_errors', 'On'); ' Es kann helfen, das genaue Problem zu finden. –