-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[athenaeum-flysystem-db] Unable to persist binary data to MariaDB #189
Comments
Apparently the problem is this line. The latest version of this library (8.3.0) should be affected by this too. The comment reads:
Since the value of the key Before: protected function prepareContentsRecord(string $path, FileStream $stream, Config $config): array
{
// Note: path is not used here, but it is kept to allow eventual customisation / extended
// versions of this adapter!
return [
'hash' => $this->resolveContentHash($stream, $config),
// Initial reference count. This is ONLY valid when inserting a new
// record. It must be updated when existing record is updated.
'reference_count' => 1,
// Database driver should automatically deal with "resource".
// Alternatively, the resource should be converted to a string, but
// that COULD increase memory consumption a lot (depending on filesize).
'contents' => $stream
->positionToStart()
->resource()
];
} After: protected function prepareContentsRecord(string $path, FileStream $stream, Config $config): array
{
// Note: path is not used here, but it is kept to allow eventual customisation / extended
// versions of this adapter!
return [
'hash' => $this->resolveContentHash($stream, $config),
// Initial reference count. This is ONLY valid when inserting a new
// record. It must be updated when existing record is updated.
'reference_count' => 1,
// Database driver should automatically deal with "resource".
// Alternatively, the resource should be converted to a string, but
// that COULD increase memory consumption a lot (depending on filesize).
'contents' => $stream
->positionToStart()
->getContents()
];
} |
Hi @goldmont Thx for reporting this issue. I will try to take a look it as soon as possible,... but this could be a while - got lots of stuff to do this weekend (really sorry). If your work-around / hotfix works for you right now, keep it (You can eventually create a custom extended version of this In the mean time, my best guess is that either Laravel's database component or PDO is not able to handle a resource (for Maria DB), in the same way that other drivers do (see old issue / pull request for details):
But to verify this, I will have to get MariaDB running and test this myself. Also, you are using an outdated / unsupported version of Laravel & this package. Even when/if I can reproduce this issue, I cannot guarantee to release a patch for the version |
Hi, This is exactly what I did. I've extended both the adapter and the provider. FYI: |
I fear that this could be more PDO related. If so, then it will become very difficult to resolve. In any case, I will try to reproduce this defect in my current setup (latest version of Laravel, Athenaeum, PHP v8.2,...etc). |
Hi @goldmont I have attempted to reproduce this issue, but sadly without any success. Please see pull request #190 for a few details. As I previously mentioned, it can either be your PHP / PDO and or your version of Laravel that are outdated and thus causing this behaviour. If you are able to update your application's dependencies, then you should do so. Otherwise, your own work-around could be the way forward, until you do have the time/resources for upgrading your dependencies and system. I'm sorry for not being able to help you more than this. Please do feel free to open another issue, if this should arise again - using a newer version of this package, etc. |
Hi @aedart Thank you for your time. Could you tell me what PHP version are you using, your MySQL version and so on? My stack: |
Hi @goldmont I have the following installed:
|
@goldmont Could you please let me know, if I should close this issue - or keep it open? |
Hi, You can close this issue for now. Once upgraded to L11, I'll let you know here 👍🏻 Thank you |
Description
Hi,
After a few days I'm still unable to persist my binary data into a MariaDB instance using Laravel. I tried the example in the documentation page and the library seems to save everything correctly into the database except to the blob field which contains always something like
Resource id #...
. Whatever kind of data I try to save, the result is the same. Could you help me please?Version & Environment
Laravel: 9
athenaeum-flysystem-db: 6.8.1
Steps to reproduce
Storage::disk('my_disk')->put('example.txt', 'Contents');
Expected behaviour
To see the correct data (the text "Contents" in my case)
The text was updated successfully, but these errors were encountered: