James Cole
2023-11-25 19:03:51 +01:00
parent bac0710a9c
commit 3355645cb4
5 changed files with 29 additions and 17 deletions

View File

@@ -226,16 +226,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.39.0",
"version": "v3.39.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "04bf7b28fc847185b247d112cab617da941e3cca"
"reference": "857046d26b0d92dc13c4be769309026b100b517e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/04bf7b28fc847185b247d112cab617da941e3cca",
"reference": "04bf7b28fc847185b247d112cab617da941e3cca",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/857046d26b0d92dc13c4be769309026b100b517e",
"reference": "857046d26b0d92dc13c4be769309026b100b517e",
"shasum": ""
},
"require": {
@@ -307,7 +307,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.39.0"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.39.1"
},
"funding": [
{
@@ -315,7 +315,7 @@
"type": "github"
}
],
"time": "2023-11-22T11:20:09+00:00"
"time": "2023-11-24T22:59:03+00:00"
},
{
"name": "psr/container",

View File

@@ -100,13 +100,15 @@ class CreateController extends Controller
session()->flash('warning', trans('firefly.rule_from_search_words', ['string' => $words]));
$operators[] = [
'type' => 'description_contains',
'value' => $words];
'value' => $words
];
}
$oldTriggers = $this->parseFromOperators($operators);
}
//var_dump($oldTriggers);exit;
// restore actions and triggers from old input:
if (null !== $request->old()) {
if (is_array($request->old()) && count($request->old()) > 0) {
$oldTriggers = $this->getPreviousTriggers($request);
$oldActions = $this->getPreviousActions($request);
}

View File

@@ -138,12 +138,14 @@ trait RuleManagement
$index = 0;
foreach ($submittedOperators as $operator) {
$rootOperator = OperatorQuerySearch::getRootOperator($operator['type']);
$needsContext = (bool) config(sprintf('search.operators.%s.needs_context',$rootOperator));
try {
$renderedEntries[] = view(
'rules.partials.trigger',
[
'oldTrigger' => OperatorQuerySearch::getRootOperator($operator['type']),
'oldValue' => $operator['value'],
'oldTrigger' => $rootOperator,
'oldValue' => $needsContext ? $operator['value'] : '',
'oldChecked' => false,
'oldProhibited' => $operator['prohibited'] ?? false,
'count' => $index + 1,

View File

@@ -60,8 +60,7 @@ use TypeError;
/**
* Class OperatorQuerySearch
*/
class
OperatorQuerySearch implements SearchInterface
class OperatorQuerySearch implements SearchInterface
{
protected Carbon $date;
private AccountRepositoryInterface $accountRepository;
@@ -212,8 +211,14 @@ OperatorQuerySearch implements SearchInterface
$context = config(sprintf('search.operators.%s.needs_context', $operator));
// is an operator that needs no context, and value is false, then prohibited = true.
if ('false' === $value && in_array($operator, $this->validOperators, true) && false === $context) {
if ('false' === $value && in_array($operator, $this->validOperators, true) && false === $context && !$prohibited) {
$prohibited = true;
$value = 'true';
}
// if the operator is prohibited, but the value is false, do an uno reverse
if ('false' === $value && $prohibited && in_array($operator, $this->validOperators, true) && false === $context) {
$prohibited = false;
$value = 'true';
}
// must be valid operator:

View File

@@ -115,13 +115,13 @@ class SearchRuleEngine implements RuleEngineInterface
}
// if needs no context, value is different:
$needsContext = config(sprintf('search.operators.%s.needs_context', $ruleTrigger->trigger_type)) ?? true;
$needsContext = (bool) config(sprintf('search.operators.%s.needs_context', $ruleTrigger->trigger_type)) ?? true;
if (false === $needsContext) {
app('log')->debug(sprintf('SearchRuleEngine:: add a rule trigger: %s:true', $ruleTrigger->trigger_type));
app('log')->debug(sprintf('SearchRuleEngine:: add a rule trigger (no context): %s:true', $ruleTrigger->trigger_type));
$searchArray[$ruleTrigger->trigger_type][] = 'true';
}
if (true === $needsContext) {
app('log')->debug(sprintf('SearchRuleEngine:: add a rule trigger: %s:"%s"', $ruleTrigger->trigger_type, $ruleTrigger->trigger_value));
app('log')->debug(sprintf('SearchRuleEngine:: add a rule trigger (context): %s:"%s"', $ruleTrigger->trigger_type, $ruleTrigger->trigger_value));
$searchArray[$ruleTrigger->trigger_type][] = sprintf('"%s"', $ruleTrigger->trigger_value);
}
}
@@ -136,6 +136,7 @@ class SearchRuleEngine implements RuleEngineInterface
if ($this->hasSpecificJournalTrigger($searchArray)) {
$date = $this->setDateFromJournalTrigger($searchArray);
}
// build and run the search engine.
$searchEngine = app(SearchInterface::class);
$searchEngine->setUser($this->user);
@@ -145,7 +146,9 @@ class SearchRuleEngine implements RuleEngineInterface
foreach ($searchArray as $type => $searches) {
foreach ($searches as $value) {
$searchEngine->parseQuery(sprintf('%s:%s', $type, $value));
$query = sprintf('%s:%s', $type, $value);
app('log')->debug(sprintf('SearchRuleEngine:: add query "%s"', $query));
$searchEngine->parseQuery($query);
}
}