From 9964cf11a401c089010849d84b19bdd423149b8d Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Sep 2020 15:20:14 +0200 Subject: [PATCH 1/8] Fix #3809 --- app/Http/Controllers/Auth/LoginController.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index fe57449a1c..3eb1e8f4e1 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -127,14 +127,6 @@ class LoginController extends Controller */ public function showLoginForm(Request $request) { - $loginProvider = config('firefly.login_provider'); - $authGuard = config('firefly.authentication_guard'); - $route = request()->route()->getName(); - if (('eloquent' !== $loginProvider || 'web' !== $authGuard) && 'logout' !== $route) { - throw new FireflyException('Using external identity provider. Cannot continue.'); - } - - Log::channel('audit')->info('Show login form (1.1).'); $count = DB::table('users')->count(); From b58cde5431d5a55bbcf94d69f80459be27500f0a Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Sep 2020 15:30:54 +0200 Subject: [PATCH 2/8] Add some debug info. --- .../Controllers/Account/IndexController.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php index 181f9fd607..79061b6a99 100644 --- a/app/Http/Controllers/Account/IndexController.php +++ b/app/Http/Controllers/Account/IndexController.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Account; use Carbon\Carbon; +use Exception; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Account; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -32,7 +33,7 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\View\View; -use Exception; +use Log; /** * @@ -41,8 +42,8 @@ use Exception; class IndexController extends Controller { use BasicDataSupport; - /** @var AccountRepositoryInterface The account repository */ - private $repository; + + private AccountRepositoryInterface $repository; /** * IndexController constructor. @@ -122,32 +123,31 @@ class IndexController extends Controller * @param Request $request * @param string $objectType * - * @throws Exception * @return Factory|View + * @throws Exception */ public function index(Request $request, string $objectType) { - // reset account order: - + Log::debug(sprintf('Now at %s', __METHOD__)); $objectType = $objectType ?? 'asset'; $subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType)); $subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType)); $types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType)); if (1 === random_int(0, 20)) { + Log::debug('Will reset order.'); $this->repository->resetAccountOrder($types); } $collection = $this->repository->getActiveAccountsByType($types); - - - $total = $collection->count(); $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; $accounts = $collection->slice(($page - 1) * $pageSize, $pageSize); $inactiveCount = $this->repository->getInactiveAccountsByType($types)->count(); + Log::debug(sprintf('Count of collection: %d, count of accounts: %d', $total, $accounts->count())); + unset($collection); /** @var Carbon $start */ $start = clone session('start', Carbon::now()->startOfMonth()); @@ -174,9 +174,14 @@ class IndexController extends Controller } ); // make paginator: + Log::debug(sprintf('Count of accounts before LAP: %d', $accounts->count())); + /** @var LengthAwarePaginator $accounts */ $accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page); $accounts->setPath(route('accounts.index', [$objectType])); + Log::debug(sprintf('Count of accounts after LAP (1): %d', $accounts->count())); + Log::debug(sprintf('Count of accounts after LAP (2): %d', $accounts->getCollection()->count())); + return view('accounts.index', compact('objectType', 'inactiveCount', 'subTitleIcon', 'subTitle', 'page', 'accounts')); } From 766abd3336ead6569e02d210f34a9b2fa178801f Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Sep 2020 15:39:03 +0200 Subject: [PATCH 3/8] Extra info for debug screen. --- app/Http/Controllers/DebugController.php | 6 ++++++ resources/views/v1/debug.twig | 1 + 2 files changed, 7 insertions(+) diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index d6055e4da2..01a64ad9e6 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -142,6 +142,10 @@ class DebugController extends Controller $bcscale = bcscale(); $layout = env('FIREFLY_III_LAYOUT'); + // expected + found DB version: + $expectedDBversion = config('firefly.db_version'); + $foundDBversion = \FireflyConfig::get('db_version',1)->data; + // some new vars. $telemetry = true === config('firefly.send_telemetry') && true === config('firefly.feature_flags.telemetry'); $defaultLanguage = (string) config('firefly.default_language'); @@ -190,6 +194,8 @@ class DebugController extends Controller compact( 'phpVersion', 'localeAttempts', + 'expectedDBversion', + 'foundDBversion', 'appEnv', 'appDebug', 'logChannel', diff --git a/resources/views/v1/debug.twig b/resources/views/v1/debug.twig index be2616835c..ab629b8f23 100644 --- a/resources/views/v1/debug.twig +++ b/resources/views/v1/debug.twig @@ -38,6 +38,7 @@ Debug information generated at {{ now }} for Firefly III version **{{ FF_VERSION | BCscale | {{ bcscale }} | | DB drivers | {{ drivers }} | | Current driver | {{ currentDriver }} | +| DB version | {{ foundDBversion }} (exp. {{ expectedDBversion}}) | | Login provider | {{ loginProvider }} | | Trusted proxies (.env) | {{ trustedProxies }} | From 2a5841c631a2968ec7c44df766bc2bb2f6ee4a24 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Sep 2020 15:39:14 +0200 Subject: [PATCH 4/8] Temp debug information. --- resources/views/v1/accounts/index.twig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/views/v1/accounts/index.twig b/resources/views/v1/accounts/index.twig index b08ae48bce..fb3767667f 100644 --- a/resources/views/v1/accounts/index.twig +++ b/resources/views/v1/accounts/index.twig @@ -5,6 +5,13 @@ {% endblock %} {% block content %} + {{ dump(accounts.count) }} + {{ dump(accounts.count()) }} + {{ dump(accounts.getCollection.count()) }} + {{ dump(accounts.getCollection().count()) }} + {{ dump(accounts) }} + + {% if accounts.count > 0 %}
From 51619713736726622d027f5433af5c0d58dec528 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Sep 2020 15:45:51 +0200 Subject: [PATCH 5/8] Different call to count() --- resources/views/v1/accounts/index.twig | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/resources/views/v1/accounts/index.twig b/resources/views/v1/accounts/index.twig index fb3767667f..dd036b55e0 100644 --- a/resources/views/v1/accounts/index.twig +++ b/resources/views/v1/accounts/index.twig @@ -5,14 +5,7 @@ {% endblock %} {% block content %} - {{ dump(accounts.count) }} - {{ dump(accounts.count()) }} - {{ dump(accounts.getCollection.count()) }} - {{ dump(accounts.getCollection().count()) }} - {{ dump(accounts) }} - - - {% if accounts.count > 0 %} + {% if accounts.count() > 0 %}
@@ -72,7 +65,7 @@
{% endif %} - {% if accounts.count == 0 and page == 1 %} + {% if accounts.count() == 0 and page == 1 %} {% include 'partials.empty' with {objectType: objectType, type: 'accounts',route: route('accounts.create', [objectType])} %} {% endif %} {% endblock %} From d05fb4472c746a32430d8915acdaa9c496399e82 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 21 Sep 2020 15:56:50 +0200 Subject: [PATCH 6/8] Fix count reference. --- resources/views/v1/accounts/delete.twig | 2 +- resources/views/v1/accounts/show.twig | 6 +++--- resources/views/v1/bills/delete.twig | 4 ++-- resources/views/v1/bills/edit.twig | 4 ++-- resources/views/v1/bills/show.twig | 4 ++-- resources/views/v1/budgets/delete.twig | 4 ++-- resources/views/v1/budgets/index.twig | 8 ++++---- resources/views/v1/budgets/show.twig | 4 ++-- resources/views/v1/categories/delete.twig | 4 ++-- resources/views/v1/categories/index.twig | 2 +- resources/views/v1/categories/show.twig | 8 ++++---- resources/views/v1/list/accounts.twig | 2 +- resources/views/v1/list/bills.twig | 2 +- resources/views/v1/list/categories.twig | 2 +- resources/views/v1/list/piggy-banks.twig | 2 +- resources/views/v1/piggy-banks/show.twig | 2 +- resources/views/v1/rules/index.twig | 6 +++--- resources/views/v1/search/search.twig | 4 ++-- resources/views/v1/tags/delete.twig | 4 ++-- resources/views/v1/tags/index.twig | 2 +- resources/views/v1/tags/show.twig | 2 +- 21 files changed, 39 insertions(+), 39 deletions(-) diff --git a/resources/views/v1/accounts/delete.twig b/resources/views/v1/accounts/delete.twig index bd366b509b..76b61ae2a3 100644 --- a/resources/views/v1/accounts/delete.twig +++ b/resources/views/v1/accounts/delete.twig @@ -33,7 +33,7 @@ {% endif %}

