Announcement

#1 2021-01-25 17:35:15

Zakky24
Member
2017-09-13
14

Images truncated after upgrade to 11.1

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

 

#2 2021-01-25 19:08:58

erAck
Only trying to help
2015-09-06
1368

Re: Images truncated after upgrade to 11.1

I just tried and similar; the downloaded image file contains a leading text

Code:

<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:

Code:

$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


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2021-01-26 09:12:43

Zakky24
Member
2017-09-13
14

Re: Images truncated after upgrade to 11.1

Thanks - that's worked and the images now load ok. 

However, it would still be useful to understand what is causing the error...

Offline

 

#4 2021-01-26 11:38:44

erAck
Only trying to help
2015-09-06
1368

Re: Images truncated after upgrade to 11.1

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.


Running Piwigo at https://erack.net/gallery/

Offline

 

#5 2021-01-29 06:59:48

hosh
Member
2021-01-28
9

Re: Images truncated after upgrade to 11.1

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

 

#6 2021-01-29 13:34:47

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13548

Re: Images truncated after upgrade to 11.1

@erAck what about checking the ob before cleaning it? as we do in i.php:

Code:

    if (ob_get_length () !== FALSE)
    {
      ob_clean();
    }

Offline

 

#7 2021-01-29 14:31:57

erAck
Only trying to help
2015-09-06
1368

Re: Images truncated after upgrade to 11.1

@plg:
Looks good. At least worth a try..


Running Piwigo at https://erack.net/gallery/

Offline

 

#8 2021-01-29 14:33:11

erAck
Only trying to help
2015-09-06
1368

Re: Images truncated after upgrade to 11.1

@hosh:
local/config/config.inc.php


Running Piwigo at https://erack.net/gallery/

Offline

 

#9 2021-01-29 14:53:26

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13548

Re: Images truncated after upgrade to 11.1

Offline

 

#10 2021-01-30 12:14:26

hosh
Member
2021-01-28
9

Re: Images truncated after upgrade to 11.1

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

 

#11 2021-01-30 13:34:02

erAck
Only trying to help
2015-09-06
1368

Re: Images truncated after upgrade to 11.1

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.


Running Piwigo at https://erack.net/gallery/

Offline

 

#12 2021-01-31 11:01:34

hosh
Member
2021-01-28
9

Re: Images truncated after upgrade to 11.1

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

 

#13 2021-01-31 12:41:25

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13548

Re: Images truncated after upgrade to 11.1

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

 

#14 2021-01-31 19:08:08

erAck
Only trying to help
2015-09-06
1368

Re: Images truncated after upgrade to 11.1

@plg:
Seeing 11.2.0 was released with that, did you see my comment at [Github] Piwigo commit db65aa51?


Running Piwigo at https://erack.net/gallery/

Offline

 

#15 2021-02-01 06:57:46

hosh
Member
2021-01-28
9

Re: Images truncated after upgrade to 11.1

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

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact