From 17339378ee29cf179cd262cf2bdf1d1f18dfcb2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Mon, 28 Feb 2011 11:54:54 +0100 Subject: [PATCH 01/10] allow to disable cache gc --- cake/libs/cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index 3164b5ec916..d9504711687 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -149,7 +149,7 @@ function _buildEngine($name) { $cacheClass = $class . 'Engine'; $this->_engines[$name] =& new $cacheClass(); if ($this->_engines[$name]->init($config)) { - if (time() % $this->_engines[$name]->settings['probability'] === 0) { + if (!is_null($this->_engines[$name]->settings['probability']) && time() % $this->_engines[$name]->settings['probability'] === 0) { $this->_engines[$name]->gc(); } return true; From 99685ba2052fca34f5adb49b4861213cf571e6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Mon, 28 Feb 2011 18:34:28 +0100 Subject: [PATCH 02/10] disabling gc doesn't require an explicit null value --- cake/libs/cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index d9504711687..922dc9e6084 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -149,7 +149,7 @@ function _buildEngine($name) { $cacheClass = $class . 'Engine'; $this->_engines[$name] =& new $cacheClass(); if ($this->_engines[$name]->init($config)) { - if (!is_null($this->_engines[$name]->settings['probability']) && time() % $this->_engines[$name]->settings['probability'] === 0) { + if ($this->_engines[$name]->settings['probability'] && time() % $this->_engines[$name]->settings['probability'] === 0) { $this->_engines[$name]->gc(); } return true; From 00096b7ccb3ad7f9ab0cb78a340cd8e01e629056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Fri, 4 Mar 2011 14:14:32 +0100 Subject: [PATCH 03/10] handling bit type column --- cake/libs/model/datasources/dbo/dbo_mysql.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 1ed2ae13afa..b60b3e28360 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -504,6 +504,9 @@ function column($real) { if (strpos($col, 'enum') !== false) { return "enum($vals)"; } + if (strpos($col, 'bit') !== false) { + return 'bit'; + } return 'text'; } } @@ -667,6 +670,12 @@ function value($data, $column = null, $safe = false) { ) { return $data; } + case 'bit': + if(is_int($data)) { + return "b'" . dec2bin($data) . "'"; + } else { + return "b'" . $data . "'"; + } default: return "'" . mysql_real_escape_string($data, $this->connection) . "'"; break; From 3cf94ecb5ef9529743d4bab3c6886d146a6eca9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Fri, 4 Mar 2011 14:29:37 +0100 Subject: [PATCH 04/10] fix dbo_mysql.testQuoting test --- cake/libs/model/datasources/dbo/dbo_mysql.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index b60b3e28360..01c311ec418 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -656,6 +656,13 @@ function value($data, $column = null, $safe = false) { case 'boolean': return $this->boolean((bool)$data); break; + case 'bit': + if(is_int($data)) { + return "b'" . dec2bin($data) . "'"; + } else { + return "b'" . $data . "'"; + } + break; case 'integer': case 'float': if ($data === '') { @@ -670,12 +677,6 @@ function value($data, $column = null, $safe = false) { ) { return $data; } - case 'bit': - if(is_int($data)) { - return "b'" . dec2bin($data) . "'"; - } else { - return "b'" . $data . "'"; - } default: return "'" . mysql_real_escape_string($data, $this->connection) . "'"; break; From 293ba8a361898002fd77676eaf6e54ac76a78c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Fri, 4 Mar 2011 14:37:07 +0100 Subject: [PATCH 05/10] add bit column related tests --- .../libs/model/datasources/dbo/dbo_mysql.test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 32dad262642..9306c99c9e9 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -275,6 +275,14 @@ function testQuoting() { $expected = "'00010010001'"; $result = $this->db->value('00010010001'); $this->assertEqual($expected, $result); + + $expected = "b'00010010001'"; + $result = $this->db->value('00010010001', 'bit'); + $this->assertEqual($expected, $result); + + $expected = "b'1101'"; + $result = $this->db->value(13, 'bit'); + $this->assertEqual($expected, $result); } /** @@ -573,6 +581,10 @@ function testColumn() { $result = $this->db->column('decimal(14,7) unsigned'); $expected = 'float'; $this->assertEqual($result, $expected); + + $result = $this->db->column('bit(3)'); + $expected = 'bit'; + $this->assertEqual($result, $expected); } /** From a4db32b05742e73ea81f61decb5df860873fae22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Thu, 31 Mar 2011 11:59:30 +0200 Subject: [PATCH 06/10] use an other mehod name to get cached list sources --- cake/libs/model/datasources/datasource.php | 2 +- cake/libs/model/datasources/dbo/dbo_mssql.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_mysql.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_mysqli.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_oracle.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_postgres.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_sqlite.php | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 5de46be8a84..7d7305bd700 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -223,7 +223,7 @@ function __construct($config = array()) { * @return array Array of sources available in this datasource. * @access public */ - function listSources($data = null) { + function CachedListSources($data = null) { if ($this->cacheSources === false) { return null; } diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index b7b17f7c8a9..cff9dca0894 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -201,7 +201,7 @@ function _execute($sql) { * @return array Array of tablenames in the database */ function listSources() { - $cache = parent::listSources(); + $cache = $this->cachedListSources(); if ($cache != null) { return $cache; @@ -217,7 +217,7 @@ function listSources() { $tables[] = $table[0]['TABLE_NAME']; } - parent::listSources($tables); + $this->cachedListSources($tables); return $tables; } } diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 01c311ec418..2eb5da91af1 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -609,7 +609,7 @@ function _execute($sql) { * @return array Array of tablenames in the database */ function listSources() { - $cache = parent::listSources(); + $cache = $this->cachedListSources(); if ($cache != null) { return $cache; } @@ -623,7 +623,7 @@ function listSources() { while ($line = mysql_fetch_row($result)) { $tables[] = $line[0]; } - parent::listSources($tables); + $this->cachedListSources($tables); return $tables; } } diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index 844554cdd7c..e7661a71fb2 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -133,7 +133,7 @@ function _executeProcedure($sql) { * @return array Array of tablenames in the database */ function listSources() { - $cache = parent::listSources(); + $cache = $this->cachedListSources(); if ($cache !== null) { return $cache; } @@ -148,7 +148,7 @@ function listSources() { while ($line = mysqli_fetch_row($result)) { $tables[] = $line[0]; } - parent::listSources($tables); + $this->cachedListSources($tables); return $tables; } diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index 38fb0338278..503bf658f2e 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -463,7 +463,7 @@ function createTrigger($table) { * @access public */ function listSources() { - $cache = parent::listSources(); + $cache = $this->cachedListSources(); if ($cache != null) { return $cache; } @@ -477,7 +477,7 @@ function listSources() { while($r = $this->fetchRow()) { $sources[] = strtolower($r[0]['name']); } - parent::listSources($sources); + $this->cachedListSources($sources); return $sources; } diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 9d1558e3371..d6e8c09394f 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -173,7 +173,7 @@ function _execute($sql) { * @return array Array of tablenames in the database */ function listSources() { - $cache = parent::listSources(); + $cache = $this->cachedListSources(); if ($cache != null) { return $cache; @@ -192,7 +192,7 @@ function listSources() { $tables[] = $item[0]['name']; } - parent::listSources($tables); + $this->cachedListSources($tables); return $tables; } } diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index efc660f33b8..2dbc74fcb16 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -192,7 +192,7 @@ function execute($sql) { * @return array Array of tablenames in the database */ function listSources() { - $cache = parent::listSources(); + $cache = $this->cachedListSources(); if ($cache != null) { return $cache; @@ -206,7 +206,7 @@ function listSources() { foreach ($result as $table) { $tables[] = $table[0]['name']; } - parent::listSources($tables); + $this->cachedListSources($tables); return $tables; } return array(); From 360d398f44d1de8a65d49d995841cbe6a8cb77fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Thu, 31 Mar 2011 12:02:23 +0200 Subject: [PATCH 07/10] fix uppercase issue --- cake/libs/model/datasources/datasource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 7d7305bd700..c71c8eae488 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -223,7 +223,7 @@ function __construct($config = array()) { * @return array Array of sources available in this datasource. * @access public */ - function CachedListSources($data = null) { + function cachedListSources($data = null) { if ($this->cacheSources === false) { return null; } From f708e5fdae6ee70b2ba3dc5b373c0472e2dedff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Thu, 21 Jul 2011 17:49:11 +0200 Subject: [PATCH 08/10] add cache hash file engine --- cake/libs/cache/hashfile.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cake/libs/cache/hashfile.php diff --git a/cake/libs/cache/hashfile.php b/cake/libs/cache/hashfile.php new file mode 100644 index 00000000000..b94fabd1723 --- /dev/null +++ b/cake/libs/cache/hashfile.php @@ -0,0 +1,36 @@ +_File->name), 0, self::HASH_DIGITS_NUMBER); + + $this->_File->Folder->create( + $this->_File->Folder->addPathElement( + $this->_File->Folder->pwd(), + $intermediate_key + ) + ); + $this->_File->Folder->cd($intermediate_key); + $this->_File->path = null; + $this->_File->pwd(); + + } + +} \ No newline at end of file From ab4809996c5e6ddaf528e16f8df4200bba4be30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Thu, 21 Jul 2011 18:51:21 +0200 Subject: [PATCH 09/10] fix wrong function name --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 01c311ec418..4a45a70f2c5 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -658,7 +658,7 @@ function value($data, $column = null, $safe = false) { break; case 'bit': if(is_int($data)) { - return "b'" . dec2bin($data) . "'"; + return "b'" . decbin($data) . "'"; } else { return "b'" . $data . "'"; } From 4d9afe8338e53ec7b342152cfcdc3ac48b525239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Fri, 22 Jul 2011 11:14:43 +0200 Subject: [PATCH 10/10] merge requested js buffer to the main one --- cake/libs/view/helpers/js.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 8ecb5c5bc1f..afbf1f36a68 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -445,6 +445,19 @@ function _getHtmlOptions($options, $additional = array()) { } return array($options, $htmlOptions); } + + function beforeRender() { + if(!isset($this->params['requested'])) { + ClassRegistry::addObject('main_js_helper', $this); + } + } + + function afterRender() { + if(isset($this->params['requested']) && ClassRegistry::isKeySet('main_js_helper')) { + ClassRegistry::getObject('main_js_helper')->buffer(implode("\n", $this->getBuffer())); + } + } + } /**