{% endif %} - {% if account.transactions.count > 0 and account.accountType.type == 'Asset account' %} + {% if account.transactions.count() > 0 and account.accountType.type == 'Asset account' %}

{{ trans_choice('firefly.save_transactions_by_moving', account.transactions|length ) }}

diff --git a/resources/views/v1/accounts/show.twig b/resources/views/v1/accounts/show.twig index 944083cfe8..9744a83cdf 100644 --- a/resources/views/v1/accounts/show.twig +++ b/resources/views/v1/accounts/show.twig @@ -7,7 +7,7 @@ {% block content %}
-
+

@@ -32,7 +32,7 @@

- {% if attachments.count > 0 %} + {% if attachments.count() > 0 %}
@@ -115,7 +115,7 @@
{% endif %} - {% if account.notes.count == 1 %} + {% if account.notes.count() == 1 %}
diff --git a/resources/views/v1/bills/delete.twig b/resources/views/v1/bills/delete.twig index b717d8bf37..3f3284af8e 100644 --- a/resources/views/v1/bills/delete.twig +++ b/resources/views/v1/bills/delete.twig @@ -24,8 +24,8 @@

- {% if bill.transactionjournals.count > 0 %} - {{ Lang.choice('form.bill_keep_transactions', bill.transactionjournals.count,{count: bill.transactionjournals.count}) }} + {% if bill.transactionjournals.count() > 0 %} + {{ Lang.choice('form.bill_keep_transactions', bill.transactionjournals.count(),{count: bill.transactionjournals.count()}) }} {% endif %}

