Skip to content

Commit

Permalink
Migration - addField() fix array content checks (glpi-project#1561)
Browse files Browse the repository at this point in the history
* Issue glpi-project#1476 - fix bad display of attachment's date in a ticket

* Revert "Issue glpi-project#1476 - fix bad display of attachment's date in a ticket"

This reverts commit 2efd34c.

* Fix 'FIRST' is added as it haven't been requested
+ clearly check if array case have content or not (isset not required are we create theses cases inside the function)
  • Loading branch information
AnaelMobilia authored and orthagh committed Jan 9, 2017
1 parent 592e02b commit 1ae3f9d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions inc/migration.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,13 @@ function addField($table, $field, $type, $options=array()) {

$format = $this->fieldFormat($type, $params['value'], $params['nodefault']);

if ($params['comment']) {
if (!empty($params['comment'])) {
$params['comment'] = " COMMENT '".addslashes($params['comment'])."'";
}

if ($params['after']) {
if (!empty($params['after'])) {
$params['after'] = " AFTER `".$params['after']."`";
} else if (isset($params['first'])) {
} else if (!empty($params['first'])) {
$params['first'] = " FIRST ";
}

Expand All @@ -346,7 +346,7 @@ function addField($table, $field, $type, $options=array()) {
$this->change[$table][] = "ADD `$field` $format ".$params['comment'] ." ".
$params['first'].$params['after']."";

if (isset($params['update']) && strlen($params['update'])) {
if (!empty($params['update'])) {
$this->migrationOneTable($table);
$query = "UPDATE `$table`
SET `$field` = ".$params['update']." ".
Expand Down

0 comments on commit 1ae3f9d

Please sign in to comment.