Вот минимальное воспроизведение:
Код: Выделить всё
run()Код: Выделить всё
namespace App\Models;
class CronRunner extends CI_Model {
public function run($data) {
$result = "OK";
$executedAt = date('Y-m-d H:i:s'); // for logs
$executedAtUnix = time(); // for duration calc
$lockFile = WRITEPATH . 'cache/cronRunner.lock';
if (file_exists($lockFile))
return;
file_put_contents($lockFile, ENVIRONMENT);
// This works — when it's enabled, the file gets removed
// register_shutdown_function(function () use ($lockFile) {
// if (file_exists($lockFile)) {
// unlink($lockFile);
// }
// });
try {
$this->notifyLongRunningTask();
} catch (\Throwable $e2) {
$result = $e2->getMessage();
log_message('error', (string) $result);
} finally {
log_message('error', 'FINALLY BLOCK REACHED');
if (file_exists($lockFile)) {
unlink($lockFile);
}
}
return ['result' => $result];
}
}
< /code>
Здесь notifylongrunningtask () < /code> < /h3>
function notifyLongRunningTask() {
$PushSubscriptions = new PushSubscriptions();
$PushSentLog = new PushSentLog();
$db = \Config\Database::connect();
$sql = "
SELECT hs.id as hourly_id, date_started, time_started, hs.organization_id, hs.user_created, c.name Client, p.client_id
FROM HourlySheet hs
JOIN ToDo t ON hs.todo_id = t.id
JOIN Project p ON t.project_id = p.id
JOIN Client c ON p.client_id = c.id
WHERE time_finished IS NULL
";
$query = $db->query($sql);
foreach ($query->getResult() as $row) {
$startedAt = strtotime($row->date_started . ' ' . $row->time_started);
$now = time();
// This line causes the issue
$PushSentLog_res = $PushSentLog->select(" AND user_created = {$row->user_created} AND name = 'notifyLongRunningTask' ORDER BY id DESC LIMIT 1 ");
// ...
}
}
< /code>
Фактическая ошибка запроса < /h3>
mysqli_sql_exception: Column 'name' in WHERE is ambiguous
Код: Выделить всё
if (!$query) {
$error = $db->error()["message"];
$baseClass = get_parent_class($this);
$this->log_it($error, $baseClass . " " . __FUNCTION__ . ' DB Error');
return ['result' => (string) $error];
}
[*] поймал
[*]
[*] как часть ['result' => '...']
Но все же - каким -то образом - это вызывает php/ci4 до завершить выполнение, прежде чем, наконец, runs , а файл блокировки не удален .
что работает
, если я не знаю регистрации, а затем код блокировки> . удален, как и ожидалось. 8.1.32 и ci4 4.4.3 < /li>
Код: Выделить всё
DBDebug[*]The query fails with a typical ambiguous column error
[*]It is handled inside select() (custom function)
[*]But the finally block from the run() method is never reached
Функция выключения действительно называется < /strong> < /li>
< /ul>
Вопрос < /h3>
Почему, наконец, < /code> block не выполняется < /strong>, даже если исключение обрабатывается и не отображается Fatal? CI4 побочный эффект?
или определенные внутренние поведения CI4, заставляющие выключение?>
Подробнее здесь: https://stackoverflow.com/questions/796 ... occurs-but
Мобильная версия