From 9eb195064674851e630a4323eb8ce6b1f2e827f3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 16 Nov 2009 20:10:08 -0500 Subject: [PATCH 01/19] Removing duplicate condition check. Fixes #314 --- cake/libs/router.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 579b3ff4a..6bb72b440 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -581,10 +581,6 @@ class Router extends Object { * @access private */ function __connectDefaultRoutes() { - if ($this->__defaultsMapped) { - return; - } - if ($this->__admin) { $params = array('prefix' => $this->__admin, $this->__admin => true); } From 4a8808eb211261073114faa130101ee8b44b9307 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Thu, 19 Nov 2009 16:28:11 -0200 Subject: [PATCH 02/19] Removing the argument passed to mssql_get_last_message(), it does not accept any argument. --- cake/libs/model/datasources/dbo/dbo_mssql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index b93192f95..9e5cad49a 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -412,7 +412,7 @@ class DboMssql extends DboSource { * @return string Error message with error number */ function lastError() { - $error = mssql_get_last_message($this->connection); + $error = mssql_get_last_message(); if ($error) { if (!preg_match('/contexto de la base de datos a|contesto di database|changed database|datenbankkontext/i', $error)) { From 9dcac18b87739e3e46100ef7b29e4651093091e4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Nov 2009 13:26:33 -0500 Subject: [PATCH 03/19] Adding commented Asset.timestamp block to core.php --- app/config/core.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/config/core.php b/app/config/core.php index fbd02e74a..cac5eb8ab 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -149,6 +149,15 @@ * A random string used in security hashing methods. */ Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); +/** + * Apply timestamps with the last modified time to static assets (js, css, images). + * Will append a querysting parameter containing the time the file was modified. This is + * useful for invalidating browser caches. + * + * Set to `true` to apply timestamps, when debug = 0, or set to 'force' to always enable + * timestamping. + */ + //Configure::write('Asset.timestamp', true); /** * Compress CSS output by removing comments, whitespace, repeating tags, etc. * This requires a/var/cache directory to be writable by the web server for caching. From 9b6b258fede89ec09275234270fe6ee0e2d61af1 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:04:32 -0200 Subject: [PATCH 04/19] Replace function is_integer (alias) by is_int. Signed-off-by: Mark Story --- cake/libs/controller/components/cookie.php | 2 +- cake/libs/view/helpers/time.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index 56713f5c4..f84770922 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -348,7 +348,7 @@ class CookieComponent extends Object { return $this->__expires; } $this->__reset = $this->__expires; - if (is_integer($expires) || is_numeric($expires)) { + if (is_int($expires) || is_numeric($expires)) { return $this->__expires = $now + intval($expires); } return $this->__expires = strtotime($expires, $now); diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 179ca4409..fbd5cef7e 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -63,7 +63,7 @@ class TimeHelper extends AppHelper { if (empty($dateString)) { return false; } - if (is_integer($dateString) || is_numeric($dateString)) { + if (is_int($dateString) || is_numeric($dateString)) { $date = intval($dateString); } else { $date = strtotime($dateString); From 1acc60b04cfb3d601ee561662cfd5f30d71e0b5e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:05:59 -0200 Subject: [PATCH 05/19] Replace function die (alias) by exit. Signed-off-by: Mark Story --- cake/console/libs/templates/skel/config/acl.ini.php | 2 +- cake/console/libs/templates/skel/webroot/css.php | 4 ++-- cake/console/libs/templates/skel/webroot/test.php | 2 +- cake/libs/debugger.php | 2 +- cake/libs/model/datasources/dbo/dbo_odbc.php | 2 +- cake/tests/test_app/config/acl.ini.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/console/libs/templates/skel/config/acl.ini.php b/cake/console/libs/templates/skel/config/acl.ini.php index a9868e685..ee585c27a 100644 --- a/cake/console/libs/templates/skel/config/acl.ini.php +++ b/cake/console/libs/templates/skel/config/acl.ini.php @@ -1,4 +1,4 @@ -; +; ; SVN FILE: $Id$ ;/** ; * Short description for file. diff --git a/cake/console/libs/templates/skel/webroot/css.php b/cake/console/libs/templates/skel/webroot/css.php index 52b57fee7..8c5e9ab0a 100644 --- a/cake/console/libs/templates/skel/webroot/css.php +++ b/cake/console/libs/templates/skel/webroot/css.php @@ -66,7 +66,7 @@ if (!class_exists('File')) { } if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) { - die('Wrong file name.'); + exit('Wrong file name.'); } $filename = 'css/' . $regs[1]; @@ -74,7 +74,7 @@ if (!class_exists('File')) { $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]); if (!file_exists($filepath)) { - die('Wrong file name.'); + exit('Wrong file name.'); } if (file_exists($cachepath)) { diff --git a/cake/console/libs/templates/skel/webroot/test.php b/cake/console/libs/templates/skel/webroot/test.php index a57d15747..1d668947b 100644 --- a/cake/console/libs/templates/skel/webroot/test.php +++ b/cake/console/libs/templates/skel/webroot/test.php @@ -95,7 +95,7 @@ if (isset($corePath[0])) { require_once CAKE_TESTS_LIB . 'test_manager.php'; if (Configure::read('debug') < 1) { - die(__('Debug setting does not allow access to this url.', true)); + exit(__('Debug setting does not allow access to this url.', true)); } if (!isset($_SERVER['SERVER_NAME'])) { diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index a49b39abb..b5693da97 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -218,7 +218,7 @@ class Debugger extends Object { } if ($error == 'Fatal Error') { - die(); + exit(); } return true; } diff --git a/cake/libs/model/datasources/dbo/dbo_odbc.php b/cake/libs/model/datasources/dbo/dbo_odbc.php index e68948668..c6af41d25 100644 --- a/cake/libs/model/datasources/dbo/dbo_odbc.php +++ b/cake/libs/model/datasources/dbo/dbo_odbc.php @@ -95,7 +95,7 @@ class DboOdbc extends DboSource { $connect = 'odbc_connect'; } if (!function_exists($connect)) { - die('no odbc?'); + exit('no odbc?'); } $this->connected = false; $this->connection = $connect($config['database'], $config['login'], $config['password'], SQL_CUR_USE_ODBC); diff --git a/cake/tests/test_app/config/acl.ini.php b/cake/tests/test_app/config/acl.ini.php index 351f02c99..9ac2b5d60 100644 --- a/cake/tests/test_app/config/acl.ini.php +++ b/cake/tests/test_app/config/acl.ini.php @@ -1,4 +1,4 @@ -; +; ; SVN FILE: $Id$ ;/** ; * Test App Ini Based Acl Config File From df9e1e0bd1a1445e3854c41f5af6d1f2a7679476 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:13:35 -0200 Subject: [PATCH 06/19] Replace function join (alias) by implode. Signed-off-by: Mark Story --- cake/basics.php | 4 +- cake/console/libs/console.php | 2 +- cake/console/libs/tasks/controller.php | 6 +-- cake/console/libs/tasks/extract.php | 14 +++---- cake/console/libs/tasks/model.php | 12 +++--- .../skel/controllers/pages_controller.php | 2 +- cake/libs/controller/components/security.php | 2 +- cake/libs/controller/pages_controller.php | 2 +- cake/libs/debugger.php | 8 ++-- cake/libs/flay.php | 2 +- cake/libs/http_socket.php | 8 ++-- cake/libs/inflector.php | 8 ++-- cake/libs/model/behaviors/containable.php | 2 +- cake/libs/model/datasources/dbo/dbo_mssql.php | 4 +- cake/libs/model/datasources/dbo/dbo_mysql.php | 8 ++-- .../libs/model/datasources/dbo/dbo_oracle.php | 8 ++-- .../model/datasources/dbo/dbo_postgres.php | 10 ++--- .../libs/model/datasources/dbo/dbo_sqlite.php | 4 +- cake/libs/model/datasources/dbo_source.php | 38 +++++++++---------- cake/libs/model/model.php | 4 +- cake/libs/model/schema.php | 10 ++--- cake/libs/router.php | 8 ++-- cake/libs/set.php | 2 +- cake/libs/view/helper.php | 4 +- cake/libs/view/helpers/ajax.php | 8 ++-- cake/libs/view/helpers/form.php | 6 +-- cake/libs/view/helpers/html.php | 12 +++--- cake/libs/view/helpers/javascript.php | 4 +- cake/libs/view/helpers/js.php | 8 ++-- cake/libs/view/helpers/rss.php | 4 +- cake/libs/view/view.php | 2 +- cake/tests/lib/cake_test_case.php | 4 +- cake/tests/lib/test_manager.php | 2 +- 33 files changed, 111 insertions(+), 111 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index 8a9c7b527..0659d28ec 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -423,7 +423,7 @@ if (!function_exists('file_put_contents')) { /** * Writes data into file. * - * If file exists, it will be overwritten. If data is an array, it will be join()ed with an empty string. + * If file exists, it will be overwritten. If data is an array, it will be implode()ed with an empty string. * * @param string $fileName File name. * @param mixed $data String or array. @@ -431,7 +431,7 @@ if (!function_exists('file_put_contents')) { */ function file_put_contents($fileName, $data) { if (is_array($data)) { - $data = join('', $data); + $data = implode('', $data); } $res = @fopen($fileName, 'w+b'); diff --git a/cake/console/libs/console.php b/cake/console/libs/console.php index 19b075092..189da32e8 100644 --- a/cake/console/libs/console.php +++ b/cake/console/libs/console.php @@ -286,7 +286,7 @@ class ConsoleShell extends Shell { break; case (preg_match("/^routes\s+show/i", $command, $tmp) == true): $router =& Router::getInstance(); - $this->out(join("\n", Set::extract($router->routes, '{n}.0'))); + $this->out(implode("\n", Set::extract($router->routes, '{n}.0'))); break; case (preg_match("/^route\s+(.*)/i", $command, $tmp) == true): $this->out(var_export(Router::parse($tmp[1]), true)); diff --git a/cake/console/libs/tasks/controller.php b/cake/console/libs/tasks/controller.php index c49735ed8..428cdcebe 100644 --- a/cake/console/libs/tasks/controller.php +++ b/cake/console/libs/tasks/controller.php @@ -126,7 +126,7 @@ class ControllerTask extends Shell { if (file_exists($this->path . $controllerFile .'_controller.php')) { $question[] = sprintf(__("Warning: Choosing no will overwrite the %sController.", true), $controllerName); } - $doItInteractive = $this->in(join("\n", $question), array('y','n'), 'y'); + $doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y'); if (strtolower($doItInteractive) == 'y' || strtolower($doItInteractive) == 'yes') { $this->interactive = true; @@ -313,7 +313,7 @@ class ControllerTask extends Shell { } } if (!empty($compact)) { - $actions .= "\t\t\$this->set(compact(" . join(', ', $compact) . "));\n"; + $actions .= "\t\t\$this->set(compact(" . implode(', ', $compact) . "));\n"; } $actions .= "\t}\n"; $actions .= "\n"; @@ -365,7 +365,7 @@ class ControllerTask extends Shell { } } if (!empty($compact)) { - $actions .= "\t\t\$this->set(compact(" . join(',', $compact) . "));\n"; + $actions .= "\t\t\$this->set(compact(" . implode(',', $compact) . "));\n"; } $actions .= "\t}\n"; $actions .= "\n"; diff --git a/cake/console/libs/tasks/extract.php b/cake/console/libs/tasks/extract.php index 7918e8cd7..1e4f75e9e 100644 --- a/cake/console/libs/tasks/extract.php +++ b/cake/console/libs/tasks/extract.php @@ -414,13 +414,13 @@ class ExtractTask extends Shell{ if ($this->__oneFile === true) { foreach ($fileInfo as $file => $lines) { - $occured[] = "$file:" . join(';', $lines); + $occured[] = "$file:" . implode(';', $lines); if (isset($this->__fileVersions[$file])) { $fileList[] = $this->__fileVersions[$file]; } } - $occurances = join("\n#: ", $occured); + $occurances = implode("\n#: ", $occured); $occurances = str_replace($this->path, '', $occurances); $output = "#: $occurances\n"; $filename = $this->__filename; @@ -439,12 +439,12 @@ class ExtractTask extends Shell{ } else { foreach ($fileInfo as $file => $lines) { $filename = $str; - $occured = array("$str:" . join(';', $lines)); + $occured = array("$str:" . implode(';', $lines)); if (isset($this->__fileVersions[$str])) { $fileList[] = $this->__fileVersions[$str]; } - $occurances = join("\n#: ", $occured); + $occurances = implode("\n#: ", $occured); $occurances = str_replace($this->path, '', $occurances); $output .= "#: $occurances\n"; @@ -511,9 +511,9 @@ class ExtractTask extends Shell{ $fileList = str_replace(array($this->path), '', $fileList); if (count($fileList) > 1) { - $fileList = "Generated from files:\n# " . join("\n# ", $fileList); + $fileList = "Generated from files:\n# " . implode("\n# ", $fileList); } elseif (count($fileList) == 1) { - $fileList = 'Generated from file: ' . join('', $fileList); + $fileList = 'Generated from file: ' . implode('', $fileList); } else { $fileList = 'No version information was available in the source files.'; } @@ -535,7 +535,7 @@ class ExtractTask extends Shell{ } } $fp = fopen($this->__output . $file, 'w'); - fwrite($fp, str_replace('--VERSIONS--', $fileList, join('', $content))); + fwrite($fp, str_replace('--VERSIONS--', $fileList, implode('', $content))); fclose($fp); } } diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 0292f74ae..654911932 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -700,7 +700,7 @@ class ModelTask extends Shell { } } } - $fixture = join(", ", $fixture); + $fixture = implode(", ", $fixture); $import = $className; if (isset($this->plugin)) { @@ -904,24 +904,24 @@ class ModelTask extends Shell { } $records[] = "\t\t'$field' => $insert"; unset($value['type']); - $col .= join(', ', $schema->__values($value)); + $col .= implode(', ', $schema->__values($value)); } else { $col = "\t\t'indexes' => array("; $props = array(); foreach ((array)$value as $key => $index) { - $props[] = "'{$key}' => array(" . join(', ', $schema->__values($index)) . ")"; + $props[] = "'{$key}' => array(" . implode(', ', $schema->__values($index)) . ")"; } - $col .= join(', ', $props); + $col .= implode(', ', $props); } $col .= ")"; $cols[] = $col; } - $out .= join(",\n", $cols); + $out .= implode(",\n", $cols); } $out .= "\n\t);\n"; } } - $records = join(",\n", $records); + $records = implode(",\n", $records); $out .= "\tvar \$records = array(array(\n$records\n\t));\n"; $out .= "}\n"; $path = TESTS . DS . 'fixtures' . DS; diff --git a/cake/console/libs/templates/skel/controllers/pages_controller.php b/cake/console/libs/templates/skel/controllers/pages_controller.php index 8196616ba..7013b6e17 100644 --- a/cake/console/libs/templates/skel/controllers/pages_controller.php +++ b/cake/console/libs/templates/skel/controllers/pages_controller.php @@ -79,7 +79,7 @@ class PagesController extends AppController { $title = Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title')); - $this->render(join('/', $path)); + $this->render(implode('/', $path)); } } diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 64e0af936..2e44f45e6 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -327,7 +327,7 @@ class SecurityComponent extends Object { $out[] = 'opaque="' . md5($options['realm']).'"'; } - return $auth . ' ' . join(',', $out); + return $auth . ' ' . implode(',', $out); } /** * Parses an HTTP digest authentication response, and returns an array of the data, or null on failure. diff --git a/cake/libs/controller/pages_controller.php b/cake/libs/controller/pages_controller.php index 8196616ba..7013b6e17 100644 --- a/cake/libs/controller/pages_controller.php +++ b/cake/libs/controller/pages_controller.php @@ -79,7 +79,7 @@ class PagesController extends AppController { $title = Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title')); - $this->render(join('/', $path)); + $this->render(implode('/', $path)); } } diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index b5693da97..42d47916c 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -275,7 +275,7 @@ class Debugger extends Object { foreach ($next['args'] as $arg) { $args[] = Debugger::exportVar($arg); } - $function .= join(', ', $args); + $function .= implode(', ', $args); } $function .= ')'; } @@ -297,7 +297,7 @@ class Debugger extends Object { if ($options['format'] == 'array' || $options['format'] == 'points') { return $back; } - return join("\n", $back); + return implode("\n", $back); } /** * Shortens file paths by replacing the application base path with 'APP', and the CakePHP core @@ -406,7 +406,7 @@ class Debugger extends Object { if (count($vars) > 0) { $n = "\n"; } - return $out . join(",", $vars) . "{$n})"; + return $out . implode(",", $vars) . "{$n})"; break; case 'resource': return strtolower(gettype($var)); @@ -444,7 +444,7 @@ class Debugger extends Object { $out[] = "$className::$$key = " . $value; } } - return join("\n", $out); + return implode("\n", $out); } /** * Handles object conversion to debug string. diff --git a/cake/libs/flay.php b/cake/libs/flay.php index ed23cf7f4..7d33b4a5e 100644 --- a/cake/libs/flay.php +++ b/cake/libs/flay.php @@ -217,7 +217,7 @@ class Flay extends Object{ if (count($snips) > $max_snippets) { $snips = array_slice($snips, 0, $max_snippets); } - $joined = join(' ... ', $snips); + $joined = implode(' ... ', $snips); $snips = $joined ? "... {$joined} ..." : substr($string, 0, 80) . '...'; return $this->colorMark($words, $snips); } diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 97d2e080b..d0bf021df 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -738,7 +738,7 @@ class HttpSocket extends CakeSocket { $request['uri'] = $this->buildUri($request['uri'], '/%path?%query'); if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { - trigger_error(sprintf(__('HttpSocket::buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', true), join(',', $asteriskMethods)), E_USER_WARNING); + trigger_error(sprintf(__('HttpSocket::buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', true), implode(',', $asteriskMethods)), E_USER_WARNING); return false; } return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak; @@ -776,7 +776,7 @@ class HttpSocket extends CakeSocket { $returnHeader = ''; foreach ($header as $field => $contents) { if (is_array($contents) && $mode == 'standard') { - $contents = join(',', $contents); + $contents = implode(',', $contents); } foreach ((array)$contents as $content) { $contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content); @@ -921,7 +921,7 @@ class HttpSocket extends CakeSocket { * @todo Test $chars parameter */ function unescapeToken($token, $chars = null) { - $regex = '/"(['.join('', $this->__tokenEscapeChars(true, $chars)).'])"/'; + $regex = '/"(['.implode('', $this->__tokenEscapeChars(true, $chars)).'])"/'; $token = preg_replace($regex, '\\1', $token); return $token; } @@ -934,7 +934,7 @@ class HttpSocket extends CakeSocket { * @todo Test $chars parameter */ function escapeToken($token, $chars = null) { - $regex = '/(['.join('', $this->__tokenEscapeChars(true, $chars)).'])/'; + $regex = '/(['.implode('', $this->__tokenEscapeChars(true, $chars)).'])/'; $token = preg_replace($regex, '"\\1"', $token); return $token; } diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index 863072dfd..66a9f10bd 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -243,8 +243,8 @@ class Inflector extends Object { extract($_this->pluralRules); if (!isset($regexUninflected) || !isset($regexIrregular)) { - $regexUninflected = __enclose(join( '|', $uninflected)); - $regexIrregular = __enclose(join( '|', array_keys($irregular))); + $regexUninflected = __enclose(implode( '|', $uninflected)); + $regexIrregular = __enclose(implode( '|', array_keys($irregular))); $_this->pluralRules['regexUninflected'] = $regexUninflected; $_this->pluralRules['regexIrregular'] = $regexIrregular; } @@ -383,8 +383,8 @@ class Inflector extends Object { extract($_this->singularRules); if (!isset($regexUninflected) || !isset($regexIrregular)) { - $regexUninflected = __enclose(join( '|', $uninflected)); - $regexIrregular = __enclose(join( '|', array_keys($irregular))); + $regexUninflected = __enclose(implode( '|', $uninflected)); + $regexIrregular = __enclose(implode( '|', array_keys($irregular))); $_this->singularRules['regexUninflected'] = $regexUninflected; $_this->singularRules['regexIrregular'] = $regexIrregular; } diff --git a/cake/libs/model/behaviors/containable.php b/cake/libs/model/behaviors/containable.php index 9bec011a2..b5e8eadf9 100644 --- a/cake/libs/model/behaviors/containable.php +++ b/cake/libs/model/behaviors/containable.php @@ -283,7 +283,7 @@ class ContainableBehavior extends ModelBehavior { if (strpos($name, '.') !== false) { $chain = explode('.', $name); $name = array_shift($chain); - $children = array(join('.', $chain) => $children); + $children = array(implode('.', $chain) => $children); } $children = (array)$children; diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index 9e5cad49a..09e9d1ab7 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -591,7 +591,7 @@ class DboMssql extends DboSource { foreach (array('columns', 'indexes') as $var) { if (is_array(${$var})) { - ${$var} = "\t" . join(",\n\t", array_filter(${$var})); + ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); } } return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}"; @@ -719,7 +719,7 @@ class DboMssql extends DboSource { $out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE"; if (is_array($value['column'])) { - $value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); } else { $value['column'] = $this->name($value['column']); } diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index ef61cb675..395d2a78f 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -141,7 +141,7 @@ class DboMysqlBase extends DboSource { $alias = $joins = false; $fields = $this->_prepareUpdateFields($model, $combined, empty($conditions), !empty($conditions)); - $fields = join(', ', $fields); + $fields = implode(', ', $fields); $table = $this->fullTableName($model); if (!empty($conditions)) { @@ -281,7 +281,7 @@ class DboMysqlBase extends DboSource { } } $colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes)); - $out .= "\t" . join(",\n\t", $colList) . ";\n\n"; + $out .= "\t" . implode(",\n\t", $colList) . ";\n\n"; } } return $out; @@ -339,7 +339,7 @@ class DboMysqlBase extends DboSource { } } if (is_array($value['column'])) { - $out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; + $out .= 'KEY '. $name .' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; } else { $out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')'; } @@ -358,7 +358,7 @@ class DboMysqlBase extends DboSource { function insertMulti($table, $fields, $values) { $table = $this->fullTableName($table); if (is_array($fields)) { - $fields = join(', ', array_map(array(&$this, 'name'), $fields)); + $fields = implode(', ', array_map(array(&$this, 'name'), $fields)); } $values = implode(', ', $values); $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}"); diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index a71a4b1e2..92c81e897 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -704,7 +704,7 @@ class DboOracle extends DboSource { break; } } - $out .= "\t" . join(",\n\t", $colList) . ";\n\n"; + $out .= "\t" . implode(",\n\t", $colList) . ";\n\n"; } } return $out; @@ -925,7 +925,7 @@ class DboOracle extends DboSource { case 'schema': foreach (array('columns', 'indexes') as $var) { if (is_array(${$var})) { - ${$var} = "\t" . join(",\n\t", array_filter(${$var})); + ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); } } if (trim($indexes) != '') { @@ -977,7 +977,7 @@ class DboOracle extends DboSource { $fetch = array(); $ins = array_chunk($ins, 1000); foreach ($ins as $i) { - $q = str_replace('{$__cakeID__$}', join(', ', $i), $query); + $q = str_replace('{$__cakeID__$}', implode(', ', $i), $query); $q = str_replace('= (', 'IN (', $q); $res = $this->fetchAll($q, $model->cacheQueries, $model->alias); $fetch = array_merge($fetch, $res); @@ -1021,7 +1021,7 @@ class DboOracle extends DboSource { $fetch = array(); $ins = array_chunk($ins, 1000); foreach ($ins as $i) { - $q = str_replace('{$__cakeID__$}', '(' .join(', ', $i) .')', $query); + $q = str_replace('{$__cakeID__$}', '(' .implode(', ', $i) .')', $query); $q = str_replace('= (', 'IN (', $q); $q = str_replace(' WHERE 1 = 1', '', $q); diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 3ea5d8fa0..9dc21da27 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -539,11 +539,11 @@ class DboPostgres extends DboSource { } if (!empty($colList)) { - $out .= "\t" . join(",\n\t", $colList) . ";\n\n"; + $out .= "\t" . implode(",\n\t", $colList) . ";\n\n"; } else { $out = ''; } - $out .= join(";\n\t", $this->_alterIndexes($curTable, $indexes)) . ";"; + $out .= implode(";\n\t", $this->_alterIndexes($curTable, $indexes)) . ";"; } } return $out; @@ -580,7 +580,7 @@ class DboPostgres extends DboSource { $out .= 'INDEX '; } if (is_array($value['column'])) { - $out .= $name . ' ON ' . $table . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; + $out .= $name . ' ON ' . $table . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; } else { $out .= $name . ' ON ' . $table . ' (' . $this->name($value['column']) . ')'; } @@ -829,7 +829,7 @@ class DboPostgres extends DboSource { $out .= 'UNIQUE '; } if (is_array($value['column'])) { - $value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); } else { $value['column'] = $this->name($value['column']); } @@ -862,7 +862,7 @@ class DboPostgres extends DboSource { foreach (array('columns', 'indexes') as $var) { if (is_array(${$var})) { - ${$var} = join($join[$var], array_filter(${$var})); + ${$var} = implode($join[$var], array_filter(${$var})); } } return "CREATE TABLE {$table} (\n\t{$columns}\n);\n{$indexes}"; diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 005ffc6fe..1423aadcf 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -529,7 +529,7 @@ class DboSqlite extends DboSource { $out .= 'UNIQUE '; } if (is_array($value['column'])) { - $value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); } else { $value['column'] = $this->name($value['column']); } @@ -589,7 +589,7 @@ class DboSqlite extends DboSource { foreach (array('columns', 'indexes') as $var) { if (is_array(${$var})) { - ${$var} = "\t" . join(",\n\t", array_filter(${$var})); + ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); } } return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}"; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index ec154f25e..a48a3c6a2 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -580,8 +580,8 @@ class DboSource extends DataSource { } $query = array( 'table' => $this->fullTableName($model), - 'fields' => join(', ', $fieldInsert), - 'values' => join(', ', $valueInsert) + 'fields' => implode(', ', $fieldInsert), + 'values' => implode(', ', $valueInsert) ); if ($this->execute($this->renderStatement('create', $query))) { @@ -796,7 +796,7 @@ class DboSource extends DataSource { } if (!empty($ins)) { if (count($ins) > 1) { - $query = str_replace('{$__cakeID__$}', '(' .join(', ', $ins) .')', $query); + $query = str_replace('{$__cakeID__$}', '(' .implode(', ', $ins) .')', $query); $query = str_replace('= (', 'IN (', $query); $query = str_replace('= (', 'IN (', $query); } else { @@ -895,7 +895,7 @@ class DboSource extends DataSource { * @return array Association results */ function fetchAssociated($model, $query, $ids) { - $query = str_replace('{$__cakeID__$}', join(', ', $ids), $query); + $query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query); if (count($ids) > 1) { $query = str_replace('= (', 'IN (', $query); $query = str_replace('= (', 'IN (', $query); @@ -1272,12 +1272,12 @@ class DboSource extends DataSource { } return $this->renderStatement('select', array( 'conditions' => $this->conditions($query['conditions'], true, true, $model), - 'fields' => join(', ', $query['fields']), + 'fields' => implode(', ', $query['fields']), 'table' => $query['table'], 'alias' => $this->alias . $this->name($query['alias']), 'order' => $this->order($query['order']), 'limit' => $this->limit($query['limit'], $query['offset']), - 'joins' => join(' ', $query['joins']), + 'joins' => implode(' ', $query['joins']), 'group' => $this->group($query['group']) )); } @@ -1324,7 +1324,7 @@ class DboSource extends DataSource { case 'schema': foreach (array('columns', 'indexes') as $var) { if (is_array(${$var})) { - ${$var} = "\t" . join(",\n\t", array_filter(${$var})); + ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); } } if (trim($indexes) != '') { @@ -1378,7 +1378,7 @@ class DboSource extends DataSource { } else { $combined = array_combine($fields, $values); } - $fields = join(', ', $this->_prepareUpdateFields($model, $combined, empty($conditions))); + $fields = implode(', ', $this->_prepareUpdateFields($model, $combined, empty($conditions))); $alias = $joins = null; $table = $this->fullTableName($model); @@ -1728,7 +1728,7 @@ class DboSource extends DataSource { } else { $field[0] = explode('.', $field[1]); if (!Set::numeric($field[0])) { - $field[0] = join('.', array_map(array($this, 'name'), $field[0])); + $field[0] = implode('.', array_map(array($this, 'name'), $field[0])); $fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1); } } @@ -1760,7 +1760,7 @@ class DboSource extends DataSource { if (empty($out)) { return $clause . ' 1 = 1'; } - return $clause . join(' AND ', $out); + return $clause . implode(' AND ', $out); } if (empty($conditions) || trim($conditions) == '' || $conditions === true) { @@ -1829,7 +1829,7 @@ class DboSource extends DataSource { $out[] = $value[0] ; } } else { - $out[] = '(' . $not . '(' . join(') ' . strtoupper($key) . ' (', $value) . '))'; + $out[] = '(' . $not . '(' . implode(') ' . strtoupper($key) . ' (', $value) . '))'; } } else { @@ -1856,13 +1856,13 @@ class DboSource extends DataSource { if (is_object($model)) { $columnType = $model->getColumnType($key); } - $data .= join(', ', $this->value($value, $columnType)); + $data .= implode(', ', $this->value($value, $columnType)); } $data .= ')'; } else { $ret = $this->conditionKeysToString($value, $quoteValues, $model); if (count($ret) > 1) { - $data = '(' . join(') AND (', $ret) . ')'; + $data = '(' . implode(') AND (', $ret) . ')'; } elseif (isset($ret[0])) { $data = $ret[0]; } @@ -1896,7 +1896,7 @@ class DboSource extends DataSource { * @access private */ function __parseKey($model, $key, $value) { - $operatorMatch = '/^((' . join(')|(', $this->__sqlOps); + $operatorMatch = '/^((' . implode(')|(', $this->__sqlOps); $operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); @@ -1942,7 +1942,7 @@ class DboSource extends DataSource { $operator = trim($operator); if (is_array($value)) { - $value = join(', ', $value); + $value = implode(', ', $value); switch ($operator) { case '=': @@ -2069,7 +2069,7 @@ class DboSource extends DataSource { } $order[] = $this->order($key . $value); } - return ' ORDER BY ' . trim(str_replace('ORDER BY', '', join(',', $order))); + return ' ORDER BY ' . trim(str_replace('ORDER BY', '', implode(',', $order))); } $keys = preg_replace('/ORDER\\x20BY/i', '', $keys); @@ -2100,7 +2100,7 @@ class DboSource extends DataSource { function group($group) { if ($group) { if (is_array($group)) { - $group = join(', ', $group); + $group = implode(', ', $group); } return ' GROUP BY ' . $this->__quoteFields($group); } @@ -2224,7 +2224,7 @@ class DboSource extends DataSource { function insertMulti($table, $fields, $values) { $table = $this->fullTableName($table); if (is_array($fields)) { - $fields = join(', ', array_map(array(&$this, 'name'), $fields)); + $fields = implode(', ', array_map(array(&$this, 'name'), $fields)); } $count = count($values); for ($x = 0; $x < $count; $x++) { @@ -2396,7 +2396,7 @@ class DboSource extends DataSource { $name = $this->startQuote . $name . $this->endQuote; } if (is_array($value['column'])) { - $out .= 'KEY ' . $name . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; + $out .= 'KEY ' . $name . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; } else { $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')'; } diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 4f1934def..bfc24f4ba 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1340,7 +1340,7 @@ class Model extends Overloadable { if ($isUUID && $primaryAdded) { $values[] = $db->value(String::uuid()); } - $values = join(',', $values); + $values = implode(',', $values); $newValues[] = "({$values})"; unset($values); } elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) { @@ -1368,7 +1368,7 @@ class Model extends Overloadable { } if (!empty($newValues)) { - $fields = join(',', $fields); + $fields = implode(',', $fields); $db->insertMulti($this->{$join}, $fields, $newValues); } } diff --git a/cake/libs/model/schema.php b/cake/libs/model/schema.php index d03689926..d607dbf57 100644 --- a/cake/libs/model/schema.php +++ b/cake/libs/model/schema.php @@ -334,19 +334,19 @@ class CakeSchema extends Object { } $col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', "; unset($value['type']); - $col .= join(', ', $this->__values($value)); + $col .= implode(', ', $this->__values($value)); } else { $col = "\t\t'indexes' => array("; $props = array(); foreach ((array)$value as $key => $index) { - $props[] = "'{$key}' => array(" . join(', ', $this->__values($index)) . ")"; + $props[] = "'{$key}' => array(" . implode(', ', $this->__values($index)) . ")"; } - $col .= join(', ', $props); + $col .= implode(', ', $props); } $col .= ")"; $cols[] = $col; } - $out .= join(",\n", $cols); + $out .= implode(",\n", $cols); } $out .= "\n\t);\n"; } @@ -447,7 +447,7 @@ class CakeSchema extends Object { if (is_array($values)) { foreach ($values as $key => $val) { if (is_array($val)) { - $vals[] = "'{$key}' => array('" . join("', '", $val) . "')"; + $vals[] = "'{$key}' => array('" . implode("', '", $val) . "')"; } else if (!is_numeric($key)) { $val = var_export($val, true); $vals[] = "'{$key}' => {$val}"; diff --git a/cake/libs/router.php b/cake/libs/router.php index 6bb72b440..083787c69 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -378,7 +378,7 @@ class Router extends Object { $parsed[] = '/' . $element; } } - return array('#^' . join('', $parsed) . '[\/]*$#', $names); + return array('#^' . implode('', $parsed) . '[\/]*$#', $names); } /** * Returns the list of prefixes used in connected routes @@ -880,11 +880,11 @@ class Router extends Object { if ($_this->__admin && isset($url[$_this->__admin])) { array_unshift($urlOut, $_this->__admin); } - $output = join('/', $urlOut) . '/'; + $output = implode('/', $urlOut) . '/'; } if (!empty($args)) { - $args = join('/', $args); + $args = implode('/', $args); if ($output{strlen($output) - 1} != '/') { $args = '/'. $args; } @@ -1066,7 +1066,7 @@ class Router extends Object { for ($i = 0; $i < $count; $i++) { $named[] = $keys[$i] . $this->named['separator'] . $params['named'][$keys[$i]]; } - $params['named'] = join('/', $named); + $params['named'] = implode('/', $named); } $params['pass'] = str_replace('//', '/', $params['pass'] . '/' . $params['named']); } diff --git a/cake/libs/set.php b/cake/libs/set.php index 230e22fad..11382e4dc 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -413,7 +413,7 @@ class Set extends Object { if (count($context['trace']) == 1) { $context['trace'][] = $context['key']; } - $parent = join('/', $context['trace']) . '/.'; + $parent = implode('/', $context['trace']) . '/.'; $context['item'] = Set::extract($parent, $data); $context['key'] = array_pop($context['trace']); if (isset($context['trace'][1]) && $context['trace'][1] > 0) { diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 076622c73..3cdec2c2f 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -313,7 +313,7 @@ class Helper extends Overloadable { if ($setScope) { $view->modelScope = false; - } elseif (join('.', $view->entity()) == $entity) { + } elseif (implode('.', $view->entity()) == $entity) { return; } @@ -530,7 +530,7 @@ class Helper extends Overloadable { $name = $field; break; default: - $name = 'data[' . join('][', $view->entity()) . ']'; + $name = 'data[' . implode('][', $view->entity()) . ']'; break; } diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index ed0de9782..d2eda08db 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -251,7 +251,7 @@ class AjaxHelper extends AppHelper { $options['requestHeaders'] = array(); } if (is_array($options['update'])) { - $options['update'] = join(' ', $options['update']); + $options['update'] = implode(' ', $options['update']); } $options['requestHeaders']['X-Update'] = $options['update']; } else { @@ -799,7 +799,7 @@ class AjaxHelper extends AppHelper { $keys[] = "'" . $key . "'"; $keys[] = "'" . $val . "'"; } - $jsOptions['requestHeaders'] = '[' . join(', ', $keys) . ']'; + $jsOptions['requestHeaders'] = '[' . implode(', ', $keys) . ']'; break; } } @@ -846,7 +846,7 @@ class AjaxHelper extends AppHelper { } } - $out = join(', ', $out); + $out = implode(', ', $out); $out = '{' . $out . '}'; return $out; } else { @@ -965,7 +965,7 @@ class AjaxHelper extends AppHelper { $data[] = $key . ':"' . rawurlencode($val) . '"'; } } - $out = 'var __ajaxUpdater__ = {' . join(", \n", $data) . '};' . "\n"; + $out = 'var __ajaxUpdater__ = {' . implode(", \n", $data) . '};' . "\n"; $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"'; $out .= ' && $(n)) Element.update($(n), unescape(decodeURIComponent('; $out .= '__ajaxUpdater__[n]))); }'; diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index e1f3c4422..6e47d44cf 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -355,7 +355,7 @@ class FormHelper extends AppHelper { } } } - $field = join('.', $field); + $field = implode('.', $field); if (!in_array($field, $this->fields)) { if ($value !== null) { return $this->fields[$field] = $value; @@ -585,7 +585,7 @@ class FormHelper extends AppHelper { function input($fieldName, $options = array()) { $view =& ClassRegistry::getObject('view'); $this->setEntity($fieldName); - $entity = join('.', $view->entity()); + $entity = implode('.', $view->entity()); $defaults = array('before' => null, 'between' => null, 'after' => null); $options = array_merge($defaults, $options); @@ -952,7 +952,7 @@ class FormHelper extends AppHelper { 'id' => $attributes['id'] . '_', 'value' => '', 'name' => $attributes['name'] )); } - $out = $hidden . join($inbetween, $out); + $out = $hidden . implode($inbetween, $out); if ($legend) { $out = sprintf( diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 8ef8406ec..b5be53a74 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -398,9 +398,9 @@ class HtmlHelper extends AppHelper { $out[] = $key.':'.$value.';'; } if ($inline) { - return join(' ', $out); + return implode(' ', $out); } - return join("\n", $out); + return implode("\n", $out); } /** * Returns the breadcrumb trail as a sequence of »-separated links. @@ -423,7 +423,7 @@ class HtmlHelper extends AppHelper { $out[] = $crumb[0]; } } - return $this->output(join($separator, $out)); + return $this->output(implode($separator, $out)); } else { return null; } @@ -481,7 +481,7 @@ class HtmlHelper extends AppHelper { foreach ($names as $arg) { $out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg); } - $data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); + $data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), implode(' ', $out)); return $this->output($data); } /** @@ -531,9 +531,9 @@ class HtmlHelper extends AppHelper { $cellsOut[] = sprintf($this->tags['tablecell'], $this->_parseAttributes($cellOptions), $cell); } $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); - $out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); + $out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut)); } - return $this->output(join("\n", $out)); + return $this->output(implode("\n", $out)); } /** * Returns a formatted block tag, i.e DIV, SPAN, P. diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index aa8d7577f..ec68f6580 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -649,9 +649,9 @@ class JavascriptHelper extends AppHelper { } if (!$numeric) { - $rt = '{' . join(',', $out) . '}'; + $rt = '{' . implode(',', $out) . '}'; } else { - $rt = '[' . join(',', $out) . ']'; + $rt = '[' . implode(',', $out) . ']'; } } $rt = $options['prefix'] . $rt . $options['postfix']; diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 15e25099f..b13bc9c33 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -128,7 +128,7 @@ class JsHelper extends Overloadable2 { $options['requestHeaders'] = array(); } if (is_array($options['update'])) { - $options['update'] = join(' ', $options['update']); + $options['update'] = implode(' ', $options['update']); } $options['requestHeaders']['X-Update'] = $options['update']; } else { @@ -257,9 +257,9 @@ class JsHelper extends Overloadable2 { } if (!$numeric) { - $rt = '{' . join(', ', $out) . '}'; + $rt = '{' . implode(', ', $out) . '}'; } else { - $rt = '[' . join(', ', $out) . ']'; + $rt = '[' . implode(', ', $out) . ']'; } $rt = $prefix . $rt . $postfix; @@ -445,7 +445,7 @@ class JsHelperObject { } $options[] = $key . ':' . $val; } - return join(', ', $options); + return implode(', ', $options); } } ?> \ No newline at end of file diff --git a/cake/libs/view/helpers/rss.php b/cake/libs/view/helpers/rss.php index a7889a2e0..5b8cb8362 100644 --- a/cake/libs/view/helpers/rss.php +++ b/cake/libs/view/helpers/rss.php @@ -209,7 +209,7 @@ class RssHelper extends XmlHelper { } $categories[] = $this->elem($key, $attrib, $category); } - $elements[$key] = join('', $categories); + $elements[$key] = implode('', $categories); continue 2; } else if (is_array($val) && isset($val['domain'])) { $attrib['domain'] = $val['domain']; @@ -259,7 +259,7 @@ class RssHelper extends XmlHelper { $elements[$key] = $this->elem($key, $attrib, $val); } if (!empty($elements)) { - $content = join('', $elements); + $content = implode('', $elements); } return $this->output($this->elem('item', $att, $content, !($content === null))); } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 199359f9f..655e6d266 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -437,7 +437,7 @@ class View extends Object { $data_for_layout = array_merge($this->viewVars, array( 'title_for_layout' => $pageTitle, 'content_for_layout' => $content_for_layout, - 'scripts_for_layout' => join("\n\t", $this->__scripts), + 'scripts_for_layout' => implode("\n\t", $this->__scripts), 'cakeDebug' => $debug )); diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index f642e36a1..c0d0bc451 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -634,10 +634,10 @@ class CakeTestCase extends UnitTestCase { $permutations = $this->__array_permute($attrs); $permutationTokens = array(); foreach ($permutations as $permutation) { - $permutationTokens[] = join('', $permutation); + $permutationTokens[] = implode('', $permutation); } $regex[] = array( - sprintf('%s', join(', ', $explanations)), + sprintf('%s', implode(', ', $explanations)), $permutationTokens, $i, ); diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index d614ed6d0..00e540571 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -575,7 +575,7 @@ class HtmlTestManager extends TestManager { foreach ($testCases as $testCaseFile => $testCase) { $title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase)); $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]); - $title = join(' / ', $title); + $title = implode(' / ', $title); $buffer .= "
  • " . $title . "
  • \n"; } From 911a99bf232b81ac320f59add5f9a8d0a2e6e198 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:16:26 -0200 Subject: [PATCH 07/19] Replace function preg_split by explode when possible. Signed-off-by: Mark Story --- cake/dispatcher.php | 2 +- cake/libs/http_socket.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index c6be13c7d..f09e10997 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -515,7 +515,7 @@ class Dispatcher extends Object { if (key($_GET) && strpos(key($_GET), '?') !== false) { unset($_GET[key($_GET)]); } - $uri = preg_split('/\?/', $uri, 2); + $uri = explode('?', $uri, 2); if (isset($uri[1])) { parse_str($uri[1], $_GET); diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index d0bf021df..da8bd0268 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -854,7 +854,7 @@ class HttpSocket extends CakeSocket { foreach ((array)$header['Set-Cookie'] as $cookie) { if (strpos($cookie, '";"') !== false) { $cookie = str_replace('";"', "{__cookie_replace__}", $cookie); - $parts = str_replace("{__cookie_replace__}", '";"', preg_split('/\;/', $cookie)); + $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); } else { $parts = preg_split('/\;[ \t]*/', $cookie); } From 1c0c1bc9c71da1ceb7bac9ea89fe0edf68d7dd25 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:17:47 -0200 Subject: [PATCH 08/19] Replace function split by explode when possible. Signed-off-by: Mark Story --- cake/console/libs/tasks/extract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/console/libs/tasks/extract.php b/cake/console/libs/tasks/extract.php index 1e4f75e9e..a956afd4d 100644 --- a/cake/console/libs/tasks/extract.php +++ b/cake/console/libs/tasks/extract.php @@ -263,9 +263,9 @@ class ExtractTask extends Shell{ } if (is_array($token)) { - $lineNumber += count(split("\n", $token[1])) - 1; + $lineNumber += count(explode("\n", $token[1])) - 1; } else { - $lineNumber += count(split("\n", $token)) - 1; + $lineNumber += count(explode("\n", $token)) - 1; } } unset($allTokens); From 1cef0ac98120c74dc8738cef849184b095fe2e18 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:21:14 -0200 Subject: [PATCH 09/19] Little optimization in postConditions of controller. Signed-off-by: Mark Story --- cake/libs/controller/controller.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 273d51e23..66569bca1 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -899,12 +899,14 @@ class Controller extends Object { foreach ($fields as $field => $value) { $key = $model.'.'.$field; $fieldOp = $op; - if (is_array($op) && array_key_exists($key, $op)) { - $fieldOp = $op[$key]; - } elseif (is_array($op) && array_key_exists($field, $op)) { - $fieldOp = $op[$field]; - } elseif (is_array($op)) { - $fieldOp = false; + if (is_array($op)) { + if (array_key_exists($key, $op)) { + $fieldOp = $op[$key]; + } elseif (array_key_exists($field, $op)) { + $fieldOp = $op[$field]; + } else { + $fieldOp = false; + } } if ($exclusive && $fieldOp === false) { continue; From 52fcabc96aac26ca7fb618b822e05777395dabe5 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:24:10 -0200 Subject: [PATCH 10/19] Little optimization in redirect of controller. Signed-off-by: Mark Story --- cake/libs/controller/controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 66569bca1..ce1b114d7 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -604,7 +604,7 @@ class Controller extends Object { 504 => 'Gateway Time-out' ); if (is_string($status)) { - $codes = array_combine(array_values($codes), array_keys($codes)); + $codes = array_flip($codes); } if (isset($codes[$status])) { From 71df8dbbba8ace80cd60b9019fc3ab65cca1df81 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 20:27:09 -0200 Subject: [PATCH 11/19] Replace function sizeof (alias) by count. Signed-off-by: Mark Story --- cake/libs/model/datasources/dbo/dbo_adodb.php | 2 +- cake/libs/validation.php | 4 ++-- cake/tests/cases/libs/model/behaviors/acl.test.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_adodb.php b/cake/libs/model/datasources/dbo/dbo_adodb.php index 45fa4048e..7feda9885 100644 --- a/cake/libs/model/datasources/dbo/dbo_adodb.php +++ b/cake/libs/model/datasources/dbo/dbo_adodb.php @@ -216,7 +216,7 @@ class DboAdodb extends DboSource { function listSources() { $tables = $this->_adodb->MetaTables('TABLES'); - if (!sizeof($tables) > 0) { + if (!count($tables) > 0) { trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE); exit; } diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 6531d97d9..22a1d1f62 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -636,10 +636,10 @@ class Validation extends Object { if (empty($check)) { return false; } - if ($options['max'] && sizeof($check) > $options['max']) { + if ($options['max'] && count($check) > $options['max']) { return false; } - if ($options['min'] && sizeof($check) < $options['min']) { + if ($options['min'] && count($check) < $options['min']) { return false; } if ($options['in'] && is_array($options['in'])) { diff --git a/cake/tests/cases/libs/model/behaviors/acl.test.php b/cake/tests/cases/libs/model/behaviors/acl.test.php index 3ca1974e3..4c8f70750 100644 --- a/cake/tests/cases/libs/model/behaviors/acl.test.php +++ b/cake/tests/cases/libs/model/behaviors/acl.test.php @@ -285,7 +285,7 @@ class AclBehaviorTestCase extends CakeTestCase { $this->assertEqual($result['Aro']['parent_id'], 5); $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8)); - $this->assertEqual(sizeof($node), 2); + $this->assertEqual(count($node), 2); $this->assertEqual($node[0]['Aro']['parent_id'], 5); $this->assertEqual($node[1]['Aro']['parent_id'], null); } @@ -315,7 +315,7 @@ class AclBehaviorTestCase extends CakeTestCase { $Person->save($data); $id = $Person->id; $node = $Person->node(); - $this->assertEqual(sizeof($node), 2); + $this->assertEqual(count($node), 2); $this->assertEqual($node[0]['Aro']['parent_id'], 5); $this->assertEqual($node[1]['Aro']['parent_id'], null); @@ -362,7 +362,7 @@ class AclBehaviorTestCase extends CakeTestCase { $Person->id = 2; $result = $Person->node(); $this->assertTrue(is_array($result)); - $this->assertEqual(sizeof($result), 1); + $this->assertEqual(count($result), 1); } } ?> \ No newline at end of file From a96c157d948e2f3c1fa55b5d422121c323859626 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Nov 2009 15:14:21 -0500 Subject: [PATCH 12/19] Applying optimizations to use of count() from 'jrbasso' --- cake/libs/configure.php | 2 +- cake/libs/controller/components/acl.php | 2 +- cake/libs/controller/controller.php | 4 +- cake/libs/debugger.php | 2 +- cake/libs/folder.php | 2 +- cake/libs/model/connection_manager.php | 2 +- cake/libs/model/datasources/dbo_source.php | 2 +- cake/libs/model/model.php | 2 +- cake/libs/multibyte.php | 91 +++++++++++++--------- cake/libs/sanitize.php | 2 +- cake/libs/set.php | 2 +- cake/libs/view/helpers/html.php | 2 +- cake/libs/xml.php | 8 +- 13 files changed, 69 insertions(+), 54 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 22d0e3fe6..4f3388186 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -373,7 +373,7 @@ class Configure extends Object { $_this =& Configure::getInstance(); $name = $_this->__configVarNames($var); - if (count($name) > 1) { + if (isset($name[1])) { unset($_this->{$name[0]}[$name[1]]); } else { unset($_this->{$name[0]}); diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index d68c61f03..3501e0b63 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -349,7 +349,7 @@ class DbAcl extends AclBase { } list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']); - if ($perms['link'] != null && count($perms['link']) > 0) { + if ($perms['link'] != null && !empty($perms['link'])) { $save['id'] = $perms['link'][0][$this->Aro->Permission->alias]['id']; } else { unset($save['id']); diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index ce1b114d7..d391c2472 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -737,7 +737,7 @@ class Controller extends Object { function validateErrors() { $objects = func_get_args(); - if (!count($objects)) { + if (empty($objects)) { return false; } @@ -747,7 +747,7 @@ class Controller extends Object { $errors = array_merge($errors, $this->{$object->alias}->invalidFields()); } - return $this->validationErrors = (count($errors) ? $errors : false); + return $this->validationErrors = (!empty($errors) ? $errors : false); } /** * Instantiates the correct view class, hands it its data, and uses it to render the view output. diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 42d47916c..873b8a23c 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -403,7 +403,7 @@ class Debugger extends Object { } } $n = null; - if (count($vars) > 0) { + if (!empty($vars)) { $n = "\n"; } return $out . implode(",", $vars) . "{$n})"; diff --git a/cake/libs/folder.php b/cake/libs/folder.php index a5331f80f..54856531c 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -744,7 +744,7 @@ class Folder extends Object { continue; } if ($part === '..') { - if (count($newparts) > 0) { + if (!empty($newparts)) { array_pop($newparts); continue; } else { diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 575348822..a0db47226 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -135,7 +135,7 @@ class ConnectionManager extends Object { function getSourceName(&$source) { $_this =& ConnectionManager::getInstance(); $names = array_keys($_this->_dataSources); - for ($i = 0; $i < count($names); $i++) { + for ($i = 0, $count = count($names); $i < $count; $i++) { if ($_this->_dataSources[$names[$i]] === $source) { return $names[$i]; } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a48a3c6a2..ae8df2cbe 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2039,7 +2039,7 @@ class DboSource extends DataSource { $keys = array_filter($keys); } - if (empty($keys) || (is_array($keys) && count($keys) && isset($keys[0]) && empty($keys[0]))) { + if (empty($keys) || (is_array($keys) && isset($keys[0]) && empty($keys[0]))) { return ''; } diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index bfc24f4ba..e688f1ea9 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1079,7 +1079,7 @@ class Model extends Overloadable { return $data[$name[0]][$name[1]]; } } - if (isset($data[0]) && count($data[0]) > 0) { + if (!empty($data[0])) { $name = key($data[0]); return $data[0][$name]; } diff --git a/cake/libs/multibyte.php b/cake/libs/multibyte.php index 724b65923..1dfcd456b 100644 --- a/cake/libs/multibyte.php +++ b/cake/libs/multibyte.php @@ -36,7 +36,8 @@ if (function_exists('mb_internal_encoding')) { * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. - * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false + * if $needle is not found. */ if (!function_exists('mb_stripos')) { function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { @@ -49,8 +50,9 @@ if (!function_exists('mb_stripos')) { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack, or false if $needle is not found. */ @@ -65,7 +67,7 @@ if (!function_exists('mb_stristr')) { * @param string $string The string being checked for length. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer The number of characters in string $string having character encoding encoding. - * A multi-byte character is counted as 1. + * A multi-byte character is counted as 1. */ if (!function_exists('mb_strlen')) { function mb_strlen($string, $encoding = null) { @@ -80,7 +82,7 @@ if (!function_exists('mb_strlen')) { * @param integer $offset The search offset. If it is not specified, 0 is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. - * If $needle is not found, it returns false. + * If $needle is not found, it returns false. */ if (!function_exists('mb_strpos')) { function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { @@ -93,8 +95,9 @@ if (!function_exists('mb_strpos')) { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack. or false if $needle is not found. */ @@ -109,8 +112,9 @@ if (!function_exists('mb_strrchr')) { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack. or false if $needle is not found. */ @@ -126,7 +130,8 @@ if (!function_exists('mb_strrichr')) { * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, + * or false if $needle is not found. */ if (!function_exists('mb_strripos')) { function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { @@ -139,9 +144,10 @@ if (!function_exists('mb_strripos')) { * @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. - * Negative values will stop searching at an arbitrary point prior to the end of the string. + * Negative values will stop searching at an arbitrary point prior to the end of the string. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. + * If $needle is not found, it returns false. */ if (!function_exists('mb_strrpos')) { function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { @@ -154,8 +160,9 @@ if (!function_exists('mb_strrpos')) { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is FALSE. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack, or true if $needle is not found. */ @@ -220,12 +227,13 @@ if (!function_exists('mb_substr')) { * * @param string $str The string being encoded * @param string $charset specifies the name of the character set in which str is represented in. - * The default value is determined by the current NLS setting (mbstring.language). - * @param string $transfer_encoding specifies the scheme of MIME encoding. It should be either "B" (Base64) or "Q" (Quoted-Printable). - * Falls back to "B" if not given. - * @param string $linefeed specifies the EOL (end-of-line) marker with which mb_encode_mimeheader() performs line-folding - * (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. - * The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. + * The default value is determined by the current NLS setting (mbstring.language). + * @param string $transfer_encoding specifies the scheme of MIME encoding. + * It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given. + * @param string $linefeed specifies the EOL (end-of-line) marker with which + * mb_encode_mimeheader() performs line-folding + * (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. + * The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. * @param integer $indent [definition unknown and appears to have no affect] * @return string A converted version of the string represented in ASCII. */ @@ -300,7 +308,7 @@ class Multibyte extends Object { if ($value < 128) { $map[] = $value; } else { - if (count($values) == 0) { + if (empty($values)) { $find = ($value < 224) ? 2 : 3; } $values[] = $value; @@ -350,7 +358,8 @@ class Multibyte extends Object { * @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle. * @param multi-byte string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. - * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, + * or false if $needle is not found. * @access public * @static */ @@ -368,8 +377,9 @@ class Multibyte extends Object { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is false. * @return int|boolean The portion of $haystack, or false if $needle is not found. * @access public * @static @@ -445,7 +455,7 @@ class Multibyte extends Object { * @param string $needle The position counted from the beginning of haystack. * @param integer $offset The search offset. If it is not specified, 0 is used. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. - * If $needle is not found, it returns false. + * If $needle is not found, it returns false. * @access public * @static */ @@ -488,8 +498,9 @@ class Multibyte extends Object { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @return string|boolean The portion of $haystack. or false if $needle is not found. * @access public * @static @@ -548,8 +559,9 @@ class Multibyte extends Object { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @return string|boolean The portion of $haystack. or false if $needle is not found. * @access public * @static @@ -610,7 +622,8 @@ class Multibyte extends Object { * @param string $haystack The string from which to get the position of the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, + * or false if $needle is not found. * @access public * @static */ @@ -661,8 +674,9 @@ class Multibyte extends Object { * @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. - * Negative values will stop searching at an arbitrary point prior to the end of the string. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. + * Negative values will stop searching at an arbitrary point prior to the end of the string. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. + * If $needle is not found, it returns false. * @access public * @static */ @@ -711,8 +725,9 @@ class Multibyte extends Object { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is FALSE. * @return string|boolean The portion of $haystack, or true if $needle is not found. * @access public * @static @@ -853,14 +868,14 @@ class Multibyte extends Object { if ($length > 1 && count($keys[$key]['lower']) > 1) { $j = 0; - for ($ii = 0; $ii < count($keys[$key]['lower']); $ii++) { + for ($ii = 0, $count = count($keys[$key]['lower']); $ii < $count; $ii++) { $nextChar = $utf8Map[$i + $ii]; if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) { $replace++; } } - if ($replace == count($keys[$key]['lower'])) { + if ($replace == $count) { $upperCase[] = $keys[$key]['upper']; $replaced = array_merge($replaced, array_values($keys[$key]['lower'])); $matched = true; @@ -873,14 +888,14 @@ class Multibyte extends Object { if (in_array($nextChar, $keys[$ii]['lower'])) { - for ($jj = 0; $jj < count($keys[$ii]['lower']); $jj++) { + for ($jj = 0, $count = count($keys[$ii]['lower']); $jj < $count; $jj++) { $nextChar = $utf8Map[$i + $jj]; if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) { $replace++; } } - if ($replace == count($keys[$ii]['lower'])) { + if ($replace == $count) { $upperCase[] = $keys[$ii]['upper']; $replaced = array_merge($replaced, array_values($keys[$ii]['lower'])); $matched = true; diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 30d424faf..8ed84a455 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -161,7 +161,7 @@ class Sanitize { $params = params(func_get_args()); $str = $params[0]; - for ($i = 1; $i < count($params); $i++) { + for ($i = 1, $count = count($params); $i < $count; $i++) { $str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str); $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str); } diff --git a/cake/libs/set.php b/cake/libs/set.php index 11382e4dc..4646387b8 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -1077,7 +1077,7 @@ class Set extends Object { if (!is_null($key)) { $id = $key; } - if (is_array($r) && count($r)) { + if (is_array($r) && !empty($r)) { $stack = array_merge($stack, Set::__flatten($r, $id)); } else { $stack[] = array('id' => $id, 'value' => $r); diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index b5be53a74..43b885a34 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -410,7 +410,7 @@ class HtmlHelper extends AppHelper { * @return string */ function getCrumbs($separator = '»', $startText = false) { - if (count($this->_crumbs)) { + if (!empty($this->_crumbs)) { $out = array(); if ($startText) { $out[] = $this->link($startText, '/'); diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 691cd5dba..34c0e370a 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -566,7 +566,7 @@ class XmlNode extends Object { * @access public */ function hasChildren() { - if (is_array($this->children) && count($this->children) > 0) { + if (is_array($this->children) && !empty($this->children)) { return true; } return false; @@ -593,7 +593,7 @@ class XmlNode extends Object { } $d .= '<' . $this->name(); - if (count($this->namespaces) > 0) { + if (!empty($this->namespaces) > 0) { foreach ($this->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; @@ -601,14 +601,14 @@ class XmlNode extends Object { } $parent =& $this->parent(); - if ($parent->name === '#document' && count($parent->namespaces) > 0) { + if ($parent->name === '#document' && !empty($parent->namespaces)) { foreach ($parent->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; } } - if (is_array($this->attributes) && count($this->attributes) > 0) { + if (is_array($this->attributes) && !empty($this->attributes)) { foreach ($this->attributes as $key => $val) { if (is_bool($val) && $val === false) { $val = 0; From 5d25780b9b1212450838f67fbc197b729be78ad4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Nov 2009 16:25:39 -0500 Subject: [PATCH 13/19] fixing typo. --- app/config/core.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/core.php b/app/config/core.php index cac5eb8ab..672a00e91 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -151,7 +151,7 @@ Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); /** * Apply timestamps with the last modified time to static assets (js, css, images). - * Will append a querysting parameter containing the time the file was modified. This is + * Will append a querystring parameter containing the time the file was modified. This is * useful for invalidating browser caches. * * Set to `true` to apply timestamps, when debug = 0, or set to 'force' to always enable From a30aec99fd39978b0532ea6f3e1027f34675af34 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Nov 2009 21:00:15 -0500 Subject: [PATCH 14/19] Applying patch from 'robustsolution' for optimization in Dispatcher::dispatch. Fixes #317 --- cake/dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index f09e10997..70790d7a4 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -136,13 +136,13 @@ class Dispatcher extends Object { ))); } - $privateAction = (bool)(strpos($this->params['action'], '_', 0) === 0); + $privateAction = $this->params['action'][0] === '_'; $prefixes = Router::prefixes(); if (!empty($prefixes)) { if (isset($this->params['prefix'])) { $this->params['action'] = $this->params['prefix'] . '_' . $this->params['action']; - } elseif (strpos($this->params['action'], '_') !== false && !$privateAction) { + } elseif (strpos($this->params['action'], '_') > 0) { list($prefix, $action) = explode('_', $this->params['action']); $privateAction = in_array($prefix, $prefixes); } From 7e889d849557f97a2f46166cef8c4bfd37b35a9e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 22 Nov 2009 12:25:53 -0500 Subject: [PATCH 15/19] Changing require_once to require for custom session handlers. If you are using a class to do your custom session handling you must include checks to prevent duplicate class errors. Fixes #324 --- cake/libs/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/session.php b/cake/libs/session.php index 38697ae23..005fe9b30 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -520,7 +520,7 @@ class CakeSession extends Object { $config = CONFIGS . Configure::read('Session.save') . '.php'; if (is_file($config)) { - require_once ($config); + require($config); } } break; From c6c747450252c01cc18495c083df16cd1dea353c Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 19 Nov 2009 22:57:53 -0200 Subject: [PATCH 16/19] Fix test of the size of lines in MagicDb (included test for it). Signed-off-by: Mark Story --- cake/libs/magic_db.php | 2 +- cake/tests/cases/libs/magic_db.test.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/libs/magic_db.php b/cake/libs/magic_db.php index 73b16017c..9d7d90bb2 100644 --- a/cake/libs/magic_db.php +++ b/cake/libs/magic_db.php @@ -95,7 +95,7 @@ class MagicDb extends Object { $lines = explode("\r\n", $data); $db = array(); - $validHeader = count($lines > 3) + $validHeader = count($lines) > 3 && preg_match('/^# Date:([0-9]{4}-[0-9]{2}-[0-9]{2})$/', $lines[1], $date) && preg_match('/^# Source:(.+)$/', $lines[2], $source) && strlen($lines[3]) == 0; diff --git a/cake/tests/cases/libs/magic_db.test.php b/cake/tests/cases/libs/magic_db.test.php index 3eba7eb46..7ab7b642e 100644 --- a/cake/tests/cases/libs/magic_db.test.php +++ b/cake/tests/cases/libs/magic_db.test.php @@ -116,6 +116,9 @@ class MagicDbTest extends UnitTestCase { $r = $this->Db->toArray(array('yeah')); $this->assertTrue($r === array('yeah')); + $r = $this->Db->toArray("# FILE_ID DB\r\n# Date:2009-10-10\r\n# Source:xxx.php"); + $this->assertTrue($r === array()); + $r = $this->Db->toArray('foo'); $this->assertTrue($r === array()); From b0aec35422733ecdcbca0be8cac6d96cff2989b4 Mon Sep 17 00:00:00 2001 From: robustsolution Date: Thu, 19 Nov 2009 20:22:50 +0000 Subject: [PATCH 17/19] Dispatch::baseUrl() needs optimization a little bit Signed-off-by: Mark Story --- cake/dispatcher.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 70790d7a4..76db8f292 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -367,9 +367,6 @@ class Dispatcher extends Object { $this->webroot = $base .'/'; return $base; } - $file = null; - - if ($baseUrl) { $file = '/' . basename($baseUrl); $base = dirname($baseUrl); @@ -385,8 +382,6 @@ class Dispatcher extends Object { $this->webroot .= $webroot . '/'; } return $base . $file; - } - return false; } /** * Restructure params in case we're serving a plugin. From 6c3bcdd7e68d39044e056c44417c926e1a5923dc Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 22 Nov 2009 17:34:11 -0500 Subject: [PATCH 18/19] Removing commented code. --- cake/tests/cases/libs/model/models.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index 086eda794..33ca715fa 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -2718,8 +2718,6 @@ class Uuiditem extends CakeTestModel { * @var array * @access public */ - //var $hasAndBelongsToMany = array('Uuidportfolio' => array('unique' => true)); -// var $hasAndBelongsToMany = array('Uuidportfolio' => array('with' => 'UuiditemsUuidportfolio')); var $hasAndBelongsToMany = array('Uuidportfolio' => array('with' => 'UuiditemsUuidportfolioNumericid')); } From 2e0acbf505fa4053aaf5d333a46dd08d9548b6da Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 22 Nov 2009 17:56:46 -0500 Subject: [PATCH 19/19] Making habtm join conditions used by __saveMulti when finding link records to remove. It should be noted that having conditions on non-joinTable tables, and not having a model on the joinTable can cause SQL issues. Fixes #304 --- cake/libs/model/model.php | 18 ++++--- .../cases/libs/model/model_write.test.php | 50 ++++++++++++++++++- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index e688f1ea9..d559af5a3 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1302,14 +1302,6 @@ class Model extends Overloadable { if (isset($this->hasAndBelongsToMany[$assoc])) { list($join) = $this->joinModel($this->hasAndBelongsToMany[$assoc]['with']); - $conditions = array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id); - - $links = $this->{$join}->find('all', array( - 'conditions' => $conditions, - 'recursive' => -1, - 'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey'] - )); - $isUUID = !empty($this->{$join}->primaryKey) && ( $this->{$join}->_schema[$this->{$join}->primaryKey]['length'] == 36 && ( $this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'string' || @@ -1351,6 +1343,16 @@ class Model extends Overloadable { } if ($this->hasAndBelongsToMany[$assoc]['unique']) { + $conditions = array_merge( + array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id), + (array)$this->hasAndBelongsToMany[$assoc]['conditions'] + ); + $links = $this->{$join}->find('all', array( + 'conditions' => $conditions, + 'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0, + 'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey'] + )); + $associationForeignKey = "{$join}." . $this->hasAndBelongsToMany[$assoc]['associationForeignKey']; $oldLinks = Set::extract($links, "{n}.{$associationForeignKey}"); if (!empty($oldLinks)) { diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 4d969cca9..2931b4be2 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -609,7 +609,7 @@ class ModelWriteTest extends BaseModelTest { function testBeforeValidateSaveAbortion() { $Model =& new CallbackPostTestModel(); $Model->beforeValidateReturn = false; - + $data = array( 'title' => 'new article', 'body' => 'this is some text.' @@ -1992,6 +1992,54 @@ class ModelWriteTest extends BaseModelTest { )); $this->assertEqual($result, $expected); } +/** + * test that saving habtm records respects conditions set in the the 'conditions' key + * for the association. + * + * @return void + */ + function testHabtmSaveWithConditionsInAssociation() { + $this->loadFixtures('JoinThing', 'Something', 'SomethingElse'); + $Something =& new Something(); + $Something->unbindModel(array('hasAndBelongsToMany' => array('SomethingElse')), false); + + $Something->bindModel(array( + 'hasAndBelongsToMany' => array( + 'DoomedSomethingElse' => array( + 'className' => 'SomethingElse', + 'joinTable' => 'join_things', + 'conditions' => 'JoinThing.doomed = 1', + 'unique' => true + ), + 'NotDoomedSomethingElse' => array( + 'className' => 'SomethingElse', + 'joinTable' => 'join_things', + 'conditions' => array('JoinThing.doomed' => 0), + 'unique' => true + ) + ) + ), false); + $result = $Something->read(null, 1); + $this->assertTrue(empty($result['NotDoomedSomethingElse'])); + $this->assertEqual(count($result['DoomedSomethingElse']), 1); + + $data = array( + 'Something' => array('id' => 1), + 'NotDoomedSomethingElse' => array( + 'NotDoomedSomethingElse' => array( + array('something_else_id' => 2, 'doomed' => 0), + array('something_else_id' => 3, 'doomed' => 0) + ) + ) + ); + $Something->create($data); + $result = $Something->save(); + $this->assertTrue($result); + + $result = $Something->read(null, 1); + $this->assertEqual(count($result['NotDoomedSomethingElse']), 2); + $this->assertEqual(count($result['DoomedSomethingElse']), 1); + } /** * testHabtmSaveKeyResolution method *