Laravel-Backpack / PermissionManager

Admin interface for managing users, roles, permissions, using Backpack CRUD
http://backpackforlaravel.com
Other
516 stars 166 forks source link

Unable to display user count in Role after backpack crud update #316

Closed kiddtang closed 1 year ago

kiddtang commented 1 year ago

Bug report

What I did:

Update "backpack/crud": "5.4.7" to "backpack/crud": "5.4.8"

What I expected to happen:

Role CRUD Page works properly.

What happened:

Open Role List page shows the error:

SQLSTATE[HY093]: Invalid parameter number
select count(*) as total_rows from (select `roles`.`id`, (select count(*) from `admins` inner join `model_has_roles` on `admins`.`id` = `model_has_roles`.`model_id` where `roles`.`id` = `model_has_roles`.`role_id` and `model_has_roles`.`model_type` = ?) as `users_count` from `roles`) as `roles_aggregator`

What I've already tried to fix it:

Downgrade to "backpack/crud": "5.4.7" OR Commented out these lines in RoleCrudController.php

$this->crud->query->withCount('users');
        $this->crud->addColumn([
            'label'     => trans('backpack::permissionmanager.users'),
            'type'      => 'text',
            'name'      => 'users_count',
            'wrapper'   => [
                'href' => function ($crud, $column, $entry, $related_key) {
                    return backpack_url('user?role='.$entry->getKey());
                },
            ],
            'suffix'    => ' '.strtolower(trans('backpack::permissionmanager.users')),
        ]);

FYI: I use withCount in other CRUD has no issue. FYI: my config/backpack/permissionmanager.php (not using default User model)

'models' => [
        'user'       =>  \App\Models\Admin::class,
        'permission' => Backpack\PermissionManager\app\Models\Permission::class,
        'role'       => Backpack\PermissionManager\app\Models\Role::class,
    ],

Backpack, Laravel, PHP, DB version:

### PHP VERSION:
PHP 8.1.12 (cli) (built: Oct 28 2022 17:39:37) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.12, Copyright (c), by Zend Technologies

### LARAVEL VERSION:
v9.42.0@0bb828f0b8d1b320cac0b71874807ea2f334ea89

### BACKPACK VERSION:
5.4.8@8eee661bbc55b6eac082388a988c686f975875e1
welcome[bot] commented 1 year ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

ocbrianh commented 1 year ago

I'm getting the same error as @kiddtang I did not update or upgrade anything. I installed everything fresh using composer to start on a new project.

Screenshot 2022-11-30 at 4 24 36 AM
pxpm commented 1 year ago

Hello @kiddtang and @ocbrianh thank you both for the report 🙏

I can confirm the bug, and submitted a PR https://github.com/Laravel-Backpack/CRUD/pull/4796 that from my tests fixes the issue.

If any of you want to try it out you can do it so by running the following command: composer require backpack/crud:"dev-re-set-query-bindings as 5.4.99"

In the meanwhile someone from the team will test it and we will permanently merge the fix if everything is working as expected.

I will be closing this so that we keep any relevant conversation about this in the PR thread.

Cheers 👍

itsnotyoutoday commented 1 year ago

I got the same bug...

https://flareapp.io/share/17Dr19Rm

kiddtang commented 1 year ago

If any of you want to try it out you can do it so by running the following command: composer require backpack/crud:"dev-re-set-query-bindings as 5.4.99"

@pxpm tested and it is working! waiting for the PR to be merged. thanks! Agree to close it and follow up in the PR #4796 thread

rolandalla commented 1 year ago

same bug for me also on a fresh install

pxpm commented 1 year ago

@tabacitu made some confusion here while merging the fix.

It will be merged tomorrow (05/12) with a new release, sorry for the inconvenience guys, and thanks for raising the issue and sticking with us to fix it! 🙏

Best wishes 🎅

kiddtang commented 1 year ago

@tabacitu @pxpm this time it really needs to be reopened.

Just solely update "backpack/crud": "5.4.7" to "backpack/crud": "5.4.10" still having the same issue.

Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading backpack/crud (5.4.7 => 5.4.10)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals

❌ Issue come back!

Trying to use the previous patch with composer require backpack/crud:"dev-re-set-query-bindings as 5.4.99"

Running composer update backpack/crud
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading backpack/crud (5.4.10 => dev-re-set-query-bindings d1cd123)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals

✔️ Issue immediately resolved!

tabacitu commented 1 year ago

@kiddtang 5.4.11 should solve it - can you please confirm?

kiddtang commented 1 year ago

@kiddtang 5.4.11 should solve it - can you please confirm?

Opps... sorry... I thought 5.4.10 was the new release yesterday. I just saw the PR was merged but I didn't check the release notes before reopening it. @tabacitu it is working now. thanks a lot!!

tabacitu commented 1 year ago

nicole-scherzinger-television-gif

Krouwel commented 1 year ago

I just updated to backpack/crud 5.5.6 and the same issue is there again. Reverted back to version 5.5.5 solved it for me.

tabacitu commented 1 year ago

Ouch! Pedro has just pushed a hot fix @Krouwel - it should be fixed in 5.5.7 again. Let us know if that's not the case please.

Thanks, cheers!

Krouwel commented 1 year ago

Yes, it is fixed in 5.5.7. Thank you for your very quick action!