fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
454 stars 298 forks source link

Admin Media Error #509

Closed makitso closed 9 years ago

makitso commented 9 years ago

When in the Admin interface and I select media I get this:

DataTables warning: table id=media-table-d2d799cc98bc16acdfc942ad76404cae - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

makitso commented 9 years ago

Sorry, looks like the GencomRecord update fixed it.

khatri22nukh commented 4 years ago

Got the same how to fix

fisharebest commented 4 years ago

@khatri22nukh - there will be an error message in one of the AJAX server responses. You'll need to use the developer tools in your browser (e.g. CTRL-SHIFT-I in chrome/firefox or F12 in IE). If you don't know what this means, search the forum. It has been covered many times.

f00b4r0 commented 4 years ago

Same error after adding a jpg that doesn't display as an attached media. Trying to debug (Safari 13.1) but the instructions here are quite unhelpful webtrees 1.7.17, PHP 7.0.33-0+deb9u7 If I manually remove (on the server) the offending file, the website loads normally. Here's the output of file: image.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1080x1440, frames 3

fisharebest commented 4 years ago

The instructions at https://webtrees.net/faq/xhr/ are more helpful that the ones at datatables.net

f00b4r0 commented 4 years ago

@fisharebest this seems to be caused by specific images (I have two that triggered the issue, which I received over SMS). I can send one if you want to try to reproduce the issue. Adding these files either via the web interface, or adding them on the server and then trying to point webtrees at them will completely lock the current task.

fisharebest commented 4 years ago

I can send one if you want to try to reproduce the issue.

Sure - if you think it will help. But I have a huge backlog of email right now...

Did you look at the XHR responses to see if they contained error messages?

f00b4r0 commented 4 years ago

I'll send the image to your email listed on GH.

The XHR response seems mostly empty. The network says 304 bytes have been exchanged, and here's the output

Initiateur: 
jquery.min.js:4:15859

Demande
GET /admin_media.php HTTP/1.1
Cookie: WT_SESSION=veod9f4j1tjlt467bvf1hsv320; allPartners=true
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: fr-fr
Host: genealogy.slashdirt.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
Referer: http://genealogy.slashdirt.org/admin_media.php
Accept-Encoding: gzip, deflate
Connection: keep-alive
X-Requested-With: XMLHttpRequest

Réponse
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Pragma: no-cache
Content-Language: fr
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Date: Mon, 25 May 2020 20:59:33 GMT
Keep-Alive: timeout=5, max=95
Content-Length: 0
Connection: Keep-Alive
Server: Apache/2.4.25 (Debian)

Paramètres de chaîne de requête
action: load_json
files: local
media_folder: media/
media_path
subfolders: include
draw: 1
columns[0][data]: 0
columns[0][name]
columns[0][searchable]: true
columns[0][orderable]: true
columns[0][search][value]
columns[0][search][regex]: false
columns[1][data]: 1
columns[1][name]
columns[1][searchable]: true
columns[1][orderable]: false
columns[1][search][value]
columns[1][search][regex]: false
columns[2][data]: 2
columns[2][name]
columns[2][searchable]: true
columns[2][orderable]: true
columns[2][search][value]
columns[2][search][regex]: false
order[0][column]: 0
order[0][dir]: asc
start: 0
length: 10
search[value]
search[regex]: false
_: 1590440373748

HTH

f00b4r0 commented 4 years ago

