Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit 2bad4e4

Browse files
authored
Fix print history bug (#324)
1 parent 464eca7 commit 2bad4e4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/Console/Commands.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public static function updateCompletedPrintingJobs()
2020
if (self::isDebugMode()) {
2121
$result = [0];
2222
} else {
23-
$result = exec("lpstat -W completed -o " . config('print.printer_name') . " | awk '{print $1}'", $result);
23+
$result = [];
24+
exec("lpstat -W completed -o " . config('print.printer_name') . " | awk '{print $1}'", $result);
2425
}
2526
return $result;
2627
}

app/Http/Controllers/PrintController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ public function cancelPrintJob($id) {
218218
/** Private helper functions */
219219

220220
private function updateCompletedPrintingJobs() {
221-
$result = Commands::updateCompletedPrintingJobs();
222-
Log::info("Completed jobs: " . implode(', ', $result));
223-
PrintJob::whereIn('job_id', $result)->update(['state' => PrintJob::SUCCESS]);
221+
try {
222+
$result = Commands::updateCompletedPrintingJobs();
223+
Log::info("Completed jobs: " . implode(', ', $result));
224+
PrintJob::whereIn('job_id', $result)->update(['state' => PrintJob::SUCCESS]);
225+
} catch (\Exception $e) {
226+
Log::error("Printing error at line: " . __FILE__ . ":" . __LINE__ . " (in function " . __FUNCTION__ . "). " . $e->getMessage());
227+
}
224228
}
225229

226230
private function storeFile($file)

0 commit comments

Comments
 (0)