@@ -119,6 +119,52 @@ class UserRepository extends Repository
119119
120120This change is also ** 100% backward compatible** - existing static arrays continue to work perfectly.
121121
122+ ## Breaking Changes
123+
124+ ### Default Search Behavior Change
125+
126+ 🚨 ** Breaking Change** : In version 10, repositories no longer search by the model's primary key (ID) by default when no searchable fields are defined.
127+
128+ ** Before (v9 and earlier):**
129+ ``` php
130+ class UserRepository extends Repository
131+ {
132+ // No $search property defined
133+ // Automatically searched by 'id' field by default
134+ }
135+ ```
136+
137+ ** After (v10):**
138+ ``` php
139+ class UserRepository extends Repository
140+ {
141+ // No $search property defined
142+ // No searchable fields available - search returns empty results
143+ }
144+ ```
145+
146+ ** To maintain the previous behavior** , add this method to your Repository parent class or individual repositories:
147+
148+ ``` php
149+ public static function searchables(): array
150+ {
151+ return empty(static::$search)
152+ ? [static::newModel()->getKeyName()]
153+ : static::$search;
154+ }
155+ ```
156+
157+ ** Why this change was made:**
158+ - ** Security** : Prevents unintended ID-based searches on sensitive repositories
159+ - ** Explicit configuration** : Forces developers to explicitly define searchable fields
160+ - ** Performance** : Avoids unnecessary database queries when search isn't intended
161+ - ** Consistency** : Aligns with the principle of explicit over implicit behavior
162+
163+ ** Migration strategy:**
164+ 1 . ** Immediate fix** : Add the ` searchables() ` method to your base Repository class to restore v9 behavior globally
165+ 2 . ** Recommended approach** : Review each repository and explicitly define ` $search ` arrays with appropriate fields
166+ 3 . ** Security review** : Consider which repositories should actually be searchable and by which fields
167+
122168### Configuration File Updates
123169
124170When upgrading to v10, it's important to ensure your local ` config/restify.php ` file includes all the new configuration options that have been added.
0 commit comments