Hi,
Since upgrading to version 11.1 anytime a user downloads an image they get an error when opening the image;
In Photoshop the error is "This document may be damaged (the file may be truncated or incomplete)" - if you continue then the image loads ok.
In Paint the error is "This is not a valid bitmap file, or its format is not currently supported"
The images haven't changed, and they worked perfectly before the upgrade.
Any ideas?
Kind Regards,
John
Offline
I just tried and similar; the downloaded image file contains a leading text
<br /> <b>Notice</b>: ob_clean(): failed to delete buffer. No buffer to delete in <b>/.../piwigo/action.php</b> on line <b>224</b><br />
That can be circumvented by excluding PHP Notice messages in the local config like this:
$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED & ~E_NOTICE;
However, the ob_clean() call in this case does the opposite of what it was intended for.. commented as
// Without clean and flush there may be some image download problems, or image can be corrupted after download
Offline
Thanks - that's worked and the images now load ok.
However, it would still be useful to understand what is causing the error...
Offline
It is a Notice message, not a real error, and notice messages in a production environment are safe to suppress.
However...
@plg:
There doesn't seem to be a corresponding ob_start(..., ..., PHP_OUTPUT_HANDLER_CLEANABLE) call that would had created a cleanable output buffer for this ob_clean() call, which seems to be the underlying cause.
Offline
Thanks, erAck.
So you are saying that a workaround is to add the line that excludes the PHP notice to a configuration file.
In piwigo's directory local/config there are 3 files: index.php, database.inc.php and config-inc.php. To which of these files should we add the line, please?
Offline
@erAck what about checking the ob before cleaning it? as we do in i.php:
if (ob_get_length () !== FALSE) { ob_clean(); }
Offline
@plg:
Looks good. At least worth a try..
Offline
@hosh:
local/config/config.inc.php
Offline
Offline
Thanks all. Andy Dunkel's solution in [Github] Piwigo issue #1297 seems to have worked for me.
(changed lines from 224 in action.php)
//ob_clean();
if (ob_get_contents()) ob_end_clean();
flush();
@readfile($file);
Offline
That is a less preferable way though because ob_end_clean() also destroys the current buffer and turns off existing buffering, which may be unexpected (I don't know the scenario when that buffer actually was active causing harm); furthermore, ob_get_contents() obtains the contents just to throw them away. A better way using ob_clean() probably is mentioned above in this topic thread and used in the recent [Github] Piwigo commit db65aa51 but the flush() position is still odd, I commented there.
Offline
Okay. Will the configuration files get overwritten in the next upgrade, because if so, I'm assuming the preferred solution will be included there... ?
Offline
hosh wrote:
Okay. Will the configuration files get overwritten in the next upgrade, because if so, I'm assuming the preferred solution will be included there... ?
local/config/config.inc.php is never included in Piwigo downloadable installs or updates. You can safely rely on it never be overwritten (that's the whole point compared to include/config_default.inc.php)
Offline
@plg:
Seeing 11.2.0 was released with that, did you see my comment at [Github] Piwigo commit db65aa51?
Offline
thanks again @plg an @erAck
I was only worried about the change I'd made to action.php might not be overwritten, in the case that this turned out not to be the final solution. Anyway, now I see that 11.2.0 over-writ the file, and the downloads are working fine; I'll now leave the discussion, since that's all I understand.
Offline