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/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 74b65e7b6..8cd10fdf1 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -751,7 +751,7 @@ class Controller extends Object implements CakeEventListener { * * @param string|array $url A string or array-based URL pointing to another location within the app, * or an absolute URL - * @param int $status Optional HTTP status code (eg: 404) + * @param int|array|null $status HTTP status code (eg: 301). Defaults to 302 when null is passed. * @param bool $exit If true, exit() will be called after the redirect * @return void * @triggers Controller.beforeRedirect $this, array($url, $status, $exit) @@ -785,9 +785,10 @@ class Controller extends Object implements CakeEventListener { } } - if ($status) { - $this->response->statusCode($status); + if ($status === null) { + $status = 302; } + $this->response->statusCode($status); if ($exit) { $this->response->send(); diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 66ec1bd4c..f533e72e5 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1428,8 +1428,12 @@ class Model extends Object implements CakeEventListener { * @return string Column type */ public function getColumnType($column) { - $db = $this->getDataSource(); $cols = $this->schema(); + if (isset($cols[$column]) && isset($cols[$column]['type'])) { + return $cols[$column]['type']; + } + + $db = $this->getDataSource(); $model = null; $startQuote = isset($db->startQuote) ? $db->startQuote : null; diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 2c1c3fff5..21a516d59 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -106,7 +106,7 @@ class CakeRequest implements ArrayAccess { 'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'), 'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'), 'mobile' => array('env' => 'HTTP_USER_AGENT', 'options' => array( - 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', + 'Android', 'AvantGo', 'BB10', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' 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. * diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 839af6671..8f941b059 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -2497,4 +2497,17 @@ class ModelIntegrationTest extends BaseModelTest { $model->expects($this->never())->method('getDataSource'); $this->assertEmpty($model->schema()); } + +/** + * Tests that calling getColumnType() on a model that is not supposed to use a table + * does not trigger any calls on any datasource + * + * @return void + */ + public function testGetColumnTypeNoDB() { + $model = $this->getMock('Example', array('getDataSource')); + $model->expects($this->never())->method('getDataSource'); + $result = $model->getColumnType('filefield'); + $this->assertEquals('string', $result); + } } diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index a4ce60c91..ced7a56b3 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -5048,3 +5048,34 @@ class CustomArticle extends AppModel { } } + +/** + * Example class + * + * @package Cake.Test.Case.Model + */ +class Example extends AppModel { + +/** + * useTable property + * + * @var string + */ + public $useTable = false; + +/** + * schema property + * + * @var array + */ + protected $_schema = array( + 'filefield' => array( + 'type' => 'string', + 'length' => 254, + 'default' => null, + 'null' => true, + 'comment' => null + ), + ); + +} diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index e101505d8..cfe012813 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -297,6 +297,7 @@ class ControllerTestCaseTest extends CakeTestCase { 'Location' => 'http://cakephp.org' ); $this->assertEquals($expected, $results); + $this->assertSame(302, $Controller->response->statusCode()); } /** diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 144a0318f..1208b4401 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -91,7 +91,7 @@ class ClassRegistry { * stored in the registry and returned. * @param bool $strict if set to true it will return false if the class was not found instead * of trying to create an AppModel - * @return object instance of ClassName. + * @return $class instance of ClassName. * @throws CakeException when you try to construct an interface or abstract class. */ public static function init($class, $strict = false) { diff --git a/lib/Cake/View/ViewBlock.php b/lib/Cake/View/ViewBlock.php index 51ec8e767..2d4908a28 100644 --- a/lib/Cake/View/ViewBlock.php +++ b/lib/Cake/View/ViewBlock.php @@ -75,7 +75,7 @@ class ViewBlock { */ public function start($name) { if (in_array($name, $this->_active)) { - throw new CakeException(__("A view block with the name '%s' is already/still open.", $name)); + throw new CakeException(__d('cake', "A view block with the name '%s' is already/still open.", $name)); } $this->_active[] = $name; ob_start();