Description
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