Skip to content

Commit 42bba7c

Browse files
authored
Merge pull request #24 from RobTrehy/20-passing-null-to-parameter-1-is-deprecated
Version 4.1.1 - Patch for null
2 parents 0c5f9d3 + 08f1aa3 commit 42bba7c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `robtrehy/laravel-user-preferences` will be documented in this file.
44

5+
## 4.1.1 - 2025-11-09
6+
- Fix: Avoid deprecation warning in PHP 8.1+ when preferences column is null (#20)
7+
58
## 4.1.0 - 2025-11-09
69
- Added methods for working with preferences for any user instance or ID:
710
- `getForUser()`

src/UserPreferences.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function () use ($userId) {
7878
if ($data->isEmpty()) {
7979
self::$preferencesCache[$userId] = (object) config('user-preferences.defaults');
8080
} else {
81-
$preferences = json_decode($data[0]->{config('user-preferences.database.column')});
81+
$preferences = json_decode($data[0]->{config('user-preferences.database.column')} ?? '{}');
8282
if (json_last_error() !== JSON_ERROR_NONE) {
8383
self::$preferencesCache[$userId] = (object) config('user-preferences.defaults');
8484
} else {

0 commit comments

Comments
 (0)