Resolve PHP merge conflict test failures

This commit is contained in:
Jeppe B
2026-06-02 00:58:15 +02:00
parent c9ceac8533
commit 140365c8bb
3 changed files with 17 additions and 59 deletions
@@ -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<int, string> $terms
* @param array<string, bool> $moduleConfigVisibility
* @param array<int, int> $allowedDepartmentIds
* @param array<int, int> $forcedCustomerNumbers
* @return array<int, array<string, mixed>>
*/
@@ -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<int, string> $terms
* @param array<int, int> $customerNumbers
* @param string|null $customerField
<<<<<<< HEAD
* @param string $customerFieldMode
* @param array<int, int> $departmentIds
* @param string|null $departmentField
=======
* @param string $customerFieldMode
>>>>>>> origin/master
* @param array<string, mixed> $fixedConditions
* @return array<int, array<string, mixed>>
*/
@@ -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;
+3 -10
View File
@@ -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;
@@ -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
});