Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
641 stars 105 forks source link

"warning" if $element in strlen($element) have null value #209

Closed trisnolase closed 6 months ago

trisnolase commented 1 year ago

I have some data with 4 column. For example id, name, phone, address. This data can be filtered by name or phone with form method get and query sql "like".

First time opened the page there no "warning" log shown. If I try to filter with name and phone it good as should be. Maybe the url have some text like this

employee?name=jhon&phone=7878

But if form filter/search just input name without phone, of course I just remember the name for example. addres bar show like this

employee?name=jhon&phone=

There some input will passing null data from submitting form and show warning on log. Warning have reference on line 251 in file SortableLink.php

This is the code

_return isarray($element) ? $element : strlen($element);

strlen($element) can't count null data if some of filter pass null data.

how about if use this code instead ?

_return isarray($element) ? $element : strlen($element ?? '');

so if $element catch null parameter it will go to next value "empy string" and it can allowed in php function strlen() without warning.

or maybe there another way to solve this "warning" condition ?