Skip to content

Commit 78ea003

Browse files
committed
Fixing bug - overflowing error strings in async jobs.
1 parent 576214a commit 78ea003

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/model/entity/AsyncJob.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,21 @@ public function getError(): ?string
211211
return $this->error;
212212
}
213213

214+
/**
215+
* Makes sure the error string fits the data column.
216+
* Truncates and adds ellipsis '...' at the end if it overflows.
217+
*/
218+
private function sanitizeErrorLength(): void
219+
{
220+
if ($this->error !== null && strlen($this->error) > 250) {
221+
$this->error = substr($this->error, 0, 250) . '...';
222+
}
223+
}
224+
214225
public function setError(?string $error)
215226
{
216227
$this->error = $error;
228+
$this->sanitizeErrorLength();
217229
}
218230

219231
public function appendError(string $error)
@@ -223,6 +235,7 @@ public function appendError(string $error)
223235
} else {
224236
$this->error .= "\n$error";
225237
}
238+
$this->sanitizeErrorLength();
226239
}
227240

228241
/**

0 commit comments

Comments
 (0)