Skip to content

Commit

Permalink
[#431] Fix PHP warnings during task delete operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaragunde committed May 5, 2021
1 parent 349c88f commit c7ffb82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions model/dao/TaskDAO/PostgreSQLTaskDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ protected function setValues($row)

/** Task retriever by id for PostgreSQL.
*
* This function retrieves the row from Task table with the id <var>$taskId</var> and creates a {@link TaskVO} with its data.
* This function retrieves the row from Task table with the id
* <var>$taskId</var> and creates a {@link TaskVO} with its data.
*
* @param int $taskId the id of the row we want to retrieve.
* @return TaskVO a value object {@link TaskVO} with its properties set to the values from the row.
* @return TaskVO a value object {@link TaskVO} with its properties set to
* the values from the row, or NULL if no task was found.
* @throws {@link SQLIncorrectTypeException}
* @throws {@link SQLQueryErrorException}
*/
Expand Down Expand Up @@ -996,13 +998,13 @@ public function delete(TaskVO $taskVO) {
}

// Otherwise delete a task.
if(sizeof($currTaskVO) > 0) {
if(!is_null($currTaskVO)) {
$sql = "DELETE FROM task WHERE id=".$taskVO->getId();

$res = pg_query($this->connect, $sql);
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
$affectedRows = pg_affected_rows($res);
}
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
$affectedRows = pg_affected_rows($res);
}

return $affectedRows;
}
Expand Down
2 changes: 1 addition & 1 deletion web/services/deleteTasksService.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
if (TasksFacade::DeleteReports($deleteTasks) == -1)
$string = "<return service='deleteTasks'><success>false</success><error id='1'>There was some error while deleting the tasks</error></return>";

if (!$string)
if (!isset($string))
$string = "<return service='deleteTasks'><success>true</success><ok>Operation Success!</ok></return>";


Expand Down

0 comments on commit c7ffb82

Please sign in to comment.