Files
occweb/lib/Controller/OccOutput.php
T
dillard 35e1f5df32 Fix NC35 fatal in OccOutput, verify+narrow supported version range to 32-35
testbak/ (local, non-AIO docker compat rigs for NC32/33/34/35) found a real
fatal on NC35: OccOutput::setErrorOutput() didn't declare the ": void"
return type the Symfony Console version NC35 bundles now requires on
ConsoleOutputInterface. Fixed by declaring it - compatible with older
Symfony/NC versions too since it only narrows an untyped parent signature.

32/33 were also verified functional (the previously-suspected jQuery
getter-conflict console exception on those versions is real but harmless -
the app attaches via window.jQuery, not window.$).

min-version/max-version narrowed from 30/34 to 32/35: 30/31 were never
actually tested even before this session, so keeping them was an unverified
claim; 35 is now genuinely verified rather than guessed.
2026-09-27 00:17:28 +02:00

63 lines
1.7 KiB
PHP

<?php
namespace OCA\OCCWeb\Controller;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\OutputInterface;
class OccOutput extends BufferedOutput implements ConsoleOutputInterface
{
private $consoleSectionOutputs = [];
private $stream;
public function getErrorOutput(): OutputInterface
{
return $this;
}
// NC35 bundles a Symfony Console version whose ConsoleOutputInterface
// declares this method `: void` - PHP 8 fatals ("Declaration must be
// compatible") without a matching return type here. Declaring `: void`
// is a valid narrowing of the untyped signature older Symfony/NC
// versions have, so this stays compatible with NC30-34 too.
public function setErrorOutput(OutputInterface $error): void
{
}
public function section(): ConsoleSectionOutput
{
if ($this->stream === null) {
$this->stream = fopen('php://temp', 'w+');
}
return new ConsoleSectionOutput(
$this->stream,
$this->consoleSectionOutputs,
$this->getVerbosity(),
$this->isDecorated(),
$this->getFormatter()
);
}
public function fetch(): string
{
// Get the main buffer
$content = parent::fetch();
// If there's a stream from sections, read that too
if ($this->stream !== null) {
rewind($this->stream);
$streamContent = stream_get_contents($this->stream);
if ($streamContent !== false) {
$content .= $streamContent;
}
// Clear the stream for the next call
ftruncate($this->stream, 0);
rewind($this->stream);
}
return $content;
}
}