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

[Bug] mb_strwidth(): Passing null to parameter #1 ($string) of type string is deprecated #4492

Closed
Polfo opened this issue Jul 4, 2022 · 4 comments
Assignees

Comments

@Polfo
Copy link

Polfo commented Jul 4, 2022

Bug report

What I did

Open a backpack view

What I expected to happen

See the rows.

What happened

"message": "mb_strwidth(): Passing null to parameter #1 ($string) of type string is deprecated (View: /home/polfo/www/lrvl/vendor/backpack/crud/src/resources/views/crud/columns/text.blade.php)",
"exception": "Facade\\Ignition\\Exceptions\\ViewException",
"file": "/home/polfo/www/lrvl/vendor/laravel/framework/src/Illuminate/Support/Str.php",
"line": 363,
"trace": [
    {
        "function": "handleError",
        "class": "Barryvdh\\Debugbar\\LaravelDebugbar",
        "type": "->"
    },
    {
        "file": "/home/polfo/www/lrvl/vendor/laravel/framework/src/Illuminate/Support/Str.php",
        "line": 363,
        "function": "mb_strwidth"
    },
    {
        "file": "/home/polfo/www/lrvl/vendor/backpack/crud/src/resources/views/crud/columns/text.blade.php",
        "line": 11,
        "function": "limit",
        "class": "Illuminate\\Support\\Str",
        "type": "::"
    },

What I've already tried to fix it

In vendor/backpack/crud/src/resources/views/crud/columns/text.blade.php:10 replace

$column['text'] = $column['prefix'].Str::limit($value , $column['limit'], '[...]').$column['suffix'];

by

$column['text'] = $column['prefix'].Str::limit($value ?? '' , $column['limit'], '[...]').$column['suffix'];

solves the issue

Is it a bug in the latest version of Backpack?

yes

Backpack, Laravel, PHP, DB version

PHP VERSION:

PHP 8.1.7 (cli) (built: Jun 25 2022 08:12:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies
with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans

LARAVEL VERSION:

v8.83.18@db8188e9cc8359a5c6706fa9d9f55aad7f235077

BACKPACK VERSION:

4.1.69@248e2e034cedcffe01732cdce01fb3d1ecad9ffa

@Polfo Polfo added the triage label Jul 4, 2022
Polfo pushed a commit to Polfo/CRUD that referenced this issue Jul 4, 2022
@pxpm
Copy link
Contributor

pxpm commented Jul 4, 2022

Hello @Polfo thanks for the report.

I guess you need to update your column html or something because it should not be possible for you to reach that error.

Have a look at:

if(!empty($column['value'])) {

And ofcourse ! empty(null) = false so you should never reach that statemente with $column['value'] = null.

Let me know if I am missing something.

Cheers

@Polfo
Copy link
Author

Polfo commented Jul 4, 2022

That is indeed not an issue for backpack 5, but I am using backpack 4.
https://github.com/Laravel-Backpack/CRUD/blob/4.1/src/resources/views/crud/columns/text.blade.php

@tabacitu
Copy link
Member

tabacitu commented Jul 11, 2022

We've decided to fix this in v4, fix all columns. Thanks @Polfo for the PR. @promatik can you please expand his PR to fix all columns?

@promatik
Copy link
Member

Moving this to #4493 👌

tabacitu added a commit that referenced this issue Jul 19, 2022
Fix `mb_strwidth()` Passing null to parameter 1 is deprecated #4492
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

4 participants