mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 08:11:20 +00:00
Add feature flag for expression engine and disable it by default.
This commit is contained in:
@@ -78,6 +78,9 @@ class RuleAction extends Model
|
||||
|
||||
public function getValue(array $journal): string
|
||||
{
|
||||
if (false === config('firefly.feature_flags.expression_engine')) {
|
||||
return (string)$this->action_value;
|
||||
}
|
||||
$expr = new ActionExpression($this->action_value);
|
||||
|
||||
return $expr->evaluate($journal);
|
||||
|
@@ -40,13 +40,18 @@ class IsValidActionExpression implements ValidationRule
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, \Closure $fail): void
|
||||
{
|
||||
if (false === config('firefly.feature_flags.expression_engine')) {
|
||||
return;
|
||||
}
|
||||
$value ??= '';
|
||||
$expr = new ActionExpression($value);
|
||||
|
||||
if (!$expr->isValid()) {
|
||||
$fail('validation.rule_action_expression')->translate([
|
||||
$fail('validation.rule_action_expression')->translate(
|
||||
[
|
||||
'error' => $expr->getValidationError()->getMessage(),
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -269,7 +269,7 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
// if value is an expression, assume valid
|
||||
if (str_starts_with($value, '=')) {
|
||||
if (true === config('firefly.feature_flags.expression_engine') && str_starts_with($value, '=') && strlen($value) > 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -522,8 +522,7 @@ class FireflyValidator extends Validator
|
||||
/** @var null|Account $result */
|
||||
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
->first();
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
@@ -540,8 +539,7 @@ class FireflyValidator extends Validator
|
||||
/** @var null|Account $result */
|
||||
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
->first();
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
@@ -559,8 +557,7 @@ class FireflyValidator extends Validator
|
||||
|
||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
->first();
|
||||
|
||||
return null === $entry;
|
||||
}
|
||||
@@ -578,8 +575,7 @@ class FireflyValidator extends Validator
|
||||
|
||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
->first();
|
||||
|
||||
return null === $entry;
|
||||
}
|
||||
@@ -607,8 +603,7 @@ class FireflyValidator extends Validator
|
||||
->whereNull('accounts.deleted_at')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->where('account_meta.name', 'account_number')
|
||||
->where('account_meta.data', json_encode($value))
|
||||
;
|
||||
->where('account_meta.data', json_encode($value));
|
||||
|
||||
if ($accountId > 0) {
|
||||
// exclude current account from check.
|
||||
@@ -715,8 +710,7 @@ class FireflyValidator extends Validator
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('id', '!=', $existingId)
|
||||
->where('url', $url)->count()
|
||||
;
|
||||
->where('url', $url)->count();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -752,8 +746,7 @@ class FireflyValidator extends Validator
|
||||
$result = \DB::table($table)->where('user_id', auth()->user()->id)->whereNull('deleted_at')
|
||||
->where('id', '!=', $exclude)
|
||||
->where($field, $value)
|
||||
->first([$field])
|
||||
;
|
||||
->first([$field]);
|
||||
if (null === $result) {
|
||||
return true; // not found, so true.
|
||||
}
|
||||
@@ -775,8 +768,7 @@ class FireflyValidator extends Validator
|
||||
$query = \DB::table('object_groups')
|
||||
->whereNull('object_groups.deleted_at')
|
||||
->where('object_groups.user_id', auth()->user()->id)
|
||||
->where('object_groups.title', $value)
|
||||
;
|
||||
->where('object_groups.title', $value);
|
||||
if (null !== $exclude) {
|
||||
$query->where('object_groups.id', '!=', (int)$exclude);
|
||||
}
|
||||
@@ -795,8 +787,7 @@ class FireflyValidator extends Validator
|
||||
{
|
||||
$exclude = $parameters[0] ?? null;
|
||||
$query = \DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id)
|
||||
;
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id);
|
||||
if (null !== $exclude) {
|
||||
$query->where('piggy_banks.id', '!=', (int)$exclude);
|
||||
}
|
||||
@@ -829,8 +820,7 @@ class FireflyValidator extends Validator
|
||||
->where('trigger', $trigger)
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('url', $url)->count()
|
||||
;
|
||||
->where('url', $url)->count();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -113,6 +113,7 @@ return [
|
||||
'telemetry' => false,
|
||||
'webhooks' => true,
|
||||
'handle_debts' => true,
|
||||
'expression_engine' => false,
|
||||
// see cer.php for exchange rates feature flag.
|
||||
],
|
||||
'version' => 'develop/2024-03-07',
|
||||
|
Reference in New Issue
Block a user