diff --git a/resources/views/v1/bills/edit.twig b/resources/views/v1/bills/edit.twig index d916d702a4..f55a38dc95 100644 --- a/resources/views/v1/bills/edit.twig +++ b/resources/views/v1/bills/edit.twig @@ -17,8 +17,8 @@

{{ 'mandatoryFields'|_ }}

- {% if rules.count > 0 %} - {{ ExpandedForm.text('name',null, {helpText: trans_choice('firefly.bill_edit_rules', rules.count)}) }} + {% if rules.count() > 0 %} + {{ ExpandedForm.text('name',null, {helpText: trans_choice('firefly.bill_edit_rules', rules.count())}) }} {% else %} {{ ExpandedForm.text('name') }} {% endif %} diff --git a/resources/views/v1/bills/show.twig b/resources/views/v1/bills/show.twig index 05c2f751bb..7efc81111f 100644 --- a/resources/views/v1/bills/show.twig +++ b/resources/views/v1/bills/show.twig @@ -85,7 +85,7 @@

{{ 'bill_related_rules'|_ }}

- {% if rules.count > 0 %} + {% if rules.count() > 0 %}
    {% for rule in rules %}
  • {{ rule.title }} @@ -116,7 +116,7 @@ {% endif %} - {% if attachments.count > 0 %} + {% if attachments.count() > 0 %}

    {{ 'attachments'|_ }}

    diff --git a/resources/views/v1/budgets/delete.twig b/resources/views/v1/budgets/delete.twig index 523f8e8781..be71b1d140 100644 --- a/resources/views/v1/budgets/delete.twig +++ b/resources/views/v1/budgets/delete.twig @@ -25,8 +25,8 @@

    - {% if budget.transactionjournals.count > 0 %} - {{ Lang.choice('form.budget_keep_transactions', budget.transactionjournals.count, {count: budget.transactionjournals.count }) }} + {% if budget.transactionjournals.count() > 0 %} + {{ Lang.choice('form.budget_keep_transactions', budget.transactionjournals.count(), {count: budget.transactionjournals.count() }) }} {% endif %}

    diff --git a/resources/views/v1/budgets/index.twig b/resources/views/v1/budgets/index.twig index b296cd689e..1e0b0fa08d 100644 --- a/resources/views/v1/budgets/index.twig +++ b/resources/views/v1/budgets/index.twig @@ -197,7 +197,7 @@ {% endif %}
    {% endif %} - {% if budgets|length == 0 and inactive.count == 0 %} + {% if budgets|length == 0 and inactive.count() == 0 %} {% include 'partials.empty' with {objectType: 'default', type: 'budgets',route: route('budgets.create')} %} {# make FF ignore demo for now. #} {% set shownDemo = true %} @@ -243,7 +243,7 @@ {% endif %} {% endif %} - {% if budget.attachments.count > 0 %} + {% if budget.attachments.count() > 0 %} {% endif %} @@ -284,7 +284,7 @@ style="display:none;"> {% endfor %} {% endif %} - {% if budget.budgeted|length < currencies.count %} + {% if budget.budgeted|length < currencies.count() %} @@ -394,7 +394,7 @@
- {% if paginator.count > 0 and inactive.count > 0 %} + {% if paginator.count() > 0 and inactive.count() > 0 %}
diff --git a/resources/views/v1/budgets/show.twig b/resources/views/v1/budgets/show.twig index d4cfbdb76a..0c18acd7b1 100644 --- a/resources/views/v1/budgets/show.twig +++ b/resources/views/v1/budgets/show.twig @@ -6,7 +6,7 @@ {% block content %}
-
+

@@ -38,7 +38,7 @@ {% endif %}

- {% if attachments.count > 0 %} + {% if attachments.count() > 0 %}
diff --git a/resources/views/v1/categories/delete.twig b/resources/views/v1/categories/delete.twig index 2873573ec5..9d5c4dec09 100644 --- a/resources/views/v1/categories/delete.twig +++ b/resources/views/v1/categories/delete.twig @@ -24,8 +24,8 @@

- {% if category.transactionjournals.count > 0 %} - {{ Lang.choice('form.category_keep_transactions', category.transactionjournals.count, {count: category.transactionjournals.count }) }} + {% if category.transactionjournals.count() > 0 %} + {{ Lang.choice('form.category_keep_transactions', category.transactionjournals.count(), {count: category.transactionjournals.count() }) }} {% endif %}

diff --git a/resources/views/v1/categories/index.twig b/resources/views/v1/categories/index.twig index 4754267898..e73ec09bdf 100644 --- a/resources/views/v1/categories/index.twig +++ b/resources/views/v1/categories/index.twig @@ -5,7 +5,7 @@ {% endblock %} {% block content %} - {% if categories.count > 0 %} + {% if categories.count() > 0 %}
diff --git a/resources/views/v1/categories/show.twig b/resources/views/v1/categories/show.twig index 5865a04a12..0c519ee6c7 100644 --- a/resources/views/v1/categories/show.twig +++ b/resources/views/v1/categories/show.twig @@ -8,7 +8,7 @@
{% if Route.getCurrentRoute.getName == 'categories.show' %} {# both charts #} -
+

@@ -20,7 +20,7 @@

-
+

@@ -35,7 +35,7 @@ {% endif %} {% if Route.getCurrentRoute.getName == 'categories.show.all' %} {# all chart #} -
+

@@ -48,7 +48,7 @@

{% endif %} - {% if attachments.count > 0 %} + {% if attachments.count() > 0 %}
diff --git a/resources/views/v1/list/accounts.twig b/resources/views/v1/list/accounts.twig index eed834c4e5..02e3e21b48 100644 --- a/resources/views/v1/list/accounts.twig +++ b/resources/views/v1/list/accounts.twig @@ -36,7 +36,7 @@ {% if account.location %} {% endif %} - {% if account.attachments.count > 0 %} + {% if account.attachments.count() > 0 %} {% endif %} diff --git a/resources/views/v1/list/bills.twig b/resources/views/v1/list/bills.twig index 92fb9047df..958ba080d3 100644 --- a/resources/views/v1/list/bills.twig +++ b/resources/views/v1/list/bills.twig @@ -38,7 +38,7 @@ {% endif %} {{ entry.name }} {# count attachments #} - {% if entry.attachments.count > 0 %} + {% if entry.attachments.count() > 0 %} {% endif %} diff --git a/resources/views/v1/list/categories.twig b/resources/views/v1/list/categories.twig index de31f39fc8..115f4a131c 100644 --- a/resources/views/v1/list/categories.twig +++ b/resources/views/v1/list/categories.twig @@ -25,7 +25,7 @@ {{ category.name }} - {% if category.attachments.count > 0 %} + {% if category.attachments.count() > 0 %} {% endif %} diff --git a/resources/views/v1/list/piggy-banks.twig b/resources/views/v1/list/piggy-banks.twig index b7e010d120..12f0bc8d1f 100644 --- a/resources/views/v1/list/piggy-banks.twig +++ b/resources/views/v1/list/piggy-banks.twig @@ -41,7 +41,7 @@ {{ piggy.name }} - {% if piggy.attachments.count > 0 %} + {% if piggy.attachments.count() > 0 %} {% endif %} diff --git a/resources/views/v1/piggy-banks/show.twig b/resources/views/v1/piggy-banks/show.twig index 5dba31c53b..100e99feda 100644 --- a/resources/views/v1/piggy-banks/show.twig +++ b/resources/views/v1/piggy-banks/show.twig @@ -117,7 +117,7 @@
{% endif %} - {% if attachments.count > 0 %} + {% if attachments.count() > 0 %}
diff --git a/resources/views/v1/rules/index.twig b/resources/views/v1/rules/index.twig index 2e4bcb4072..0bb763b408 100644 --- a/resources/views/v1/rules/index.twig +++ b/resources/views/v1/rules/index.twig @@ -55,7 +55,7 @@ {{ ruleGroup.description }}

- {% if ruleGroup.rules.count > 0 %} + {% if ruleGroup.rules.count() > 0 %} @@ -120,7 +120,7 @@
{% if rule.strict %}{{ 'rule_is_strict'|_ }}{% else %}{{ 'rule_is_not_strict'|_ }}{% endif %}