From a8ae12a700909a3b34424dfe390dbe61b8c80e63 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 25 Jan 2015 22:24:24 -0500 Subject: [PATCH] Fix warnings when php://output is used with ConsoleOutput. The php://output stream is not compatible with posix functions. Refs #4901 --- lib/Cake/Console/ConsoleOutput.php | 1 + lib/Cake/Test/Case/Console/ConsoleOutputTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index 32abf7123..4f56fb5c4 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -162,6 +162,7 @@ class ConsoleOutput { $this->_output = fopen($stream, 'w'); if ((DS === '\\' && !(bool)env('ANSICON')) || + $stream === 'php://output' || (function_exists('posix_isatty') && !posix_isatty($this->_output)) ) { $this->_outputAs = self::PLAIN; diff --git a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php index 4b26aae25..5eabefd58 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php @@ -231,6 +231,17 @@ class ConsoleOutputTest extends CakeTestCase { $this->output->write('Bad Regular', false); } +/** + * test plain output when php://output, as php://output is + * not compatible with posix_ functions. + * + * @return void + */ + public function testOutputAsPlainWhenOutputStream() { + $output = $this->getMock('ConsoleOutput', array('_write'), array('php://output')); + $this->assertEquals(ConsoleOutput::PLAIN, $output->outputAs()); + } + /** * test plain output only strips tags used for formatting. *