JustCarmen / webtrees-fancy-imagebar

Fancy Imagebar module for webtrees
http://justcarmen.nl
GNU General Public License v3.0
12 stars 6 forks source link

Error - Division by zero #50

Closed melizaa closed 3 years ago

melizaa commented 4 years ago

In my test system I show very few media objects to site visitors. When I am not signed-in I see

Division by zero …/modules_v4/jc-fancy-imagebar/FancyImagebarModule.php:487

0 …/modules_v4/jc-fancy-imagebar/FancyImagebarModule.php(487): Fisharebest\Webtrees\Webtrees::Fisharebest\Webtrees{closure}(2, 'Division by zer...', '/home/amitys/fu...', 487, Array)

1 …/modules_v4/jc-fancy-imagebar/FancyImagebarModule.php(336): JustCarmen\Webtrees\Module\FancyImagebarModule->fancyThumb('../webtrees-dat...', '80', '0')

2 …/modules_v4/jc-fancy-imagebar/FancyImagebarModule.php(215): JustCarmen\Webtrees\Module\FancyImagebarModule->fancyImagebar()

etc.

https://www.amitys.com/future/index.php?route=%2Ffuture%2Ftree%2FGedcomFuture.ged

JustCarmen commented 4 years ago

This error is caused by a wrong image I think. It has probably nothing to do with being logged off or not. Only because there are fewer images when you are logged out, the error message appears sooner. The images appear in randomly order. When refreshing the page one or more times the message disappears and after a few refreshes the message return. So every time the wrong image is picked up the error message appears.

The point in the code where it goes wrong is at the moment when the height of the original image is retrieved. It returns zero, which is not possible under normal circumstances, because there has been checked already if the file is an image with a build in webtrees function and it is. But I now see, the build in webtrees function returns true when the image is a jpeg, png or gif file, while the further code only processes jpeg and png files. Could that be the case? Is there a gif file involved?

melizaa commented 4 years ago

I have 8 gif files that I see on the test system's wt individual page, in the media list and in the control panel - manage media.

How can I adjust the code and print in testing the file name of the media record that causes $source_height to be zero?

melizaa commented 4 years ago

I changed the media type that I show to Photo and I made sure that none of the .gif files of the GEDCOM file that I look at are defined as Photo.

The GEDCOM is configured with "Show the family tree" and "Show private relationships" as Show to visitors. All the rest is defined as Show to members or Show to managers.

Two individuals are defined as "Show to visitors" on their individual page.

I see still the error when I am not signed-in.

JustCarmen commented 4 years ago

Does this help? https://github.com/JustCarmen/webtrees-fancy-imagebar/commit/a3d48d551190a93e9a06547476916d7ca557c1c6

melizaa commented 4 years ago

It does not help.

I updated the configuration and changed the Media Folder from media to media/pictures and since then I do not see the error.

JustCarmen commented 3 years ago

Since you haven't seen the error recently (as far as I know) and I still can not reproduce it I will close this issue. You may reopen it whenever you reencounter the problem.

melizaa commented 3 years ago

I continue to see the error every now and again when I am signed-in to my future and test test systems. I have edited a lot of media files and I do not see the error often. It would be great, if we would get an error message that would tell us which media object causes the problem.