Skip to content

Recurrent warning in Snipe-IT logs due to null values in QueryCollector.php #1775

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

Open
Mathias-DS opened this issue Apr 8, 2025 · 0 comments

Comments

@Mathias-DS
Copy link
Contributor

This is a fix for grokability/snipe-it#16476 where a null value makes laravel-debug bar fill the log with warnings.

While running Snipe-IT on PHP 8.2.12, I encountered the following Laravel Debugbar warning:

LOG.warning: strpos(): Passing null to parameter grokability/snipe-it#1 ($haystack) of type string is deprecated in snipe-it\vendor\barryvdh\laravel-debugbar\src\DataCollector\QueryCollector.php on line 381

This issue occurs because PHP 8.1 and later deprecated passing null values to strpos(). If either $class or $filename is null, strpos() throws a warning.

To fix this temporarily, I modified the code as follows:
Original Code (QueryCollector.php Line 381):

if (strpos($class, $filename) !== false) {


Fixed Version (Ensuring Null Safety):

if (!is_null($class) && !is_null($filename) && strpos($class, $filename) !== false) {

After applying this fix, Debugbar continued working without errors.

Suggested Fix:
In future updates, adding NULL checks before using strpos() will help ensure compatibility with PHP 8.1+.

System Details:
📌 Snipe-IT Version: v8.0.4 build 17196 (gc29bdbdac)
📌 PHP Version: 8.2.12
📌 Environment: Windows 11 / XAMPP

Mathias-DS added a commit to Mathias-DS/laravel-debugbar that referenced this issue Apr 8, 2025
Test for null value in strpos in QueryCollector.php to solve laravel-debugbar issue barryvdh#1775 and snipe-it issue 16476.
barryvdh pushed a commit that referenced this issue Apr 8, 2025
Test for null value in strpos in QueryCollector.php to solve laravel-debugbar issue #1775 and snipe-it issue 16476.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant