From 9f583097f05fb78ef5958b98a0ef326b3ba3128f Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 19 Jan 2011 15:10:53 -0500 Subject: [PATCH 01/17] Updating version numbers for 1.3.7 --- cake/VERSION.txt | 6 +----- cake/config/config.php | 2 +- cake/libs/view/pages/home.ctp | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cake/VERSION.txt b/cake/VERSION.txt index e5c64475c..3be949da9 100644 --- a/cake/VERSION.txt +++ b/cake/VERSION.txt @@ -18,8 +18,4 @@ // @license MIT License (http://www.opensource.org/licenses/mit-license.php) // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -1.3.6 - - - - +1.3.7 \ No newline at end of file diff --git a/cake/config/config.php b/cake/config/config.php index 09c4eec5b..c1b41fabe 100644 --- a/cake/config/config.php +++ b/cake/config/config.php @@ -17,4 +17,4 @@ * @since CakePHP(tm) v 1.1.11.4062 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -return $config['Cake.version'] = '1.3.6'; +return $config['Cake.version'] = '1.3.7'; diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index e2cc74cee..158fc0e62 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -21,7 +21,7 @@ if (Configure::read() == 0): endif; ?>

- + 0): Debugger::checkSecurityKeys(); From ed7f8d1906fac3cd35ba73b0b01950c743af7bff Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 13:31:33 -0500 Subject: [PATCH 02/17] Fixing issue where DboPostgres used the wrong type for boolean columns with a default of false or true. Added a test case. Changing Model::create() so it doesn't wipe out default values === false. Fixes #1460 --- .../model/datasources/dbo/dbo_postgres.php | 3 ++ cake/libs/model/model.php | 4 +- .../datasources/dbo/dbo_postgres.test.php | 45 ++++++++++--------- cake/tests/fixtures/datatype_fixture.php | 3 +- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index ed32e7444..9d1558e33 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -265,6 +265,9 @@ class DboPostgres extends DboSource { $this->_sequenceMap[$table][$c['name']] = $seq[1]; } } + if ($fields[$c['name']]['type'] == 'boolean' && !empty($fields[$c['name']]['default'])) { + $fields[$c['name']]['default'] = constant($fields[$c['name']]['default']); + } } } $this->__cacheDescription($table, $fields); diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 190a3660c..8906676fd 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1086,11 +1086,11 @@ class Model extends Overloadable { if ($data !== null && $data !== false) { foreach ($this->schema() as $field => $properties) { - if ($this->primaryKey !== $field && isset($properties['default'])) { + if ($this->primaryKey !== $field && isset($properties['default']) && $properties['default'] !== '') { $defaults[$field] = $properties['default']; } } - $this->set(Set::filter($defaults)); + $this->set($defaults); $this->set($data); } if ($filterKey) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 33ed58df5..d9c6d023c 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -220,6 +220,7 @@ class DboPostgresTest extends CakeTestCase { */ var $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article', 'core.tag', 'core.articles_tag', 'core.attachment', 'core.person', 'core.post', 'core.author', + 'core.datatype', ); /** * Actual DB connection used in testing @@ -437,6 +438,17 @@ class DboPostgresTest extends CakeTestCase { $this->assertFalse($this->db2->boolean('')); } +/** + * test that default -> false in schemas works correctly. + * + * @return void + */ + function testBooleanDefaultFalseInSchema() { + $model = new Model(array('name' => 'Datatype', 'table' => 'datatypes', 'ds' => 'test_suite')); + $model->create(); + $this->assertIdentical(false, $model->data['Datatype']['bool']); + } + /** * testLastInsertIdMultipleInsert method * @@ -446,23 +458,15 @@ class DboPostgresTest extends CakeTestCase { function testLastInsertIdMultipleInsert() { $db1 = ConnectionManager::getDataSource('test_suite'); - if (PHP5) { - $db2 = clone $db1; - } else { - $db2 = $db1; - } - - $db2->connect(); - $this->assertNotEqual($db1->connection, $db2->connection); - $table = $db1->fullTableName('users', false); $password = '5f4dcc3b5aa765d61d8327deb882cf99'; $db1->execute( "INSERT INTO {$table} (\"user\", password) VALUES ('mariano', '{$password}')" ); - $db2->execute("INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '{$password}')"); $this->assertEqual($db1->lastInsertId($table), 1); - $this->assertEqual($db2->lastInsertId($table), 2); + + $db1->execute("INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '{$password}')"); + $this->assertEqual($db1->lastInsertId($table), 2); } /** @@ -582,7 +586,7 @@ class DboPostgresTest extends CakeTestCase { $db1 =& ConnectionManager::getDataSource('test_suite'); $db1->cacheSources = false; $db1->reconnect(array('persistent' => false)); - $db1->query('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' ( + $db1->query('CREATE TABLE ' . $db1->fullTableName('datatype_tests') . ' ( id serial NOT NULL, "varchar" character varying(40) NOT NULL, "full_length" character varying NOT NULL, @@ -590,31 +594,30 @@ class DboPostgresTest extends CakeTestCase { date date, CONSTRAINT test_suite_data_types_pkey PRIMARY KEY (id) )'); - $model = new Model(array('name' => 'Datatype', 'ds' => 'test_suite')); + $model = new Model(array('name' => 'DatatypeTest', 'ds' => 'test_suite')); $schema = new CakeSchema(array('connection' => 'test_suite')); $result = $schema->read(array( 'connection' => 'test_suite', - 'models' => array('Datatype') )); - $schema->tables = array('datatypes' => $result['tables']['datatypes']); - $result = $db1->createSchema($schema, 'datatypes'); + $schema->tables = array('datatype_tests' => $result['tables']['missing']['datatype_tests']); + $result = $db1->createSchema($schema, 'datatype_tests'); $this->assertNoPattern('/timestamp DEFAULT/', $result); $this->assertPattern('/\"full_length\"\s*text\s.*,/', $result); $this->assertPattern('/timestamp\s*,/', $result); - $db1->query('DROP TABLE ' . $db1->fullTableName('datatypes')); + $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); $db1->query($result); $result2 = $schema->read(array( 'connection' => 'test_suite', - 'models' => array('Datatype') + 'models' => array('DatatypeTest') )); - $schema->tables = array('datatypes' => $result2['tables']['datatypes']); - $result2 = $db1->createSchema($schema, 'datatypes'); + $schema->tables = array('datatype_tests' => $result2['tables']['missing']['datatype_tests']); + $result2 = $db1->createSchema($schema, 'datatype_tests'); $this->assertEqual($result, $result2); - $db1->query('DROP TABLE ' . $db1->fullTableName('datatypes')); + $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); } /** diff --git a/cake/tests/fixtures/datatype_fixture.php b/cake/tests/fixtures/datatype_fixture.php index 7df574b27..a12335cd3 100644 --- a/cake/tests/fixtures/datatype_fixture.php +++ b/cake/tests/fixtures/datatype_fixture.php @@ -43,6 +43,7 @@ class DatatypeFixture extends CakeTestFixture { var $fields = array( 'id' => array('type' => 'integer', 'null'=> false, 'default'=> 0, 'key' => 'primary'), 'float_field' => array('type' => 'float', 'length' => '5,2', 'null' => false, 'default' => null), + 'bool' => array('type' => 'boolean', 'null' => false, 'default' => false), ); /** @@ -52,6 +53,6 @@ class DatatypeFixture extends CakeTestFixture { * @access public */ var $records = array( - array('id' => 1, 'float_field' => 42.23), + array('id' => 1, 'float_field' => 42.23, 'bool' => false), ); } From e58e3f3132da50dcad4026bcf1822e27702e3c4b Mon Sep 17 00:00:00 2001 From: Joe Beeson Date: Fri, 21 Jan 2011 13:23:29 -0700 Subject: [PATCH 03/17] Fix to resolve 'assign by reference' errors when using a '__get' magic method. Fixes #1476 Signed-off-by: mark_story --- cake/libs/controller/component.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index d2d708cc3..b1cb50c0d 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -246,7 +246,11 @@ class Component extends Object { if ($componentCn === 'SessionComponent') { $object->{$component} =& new $componentCn($base); } else { - $object->{$component} =& new $componentCn(); + if (PHP5) { + $object->{$component} = new $componentCn(); + } else { + $object->{$component} =& new $componentCn(); + } } $object->{$component}->enabled = true; $this->_loaded[$component] =& $object->{$component}; From 3747e395f118ec9c145425640b994ef8d971454b Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:02:33 -0500 Subject: [PATCH 04/17] Fixing notice errors caused by garbage urls being fed into Dispatcher. Added a test. Fixes #1463 --- cake/dispatcher.php | 4 ++-- cake/tests/cases/dispatcher.test.php | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index e95771b2c..cddd302cd 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -264,9 +264,9 @@ class Dispatcher extends Object { $namedExpressions = Router::getNamedExpressions(); extract($namedExpressions); include CONFIGS . 'routes.php'; - $params = array_merge(Router::parse($fromUrl), $params); + $params = array_merge(array('controller' => '', 'action' => ''), Router::parse($fromUrl), $params); - if (strlen($params['action']) === 0) { + if (empty($params['action'])) { $params['action'] = 'index'; } if (isset($params['form']['data'])) { diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index bb8da8aab..58f25da5c 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1406,6 +1406,26 @@ class DispatcherTest extends CakeTestCase { $this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here); } +/** + * test that a garbage url doesn't cause errors. + * + * @return void + */ + function testDispatchWithGarbageUrl() { + Configure::write('App.baseUrl', '/index.php'); + + $Dispatcher =& new TestDispatcher(); + $url = 'http://google.com'; + $result = $Dispatcher->dispatch($url); + $expected = array('missingController', array(array( + 'className' => 'Controller', + 'webroot' => '/', + 'url' => 'http://google.com', + 'base' => '/index.php' + ))); + $this->assertEqual($expected, $result); + } + /** * testAdminDispatch method * From 703272965106532764817b661ef08791d29464ac Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 23 Jan 2011 17:08:09 -0500 Subject: [PATCH 05/17] Fixing how webroot is calculated for installs not using url rewriting. Also fixes using the top level index.php file. Test cases added for using both index.php files. Cleaned up existing tests for environment detection. Fixes #1261, Fixes #1432 --- cake/dispatcher.php | 8 ++- cake/tests/cases/dispatcher.test.php | 94 ++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 7 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index cddd302cd..729bb7a44 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -357,9 +357,13 @@ class Dispatcher extends Object { if ($base === DS || $base === '.') { $base = ''; } - $this->webroot = $base .'/'; + $this->webroot = $base . '/'; - if (!empty($base)) { + $docRoot = env('DOCUMENT_ROOT'); + $script = realpath(env('SCRIPT_FILENAME')); + $docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot); + + if (!empty($base) || !$docRootContainsWebroot) { if (strpos($this->webroot, $dir) === false) { $this->webroot .= $dir . '/' ; } diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 58f25da5c..0255829b5 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1207,6 +1207,42 @@ class DispatcherTest extends CakeTestCase { $this->assertEqual($expectedWebroot, $Dispatcher->webroot); } +/** + * test baseUrl with no rewrite and using the top level index.php. + * + * @return void + */ + function testBaseUrlNoRewriteTopLevelIndex() { + $Dispatcher =& new Dispatcher(); + + Configure::write('App.baseUrl', '/index.php'); + $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev'; + $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/index.php'; + + $result = $Dispatcher->baseUrl(); + $this->assertEqual('/index.php', $result); + $this->assertEqual('/app/webroot/', $Dispatcher->webroot); + $this->assertEqual('', $Dispatcher->base); + } + +/** + * test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts. + * + * @return void + */ + function testBaseUrlNoRewriteWebrootIndex() { + $Dispatcher =& new Dispatcher(); + + Configure::write('App.baseUrl', '/index.php'); + $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev/app/webroot'; + $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/app/webroot/index.php'; + + $result = $Dispatcher->baseUrl(); + $this->assertEqual('/index.php', $result); + $this->assertEqual('/', $Dispatcher->webroot); + $this->assertEqual('', $Dispatcher->base); + } + /** * testBaseUrlAndWebrootWithBase method * @@ -2304,7 +2340,7 @@ class DispatcherTest extends CakeTestCase { 'IIS' => array( 'No rewrite base path' => array( 'App' => array('base' => false, 'baseUrl' => '/index.php?', 'server' => 'IIS'), - 'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_ACCEPT' => '*/*', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_CONNECTION' => 'Keep-Alive', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'argv' => array(), 'argc' => 0), + 'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_HOST' => 'localhost', 'argv' => array(), 'argc' => 0), 'reload' => true, 'path' => '' ), @@ -2343,18 +2379,54 @@ class DispatcherTest extends CakeTestCase { 'Apache' => array( 'No rewrite base path' => array( 'App' => array('base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot'), - 'SERVER' => array('SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '::1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'SERVER_ADDR' => '::1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '::1', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/', + 'SCRIPT_NAME' => '/index.php', + 'PHP_SELF' => '/index.php', + 'argv' => array(), + 'argc' => 0 + ), 'reload' => true, 'path' => '' ), 'No rewrite with path' => array( - 'SERVER' => array('UNIQUE_ID' => 'VardGqn@17IAAAu7LY8AAAAK', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.5 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/add', 'PHP_SELF' => '/index.php/posts/add', 'argv' => array(), 'argc' => 0), + 'SERVER' => array( + 'HTTP_HOST' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/index.php/posts/add', + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/posts/add', + 'PHP_SELF' => '/index.php/posts/add', + 'argv' => array(), + 'argc' => 0), 'reload' => false, 'path' => '/posts/add' ), 'GET Request at base domain' => array( 'App' => array('base' => false, 'baseUrl' => null, 'dir' => 'app', 'webroot' => 'webroot'), - 'SERVER' => array('UNIQUE_ID' => '2A-v8sCoAQ8AAAc-2xUAAAAB', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_COOKIE' => 'CAKEPHP=jcbv51apn84kd9ucv5aj2ln3t3', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', 'SERVER_ADMIN' => 'you@example.com', 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', 'REMOTE_PORT' => '53550', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'a=b', 'REQUEST_URI' => '/?a=b', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php'), + 'SERVER' => array( + 'HTTP_HOST' => 'cake.1.2', + 'SERVER_NAME' => 'cake.1.2', + 'SERVER_ADDR' => '127.0.0.1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '127.0.0.1', + 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', + 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', + 'REMOTE_PORT' => '53550', + 'QUERY_STRING' => 'a=b', + 'REQUEST_URI' => '/?a=b', + 'SCRIPT_NAME' => '/index.php', + 'PHP_SELF' => '/index.php' + ), 'GET' => array('a' => 'b'), 'POST' => array(), 'reload' => true, @@ -2364,7 +2436,19 @@ class DispatcherTest extends CakeTestCase { ), 'New CGI no mod_rewrite' => array( 'App' => array('base' => false, 'baseUrl' => '/limesurvey20/index.php', 'dir' => 'app', 'webroot' => 'webroot'), - 'SERVER' => array('DOCUMENT_ROOT' => '/home/.sites/110/site313/web', 'PATH_INFO' => '/installations', 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'PHPRC' => '/home/.sites/110/site313', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/limesurvey20/index.php/installations', 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'SCRIPT_NAME' => '/limesurvey20/index.php', 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', 'PHP_SELF' => '/limesurvey20/index.php/installations', 'CGI_MODE' => true), + 'SERVER' => array( + 'DOCUMENT_ROOT' => '/home/.sites/110/site313/web', + 'PATH_INFO' => '/installations', + 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', + 'PHPRC' => '/home/.sites/110/site313', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/limesurvey20/index.php/installations', + 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', + 'SCRIPT_NAME' => '/limesurvey20/index.php', + 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', + 'PHP_SELF' => '/limesurvey20/index.php/installations', + 'CGI_MODE' => true + ), 'GET' => array(), 'POST' => array(), 'reload' => true, From 32f0b20a336074b8d09d912e8e1a2b07aa8d7f0e Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 24 Jan 2011 22:05:16 -0500 Subject: [PATCH 06/17] Removing wonky and most likely incorrect manipulation of socket and port setting mangling in DboMysqli. Fixes #1478 --- cake/libs/model/datasources/dbo/dbo_mysqli.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index daf47f557..8b0543d6d 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -59,13 +59,6 @@ class DboMysqli extends DboMysqlBase { $config = $this->config; $this->connected = false; - if (is_numeric($config['port'])) { - $config['socket'] = null; - } else { - $config['socket'] = $config['port']; - $config['port'] = null; - } - $this->connection = mysqli_connect($config['host'], $config['login'], $config['password'], $config['database'], $config['port'], $config['socket']); if ($this->connection !== false) { From d192ed32f05b0b17fbc46580b1e30fb3819c6fda Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 26 Jan 2011 20:54:14 -0500 Subject: [PATCH 07/17] Adding a socket key to DboMysqli::$baseConfig. Fixes notice errors when socket is undefined. Fixes #1482 --- cake/libs/model/datasources/dbo/dbo_mysqli.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index 8b0543d6d..844554cdd 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -47,7 +47,8 @@ class DboMysqli extends DboMysqlBase { 'login' => 'root', 'password' => '', 'database' => 'cake', - 'port' => '3306' + 'port' => '3306', + 'socket' => null ); /** From 71d8e744f160c918e4a1b86dc32f9d3447145e12 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 26 Jan 2011 20:58:16 -0500 Subject: [PATCH 08/17] Fixing case-sensitivity of AS in fields. Tests added. Fixes #1474 --- cake/libs/model/datasources/dbo_source.php | 2 +- cake/tests/cases/libs/model/datasources/dbo_source.test.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 42d7db354..b610ee121 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -562,7 +562,7 @@ class DboSource extends DataSource { ); } if ( - preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/', $data, $matches + preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/i', $data, $matches )) { return $this->cacheMethod( __FUNCTION__, $cacheKey, diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index d60898dab..924e7256d 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -4077,10 +4077,14 @@ class DboSourceTest extends CakeTestCase { $result = $this->testDb->name(array('my-name', 'Foo-Model.*')); $expected = array('`my-name`', '`Foo-Model`.*'); $this->assertEqual($result, $expected); - + $result = $this->testDb->name(array('Team.P%', 'Team.G/G')); $expected = array('`Team`.`P%`', '`Team`.`G/G`'); $this->assertEqual($result, $expected); + + $result = $this->testDb->name('Model.name as y'); + $expected = '`Model`.`name` AS `y`'; + $this->assertEqual($result, $expected); } /** From 38e286e978b13a9480a9a862705468025d49460f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Jan 2011 19:30:21 -0500 Subject: [PATCH 09/17] Fixing order of paths so core paths are last in the search array. Fixes #1488 --- cake/console/libs/tasks/template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/console/libs/tasks/template.php b/cake/console/libs/tasks/template.php index 15b1721fd..aac544abc 100644 --- a/cake/console/libs/tasks/template.php +++ b/cake/console/libs/tasks/template.php @@ -56,7 +56,7 @@ class TemplateTask extends Shell { $core = array_pop($paths); $separator = DS === '/' ? '/' : '\\\\'; $core = preg_replace('#libs' . $separator . '$#', '', $core); - $paths[] = $core; + $Folder =& new Folder($core . 'templates' . DS . 'default'); $contents = $Folder->read(); $themeFolders = $contents[0]; @@ -65,6 +65,7 @@ class TemplateTask extends Shell { foreach ($plugins as $plugin) { $paths[] = $this->_pluginPath($plugin) . 'vendors' . DS . 'shells' . DS; } + $paths[] = $core; // TEMPORARY TODO remove when all paths are DS terminated foreach ($paths as $i => $path) { From 5464ed845594047b47285abd1afdc6506c3e0bc2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Jan 2011 21:05:30 -0500 Subject: [PATCH 10/17] Fixing blackholes caused by using custom name attributes with inputs. Fixes #1489 --- cake/libs/view/helpers/form.php | 11 ++++++++++- cake/tests/cases/libs/view/helpers/form.test.php | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 5c4435f97..7026d5afb 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -2190,10 +2190,19 @@ class FormHelper extends AppHelper { } else { $secure = (isset($this->params['_Token']) && !empty($this->params['_Token'])); } + + $fieldName = null; + if ($secure && !empty($options['name'])) { + preg_match_all('/\[(.*?)\]/', $options['name'], $matches); + if (isset($matches[1])) { + $fieldName = $matches[1]; + } + } + $result = parent::_initInputField($field, $options); if ($secure) { - $this->__secure(); + $this->__secure($fieldName); } return $result; } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 103a33d02..27815a8b0 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1083,6 +1083,21 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test securing inputs with custom name attributes. + * + * @return void + */ + function testFormSecureWithCustomNameAttribute() { + $this->Form->params['_Token']['key'] = 'testKey'; + + $this->Form->text('UserForm.published', array('name' => 'data[User][custom]')); + $this->assertEqual('User.custom', $this->Form->fields[0]); + + $this->Form->text('UserForm.published', array('name' => 'data[User][custom][another][value]')); + $this->assertEqual('User.custom.another.value', $this->Form->fields[1]); + } + /** * testFormSecuredInput method * From bbf6aedd9cb520ada416b9eeedc090e461ce32bc Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 28 Jan 2011 00:18:44 -0200 Subject: [PATCH 11/17] Fixed wrong viewVars store when have objects in view caching. Fixes #1486. --- cake/libs/view/helpers/cache.php | 10 +++++----- cake/tests/cases/libs/view/helpers/cache.test.php | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index e2e911b8c..65ed53ca2 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -225,15 +225,15 @@ class CacheHelper extends AppHelper { $file .= '$controller =& new ' . $this->controllerName . 'Controller(); $controller->plugin = $this->plugin = \''.$this->plugin.'\'; - $controller->helpers = $this->helpers = ' . var_export($this->helpers, true) . '; + $controller->helpers = $this->helpers = unserialize(\'' . serialize($this->helpers) . '\'); $controller->base = $this->base = \'' . $this->base . '\'; $controller->layout = $this->layout = \'' . $this->layout. '\'; $controller->webroot = $this->webroot = \'' . $this->webroot . '\'; $controller->here = $this->here = \'' . $this->here . '\'; - $controller->params = $this->params = ' . var_export($this->params, true) . '; - $controller->action = $this->action = ' . var_export($this->action, true) . '; - $controller->data = $this->data = ' . var_export($this->data, true) . '; - $controller->viewVars = $this->viewVars = ' . var_export($this->viewVars, true) . '; + $controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\')); + $controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\'); + $controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\')); + $controller->viewVars = $this->viewVars = unserialize(base64_decode(\'' . base64_encode(serialize($this->viewVars)) . '\')); $controller->theme = $this->theme = \'' . $this->theme . '\'; Router::setRequestInfo(array($this->params, array(\'base\' => $this->base, \'webroot\' => $this->webroot)));'; diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 45edea332..01a8c0bcc 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -339,7 +339,6 @@ class CacheHelperTest extends CakeTestCase { $this->assertPattern('/\$this\-\>viewVars/', $contents); $this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents); $this->assertPattern('/php echo \$variable/', $contents); - $this->assertPattern('/variableValue/', $contents); @unlink($filename); } From b30f40582e3338ebe931ff47c308126bf81ca06c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 29 Jan 2011 09:24:28 -0500 Subject: [PATCH 12/17] Making SchemaShell disable the cache when reading table information for schema generation. Fixes #1490 --- cake/console/libs/schema.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cake/console/libs/schema.php b/cake/console/libs/schema.php index 889f85453..840e3c61a 100644 --- a/cake/console/libs/schema.php +++ b/cake/console/libs/schema.php @@ -153,8 +153,13 @@ class SchemaShell extends Shell { } } + $cacheDisable = Configure::read('Cache.disable'); + Configure::write('Cache.disable', true); + $content = $this->Schema->read($options); $content['file'] = $this->params['file']; + + Configure::write('Cache.disable', $cacheDisable); if ($snapshot === true) { $Folder =& new Folder($this->Schema->path); From 6db8515e60ae0031af4ea0e9d50099c6f1bb2f1e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 30 Jan 2011 12:25:40 -0500 Subject: [PATCH 13/17] Fixing incorrectly nested sprintf + __ call. Refs #1305 --- cake/libs/controller/scaffold.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index ea5e9031f..27b7632c8 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -223,7 +223,7 @@ class Scaffold extends Object { function __scaffoldView($params) { if ($this->controller->_beforeScaffold('view')) { - $message = __(sprintf("No id set for %s::view()", Inflector::humanize($this->modelKey)), true); + $message = sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)); if (isset($params['pass'][0])) { $this->ScaffoldModel->id = $params['pass'][0]; } elseif ($this->_validSession) { From 9402f0ab79307946c0eabee63d0c19a46d6dbf60 Mon Sep 17 00:00:00 2001 From: Phally Date: Mon, 31 Jan 2011 00:06:11 +0100 Subject: [PATCH 14/17] Added missing skipIf when no SMTP server is running. --- cake/tests/cases/libs/controller/components/email.test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index de1be084e..541ed4f2a 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -437,6 +437,9 @@ TEMPDOC; * @return void */ function testSmtpSendMultipleTo() { + if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + return; + } $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost'); $this->Controller->EmailTest->from = 'noreply@example.com'; From f3812342c226ec1d3355b84f60edfc54146095b7 Mon Sep 17 00:00:00 2001 From: Phally Date: Mon, 31 Jan 2011 00:15:12 +0100 Subject: [PATCH 15/17] Minor optimization for email linefeeds. --- cake/libs/controller/components/email.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 78698b056..fd4ed3479 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -159,7 +159,7 @@ class EmailComponent extends Object{ /** * Line feed character(s) to be used when sending using mail() function - * If null PHP_EOL is used. + * By default PHP_EOL is used. * RFC2822 requires it to be CRLF but some Unix * mail transfer agents replace LF by CRLF automatically * (which leads to doubling CR if CRLF is used). @@ -167,7 +167,7 @@ class EmailComponent extends Object{ * @var string * @access public */ - var $lineFeed = null; + var $lineFeed = PHP_EOL; /** * @deprecated see lineLength @@ -819,13 +819,8 @@ class EmailComponent extends Object{ * @access private */ function _mail() { - if ($this->lineFeed === null) { - $lineFeed = PHP_EOL; - } else { - $lineFeed = $this->lineFeed; - } - $header = implode($lineFeed, $this->__header); - $message = implode($lineFeed, $this->__message); + $header = implode($this->lineFeed, $this->__header); + $message = implode($this->lineFeed, $this->__message); if (is_array($this->to)) { $to = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); } else { From cf50cbdd9d40595a2cd32768888467fe5c374d99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 06:43:00 -0500 Subject: [PATCH 16/17] Fixing issue in FormHelper where CURRENT_TIMESTAMP or other invalid data could cause a notice error. Fixes #1508 --- cake/libs/view/helpers/form.php | 7 +++++-- cake/tests/cases/libs/view/helpers/form.test.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 7026d5afb..7b6dd35a5 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1843,8 +1843,11 @@ class FormHelper extends AppHelper { if ($time[0] == 0 && $timeFormat == '12') { $time[0] = 12; } - $hour = $time[0]; - $min = $time[1]; + $hour = $min = null; + if (isset($time[1])) { + $hour = $time[0]; + $min = $time[1]; + } } } } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 27815a8b0..3aea5e665 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -4494,6 +4494,16 @@ class FormHelperTest extends CakeTestCase { $this->assertPattern('/]+value="06"[^<>]+selected="selected"[^>]*>June<\/option>/', $result); } +/** + * test that bogus non-date time data doesn't cause errors. + * + * @return void + */ + function testDateTimeWithBogusData() { + $result = $this->Form->dateTime('Contact.updated', 'DMY', '12', 'CURRENT_TIMESTAMP'); + $this->assertNoPattern('/selected="selected">\d/', $result); + } + /** * testFormDateTimeMulti method * From 8d5e68d582ef13f32534d1d185176acecf8c5060 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 11:19:05 -0500 Subject: [PATCH 17/17] Fixing issue where habtm tables would not have the connection prefix removed when generating schema. Fixes #1180 --- cake/libs/model/cake_schema.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index fefc41f7f..4acf9a18d 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -274,11 +274,16 @@ class CakeSchema extends Object { } if (is_object($Object->$class)) { $withTable = $db->fullTableName($Object->$class, false); + if ($prefix && strpos($withTable, $prefix) !== 0) { + continue; + } if (in_array($withTable, $currentTables)) { $key = array_search($withTable, $currentTables); - $tables[$withTable] = $this->__columns($Object->$class); - $tables[$withTable]['indexes'] = $db->index($Object->$class); - $tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable); + $noPrefixWith = str_replace($prefix, '', $withTable); + + $tables[$noPrefixWith] = $this->__columns($Object->$class); + $tables[$noPrefixWith]['indexes'] = $db->index($Object->$class); + $tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable); unset($currentTables[$key]); } }