I could reproduce the headers sent problem. But instead of rolling back I suggest to move only the
foreach ($http_headers as $header)
loop before the
if (ob_get_length() !== FALSE)
but keep the ob_flush()/flush() change. With that, the problem is gone for me.
Though I have no idea how headers could had been sent before the foreach sending headers was executed..
Edit: I created PR
https://github.com/Piwigo/Piwigo/pull/1749
Edit2: that
https://www.php.net/manual/en/function.header.php sheds some light:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called.
PHP is such a crap..