Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ProcessMaker/Http/Controllers/Api/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,18 @@ public function index(Request $request, $getTotal = false, User $user = null)

$this->applyForCurrentUser($query, $user);

try {
// Count up the total number of results, but
// watch for PMQL query exceptions and handle
// them if they occur
$totalResultCount = $query->count();
} catch (QueryException $e) {
return $this->handleQueryException($e);
}

// If only the total is being requested (by a Saved Search), send it now
if ($getTotal === true) {
return $query->count();
return $totalResultCount;
}

// Apply filter overdue
Expand All @@ -133,7 +142,7 @@ public function index(Request $request, $getTotal = false, User $user = null)
// If we should manually add pagination to the
// query in advance (also used by saved search)
if ($this->isPaginationEnabled()) {
$query->paginate($request->input('per_page', 10));
$query->limit($request->input('per_page', 10));
}

try {
Expand All @@ -153,7 +162,7 @@ public function index(Request $request, $getTotal = false, User $user = null)

$response->inOverdue = $inOverdueQuery->count();

return new TaskCollection($response);
return new TaskCollection($response, $totalResultCount);
}

/**
Expand Down Expand Up @@ -269,6 +278,7 @@ public function update(Request $request, ProcessRequestToken $task)
private function handleQueryException($e)
{
$regex = '~Column not found: 1054 Unknown column \'(.*?)\' in \'where clause\'~';

preg_match($regex, $e->getMessage(), $m);

$message = __('PMQL Is Invalid.');
Expand Down