andig / videodb

The videoDB media collection software
65 stars 42 forks source link

save httpclient error exception returned from getting actor images #169

Closed copperhead57 closed 1 year ago

copperhead57 commented 1 year ago

to test changing $actorid = req_string('actorid'); to $actorid = req_int('actorid'); n image.php will create the error.

johanneskonst commented 1 year ago

Hmmm. To me this looks like debug code for a specific problem, not something you'd want to add to a production environment. And i (think i) cannot fully grasp the reasoning behind this. There's the httpclientlog config setting that should enable some logging, and setting debug will also output some information, is that the info you are looking for? Because i was planning on removing that bit (lines 168-177 in httpclient.php) and maybe put something better in place (just one debug flag, all debug info into one logfile, maybe separate files for queries done and requests made, etc)..

copperhead57 commented 1 year ago

@johanneskonst i am so sorry, i have been inconcise on where the exception is being throw. it is inside the guzzle suite and does not return control back to httpclient. CurlMultiHandler - public function __destruct() to core/functions - function exception_handler to functions - function errorpage

You are totally correct that this should only be active in debug mode. i am happy to add a check if debug is active to capture the info, change to write to debug.log etc.

johanneskonst commented 1 year ago

No worries... There is basic exception handling in videoDB currently, if it fails that way, it usually fails hard indeed... The CurlMultiHandler::__destruct only contains the curl_multi_close function, cannot find any info why that would throw an exception btw... Do you have more info on the exception itself?

copperhead57 commented 1 year ago

trying to debug guzzle is a very arduous task and every time i look gain a small insight (thus this story changes).

so guzzle is trying to retrieve the image with an incorrect url and is getting a 404 not found error (client error). it then formats an error message for videodb to display by throwing an exception and then dieing via The CurlMultiHandler::__destruct. now control is returned to videodb exceptionhandler then to errorpage for display. As videodb has already displayed some data, the error page is not able to display the echo commands in function errorpage.

I believe that this will occur for any error guzzle encounters (not just 404) when trying to retrieve actor images. 404 is just easy to cause by changing the $actorid to int.

this is my best understanding to now.

I have changed the code to use debug log and only run in debug mode.

johanneskonst commented 1 year ago

I ran into the no-actor-thumbnails problem as well, but to my understanding it was caused by output generated by img.php because of the debug=1 setting. If i try to recreate the problem with debug=0 it doesn't happen/goes away. Can you confirm this is also the case with your installation?

If it's OK with you I would like to remove all debugging output made towards the browser, remove the httpclientlog setting and move it all to only error.log and/or specific folder with requests made. I'll open an issue for that and tag you there...