Skip to content

Commit d8967b6

Browse files
authored
Fix - SQL syntax errors in cronComputeLateOrders method (#509)
* Fix - SQL syntax errors in cronComputeLateOrders method * Update CHANGELOG * Fix Rector
1 parent e0da948 commit d8967b6

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [UNRELEASED]
9+
10+
### Fixed
11+
12+
- Fix SQL syntax errors in cronComputeLateOrders cron task
13+
814
## [2.12.2] - 2025-11-13
915

1016
### Fixed

inc/order.class.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,44 +2399,46 @@ public static function cronComputeLateOrders($task)
23992399
$config = PluginOrderConfig::getConfig();
24002400

24012401
$query = [
2402-
'SELECT' => `id`,
2403-
'FROM' => `glpi_entities`,
2404-
'ORDER' => `id ASC`,
2402+
'SELECT' => 'id',
2403+
'FROM' => 'glpi_entities',
2404+
'ORDER' => 'id ASC',
24052405
];
24062406

24072407
$entities[] = 0;
24082408
foreach ($DB->request($query) as $entity) {
24092409
$entities[] = $entity['id'];
24102410
}
24112411

2412+
24122413
foreach ($entities as $entity) {
24132414
$query_alert = [
24142415
'SELECT' => [
2415-
`$table.id AS id`,
2416-
`$table.name AS name`,
2417-
`$table.num_order AS num_order`,
2418-
`$table.order_date AS order_date`,
2419-
`$table.duedate AS duedate`,
2420-
`$table.deliverydate AS deliverydate`,
2421-
`$table.comment AS comment`,
2422-
`$table.plugin_order_orderstates_id AS plugin_order_orderstates_id`,
2423-
`glpi_alerts.id AS alertID`,
2424-
`glpi_alerts.date`,
2416+
$table . '.id AS id',
2417+
$table . '.name AS name',
2418+
$table . '.num_order AS num_order',
2419+
$table . '.order_date AS order_date',
2420+
$table . '.duedate AS duedate',
2421+
$table . '.deliverydate AS deliverydate',
2422+
$table . '.comment AS comment',
2423+
$table . '.plugin_order_orderstates_id AS plugin_order_orderstates_id',
2424+
"glpi_alerts.id AS alertID",
2425+
"glpi_alerts.date",
24252426
],
24262427
'FROM' => $table,
24272428
'LEFT JOIN' => [
2428-
`glpi_alerts` => [
2429+
'glpi_alerts' => [
24292430
'ON' => [
2430-
sprintf('`%s`.`id` = `glpi_alerts`.`items_id`', $table),
2431-
"`glpi_alerts`.`itemtype` = '" . self::class . "'",
2431+
'glpi_alerts' => 'items_id',
2432+
$table => 'id',
2433+
['AND' => ['glpi_alerts.itemtype' => self::class]],
24322434
],
24332435
],
24342436
],
24352437
'WHERE' => [
24362438
$table . '.entities_id' => $entity,
2437-
"glpi_alerts.date" => "IS NULL",
2438-
$table . '.is_late' => "1",
2439-
$table . '.plugin_order_orderstates_id' => "!=" . $config->getDeliveredState(),
2439+
'glpi_alerts.date' => null,
2440+
$table . '.is_late' => 1,
2441+
'NOT' => [$table . '.plugin_order_orderstates_id' => $config->getDeliveredState()],
24402442
],
24412443
];
24422444
$orders = [];

0 commit comments

Comments
 (0)