Skip to content

Commit 0dec2ed

Browse files
committed
Fix dynamic groups actors
closes #770 Revert "Fix tu deploy (#724)" This reverts commit 938c71a.
1 parent 409abe3 commit 0dec2ed

File tree

4 files changed

+6
-40
lines changed

4 files changed

+6
-40
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [1.6.1] - unreleased
99

10+
- Fix visibility issue on deploy dynamic groups with GLPI v11.0.2
1011
- Fix deploy ajax action path
1112
- Prevent fatal errors when ini_set is not allowed
1213

hook.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

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

@@ -38,39 +37,6 @@
3837
* ---------------------------------------------------------------------
3938
*/
4039

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-
7440
/**
7541
* Add search options for GLPI objects
7642
*

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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ public function testReportMyPackage()
409409
// Prepare task
410410
PluginGlpiinventoryTask::cronTaskscheduler();
411411

412+
$reference = [
413+
'agents_prepared',
414+
];
415+
412416
$_SERVER['REQUEST_URI'] = 'front/deploypackage.php'; // URL is used to fix addDefaultWhere
413417
$packages = $pfDeployPackage->getPackageForMe($userId);
414418
$packages_deploy = [];
@@ -419,7 +423,7 @@ public function testReportMyPackage()
419423
}
420424
}
421425
}
422-
$this->assertEquals([], $packages_deploy);
426+
$this->assertEquals($reference, $packages_deploy);
423427

424428
$_SERVER['REQUEST_URI'] = 'front/deploypackage.public.php'; // URL is used to fix addDefaultWhere
425429
$packages = $pfDeployPackage->getPackageForMe($userId);
@@ -431,9 +435,6 @@ public function testReportMyPackage()
431435
}
432436
}
433437
}
434-
$reference = [
435-
'agents_prepared',
436-
];
437438
$this->assertEquals($reference, $packages_deploy);
438439
}
439440

0 commit comments

Comments
 (0)