joomla / joomla-framework

[READ-ONLY] This repo is no longer in active development. Please see https://github.com/joomla-framework for the individual Framework packages.
http://framework.joomla.org
GNU General Public License v2.0
189 stars 140 forks source link

Missing processor in Joomla\Application\Cli\Output\Stdout #354

Closed ghost closed 10 years ago

ghost commented 10 years ago

Since Joomla\Application\Cli\Output\Stdout does not require a processor while constructing, we need to make sure that there is a processor if we do something like:

// Stdout.php line 32
fwrite(STDOUT, $this->processor->process($text) . ($nl ? "\n" : null));

especially if we create an unusable output object in Joomla\Application\AbstractCliApplication

// AbstractCliApplication.php line 62
$this->output = ($output instanceof CliOutput) ? $output : new Cli\Output\Stdout;

Today, every use of Joomla\Application\AbstractCliApplication without injecting an output object will bring a fatal error.

piotr-cz commented 10 years ago

The exact error is:

PHP Fatal error:  Call to a member function process() on a non-object in ...\vendor\joomla\application\src\Cli\Output\Stdout.php on line 32

Workaround is to set processor in your application, after __construct and before you try to output anything:

public function execute()
{
    // Set the output processor
    $this->output->setProcessor(new \Joomla\Application\Cli\Output\Processor\ColorProcessor);
}

I would check for processor in the Stdout->out method and if there's null, instantiate new ColorProcessor. Or update the docs.

BTW: Why the Issues in Application repo are disabled?

mbabker commented 10 years ago

https://github.com/joomla-framework/application/pull/2 should fix this issue.