Skip to content

Commit e3d8a96

Browse files
authored
Merge pull request #12 from laravel-workflow/feature/filter-closures
Update new exception format
2 parents 32d1b4e + fa66ade commit e3d8a96

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

app/Http/Controllers/DashboardStatsController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ public function index() {
2525
->first();
2626

2727
$maxDurationWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::select('*')
28-
->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'))
28+
->when(config('database.default') === 'mysql', function ($q) {
29+
return $q->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'));
30+
})
31+
->when(config('database.default') === 'pgsql', function ($q) {
32+
return $q->addSelect(DB::raw('(EXTRACT(EPOCH FROM created_at - updated_at)) as duration'));
33+
})
2934
->where('status', '!=', 'pending')
3035
->orderBy('duration')
3136
->first();

app/Http/Controllers/WorkflowsController.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,33 @@ public function show($id) {
4343

4444
$flow->exceptions = $flow->exceptions->map(function ($exception) {
4545
$unserialized = Y::unserialize($exception->exception);
46-
if (is_object($unserialized) && method_exists($unserialized, 'getFile')) {
47-
$file = new SplFileObject($unserialized->getFile());
48-
$file->seek($unserialized->getLine() - 4);
46+
if (is_array($unserialized) && array_key_exists('class', $unserialized) && is_subclass_of($unserialized['class'], \Throwable::class)) {
47+
$file = new SplFileObject($unserialized['file']);
48+
$file->seek($unserialized['line'] - 4);
4949
for ($line = 0; $line < 7; ++$line) {
5050
$exception->code .= $file->current();
5151
$file->next();
5252
if ($file->eof()) break;
5353
}
5454
$exception->code = rtrim($exception->code);
55-
try {
56-
$unserialized->trace = $unserialized->getTrace();
57-
} catch (\Throwable $th) {
55+
$exception->exception = serialize($unserialized);
56+
} else {
57+
if (is_object($unserialized) && method_exists($unserialized, 'getFile')) {
58+
$file = new SplFileObject($unserialized->getFile());
59+
$file->seek($unserialized->getLine() - 4);
60+
for ($line = 0; $line < 7; ++$line) {
61+
$exception->code .= $file->current();
62+
$file->next();
63+
if ($file->eof()) break;
64+
}
65+
$exception->code = rtrim($exception->code);
66+
try {
67+
$unserialized->trace = $unserialized->getTrace();
68+
} catch (\Throwable $th) {
69+
}
5870
}
71+
$exception->exception = serialize($unserialized);
5972
}
60-
$exception->exception = serialize($unserialized);
6173
return $exception;
6274
});
6375

public/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"/app.js": "/app.js?id=2cc20d4b72226021ffad651f80cc7963",
2+
"/app.js": "/app.js?id=2d746dcd282d0f999e7bd41a3187dc71",
33
"/app-dark.css": "/app-dark.css?id=f522096d329c54701f099916e0416c38",
44
"/app.css": "/app.css?id=768ca5ff3a1358fcfb02f40296b64d0b",
55
"/img/favicon.png": "/img/favicon.png?id=7c006241b093796d6abfa3049df93a59",
6-
"/img/sprite.svg": "/img/sprite.svg?id=afc4952b74895bdef3ab4ebe9adb746f",
7-
"/img/waterline.svg": "/img/waterline.svg?id=904d5b5185fefb09035384e15bfca765"
6+
"/img/sprite.svg": "/img/sprite.svg?id=afc4952b74895bdef3ab4ebe9adb746f"
87
}

resources/js/screens/flows/flow.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ export default {
239239
if (seriesIndex === 1) {
240240
let exception = phpunserialize(this.flow.exceptions[dataPointIndex].exception)
241241
if (typeof exception !== 'object') return '';
242-
exception.__constructor = this.flow.exceptions[dataPointIndex].exception.split('"')[1]
242+
if (exception.class) {
243+
exception.__constructor = exception.class
244+
} else {
245+
exception.__constructor = this.flow.exceptions[dataPointIndex].exception.split('"')[1]
246+
}
243247
244248
return '<div style="padding: 1em">' +
245249
'<b>Class</b>: ' + exception.__constructor + '<br />' +
@@ -340,7 +344,11 @@ export default {
340344
unserialize(data) {
341345
try {
342346
let result = phpunserialize(data)
343-
result.__constructor = data.split('"')[1]
347+
if (result.class) {
348+
result.__constructor = result.class
349+
} else {
350+
result.__constructor = data.split('"')[1]
351+
}
344352
return result
345353
} catch (err) {
346354
try {

0 commit comments

Comments
 (0)