diff --git a/services/nginx/app/classes/system_search_service.php b/services/nginx/app/classes/system_search_service.php index 5d449d5e..98f5dbbf 100644 --- a/services/nginx/app/classes/system_search_service.php +++ b/services/nginx/app/classes/system_search_service.php @@ -211,24 +211,6 @@ class system_search_service $activeTypes, $this->associationEntityTypes() )); -<<<<<<< HEAD - foreach ($customerNumbers as $customerNumber) { - $associated = $this->executeLexicalSearch( - $associationTypes, - [(string)$customerNumber], - [], - $ownOnlyTypes, - $ownCustomerNumber, - $permissionsCatalogAll, - $permissionsCatalogOwn, - $moduleConfigVisibility, - $allowedDepartmentIds, - [$customerNumber] - ); - foreach ($associated as &$item) { - if (!isset($item['association_reason'])) { - $item['association_reason'] = 'customer:' . $customerNumber; -======= $associationTypes = array_values(array_diff($associationTypes, $ownOnlyTypes)); if (!empty($associationTypes)) { foreach ($customerNumbers as $customerNumber) { @@ -241,6 +223,7 @@ class system_search_service $permissionsCatalogAll, $permissionsCatalogOwn, $moduleConfigVisibility, + $allowedDepartmentIds, [$customerNumber] ); foreach ($associated as &$item) { @@ -248,7 +231,6 @@ class system_search_service $item['association_reason'] = 'customer:' . $customerNumber; } $item['score'] = max((int)$item['score'], 35); ->>>>>>> origin/master } $initialResults = $this->mergeResults($initialResults, $associated); } @@ -351,20 +333,6 @@ class system_search_service foreach ($activeTypes as $entityType) { $boost = (int)($entityBoost[$entityType] ?? 0); $ownOnly = in_array($entityType, $ownOnlyTypes, true); -<<<<<<< HEAD - $rows = $this->searchEntity( - $entityType, - $terms, - $boost, - $ownOnly, - $ownCustomerNumber, - $permissionsCatalogAll, - $permissionsCatalogOwn, - $moduleConfigVisibility, - $allowedDepartmentIds, - $forcedCustomerNumbers - ); -======= if ($ownOnly && $ownCustomerNumber === null && empty($forcedCustomerNumbers)) { continue; } @@ -376,6 +344,7 @@ class system_search_service $ownOnly, $ownCustomerNumber, $moduleConfigVisibility, + $allowedDepartmentIds, $forcedCustomerNumbers ); if (empty($rows)) { @@ -388,6 +357,7 @@ class system_search_service $permissionsCatalogAll, $permissionsCatalogOwn, $moduleConfigVisibility, + $allowedDepartmentIds, $forcedCustomerNumbers ); } @@ -401,10 +371,10 @@ class system_search_service $permissionsCatalogAll, $permissionsCatalogOwn, $moduleConfigVisibility, + $allowedDepartmentIds, $forcedCustomerNumbers ); } ->>>>>>> origin/master $results = $this->mergeResults($results, $rows); } return $results; @@ -488,6 +458,7 @@ class system_search_service /** * @param array $terms * @param array $moduleConfigVisibility + * @param array $allowedDepartmentIds * @param array $forcedCustomerNumbers * @return array> */ @@ -498,6 +469,7 @@ class system_search_service bool $ownOnly, ?int $ownCustomerNumber, array $moduleConfigVisibility, + array $allowedDepartmentIds, array $forcedCustomerNumbers ): array { global $db; @@ -519,6 +491,9 @@ class system_search_service if (!empty($customerNumbers)) { $wheres[] = "`customer_number` IN (" . implode(',', array_map('intval', $customerNumbers)) . ")"; } + if (!empty($allowedDepartmentIds)) { + $wheres[] = "`department_id` IN (" . implode(',', array_map('intval', $allowedDepartmentIds)) . ")"; + } $booleanQuery = $this->buildBooleanFullTextQuery($terms); $rows = []; @@ -1649,12 +1624,9 @@ class system_search_service $terms, $customerNumbers, $customerField, -<<<<<<< HEAD + $customerFieldMode, $allowedDepartmentIds, $departmentField, -======= - $customerFieldMode, ->>>>>>> origin/master $fixedConditions ); @@ -1849,12 +1821,9 @@ class system_search_service * @param array $terms * @param array $customerNumbers * @param string|null $customerField -<<<<<<< HEAD + * @param string $customerFieldMode * @param array $departmentIds * @param string|null $departmentField -======= - * @param string $customerFieldMode ->>>>>>> origin/master * @param array $fixedConditions * @return array> */ @@ -1865,12 +1834,9 @@ class system_search_service array $terms, array $customerNumbers = [], ?string $customerField = null, -<<<<<<< HEAD + string $customerFieldMode = 'default', array $departmentIds = [], ?string $departmentField = null, -======= - string $customerFieldMode = 'default', ->>>>>>> origin/master array $fixedConditions = [] ): array { global $db; diff --git a/services/nginx/app/index.php b/services/nginx/app/index.php index 1625485a..53b1ef5f 100644 --- a/services/nginx/app/index.php +++ b/services/nginx/app/index.php @@ -60,7 +60,7 @@ try { */ spl_autoload_register(function (string $class): void { $class = ltrim($class, '\\'); -<<<<<<< HEAD + $cache_key = 'autoload:' . $class; $wdReal = rtrim((string) realpath(WD), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $modulesRoot = $wdReal . 'modules' . DIRECTORY_SEPARATOR; $isPathInside = static function (string $path, string $root): bool { @@ -71,26 +71,19 @@ spl_autoload_register(function (string $class): void { $resolved = rtrim($resolved, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; return str_starts_with($resolved, $root); -======= - $cache_key = 'autoload:' . $class; + }; $is_loaded = static function (string $candidate): bool { return class_exists($candidate, false) || interface_exists($candidate, false) || trait_exists($candidate, false) || (function_exists('enum_exists') && enum_exists($candidate, false)); ->>>>>>> refs/remotes/origin/master }; // Check Redis cache first if (defined('redis')) { try { -<<<<<<< HEAD - $cached = redis->get('autoload:' . $class); - if ($cached && is_file($cached) && $isPathInside($cached, $wdReal)) { -======= $cached = redis->get($cache_key); - if (is_string($cached) && $cached !== '' && is_file($cached)) { ->>>>>>> refs/remotes/origin/master + if (is_string($cached) && $cached !== '' && is_file($cached) && $isPathInside($cached, $wdReal)) { require_once $cached; if ($is_loaded($class)) { return; diff --git a/services/nginx/app/tests/Unit/Search/SystemSearchServiceIntentFlowTest.php b/services/nginx/app/tests/Unit/Search/SystemSearchServiceIntentFlowTest.php index fab6f96a..b3f0833a 100644 --- a/services/nginx/app/tests/Unit/Search/SystemSearchServiceIntentFlowTest.php +++ b/services/nginx/app/tests/Unit/Search/SystemSearchServiceIntentFlowTest.php @@ -387,7 +387,6 @@ it('caps AI-driven expanded terms to prevent query amplification', function (): expect($maxLen)->toBeLessThanOrEqual(64); }); -<<<<<<< HEAD it('passes allowed department ids into lexical execution context', function (): void { $parser = new FakeSystemSearchIntentParser(); @@ -405,7 +404,8 @@ it('passes allowed department ids into lexical execution context', function (): expect(count($service->lexicalCalls))->toBe(1); expect($service->lexicalCalls[0]['allowedDepartmentIds'])->toBe([3, 7]); -======= +}); + it('does not expand associations for own-only entity types', function (): void { $parser = new FakeSystemSearchIntentParser(); $service = new TestableSystemSearchService($parser, [ @@ -979,5 +979,4 @@ it('includes the economic customer index in cache dependencies for customer scop $tables = system_search_service_invoke_private($service, 'relevantSourceTables', [['objects', 'orders', 'vehicles']]); expect($tables)->toContain(system_search_economic_customer_index::TABLE); ->>>>>>> origin/master });