mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
commit
35e0dc2bbd
10 changed files with 69 additions and 7 deletions
|
@ -162,6 +162,7 @@ class ConsoleOutput {
|
||||||
$this->_output = fopen($stream, 'w');
|
$this->_output = fopen($stream, 'w');
|
||||||
|
|
||||||
if ((DS === '\\' && !(bool)env('ANSICON')) ||
|
if ((DS === '\\' && !(bool)env('ANSICON')) ||
|
||||||
|
$stream === 'php://output' ||
|
||||||
(function_exists('posix_isatty') && !posix_isatty($this->_output))
|
(function_exists('posix_isatty') && !posix_isatty($this->_output))
|
||||||
) {
|
) {
|
||||||
$this->_outputAs = self::PLAIN;
|
$this->_outputAs = self::PLAIN;
|
||||||
|
|
|
@ -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,
|
* @param string|array $url A string or array-based URL pointing to another location within the app,
|
||||||
* or an absolute URL
|
* 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
|
* @param bool $exit If true, exit() will be called after the redirect
|
||||||
* @return void
|
* @return void
|
||||||
* @triggers Controller.beforeRedirect $this, array($url, $status, $exit)
|
* @triggers Controller.beforeRedirect $this, array($url, $status, $exit)
|
||||||
|
@ -785,9 +785,10 @@ class Controller extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status) {
|
if ($status === null) {
|
||||||
$this->response->statusCode($status);
|
$status = 302;
|
||||||
}
|
}
|
||||||
|
$this->response->statusCode($status);
|
||||||
|
|
||||||
if ($exit) {
|
if ($exit) {
|
||||||
$this->response->send();
|
$this->response->send();
|
||||||
|
|
|
@ -1428,8 +1428,12 @@ class Model extends Object implements CakeEventListener {
|
||||||
* @return string Column type
|
* @return string Column type
|
||||||
*/
|
*/
|
||||||
public function getColumnType($column) {
|
public function getColumnType($column) {
|
||||||
$db = $this->getDataSource();
|
|
||||||
$cols = $this->schema();
|
$cols = $this->schema();
|
||||||
|
if (isset($cols[$column]) && isset($cols[$column]['type'])) {
|
||||||
|
return $cols[$column]['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = $this->getDataSource();
|
||||||
$model = null;
|
$model = null;
|
||||||
|
|
||||||
$startQuote = isset($db->startQuote) ? $db->startQuote : null;
|
$startQuote = isset($db->startQuote) ? $db->startQuote : null;
|
||||||
|
|
|
@ -106,7 +106,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'),
|
'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'),
|
||||||
'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'),
|
'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'),
|
||||||
'mobile' => array('env' => 'HTTP_USER_AGENT', 'options' => array(
|
'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',
|
'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource',
|
||||||
'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser',
|
'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser',
|
||||||
'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino'
|
'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino'
|
||||||
|
|
|
@ -231,6 +231,17 @@ class ConsoleOutputTest extends CakeTestCase {
|
||||||
$this->output->write('<error>Bad</error> Regular', false);
|
$this->output->write('<error>Bad</error> 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.
|
* test plain output only strips tags used for formatting.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2497,4 +2497,17 @@ class ModelIntegrationTest extends BaseModelTest {
|
||||||
$model->expects($this->never())->method('getDataSource');
|
$model->expects($this->never())->method('getDataSource');
|
||||||
$this->assertEmpty($model->schema());
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -297,6 +297,7 @@ class ControllerTestCaseTest extends CakeTestCase {
|
||||||
'Location' => 'http://cakephp.org'
|
'Location' => 'http://cakephp.org'
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, $results);
|
$this->assertEquals($expected, $results);
|
||||||
|
$this->assertSame(302, $Controller->response->statusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ClassRegistry {
|
||||||
* stored in the registry and returned.
|
* stored in the registry and returned.
|
||||||
* @param bool $strict if set to true it will return false if the class was not found instead
|
* @param bool $strict if set to true it will return false if the class was not found instead
|
||||||
* of trying to create an AppModel
|
* 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.
|
* @throws CakeException when you try to construct an interface or abstract class.
|
||||||
*/
|
*/
|
||||||
public static function init($class, $strict = false) {
|
public static function init($class, $strict = false) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ class ViewBlock {
|
||||||
*/
|
*/
|
||||||
public function start($name) {
|
public function start($name) {
|
||||||
if (in_array($name, $this->_active)) {
|
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;
|
$this->_active[] = $name;
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
Loading…
Reference in a new issue