Skip to content

Commit

Permalink
[Igalia#431] Fix PHP warnings during project update operation.
Browse files Browse the repository at this point in the history
Also fix indentation of surrounding code.
  • Loading branch information
jaragunde authored and anarute committed Jul 27, 2021
1 parent 4abee36 commit a9ef46a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
64 changes: 32 additions & 32 deletions model/dao/ProjectDAO/PostgreSQLProjectDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,56 +586,56 @@ public function partialUpdate(ProjectVO $projectVO, $update) {
}

// If the query returned a row then update
if(sizeof($currProjectVO) > 0) {
if (!is_null($currProjectVO)) {

$sql = "UPDATE project SET ";
$sql = "UPDATE project SET ";

if ($update['activation'])
$sql = $sql . "activation=" . DBPostgres::boolToString($projectVO->getActivation()) . ", ";
if ($update['activation'])
$sql .= "activation=" . DBPostgres::boolToString($projectVO->getActivation()) . ", ";

if ($update['init'])
$sql = $sql . "init=" . DBPostgres::formatDate($projectVO->getInit()) . ", ";
if ($update['init'])
$sql .= "init=" . DBPostgres::formatDate($projectVO->getInit()) . ", ";

if ($update['end'])
$sql = $sql . "_end=" . DBPostgres::formatDate($projectVO->getEnd()) . ", ";
if ($update['end'])
$sql .= "_end=" . DBPostgres::formatDate($projectVO->getEnd()) . ", ";

if ($update['invoice'])
$sql = $sql . "invoice=" . DBPostgres::checkNull($projectVO->getInvoice()) . ", ";
if ($update['invoice'])
$sql .= "invoice=" . DBPostgres::checkNull($projectVO->getInvoice()) . ", ";

if ($update['estHours'])
$sql = $sql . "est_hours=" . DBPostgres::checkNull($projectVO->getEstHours()) . ", ";
if ($update['estHours'])
$sql .= "est_hours=" . DBPostgres::checkNull($projectVO->getEstHours()) . ", ";

if ($update['areaId'])
$sql = $sql . "areaid=" . DBPostgres::checkNull($projectVO->getAreaId()) . ", ";
if ($update['areaId'])
$sql .= "areaid=" . DBPostgres::checkNull($projectVO->getAreaId()) . ", ";

if ($update['customerId'])
$sql = $sql . "customerid=" . DBPostgres::checkNull($projectVO->getCustomerId()) . ", ";
if ($update['customerId'])
$sql .= "customerid=" . DBPostgres::checkNull($projectVO->getCustomerId()) . ", ";

if ($update['description'])
$sql = $sql . "description=" . DBPostgres::checkStringNull($projectVO->getDescription()) . ", ";
if ($update['description'])
$sql .= "description=" . DBPostgres::checkStringNull($projectVO->getDescription()) . ", ";

if ($update['type'])
$sql = $sql . "type=" . DBPostgres::checkStringNull($projectVO->getType()) . ", ";
if ($update['type'])
$sql .= "type=" . DBPostgres::checkStringNull($projectVO->getType()) . ", ";

if ($update['movHours'])
$sql = $sql . "moved_hours=" . DBPostgres::checkNull($projectVO->getMovedHours()) . ", ";
if ($update['movHours'])
$sql .= "moved_hours=" . DBPostgres::checkNull($projectVO->getMovedHours()) . ", ";

if ($update['schedType'])
$sql = $sql . "sched_type=" . DBPostgres::checkStringNull($projectVO->getSchedType());
if ($update['schedType'])
$sql .= "sched_type=" . DBPostgres::checkStringNull($projectVO->getSchedType());

if (strlen($sql) == strlen("UPDATE project SET "))
return NULL;
if (strlen($sql) == strlen("UPDATE project SET "))
return NULL;

$last = strrpos($sql, ",");
$last = strrpos($sql, ",");

if ($last == (strlen($sql) - 2))
$sql = substr($sql, 0, -2);
if ($last == (strlen($sql) - 2))
$sql = substr($sql, 0, -2);

$sql = $sql . " WHERE id=".$projectVO->getId();
$sql .= " WHERE id=".$projectVO->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
26 changes: 13 additions & 13 deletions web/services/updateProjectsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
$parser->next();
$parser->next();
}
$update[activation] = true;
$update["activation"] = true;
break;

case "init": $dateFormat = $parser->getAttribute("format");
Expand All @@ -111,7 +111,7 @@
$parser->next();
$parser->next();
}
$update[init] = true;
$update["init"] = true;
break;

case "end": $dateFormat = $parser->getAttribute("format");
Expand All @@ -127,7 +127,7 @@
$parser->next();
$parser->next();
}
$update[end] = true;
$update["end"] = true;
break;

case "invoice":$parser->read();
Expand All @@ -137,7 +137,7 @@
$parser->next();
$parser->next();
}
$update[invoice] = true;
$update["invoice"] = true;
break;

case "estHours":$parser->read();
Expand All @@ -147,7 +147,7 @@
$parser->next();
$parser->next();
}
$update[estHours] = true;
$update["estHours"] = true;
break;

case "description":$parser->read();
Expand All @@ -157,7 +157,7 @@
$parser->next();
$parser->next();
}
$update[description] = true;
$update["description"] = true;
break;

case "areaId":$parser->read();
Expand All @@ -167,7 +167,7 @@
$parser->next();
$parser->next();
}
$update[areaId] = true;
$update["areaId"] = true;
break;

case "customerId":$parser->read();
Expand All @@ -177,7 +177,7 @@
$parser->next();
$parser->next();
}
$update[customerId] = true;
$update["customerId"] = true;
break;

case "type": $parser->read();
Expand All @@ -187,7 +187,7 @@
$parser->next();
$parser->next();
}
$update[type] = true;
$update["type"] = true;
break;

case "movedHours": $parser->read();
Expand All @@ -197,7 +197,7 @@
$parser->next();
$parser->next();
}
$update[movHours] = true;
$update["movHours"] = true;
break;

case "schedType": $parser->read();
Expand All @@ -207,7 +207,7 @@
$parser->next();
$parser->next();
}
$update[schedType] = true;
$update["schedType"] = true;
break;

default: $parser->next();
Expand All @@ -232,8 +232,8 @@
$string = "<return service='updateProjects'><error id='1'>There was some error while updating the projects</error></return>";


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


// make it into a proper XML document with header etc
Expand Down

0 comments on commit a9ef46a

Please sign in to comment.