From f00b22469cc295ff8e40f24da80ffdae26cb1b7e Mon Sep 17 00:00:00 2001 From: Herafia Date: Wed, 20 May 2026 09:30:11 +0200 Subject: [PATCH 01/15] fix/ escape SQL values --- inc/commoninjectionlib.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 1ee5679c..5b85fed3 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1903,7 +1903,7 @@ private function dataAlreadyInDB($injectionClass, $itemtype) //If it's a computer device if ($item instanceof CommonDevice) { $sql .= " WHERE `designation` = '" . - $this->getValueByItemtypeAndName($itemtype, 'designation') . "'"; + $DB->escape($this->getValueByItemtypeAndName($itemtype, 'designation')) . "'"; } elseif ($item instanceof CommonDBRelation) { //Type is a relation : check it this relation still exists //Define the side of the relation to use @@ -1920,13 +1920,13 @@ private function dataAlreadyInDB($injectionClass, $itemtype) $destination_itemtype = $item::$itemtype_2; } $where .= " AND `$source_id`='" . - $this->getValueByItemtypeAndName($itemtype, $source_id) . "'"; + $DB->escape($this->getValueByItemtypeAndName($itemtype, $source_id)) . "'"; if ($item->isField('itemtype')) { $where .= " AND `$source_itemtype`='" . - $this->getValueByItemtypeAndName($itemtype, $source_itemtype) . "'"; + $DB->escape($this->getValueByItemtypeAndName($itemtype, $source_itemtype)) . "'"; } $where .= " AND `" . $destination_id . "`='" . - $this->getValueByItemtypeAndName($itemtype, $destination_id) . "'"; + $DB->escape($this->getValueByItemtypeAndName($itemtype, $destination_id)) . "'"; $sql .= " WHERE 1 " . $where; } else { //Type is not a relation @@ -1958,7 +1958,7 @@ private function dataAlreadyInDB($injectionClass, $itemtype) } else { //Type cannot be recursive $where_entity = " AND `entities_id` = '" . - $this->getValueByItemtypeAndName($itemtype, 'entities_id') . "'"; + $DB->escape($this->getValueByItemtypeAndName($itemtype, 'entities_id')) . "'"; } } else { //If no entity assignment for this itemtype $where_entity = ""; @@ -1972,25 +1972,25 @@ private function dataAlreadyInDB($injectionClass, $itemtype) $email = $DB->escape($this->getValueByItemtypeAndName($itemtype, $field)); $where .= " AND `id` IN (SELECT `users_id` FROM glpi_useremails WHERE `email` = '$email') "; } else { - $where .= " AND `" . $field . "`='" . (string) $this->getValueByItemtypeAndName($itemtype, $field) . "'"; + $where .= " AND `" . $field . "`='" . $DB->escape((string) $this->getValueByItemtypeAndName($itemtype, $field)) . "'"; } } } } else { //Table contains an itemtype field if ($injectionClass->isField('itemtype')) { - $where .= " AND `itemtype` = '" . $this->getValueByItemtypeAndName( + $where .= " AND `itemtype` = '" . $DB->escape($this->getValueByItemtypeAndName( $itemtype, 'itemtype', - ) . "'"; + )) . "'"; } //Table contains an items_id field if ($injectionClass->isField('items_id')) { - $where .= " AND `items_id` = '" . $this->getValueByItemtypeAndName( + $where .= " AND `items_id` = '" . $DB->escape($this->getValueByItemtypeAndName( $itemtype, 'items_id', - ) . "'"; + )) . "'"; } } From acde442433ea8cefe5e7bc4d794803d00739bf2a Mon Sep 17 00:00:00 2001 From: Herafia Date: Wed, 20 May 2026 09:34:35 +0200 Subject: [PATCH 02/15] CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90c89964..f0c8a57d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Fixed + +- fix escape SQL values + ## [2.15.6] - 2026-05-05 ### Fixed From e980f99e4482166472016a69a5fe3a474c13206a Mon Sep 17 00:00:00 2001 From: Herafia Date: Wed, 20 May 2026 14:43:54 +0200 Subject: [PATCH 03/15] refracto to glpi querybuilder --- inc/commoninjectionlib.class.php | 84 +++++++++++++++----------------- inc/model.class.php | 1 + 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 5b85fed3..45ace748 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -27,6 +27,8 @@ * @link https://github.com/pluginsGLPI/datainjection * ------------------------------------------------------------------------- */ +use Glpi\DBAL\QueryExpression; +use Glpi\DBAL\QuerySubQuery; use Glpi\Exception\Http\HttpException; use Glpi\Features\AssignableItem; @@ -1865,7 +1867,6 @@ private function dataAlreadyInDB($injectionClass, $itemtype) /** @var DBmysql $DB */ global $DB; - $where = ""; $continue = true; $injectionClass->getOptions($this->primary_type); @@ -1893,17 +1894,15 @@ private function dataAlreadyInDB($injectionClass, $itemtype) if (!$continue) { $this->values[$itemtype]['id'] = self::ITEM_NOT_FOUND; } else { - $sql = "SELECT * - FROM `" . $injectionClass->getTable() . "`"; - if (!is_a($itemtype, CommonDBTM::class, true)) { throw new HttpException(500, 'Class ' . $itemtype . ' is not a valid class'); } - $item = new $itemtype(); + $item = new $itemtype(); + $where = []; + //If it's a computer device if ($item instanceof CommonDevice) { - $sql .= " WHERE `designation` = '" . - $DB->escape($this->getValueByItemtypeAndName($itemtype, 'designation')) . "'"; + $where['designation'] = $this->getValueByItemtypeAndName($itemtype, 'designation'); } elseif ($item instanceof CommonDBRelation) { //Type is a relation : check it this relation still exists //Define the side of the relation to use @@ -1919,49 +1918,41 @@ private function dataAlreadyInDB($injectionClass, $itemtype) $source_itemtype = $item::$itemtype_1; $destination_itemtype = $item::$itemtype_2; } - $where .= " AND `$source_id`='" . - $DB->escape($this->getValueByItemtypeAndName($itemtype, $source_id)) . "'"; + $where[$source_id] = $this->getValueByItemtypeAndName($itemtype, $source_id); + $where[$destination_id] = $this->getValueByItemtypeAndName($itemtype, $destination_id); if ($item->isField('itemtype')) { - $where .= " AND `$source_itemtype`='" . - $DB->escape($this->getValueByItemtypeAndName($itemtype, $source_itemtype)) . "'"; + $where[$source_itemtype] = $this->getValueByItemtypeAndName($itemtype, $source_itemtype); } - $where .= " AND `" . $destination_id . "`='" . - $DB->escape($this->getValueByItemtypeAndName($itemtype, $destination_id)) . "'"; - $sql .= " WHERE 1 " . $where; } else { //Type is not a relation //Type can be deleted if ($injectionClass->maybeDeleted()) { - $where .= " AND `is_deleted` = '0' "; + $where['is_deleted'] = 0; } //Type can be a template if ($injectionClass->maybeTemplate()) { - $where .= " AND `is_template` = '0' "; + $where['is_template'] = 0; } //Type can be assigned to an entity if ($injectionClass->isEntityAssign()) { //Type can be recursive if ($injectionClass->maybeRecursive()) { - $where_entity = getEntitiesRestrictRequest( - " AND", - $injectionClass->getTable(), - "entities_id", - $this->getValueByItemtypeAndName( - $itemtype, + $where = array_merge( + $where, + getEntitiesRestrictCriteria( + $injectionClass->getTable(), 'entities_id', + $this->getValueByItemtypeAndName($itemtype, 'entities_id'), + true, ), - true, ); } else { //Type cannot be recursive - $where_entity = " AND `entities_id` = '" . - $DB->escape($this->getValueByItemtypeAndName($itemtype, 'entities_id')) . "'"; + $where['entities_id'] = $this->getValueByItemtypeAndName($itemtype, 'entities_id'); } - } else { //If no entity assignment for this itemtype - $where_entity = ""; } //Add mandatory fields to the query only if it's the primary_type to be injected @@ -1969,44 +1960,49 @@ private function dataAlreadyInDB($injectionClass, $itemtype) foreach ($this->mandatory_fields[$itemtype] as $field => $is_mandatory) { if ($is_mandatory) { if ($item instanceof User && $field == "useremails_id") { - $email = $DB->escape($this->getValueByItemtypeAndName($itemtype, $field)); - $where .= " AND `id` IN (SELECT `users_id` FROM glpi_useremails WHERE `email` = '$email') "; + $where['id'] = new QuerySubQuery([ + 'SELECT' => 'users_id', + 'FROM' => 'glpi_useremails', + 'WHERE' => ['email' => $this->getValueByItemtypeAndName($itemtype, $field)], + ]); } else { - $where .= " AND `" . $field . "`='" . $DB->escape((string) $this->getValueByItemtypeAndName($itemtype, $field)) . "'"; + $where[$field] = $this->getValueByItemtypeAndName($itemtype, $field); } } } } else { //Table contains an itemtype field if ($injectionClass->isField('itemtype')) { - $where .= " AND `itemtype` = '" . $DB->escape($this->getValueByItemtypeAndName( - $itemtype, - 'itemtype', - )) . "'"; + $where['itemtype'] = $this->getValueByItemtypeAndName($itemtype, 'itemtype'); } //Table contains an items_id field if ($injectionClass->isField('items_id')) { - $where .= " AND `items_id` = '" . $DB->escape($this->getValueByItemtypeAndName( - $itemtype, - 'items_id', - )) . "'"; + $where['items_id'] = $this->getValueByItemtypeAndName($itemtype, 'items_id'); } } //Add additional parameters specific to this itemtype (or function checkPresent exists) if (method_exists($injectionClass, 'checkPresent')) { - $where .= $injectionClass->checkPresent($this->values, $options); + $extra = trim((string) $injectionClass->checkPresent($this->values, $options)); + $extra = trim(preg_replace('/^\s*AND\s+/i', '', $extra)); + if ($extra !== '') { + $where[] = new QueryExpression($extra); + } } - $sql .= " WHERE 1 " . $where_entity . " " . $where; } - $result = $DB->doQuery($sql); - if ($DB->numrows($result) > 0) { - $db_fields = $DB->fetchAssoc($result); + + $result = $DB->request([ + 'FROM' => $injectionClass->getTable(), + 'WHERE' => $where, + ]); + + if (count($result) > 0) { + $db_fields = $result->current(); foreach ($db_fields as $key => $value) { $this->setValueForItemtype($itemtype, $key, $value, true); } - $this->setValueForItemtype($itemtype, 'id', $DB->result($result, 0, 'id')); + $this->setValueForItemtype($itemtype, 'id', $db_fields['id']); } else { $this->setValueForItemtype($itemtype, 'id', self::ITEM_NOT_FOUND); } diff --git a/inc/model.class.php b/inc/model.class.php index 26af99be..29b03cf1 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -993,6 +993,7 @@ public function readUploadedFile($options = []) ), ]; } + unset($_FILES['filename']); } //If file has not the right extension, reject it and delete if From db8d43abbfe73f0cf6d4b4c49907a24ebab64c42 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 21 May 2026 09:52:51 +0200 Subject: [PATCH 04/15] return array criteria --- inc/commoninjectionlib.class.php | 7 +++--- inc/networkportinjection.class.php | 32 ++++++++++++-------------- inc/softwarelicenseinjection.class.php | 12 ++++++---- inc/softwareversioninjection.class.php | 12 ++++++---- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 45ace748..6eb816b8 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1984,10 +1984,9 @@ private function dataAlreadyInDB($injectionClass, $itemtype) //Add additional parameters specific to this itemtype (or function checkPresent exists) if (method_exists($injectionClass, 'checkPresent')) { - $extra = trim((string) $injectionClass->checkPresent($this->values, $options)); - $extra = trim(preg_replace('/^\s*AND\s+/i', '', $extra)); - if ($extra !== '') { - $where[] = new QueryExpression($extra); + $extra = $injectionClass->checkPresent($this->values, $options); + if (is_array($extra) && count($extra) > 0) { + $where = array_merge($where, $extra); } } } diff --git a/inc/networkportinjection.class.php b/inc/networkportinjection.class.php index 7d14651d..cdb391a7 100644 --- a/inc/networkportinjection.class.php +++ b/inc/networkportinjection.class.php @@ -184,13 +184,13 @@ public function addOrUpdateObject($values = [], $options = []) * @param array $fields_toinject array * @param array $options array **/ - public function checkPresent($fields_toinject = [], $options = []) + public function checkPresent($fields_toinject = [], $options = []): array { - return $this->getUnicityRequest($fields_toinject['NetworkPort'], $options['checks']); } + /** * @param array $fields_toinject * @param array $options @@ -245,40 +245,38 @@ public function checkParameters($fields_toinject, $options) * @param array $fields_toinject array the fields to insert into DB * @param array $options array * - * @return string the sql where clause + * @return array **/ - public function getUnicityRequest($fields_toinject = [], $options = []) + public function getUnicityRequest($fields_toinject = [], $options = []): array { - - $where = ""; - + $where = []; switch ($options['port_unicity']) { case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER: - $where .= " AND `logical_number` = '" . ($fields_toinject["logical_number"] ?? '') . "'"; + $where['logical_number'] = $fields_toinject['logical_number'] ?? ''; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_MAC: - $where .= " AND `logical_number` = '" . ($fields_toinject["logical_number"] ?? '') . "' - AND `mac` = '" . ($fields_toinject["mac"] ?? '') . "'"; + $where['logical_number'] = $fields_toinject['logical_number'] ?? ''; + $where['mac'] = $fields_toinject['mac'] ?? ''; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_NAME: - $where .= " AND `logical_number` = '" . ($fields_toinject["logical_number"] ?? '') . "' - AND `name` = '" . ($fields_toinject["name"] ?? '') . "'"; + $where['logical_number'] = $fields_toinject['logical_number'] ?? ''; + $where['name'] = $fields_toinject['name'] ?? ''; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_LOGICAL_NUMBER_NAME_MAC: - $where .= " AND `logical_number` = '" . ($fields_toinject["logical_number"] ?? '') . "' - AND `name` = '" . ($fields_toinject["name"] ?? '') . "' - AND `mac` = '" . ($fields_toinject["mac"] ?? '') . "'"; + $where['logical_number'] = $fields_toinject['logical_number'] ?? ''; + $where['name'] = $fields_toinject['name'] ?? ''; + $where['mac'] = $fields_toinject['mac'] ?? ''; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_MACADDRESS: - $where .= " AND `mac` = '" . ($fields_toinject["mac"] ?? '') . "'"; + $where['mac'] = $fields_toinject['mac'] ?? ''; break; case PluginDatainjectionCommonInjectionLib::UNICITY_NETPORT_NAME: - $where .= " AND `name` = '" . ($fields_toinject["name"] ?? '') . "'"; + $where['name'] = $fields_toinject['name'] ?? ''; break; } diff --git a/inc/softwarelicenseinjection.class.php b/inc/softwarelicenseinjection.class.php index 1be2e53c..450b55be 100644 --- a/inc/softwarelicenseinjection.class.php +++ b/inc/softwarelicenseinjection.class.php @@ -200,14 +200,16 @@ public function addSpecificNeededFields($primary_type, $values) /** * @param array $fields_toinject array * @param array $options array + * @retrun array **/ - public function checkPresent($fields_toinject = [], $options = []) + public function checkPresent($fields_toinject = [], $options = []): array { - if ($options['itemtype'] != 'SoftwareLicense') { - return (" AND `softwares_id` = '" . $fields_toinject['Software']['id'] . "' - AND `name` = '" . $fields_toinject['SoftwareLicense']['name'] . "'"); + return [ + 'softwares_id' => $fields_toinject['Software']['id'], + 'name' => $fields_toinject['SoftwareLicense']['name'], + ]; } - return ""; + return []; } } diff --git a/inc/softwareversioninjection.class.php b/inc/softwareversioninjection.class.php index fd627ce4..4e391791 100644 --- a/inc/softwareversioninjection.class.php +++ b/inc/softwareversioninjection.class.php @@ -195,14 +195,16 @@ public function addSpecificNeededFields($primary_type, $values) /** * @param array $fields_toinject array * @param array $options array + * @return array **/ - public function checkPresent($fields_toinject = [], $options = []) + public function checkPresent($fields_toinject = [], $options = []): array { - if ($options['itemtype'] != 'SoftwareVersion') { - return (" AND `softwares_id` = '" . $fields_toinject['Software']['id'] . "' - AND `name` = '" . $fields_toinject['SoftwareVersion']['name'] . "'"); + return [ + 'softwares_id' => $fields_toinject['Software']['id'], + 'name' => $fields_toinject['SoftwareVersion']['name'], + ]; } - return ""; + return []; } } From 2d3b54d2c585263bd97a6f309078e3a12b31a0fb Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 21 May 2026 10:09:15 +0200 Subject: [PATCH 05/15] rector --- inc/commoninjectionlib.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 6eb816b8..154117d3 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -27,7 +27,7 @@ * @link https://github.com/pluginsGLPI/datainjection * ------------------------------------------------------------------------- */ -use Glpi\DBAL\QueryExpression; + use Glpi\DBAL\QuerySubQuery; use Glpi\Exception\Http\HttpException; use Glpi\Features\AssignableItem; From 02e3ff2fac2a72ddd986088028d4187527b2a9ff Mon Sep 17 00:00:00 2001 From: Herafia Date: Wed, 27 May 2026 12:23:11 +0200 Subject: [PATCH 06/15] catch error --- inc/commoninjectionlib.class.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 154117d3..fc475c95 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -1985,8 +1985,19 @@ private function dataAlreadyInDB($injectionClass, $itemtype) //Add additional parameters specific to this itemtype (or function checkPresent exists) if (method_exists($injectionClass, 'checkPresent')) { $extra = $injectionClass->checkPresent($this->values, $options); - if (is_array($extra) && count($extra) > 0) { - $where = array_merge($where, $extra); + if (is_array($extra)) { + if (count($extra) > 0) { + $where = array_merge($where, $extra); + } + } elseif (!empty($extra)) { + trigger_error( + sprintf( + '%s::checkPresent() must return an array, %s returned instead.', + get_class($injectionClass), + gettype($extra), + ), + E_USER_WARNING, + ); } } } From f45c2d08ef42dda2e216cb34d6196f9328dae3cc Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 28 May 2026 12:21:49 +0200 Subject: [PATCH 07/15] test datainjection --- .../CommonInjectionLibDataAlreadyInDbTest.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/unit/CommonInjectionLibDataAlreadyInDbTest.php diff --git a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php new file mode 100644 index 00000000..97b65e50 --- /dev/null +++ b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php @@ -0,0 +1,56 @@ +createItem(Manufacturer::class, [ + 'name' => $manufacturer_name, + ]); + + $injection_class = new \PluginDatainjectionManufacturerInjection(); + $common_injection_lib = new PluginDatainjectionCommonInjectionLib( + $injection_class, + [ + 'Manufacturer' => [ + 'name' => $manufacturer_name, + ], + ], + [ + 'mandatory_fields' => [ + 'Manufacturer' => [ + 'name' => true, + ], + ], + ], + ); + + $invoke_data_already_in_db = \Closure::bind( + function ($injection_class, string $itemtype): void { + $this->dataAlreadyInDB($injection_class, $itemtype); + }, + $common_injection_lib, + PluginDatainjectionCommonInjectionLib::class, + ); + + $invoke_data_already_in_db($injection_class, 'Manufacturer'); + + $values = $common_injection_lib->getValuesForItemtype('Manufacturer'); + self::assertIsArray($values); + self::assertSame($manufacturer->getID(), $values['id']); + } +} + + + From bcf08dd7625686df6959580efd7ac45b222f8db7 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 28 May 2026 12:26:09 +0200 Subject: [PATCH 08/15] lint --- tests/unit/CommonInjectionLibDataAlreadyInDbTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php index 97b65e50..d7549397 100644 --- a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php +++ b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php @@ -51,6 +51,3 @@ function ($injection_class, string $itemtype): void { self::assertSame($manufacturer->getID(), $values['id']); } } - - - From 818a32c0451394fc23eb146218794aca68431c6d Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 28 May 2026 14:18:59 +0200 Subject: [PATCH 09/15] header --- .../CommonInjectionLibDataAlreadyInDbTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php index d7549397..371a0ba6 100644 --- a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php +++ b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php @@ -1,5 +1,34 @@ . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/escalade + * ------------------------------------------------------------------------- + */ + + namespace GlpiPlugin\Datainjection\Tests\Unit; use Glpi\Tests\DbTestCase; From 6a138c97a713f02e95511332df3bd3702c3d5e82 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 28 May 2026 14:31:16 +0200 Subject: [PATCH 10/15] lint --- tests/unit/CommonInjectionLibDataAlreadyInDbTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php index 371a0ba6..d03ba804 100644 --- a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php +++ b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php @@ -28,7 +28,6 @@ * ------------------------------------------------------------------------- */ - namespace GlpiPlugin\Datainjection\Tests\Unit; use Glpi\Tests\DbTestCase; From 5d7202d277d820be257187e2a29c32799d3d3105 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 28 May 2026 14:44:54 +0200 Subject: [PATCH 11/15] header check --- tests/unit/CommonInjectionLibDataAlreadyInDbTest.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php index d03ba804..51f905f0 100644 --- a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php +++ b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php @@ -2,28 +2,30 @@ /** * ------------------------------------------------------------------------- - * Escalade plugin for GLPI + * DataInjection plugin for GLPI * ------------------------------------------------------------------------- * * LICENSE * - * This file is part of Escalade. + * This file is part of DataInjection. * - * Escalade is free software; you can redistribute it and/or modify + * DataInjection is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * Escalade is distributed in the hope that it will be useful, + * DataInjection is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Escalade. If not, see . + * along with DataInjection. If not, see . * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2007-2023 by DataInjection plugin team. * @copyright Copyright (C) 2015-2023 by Escalade plugin team. * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/datainjection * @link https://github.com/pluginsGLPI/escalade * ------------------------------------------------------------------------- */ From 2d55a5dfc4d377718c8cab7356e6f7f96740ec10 Mon Sep 17 00:00:00 2001 From: Herafia <35998899+Herafia@users.noreply.github.com> Date: Thu, 28 May 2026 16:44:08 +0200 Subject: [PATCH 12/15] Update tests/unit/CommonInjectionLibDataAlreadyInDbTest.php Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> --- tests/unit/CommonInjectionLibDataAlreadyInDbTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php index 51f905f0..4beab0ec 100644 --- a/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php +++ b/tests/unit/CommonInjectionLibDataAlreadyInDbTest.php @@ -23,10 +23,8 @@ * along with DataInjection. If not, see . * ------------------------------------------------------------------------- * @copyright Copyright (C) 2007-2023 by DataInjection plugin team. - * @copyright Copyright (C) 2015-2023 by Escalade plugin team. * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/pluginsGLPI/datainjection - * @link https://github.com/pluginsGLPI/escalade * ------------------------------------------------------------------------- */ From 7fbec49b55e5d2f8ed30352c366fe17534b691e2 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 28 May 2026 17:01:31 +0200 Subject: [PATCH 13/15] config tests --- .gitignore | 2 ++ phpunit.xml | 18 ++++++++++++++++++ tests/bootstrap.php | 10 ++++++++++ 3 files changed, 30 insertions(+) create mode 100644 phpunit.xml create mode 100644 tests/bootstrap.php diff --git a/.gitignore b/.gitignore index f0331232..508e8ab0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ vendor/ .gh_token *.min.* + +var/phpunit diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..b827cdfc --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + src + + + + + + tests + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 00000000..7438cd68 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,10 @@ + Date: Thu, 28 May 2026 17:11:43 +0200 Subject: [PATCH 14/15] licenceee --- tests/bootstrap.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7438cd68..cbf2d884 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,33 @@ . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2007-2023 by DataInjection plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/datainjection + * ------------------------------------------------------------------------- + */ + $current_plugin_folder = basename(realpath(__DIR__ . '/../')); require __DIR__ . '/../../../tests/bootstrap.php'; From 0ad46d4bee0992905e2ed5a1a05bb582a0eaf338 Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Fri, 29 May 2026 10:00:06 +0200 Subject: [PATCH 15/15] Update .gitignore --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 508e8ab0..044ece97 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,4 @@ dist/ vendor/ .gh_token *.min.* - - -var/phpunit +var/