From 0cfd5c044bc3acccda769b7b020cecbc9f429be5 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Wed, 18 Feb 2026 09:54:37 +0100 Subject: [PATCH] 8782 - Union queries allow all data --- core/dbunionsearch.class.php | 2 +- tests/php-unit-tests/unitary-tests/core/DBSearchTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/dbunionsearch.class.php b/core/dbunionsearch.class.php index 8d8d73684..a9c4beba8 100644 --- a/core/dbunionsearch.class.php +++ b/core/dbunionsearch.class.php @@ -59,7 +59,7 @@ class DBUnionSearch extends DBSearch public function AllowAllData($bAllowAllData = true) { foreach ($this->aSearches as $oSearch) { - $oSearch->AllowAllData(); + $oSearch->AllowAllData($bAllowAllData); } } diff --git a/tests/php-unit-tests/unitary-tests/core/DBSearchTest.php b/tests/php-unit-tests/unitary-tests/core/DBSearchTest.php index 8a7d9a5cb..b807f8980 100644 --- a/tests/php-unit-tests/unitary-tests/core/DBSearchTest.php +++ b/tests/php-unit-tests/unitary-tests/core/DBSearchTest.php @@ -694,6 +694,15 @@ class DBSearchTest extends ItopDataTestCase $this->CheckNestedSearch($sNestedQuery, false); } + public function testAllowAllDataOnUnions() + { + $oSearch = \DBObjectSearch::FromOQL('SELECT Server UNION SELECT VirtualMachine'); + $oSearch->AllowAllData(false); + self::assertFalse($oSearch->IsAllDataAllowed(), 'DBUnionSearch AllowData value'); + $oSearch->AllowAllData(true); + self::assertTrue($oSearch->IsAllDataAllowed(), 'DBUnionSearch AllowData value'); + } + private function CheckNestedSearch($sQuery, $bAllowAllData) { $oNestedQuerySearch = \DBObjectSearch::FromOQL($sQuery);