Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.2][Bug] Error in text column in Permissions #3984

Closed
tabacitu opened this issue Dec 4, 2021 · 4 comments
Closed

[4.2][Bug] Error in text column in Permissions #3984

tabacitu opened this issue Dec 4, 2021 · 4 comments

Comments

@tabacitu
Copy link
Member

tabacitu commented Dec 4, 2021

Bug report

What I did

Opened Permissions CRUD in 4.2

What I expected to happen

Work

What happened

Not work 😅 Are you getting the same thing @promatik ?

Screenshot 2021-12-04 at 08 14 04

What I've already tried to fix it

Nothing yet - currently deep into fixing other stuff.

Backpack, Laravel, PHP, DB version

4.2

@tabacitu
Copy link
Member Author

tabacitu commented Dec 7, 2021

Ok so here's a weird one. If you dd() before (or after) that particular line... it's a string. It's definitely a string.

But it turns out the problem... is a DB entry. Backpack cannot echo out a table cell that says logs because... somehow Laravel tries to turn it into a Logger object 😱 If you rename that db entry to logsss it'll work just fine.

This is... WOW...

@promatik I'll let you take a closer look at this too. Right now I was deep into something else, and it doesn't seem like this is a quick one, as I thought.

@promatik
Copy link
Contributor

Hi @tabacitu!
I'm so glad this happened! this would be a HUGE error source, and it would be super hard for us to find what was happening, and we would certainly get negative feedback on this.

Fix is here #4005.

Basically;

is_callable('logs') // true

Because;

$value = 'logs';
$value() // the same as;
logs() // returns an instance of \Illuminate\Log\LogManager

All our columns have that new feature, to verify if value is a callable.

if(is_callable($column['value'])) {
    $column['value'] = $column['value']($entry);
}

it should become;

if($column['value'] instanceof \Closure) {
    $column['value'] = $column['value']($entry);
}

@pxpm
Copy link
Contributor

pxpm commented Dec 12, 2021

@promatik is better to check if it's a closure or check if it is a function and not string?

I ask because in other places to avoid this error we check: is_callable($var) && !is_string($var).

Not sure if your solution covers it 100%, if it does, is indeed simpler, just want to make sure.

Best,
Pedro

@promatik
Copy link
Contributor

@pxpm good point, I can't see a way for this not to work, an inline function is always an instance of \Closure, we can only send instances of \Closures right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants