Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions install/migrations/update_9.4.3_to_9.4.5.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ function update943to945()
$migration->setVersion('9.4.5');

/** Add OLA TTR begin date field to Tickets */
$iterator = new DBmysqlIterator(null);
$iterator = new DBmysqlIterator($DB);
$migration->addField(
'glpi_tickets',
'ola_ttr_begin_date',
'datetime',
[
'after' => 'olalevels_id_ttr',
'update' => $DB->quoteName('date'), // Assign ticket creation date by default
'condition' => 'WHERE ' . $iterator->analyseCrit(['NOT' => ['olas_id_ttr' => '0']]),
'condition' => sprintf('WHERE NOT(%s = %d)', $DB->quoteName('olas_id_ttr'), 0),
]
);
/** /Add OLA TTR begin date field to Tickets */
Expand Down
19 changes: 19 additions & 0 deletions src/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
abstract class AbstractQuery
{
protected ?string $alias = null;
/** @var array<int, mixed> */
protected array $values = [];

/**
* Create a query
Expand Down Expand Up @@ -74,4 +76,21 @@ public function __toString()
{
return $this->getQuery();
}

/**
* @return array<int, mixed>
*/
public function getValues(): array
{
return $this->values;
}

/**
* @param array<int, mixed> $values
*/
public function setValues(array $values): static
{
$this->values = $values;
return $this;
}
}
6 changes: 3 additions & 3 deletions src/Cartridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function backToStock(array $input, $history = true)
'id' => $input['id'],
]
);
if ($result && ($DB->affectedRows() > 0)) {
if ($result && ($DB->getAffectedRows() > 0)) {
$changesCartrige = [
0,
'',
Expand Down Expand Up @@ -314,7 +314,7 @@ public function install($pID, $tID)
'date_use' => null,
]
);
if ($result && ($DB->affectedRows() > 0)) {
if ($result && ($DB->getAffectedRows() > 0)) {
$changes = [
'0',
'',
Expand Down Expand Up @@ -373,7 +373,7 @@ public function uninstall($ID)

if (
$result
&& ($DB->affectedRows() > 0)
&& ($DB->getAffectedRows() > 0)
) {
$changes = [
'0',
Expand Down
2 changes: 1 addition & 1 deletion src/CartridgeItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static function addCompatibleType($cartridgeitems_id, $printermodels_id)
];
$result = $DB->insert('glpi_cartridgeitems_printermodels', $params);

if ($result && ($DB->affectedRows() > 0)) {
if ($result && ($DB->getAffectedRows() > 0)) {
return true;
}
}
Expand Down
17 changes: 12 additions & 5 deletions src/CommonDBTM.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public function updateInDB($updates, $oldvalues = [])
$tobeupdated,
['id' => $this->fields['id']]
);
$affected_rows = $DB->affectedRows();
$affected_rows = $DB->getAffectedRows();

if (count($oldvalues) && $affected_rows > 0) {
Log::constructHistory($this, $oldvalues, $this->fields);
Expand Down Expand Up @@ -803,9 +803,8 @@ public function restoreInDB()
$params['date_mod'] = $_SESSION["glpi_currenttime"];
}

if ($DB->update(static::getTable(), $params, ['id' => $this->fields['id']])) {
return true;
}
$DB->update(static::getTable(), $params, ['id' => $this->fields['id']]);
return true;
}
return false;
}
Expand Down Expand Up @@ -1903,7 +1902,15 @@ protected function manageLocks()
);
foreach ($fields as $field) {
try {
$DB->executeStatement($stmt, [$field]);
$DB->executeStatement(
$stmt,
[
'itemtype' => static::class,
'items_id' => $this->fields['id'],
'date_creation' => $_SESSION["glpi_currenttime"],
Comment on lines +1908 to +1910
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these values are already passed to the $DB->buildInsert() on lines 1894-1896, is this change necessary ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build insert won't keep values passed as parameters; they'll all be replaced with a parameter.

'field' => $field,
]
);
} catch (StatementException $e) {
if ($e->getCode() != 1062) {
throw new RuntimeException('Unable to add locked field!', code: $e->getCode(), previous: $e);
Expand Down
4 changes: 2 additions & 2 deletions src/CronTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function start(): bool
]
);

if ($DB->affectedRows() > 0) {
if ($DB->getAffectedRows() > 0) {
$this->timer = microtime(true);
$this->volume = 0;
$log = new CronTaskLog();
Expand Down Expand Up @@ -353,7 +353,7 @@ public function end(?int $retcode, int $log_state = CronTaskLog::STATE_STOP): bo
]
);

if ($DB->affectedRows() > 0) {
if ($DB->getAffectedRows() > 0) {
// No gettext for log but add gettext line to be parsed for pot generation
// order is important for insertion in english in the database
if ($log_state === CronTaskLog::STATE_ERROR) {
Expand Down
2 changes: 1 addition & 1 deletion src/CronTaskLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function cleanOld($id, $days)
]
);

return $result ? $DB->affectedRows() : 0;
return $result ? $DB->getAffectedRows() : 0;
}


Expand Down
Loading
Loading