@fisharebest image sent (as a gzip, to avoid mail client mucking with it. Hope it won't end up in SPAM)

f00b4r0 commented 4 years ago

@fisharebest A couple more datapoints: uploading the file via the administration panel works. Listing the file among the unused files works. As soon as the file is linked to an individual in the tree, the bug reappears and the list of Media files for that linked individual shows a broken result as well:

image

I tried exporting that image to a new jpeg, converting EXIF from BE to LE, removing metadata entirely to no avail.

In case this matters: both images I have that trigger this bug have been sent to me via MMS by a Samsung smartphone user.

HTH

fisharebest commented 4 years ago

@f00b4r0 - The image loads fine on my site. The thumbnail was created OK.

I see from your screenshot that you are using webtrees 1.7. (I didn't spot that earlier).

Things tend to be much more obvious when you can see them, rather than have them described to you...

The logic in 1.7 is totally different. Thumbnails are created at the same time that we create a URL to them. (In 2.0, we create the thumbnail later, in the HTTP request that fetches the image).

The truncated page indicates a fatal error generating the thumbnail.

There may be an error message embedded in the HTML. If not, then there may be one if you enable "display_errors" in your PHP.INI

Are you able to upgrade to webtrees 2.0?

f00b4r0 commented 4 years ago

@fisharebest thanks for the feedback. I did mention here that I was using 1.7 :)

I'm not super keen on upgrading to 2.0, at least not immediately. But regardless, if there's a bug in 1.7 maybe it should be fixed.

I turned on display_errors, nothing shows.

Interestingly, I tried adding the offending image to my own user (id I1 in my tree): it completely breaks rendering. Not only is the Media not displayed, the whole user disappears:

No error is shown but the source shows rendering stops midway:

    </header>
    <main id="content">
        <div id="main">
            <div id="indi_left">
                <div id="indi_header">
                    <div id="indi_mainimage">
    </main>
    <footer>
f00b4r0 commented 4 years ago

I also do notice that no thumbnail seems to be generated in data/media/thumbs. There's no error message in apache logs either.

fisharebest commented 4 years ago

No error is shown but the source shows rendering stops midway:

Have you disabled the display of error messages in your PHP.INI?

You want display_errors=on

f00b4r0 commented 4 years ago

I think you missed the part where I said:

I turned on display_errors, nothing shows.

:)

fisharebest commented 4 years ago

But regardless, if there's a bug in 1.7 maybe it should be fixed.

1.7.9 was released in 2016. Since then, it only receives fixes for security and data-integrity issues.

It is very old software. I don't have a test/development platform for it.

No error is shown but the source shows rendering stops midway:

It stops when generating a thumbnail image. This points to a server-configuration issue. Missing/broken library. Insufficient resources. etc. Known reasons for the inability to create thumbnails are on the FAQ.

f00b4r0 commented 4 years ago

Why are you telling me about 1.7.9? This is a bug in 1.7.17 which was released 2 weeks ago: I assume it's still supported?

I can't upgrade to 2.0: my distribution only provides php-7.0.

Following the FAQ, I noticed that php-imagick was missing, so I installed it and restarted apache, but the bug still persist (as soon as it's associated to an individual, hell breaks loose).

The server has ample resources (8GB RAM, 4 CPUs sitting idle and many gigabytes of free SSD): I doubt it's the problem.

No error message of any kind seems like suboptimal failure mode TBH...

Finally, I noticed that if I manually add a thumbnail with a matching name to data/media/thumbs/ the bug disappear. Yet the write permissions are correct for that folder. In fact, simply touching an empty thumb file suffices to solve the problem.

Is there anything I can do to help fix this?

fisharebest commented 4 years ago

No error message of any kind seems like suboptimal failure mode TBH...

You are absolutely right!

That is why the 2.0 includes completely new and improved error handling!

But error handling is largely dependent on the version of PHP. Newer versions will report errors where older versions will just die.

Following the FAQ, I noticed that php-imagick was missing

The FAQ is for webtrees 2.0. webtrees 1.7 doesn't use imagemagick

In fact, simply touching an empty thumb file suffices to solve the problem.

The problem is that webtrees cannot generate the thumbnail. If you manually create it - then it doesn't need to do so.

Is there anything I can do to help fix this?

The code is here. Add some debug to find which line causes the problem?

https://github.com/fisharebest/webtrees/blob/1.7/app/Media.php#L191-L251

f00b4r0 commented 4 years ago

Following the FAQ, I noticed that php-imagick was missing

The FAQ is for webtrees 2.0. webtrees 1.7 doesn't use imagemagick

UGH. This is a key data point and IMHO one you really should make a lot more obvious on the website. I installed php-gd: problem solved 😛

f00b4r0 commented 4 years ago

One last bit: removing a media file from the media manager doesn't actually remove the file on the filesystem. Not sure this is intended (nor a good idea). HTH

fisharebest commented 4 years ago

FWIW, webtrees 2.0 would have displayed a message in the control panel (and during installation) to let you know this.