Skip to content

Commit 73f75f6

Browse files
committed
Revert "Fix tu deploy (#724)"
This reverts commit 938c71a.
1 parent b05d8d6 commit 73f75f6

File tree

3 files changed

+0
-50
lines changed

3 files changed

+0
-50
lines changed

hook.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<?php
22

3-
use Glpi\DBAL\QueryExpression;
43
use Glpi\Error\ErrorHandler;
54
use Safe\Exceptions\InfoException;
65

76
use function Safe\ini_set;
87
use function Safe\json_decode;
9-
108
/**
119
* ---------------------------------------------------------------------
1210
* GLPI Inventory Plugin
@@ -38,39 +36,6 @@
3836
* ---------------------------------------------------------------------
3937
*/
4038

41-
function plugin_glpiinventory_add_default_where($in)
42-
{
43-
[$itemtype, $condition] = $in;
44-
45-
if ($itemtype === Computer::class && str_contains($_SERVER['REQUEST_URI'] ?? '', 'deploypackage.public.php')) {
46-
// Specific case related to Self-Service profile rights:
47-
// - As Computer object has no read permission for Self-Service profile,
48-
// Computer::getAssignableVisiblityCriteria() returns a QueryExpression("0").
49-
// - This leads to a "WHERE (0)" clause in the SQL query, which discards
50-
// all results (e.g. no deployment packages shown in Self-Service).
51-
// - To fix this in the plugin, we explicitly filter out QueryExpression
52-
// instances with value "0", while keeping all other valid criteria
53-
// generated by GLPI.
54-
removeEmptyCondition($condition);
55-
}
56-
57-
return [$itemtype, $condition];
58-
}
59-
60-
function removeEmptyCondition(array &$conditions): void
61-
{
62-
foreach ($conditions as $key => $condition) {
63-
if (is_array($condition)) {
64-
removeEmptyCondition($condition);
65-
if (empty($condition)) {
66-
unset($conditions[$key]);
67-
}
68-
} elseif ($condition instanceof QueryExpression && $condition->getValue() == 0) {
69-
unset($conditions[$key]);
70-
}
71-
}
72-
}
73-
7439
/**
7540
* Add search options for GLPI objects
7641
*

setup.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,6 @@ function plugin_init_glpiinventory()
375375
$PLUGIN_HOOKS[Hooks::HANDLE_ESX_TASK]['glpiinventory'] = 'plugin_glpiinventory_handle_esx_task';
376376
$PLUGIN_HOOKS[Hooks::HANDLE_COLLECT_TASK]['glpiinventory'] = 'plugin_glpiinventory_handle_collect_task';
377377
$PLUGIN_HOOKS[Hooks::HANDLE_DEPLOY_TASK]['glpiinventory'] = 'plugin_glpiinventory_handle_deploy_task';
378-
379-
$PLUGIN_HOOKS[Hooks::ADD_DEFAULT_WHERE]['glpiinventory'] = 'plugin_glpiinventory_add_default_where';
380378
}
381379

382380

tests/Integration/Deploy/PackageSelfDeployTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -409,19 +409,6 @@ public function testReportMyPackage()
409409
// Prepare task
410410
PluginGlpiinventoryTask::cronTaskscheduler();
411411

412-
$_SERVER['REQUEST_URI'] = 'front/deploypackage.php'; // URL is used to fix addDefaultWhere
413-
$packages = $pfDeployPackage->getPackageForMe($userId);
414-
$packages_deploy = [];
415-
foreach ($packages as $data) {
416-
foreach ($data as $package_info) {
417-
if (isset($package_info['taskjobs_id'])) {
418-
$packages_deploy[] = $package_info['last_taskjobstate']['state'];
419-
}
420-
}
421-
}
422-
$this->assertEquals([], $packages_deploy);
423-
424-
$_SERVER['REQUEST_URI'] = 'front/deploypackage.public.php'; // URL is used to fix addDefaultWhere
425412
$packages = $pfDeployPackage->getPackageForMe($userId);
426413
$packages_deploy = [];
427414
foreach ($packages as $data) {

0 commit comments

Comments
 (0)