-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Bug Description
The action hook fluent_crm/list_updated does not return the expected List model instance. Instead, it returns an integer (affected rows count) from the update query.
File: fluent-crm/app/Http/Controllers/ListsController.php
Problematic Code
$list = Lists::where('id', $id)->update([
'title' => sanitize_text_field($allData['title']),
'slug' => $allData['slug'],
'description' => sanitize_textarea_field(Arr::get($allData, 'description')),
]);
do_action('fluent_crm/list_updated', $list);
Expected Behavior
According to documentation, the hook should pass the List model instance:
add_action('fluent_crm/list_updated', function($listModel) {
// Expecting $listModel to be a model object
});
Actual Behavior
The $list variable contains the result of the update() method (integer), not the updated List model. As a result, the hook receives 1 instead of a model instance.
Impact
This breaks expected extensibility for developers relying on this hook, as they cannot access updated list properties.
Suggested Fix
Instead of using update() directly, retrieve and update the model instance:
$list = Lists::findOrFail($id);
$list->update([
'title' => sanitize_text_field($allData['title']),
'slug' => $allData['slug'],
'description' => sanitize_textarea_field(Arr::get($allData, 'description')),
]);
do_action('fluent_crm/list_updated', $list);
Alternatively, fetch the model after update:
Lists::where('id', $id)->update([...]);
$list = Lists::find($id);
do_action('fluent_crm/list_updated', $list);
Also found same issue in fluent-crm/app/Http/Controllers/TagsController.php store() method
Problematic Code
$tag = Tag::where('id', $id)->update([
'title' => sanitize_text_field($allData['title']),
'slug' => $allData['slug'],
'description' => sanitize_textarea_field(Arr::get($allData, 'description')),
]);
do_action('fluentcrm_tag_updated', $id);
do_action('fluent_crm/tag_updated', $tag);