Open tjslash opened 1 day ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use GitHub Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
Based on the information provided in your bug report, it appears you're experiencing an issue with the image field being set to NULL unexpectedly when updating an article's view count. This seems to be a potential bug in Backpack CRUD. Let's analyze the situation:
CRUD::addField([
'name' => 'image',
'label' => 'Image',
'type' => 'image',
'withFiles' => [
'disk' => 'public',
'path' => 'storage/images'
],
'tab' => 'Images'
]);
$article = Article::ofSlug($request->route('article'))->firstOrFail();
$article->update([
'views' => $article->views + 1
]);
The unexpected behavior you're seeing where the image is set to NULL every 16th request is not normal and could indeed be a bug.
There's a known issue in Backpack CRUD related to image fields and updates, as mentioned in this GitHub issue. The issue describes a problem with repeatable fields containing image subfields, but it's possible that your problem is related.
Additionally, there have been other image-related issues reported, such as this one which involved problems with translated image attributes.
Given that you're using the latest versions of Backpack CRUD (6.7.41) and Laravel (11.28.1.0), it's possible that this is a new bug that hasn't been reported yet.
To troubleshoot this issue:
'temporary' => true
to your image field definition, as suggested in this community forum comment.It's also worth noting that you're using Laravel Octane with RoadRunner, which could potentially introduce complexities in how the application state is managed between requests. Make sure to test if the issue persists without Octane to isolate whether it's a Backpack-specific problem or related to the Octane setup.
If you need further assistance or if the problem continues after trying these steps, I recommend reaching out to the Backpack community or creating a new GitHub issue for more targeted support.
Relevant sources:
Github Issue (open): [Bug] CRUD Repeatable field with sub field image. Use withFiles param path broken file after update model. Github Issue (open): [Bug] CRUD Repeatable field with sub field image. Use withFiles param path broken file after update model. Github Issue (closed): [4.0] Deleting the old image while replacing is missing in docs. Github Issue (closed): [Bug] Image field broken image link after upload in BP6 Github Issue (closed): [Bug] error on replacing repeatable subfield image when first saving it empty Github Issue (closed): [Bug] Image/Upload field issue with Translated attribute Github Issue (open): [Bug] CRUD Repeatable field with sub field image. Use withFiles param path broken file after update model. Github Issue (open): [Bug] CRUD Repeatable field with sub field image. Use withFiles param path broken file after update model. Github Issue (closed): [Bug] Cannot find 'image' field view in any of the regular locations. Github Issue (closed): [Bug] Image field broken image link after upload in BP6
Hi, as long as you don't inherit your FrontController from any BackPack controller or don't use any BackPack any other traits in your FrontController and Article (except CrudTrait) I doubt it is a Backpack issue.
In general fillable fields are updated by Laravel, retrieving them automatically when you update the model.
public function update(array $attributes = [], array $options = [])
{
if (! $this->exists) {
return false;
}
return $this->fill($attributes)->save($options);
}
what is really strange is that your image column on the database changes its value to NULL at a certain point. Instead of monitoring the log query, may you refresh the database values for that record at any update and see what happens? (when the image column turns to NULL)
Hello @tjslash
Can you share full Model and FrontController to replicate the issue.
Cheers.
Bug report
What I did
CRUD article controller with field:
and a FrontController file:
What I expected to happen
The count of views should be increase.
What happened
Views has been increase successful. But each 16th request: image set is NULL;
Query log:
Is it a bug in the latest version of Backpack?
Yes.
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:Octane with RoadRunner: