Skip to content

Commit

Permalink
Revert doQuery changes (#383)
Browse files Browse the repository at this point in the history
* Revert doQuery changes

* Ignore deprecation

* fixup! Ignore deprecation
  • Loading branch information
AdrienClairembault authored Feb 21, 2024
1 parent 5d90e80 commit a701458
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
15 changes: 10 additions & 5 deletions inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@ private static function findUser($value, $entity)
WHERE LOWER(`name`) = '" . strtolower($value) . "'
OR (CONCAT(LOWER(`realname`),' ',LOWER(`firstname`)) = '" . strtolower($value) . "'
OR CONCAT(LOWER(`firstname`),' ',LOWER(`realname`)) = '" . strtolower($value) . "')";
$result = $DB->doQuery($sql);
/** @phpstan-ignore-next-line */
$result = $DB->query($sql); // phpcs:ignore
if ($DB->numrows($result) > 0) {
//check if user has right on the current entity
$ID = $DB->result($result, 0, "id");
Expand Down Expand Up @@ -780,7 +781,8 @@ private static function findContact($value, $entity)
AND (LOWER(`name`) = '" . strtolower($value) . "'
OR (CONCAT(LOWER(`name`),' ',LOWER(`firstname`)) = '" . strtolower($value) . "'
OR CONCAT(LOWER(`firstname`),' ',LOWER(`name`)) = '" . strtolower($value) . "'))";
$result = $DB->doQuery($sql);
/** @phpstan-ignore-next-line */
$result = $DB->query($sql); // phpcs:ignore

if ($DB->numrows($result) > 0) {
//check if user has right on the current entity
Expand Down Expand Up @@ -824,7 +826,8 @@ private static function findSingle($item, $searchOption, $entity, $value)
}

$query .= " AND `" . $searchOption['field'] . "` = '$value'";
$result = $DB->doQuery($query);
/** @phpstan-ignore-next-line */
$result = $DB->query($query); // phpcs:ignore

if ($DB->numrows($result) > 0) {
//check if user has right on the current entity
Expand Down Expand Up @@ -942,7 +945,8 @@ private static function getTemplateIDByName($itemtype, $name)
FROM `" . getTableForItemType($itemtype) . "`
WHERE `is_template` = '1'
AND `template_name` = '$name'";
$result = $DB->doQuery($query);
/** @phpstan-ignore-next-line */
$result = $DB->query($query); // phpcs:ignore

if ($DB->numrows($result) > 0) {
return $DB->result($result, 0, 'id');
Expand Down Expand Up @@ -1889,7 +1893,8 @@ private function dataAlreadyInDB($injectionClass, $itemtype)
$sql .= " WHERE 1 " . $where_entity . " " . $where;
}

$result = $DB->doQuery($sql);
/** @phpstan-ignore-next-line */
$result = $DB->query($sql); // phpcs:ignore
if ($DB->numrows($result) > 0) {
$db_fields = $DB->fetchAssoc($result);
foreach ($db_fields as $key => $value) {
Expand Down
3 changes: 2 additions & 1 deletion inc/modelcsv.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public function getFromDBByModelID($models_id)
FROM `" . $this->getTable() . "`
WHERE `models_id` = '" . $models_id . "'";

$results = $DB->doQuery($query);
/** @phpstan-ignore-next-line */
$results = $DB->query($query); // phpcs:ignore
$id = 0;

if ($DB->numrows($results) > 0) {
Expand Down
3 changes: 2 additions & 1 deletion inc/networkportinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
if ($use_mac) {
$sql .= " AND `glpi_networkports`.`mac` = '" . $values['NetworkPort']["netmac"] . "'";
}
$res = $DB->doQuery($sql);
/** @phpstan-ignore-next-line */
$res = $DB->query($sql); // phpcs:ignore

//if at least one parameter is given
$nb = $DB->numrows($res);
Expand Down
6 changes: 4 additions & 2 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function cleanProfiles($ID)
$query = "DELETE FROM `glpi_profiles`
WHERE `profiles_id`='$ID'
AND `name` LIKE '%plugin_datainjection%'";
$DB->doQuery($query);
/** @phpstan-ignore-next-line */
$DB->query($query); // phpcs:ignore
}

public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
Expand Down Expand Up @@ -146,7 +147,8 @@ public static function migrateProfiles()
$profiles = getAllDataFromTable('glpi_plugin_datainjection_profiles');
foreach ($profiles as $id => $profile) {
$query = "SELECT `id` FROM `glpi_profiles` WHERE `name`='" . $profile['name'] . "'";
$result = $DB->doQuery($query);
/** @phpstan-ignore-next-line */
$result = $DB->query($query); // phpcs:ignore
if ($DB->numrows($result) == 1) {
$id = $DB->result($result, 0, 'id');
switch ($profile['model']) {
Expand Down
3 changes: 2 additions & 1 deletion inc/softwarelicenseinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public function getValueForAdditionalMandatoryFields($fields_toinject = [])
$fields_toinject['SoftwareLicense']['entities_id'],
true
);
$result = $DB->doQuery($query);
/** @phpstan-ignore-next-line */
$result = $DB->query($query); // phpcs:ignore

if ($DB->numrows($result) > 0) {
$id = $DB->result($result, 0, 'id');
Expand Down
3 changes: 2 additions & 1 deletion inc/softwareversioninjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public function getValueForAdditionalMandatoryFields($fields_toinject = [])
$fields_toinject['SoftwareVersion']['entities_id'],
true
);
$result = $DB->doQuery($query);
/** @phpstan-ignore-next-line */
$result = $DB->query($query); // phpcs:ignore

if ($DB->numrows($result) > 0) {
$id = $DB->result($result, 0, 'id');
Expand Down
3 changes: 2 additions & 1 deletion inc/userinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
$query = "UPDATE `glpi_users`
SET `password` = '" . $password . "'
WHERE `id` = '" . $values['User']['id'] . "'";
$DB->doQuery($query);
/** @phpstan-ignore-next-line */
$DB->query($query); // phpcs:ignore
}
}

Expand Down

0 comments on commit a701458

Please sign in to comment.