Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Error when viewing bills with attachments

Tan Han Wen, Jackson   ( User )

Commented 4 years ago

OMG! You're an angel, Billy! Thanks alot!!!! This issue has been bugging me for months! Thank you again!

Tepui Cloud   ( User )

Commented 4 years ago

Genius!! Thanks Billy. Your solution works. Will you carry this into baseline code?

Billy Bouman   ( User )

Commented 4 years ago

https://github.com/plank/laravel-mediable/releases/tag/4.2.3

The maintainer of the composer dependency that caused this error just merged the pull request. This means that the package now contains the fix. It got released in version 4.2.3 and the composer.json file of Akaunting contains following line: plank/laravel-mediable": "4.2.*

The asterisk is a wildcard. And part of semantic versioning. It means that it will try to resolve the highest version within 4.2. Which includes 4.2.3. So, long story short, all you need to do now is run a composer update. But we are not the ones to do this. Because the composer.lock file contains the specific versions that belong to a software project, and right now it references version 4.2.2 as seen on https://github.com/akaunting/akaunting/blob/ad51d61baa003b323369517054be29eb35611e1b/composer.lock#L5429

So, long story short. I'll raise an issue on the Akaunting project on github to make sure this library gets updated on their side. A new version of Akaunting will be released. I'll keep you informed.

Billy Bouman   ( User )

Commented 4 years ago

Hi all,

Bug is fixed in version 2.0.14.

Tepui Cloud   ( User )

Commented 4 years ago

Awesome!! Thank you.

Luc Daigle   ( User )

Commented 1 year ago

I'm running into this error on version 3.0.14 after manually copying over the source files from GitHub because the automatic update failed. I verified that the code you mentioned earlier is in the Media.php file, but I'm still seeing the error references at the top of this thread.

Is there maybe something in the database that didn't get updated (because the automatic update failed) that I now need to tweak to make this work?

Thanks!

Scott Carson   ( User )

Commented 1 year ago

Hi all,

I echo Luc's comments. Whenever I try to view a bill (and some transactions), I get this error:

Plank\Mediable\Helpers\File::readableSize(): Argument #1 ($bytes) must be of type int, string given, called in public_html/akaunting3/vendor/plank/laravel-mediable/src/Media.php on line 308 (View: public_html/akaunting3/resources/views/components/media/file.blade.php) (View: public_html/akaunting3/resources/views/components/media/file.blade.php) (View: public_html/akaunting3/resources/views/components/media/file.blade.php) (View: public_html/akaunting3/resources/views/components/media/file.blade.php)

I was lost, so I asked ChatGPT :-P

It took me on a long path but none of its suggestions worked. Of note:
- It seems to suggest there is something wrong with anything that has a file attachement (which all of my bills and some of my transactions so!).
- It asked me to confirm the database table "media" had the column size set to int (which it did)
- It got me to check PHP version (I was 5.6(?!) but switched to 8.1) ... problem still persists.
- It kept mentioning a problem with $this->size but, as Billy noted, that was already fixed.
- It then references the $bytes variable, but in the ../Helpers/File.php file, $bytes is explicitly set to an int.
- It asked me to clear artisan cache using php artisan cache:clear but I got the error:

In UrlGenerator.php line 121:

Illuminate\Routing\UrlGenerator::__construct(): Argument #2 ($request) must be of type Illuminate\Http\Request, null given, called in /home/stormat/public_html/akaunting3/vendor/laravel/framework/src/Illuminate/Routing/RoutingSe
rviceProvider.php on line 67

It seems that there is a ripple effect going on, so I'm going to stop there. I spent about 4 hours trying to trace this but I can't find anything more. Hopefully this will be a start to the solution.

Scott Carson   ( User )

Commented 1 year ago

Update. My team has tracked the error down to this file, where we commented out the file size output:

/public_html/akaunting3/resources/views/components/media/file.blade.php

Specifically, change this:

               
                    {{ $file->readableSize() }}
               

... to this:

               
                    {{-- $file->readableSize() --}}
               

Obviously not an upgrade-proof solution, but basically we just commented it out as there seems to be a dependency missing or something when reading file size of PDFs.

Can anybody tell me what additional PHP extensions are required?

Scott Carson   ( User )

Commented 1 year ago

Update: After upgrading to 3.0.15, the problem persists. I wonder if this thread has gone stale since it was deemed fixed in 2.x? I'll start a new thread to be sure (developers, feel free to delete the new thread, "ReadableSize Error When Viewing Bills with Attachments"

Muhammad Hmd   ( User )

Commented 1 year ago

Hi, I faced the same problem too, I have solved this by editing one line but I don't know if this's the proper way to solve it, anyway I'm ok with that till we get new update.

in the line 308 in the file "vendor/plank/laravel-mediable/src/Media.php"
I changed this:
return File::readableSize($this->size, $precision);
to this:
return File::readableSize(intval($this->size), $precision);

the problem I think because the size has been read as string and it should be as int so I converted it by intval function

Please login or register to leave a response.

Showing 11 to 20 of 21 discussions