mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #8274
This commit is contained in:
parent
135b9fc010
commit
1f7ceb6df6
@ -82,7 +82,8 @@ class ParseDateString
|
||||
|
||||
// if regex for YYYY-MM-DD:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
return $this->parseDefaultDate($date);
|
||||
}
|
||||
|
||||
@ -223,8 +224,8 @@ class ParseDateString
|
||||
|
||||
// verify if correct
|
||||
$pattern = '/[+-]\d+[wqmdy]/';
|
||||
$res = preg_match($pattern, $part);
|
||||
if (0 === $res || false === $res) {
|
||||
$result = preg_match($pattern, $part);
|
||||
if (0 === $result || false === $result) {
|
||||
app('log')->error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part));
|
||||
|
||||
continue;
|
||||
@ -246,11 +247,19 @@ class ParseDateString
|
||||
return $today;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this matches regex for xxxx-xx-DD:
|
||||
*
|
||||
* @param string $date
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isDayRange(string $date): bool
|
||||
{
|
||||
// if regex for xxxx-xx-DD:
|
||||
|
||||
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a day range.', $date));
|
||||
|
||||
return true;
|
||||
@ -276,7 +285,8 @@ class ParseDateString
|
||||
{
|
||||
// if regex for xxxx-MM-xx:
|
||||
$pattern = '/^xxxx-(0[1-9]|1[012])-xx$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a month range.', $date));
|
||||
|
||||
return true;
|
||||
@ -303,7 +313,8 @@ class ParseDateString
|
||||
{
|
||||
// if regex for YYYY-xx-xx:
|
||||
$pattern = '/^(19|20)\d\d-xx-xx$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a year range.', $date));
|
||||
|
||||
return true;
|
||||
@ -330,7 +341,8 @@ class ParseDateString
|
||||
{
|
||||
// if regex for xxxx-MM-DD:
|
||||
$pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a month/day range.', $date));
|
||||
|
||||
return true;
|
||||
@ -344,7 +356,8 @@ class ParseDateString
|
||||
{
|
||||
// if regex for YYYY-xx-DD:
|
||||
$pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a day/year range.', $date));
|
||||
|
||||
return true;
|
||||
@ -358,7 +371,8 @@ class ParseDateString
|
||||
{
|
||||
// if regex for YYYY-MM-xx:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';
|
||||
if (false !== preg_match($pattern, $date)) {
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a month/year range.', $date));
|
||||
|
||||
return true;
|
||||
|
@ -106,10 +106,7 @@ class FireflyValidator extends Validator
|
||||
{
|
||||
$regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i';
|
||||
$result = preg_match($regex, $value);
|
||||
if (false === $result) {
|
||||
return false;
|
||||
}
|
||||
if (0 === $result) {
|
||||
if (false === $result || 0 === $result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -513,8 +510,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.
|
||||
@ -621,8 +617,7 @@ class FireflyValidator extends Validator
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('id', '!=', $existingId)
|
||||
->where('url', $url)->count()
|
||||
;
|
||||
->where('url', $url)->count();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -658,8 +653,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.
|
||||
}
|
||||
@ -681,8 +675,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);
|
||||
}
|
||||
@ -701,8 +694,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);
|
||||
}
|
||||
@ -735,8 +727,7 @@ class FireflyValidator extends Validator
|
||||
->where('trigger', $trigger)
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('url', $url)->count()
|
||||
;
|
||||
->where('url', $url)->count();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -775,8 +766,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;
|
||||
}
|
||||
@ -793,8 +783,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;
|
||||
}
|
||||
@ -812,8 +801,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;
|
||||
}
|
||||
@ -831,8 +819,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user