我在PHP上有这个Web模块,我们刚刚从5.3迁移到PHP 7.2。我们也开始使用教义,一切都正常。突然,Web 模块开始显示随机 500 个错误。甚至不是在相同的动作上。我仍然没有弄清楚为什么,但是我可以设法每次使用教义的函数lastInsertId触发它。每次它经过该函数时,它都会抛出一个通用的 500 错误(即使我在 php 上激活错误.ini我也没有获得有关该错误的任何详细信息(。
阿贾克斯调用:
function listaCandidatos() {
$('#' + GLOBAL_ID).find('#candidates-button').click(function () {
var btn = this,
url = BASE_URL + 'actualizacion-candidatos.php',
numInv = $('#' + GLOBAL_ID).find('#num_inventario').val();
$(btn).attr('disabled', 'disabled');
$.post(url, {numInv: numInv}, function (response) {
if (response.success) {
enableScannerForm();
$('#' + GLOBAL_ID).find('#master_id').val(response.masterId);
$('#' + GLOBAL_ID).find('#last_master_id').val(response.masterId);
loadListScanner();
} else {
alert(response.message);
$(btn).removeAttr('disabled');
}
}, 'json');
});
}
PHP操作:
public function candidatos()
{
ILogger::info('ACTUALIZACION DE INVENTARIO OBTENER CANDIDATOS (INICIO)');
$result = array('success' => true, 'message' => '');
if (!Request::isAjax()) {
$result['success'] = false;
$result['message'] = 'No ajax request';
} else {
$pa_idpais = $_SESSION['pa_idpais'];
$estacion = $_SESSION['estacion'];
$modulo = $_SESSION['modulo'];
$login = $_SESSION['login'];
$mModel = new InventarioMaster();
$dModel = new InventarioDetalle();
$tModel = new InventarioDetalleTemp();
$hModel = new InventarioHistorial();
ILogger::info('EJECUCION DE QUERY OBTENER CANDIDATOS (INICIO)');
$candidates = $dModel->getCandidates();
ILogger::info('EJECUCION DE QUERY OBTENER CANDIDATOS (FIN)');
$result['masterId'] = 0;
if (count($candidates) > 0) {
IDBConnection::getInstance()->beginTransaction();
try {
$dataMaster = array(
'num_folio' => time(),
'id_courier' => 0,
'pa_idpais' => $pa_idpais,
'est_idestacion' => $estacion,
'mod_idmodulo' => $modulo,
'usu_login' => $login,
'inv_fecha_ingreso' => "CONVERT(datetime, DATEADD(hh, " . $_SESSION['pa_zona'] . ", GETUTCDATE()), 103)",
'inv_tipo' => 'ACT'
);
ILogger::info('EJECUCION DE QUERY REGISTRAR INVENTARIO_MASTER (INICIO)');
**$masterId = $mModel->register($dataMaster);**
ILogger::info('EJECUCION DE QUERY REGISTRAR INVENTARIO_MASTER (FIN)');
$tmpData = array(
'id_inv_master' => $masterId,
'id_inv_detalle' => '',
'gui_idguia' => '',
'pid' => null,
'inv_actual_checkpoint' => 'CC',
'temp_fecha_actual_registro' => "CONVERT(datetime, DATEADD(hh, " . $_SESSION['pa_zona'] . ", GETUTCDATE()), 103)",
'inv_status' => 'SE'
);
foreach ($candidates as $item) {
$tmpData['id_inv_detalle'] = $item['id_inv_detalle'];
$tmpData['gui_idguia'] = $item['gui_idguia'];
$tmpData['pid'] = $item['pid'];
if ($item['inv_checkpoint'] == 'SA') {
$tmpData['inv_actual_checkpoint'] = $item['inv_checkpoint'];
}
if ($item['det_tipo_ingreso'] == 'COU' && in_array($item['inv_status'], array('IN', 'AC'))) {
$tmpData['inv_actual_checkpoint'] = 'CC';
}
ILogger::info('EJECUCION DE QUERY REGISTRAR INVENTARIO_DETALLE_TEMP (INICIO)');
$tModel->register($tmpData);
ILogger::info('EJECUCION DE QUERY REGISTRAR INVENTARIO_DETALLE_TEMP (FIN)');
$dataHistory = array(
'id_inv_master' => $masterId,
'id_inv_detalle' => $item['id_inv_detalle'],
'his_checkpoint' => $item['inv_checkpoint'],
'his_checkpoint_candidato' => $item['inv_checkpoint'],
'his_fecha_registro' => $tmpData['temp_fecha_actual_registro'],
'his_comentario' => 'Sin escanear',
'usu_login' => $login,
'inv_status' => 'SE',
'his_evento' => 'ACT'
);
ILogger::info('EJECUCION DE QUERY REGISTRAR INVENTARIO_HISTORIAL (INICIO)');
$hModel->register($dataHistory);
ILogger::info('EJECUCION DE QUERY REGISTRAR INVENTARIO_HISTORIAL (FIN)');
}
IDBConnection::getInstance()->commitTransaction();
$result['masterId'] = $masterId;
$queueData = array(
'detalleIds' => '',
'lastGuia' => '',
'lastId' => '',
'lastMasterId' => $masterId,
'lastNumInv' => '0',
'lastRequestType' => '',
'lastRequestValue' => '',
'masterId' => $masterId,
'fromMasterId' => '',
'numInv' => '',
'numPiezas' => ''
);
ScannerData::setId('inventarios_scanner_actualizacion');
ScannerData::saveData($queueData);
} catch (Exception $ex) {
IDBConnection::getInstance()->rollbackTransaction();
$result['success'] = false;
$result['message'] = utf8_encode($ex->getMessage());
$result['masterId'] = null;
}
}
}
ILogger::info('ACTUALIZACION DE INVENTARIO OBTENER CANDIDATOS (FIN)');
echo json_encode($result);
return;
}
寄存器函数中发生错误:
$masterId = $mModel->register($dataMaster);
这是这个:
public function register($data = array())
{
$sql = "
INSERT INTO
inventario_master
(
num_folio,
id_courier,
pa_idpais,
est_idestacion,
mod_idmodulo,
usu_login,
inv_fecha_ingreso,
inv_tipo
)
VALUES
(
'" . $data['num_folio'] . "',
'" . $data['id_courier'] . "',
'" . $data['pa_idpais'] . "',
'" . $data['est_idestacion'] . "',
'" . $data['mod_idmodulo'] . "',
'" . $data['usu_login'] . "',
" . $data['inv_fecha_ingreso'] . ",
'" . $data['inv_tipo'] . "'
)
";
$this->db->executeQuery($sql);
return $this->db->lastInsertId();
}
最后一个插入ID只是调用同名的教义功能。
我尝试捕获错误,但失败了。注册函数实际发生,我确实获得了该函数的 ID,但是 ajax 调用每次都返回错误。我尝试从 ajax 读取错误消息,但它是空的。这也适用于我的本地机器 IIS。这可能与该服务器配置有关,但我不确定。
引发错误的服务器是 Windows Server 2016 版本 1607 和 IIS 版本 10.0.14393.0,我们正在Microsoft SQL Server 2016 用于数据库。
提前谢谢。
错误 500 也可能导致文件中出现 BOOM。检查酷乐随身 您可以尝试返回的不是lastInsertId,而是随机数 - 错误仍然存在?