Browse Source

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/VERSION.txt
mark_story 13 years ago
parent
commit
6664acba79

+ 0 - 1
lib/Cake/Console/Command/ConsoleShell.php

@@ -175,7 +175,6 @@ class ConsoleShell extends AppShell {
 				case 'quit':
 				case 'exit':
 					return true;
-				break;
 				case 'models':
 					$this->out(__d('cake_console', 'Model classes:'));
 					$this->hr();

+ 3 - 8
lib/Cake/Console/Command/SchemaShell.php

@@ -1,12 +1,5 @@
 <?php
 /**
- * Command-line database management utility to automate programmer chores.
- *
- * Schema is CakePHP's database management utility. This helps you maintain versions of
- * of your database.
- *
- * PHP 5
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  *
@@ -291,7 +284,9 @@ class SchemaShell extends AppShell {
 		$Schema = $this->Schema->load($options);
 
 		if (!$Schema) {
-			$this->err(__d('cake_console', '%s could not be loaded', $this->Schema->path . DS . $this->Schema->file));
+			$this->err(__d('cake_console', 'The chosen schema could not be loaded. Attempted to load:'));
+			$this->err(__d('cake_console', 'File: %s', $this->Schema->path . DS . $this->Schema->file));
+			$this->err(__d('cake_console', 'Name: %s', $this->Schema->name));
 			$this->_stop();
 		}
 		$table = null;

+ 1 - 1
lib/Cake/Console/Command/TestShell.php

@@ -57,7 +57,7 @@ class TestShell extends Shell {
 			'help' => __d('cake_console', '<file> Log test execution in JUnit XML format to file.'),
 			'default' => false
 		))->addOption('log-json', array(
-			'help' => __d('cake_console', '<file> Log test execution in TAP format to file.'),
+			'help' => __d('cake_console', '<file> Log test execution in JSON format to file.'),
 			'default' => false
 		))->addOption('log-tap', array(
 			'help' => __d('cake_console', '<file> Log test execution in TAP format to file.'),

+ 1 - 1
lib/Cake/Controller/Component/EmailComponent.php

@@ -305,7 +305,7 @@ class EmailComponent extends Component {
 		if (!empty($this->return)) {
 			$lib->returnPath($this->_formatAddresses((array)$this->return));
 		}
-		if (!empty($readReceipt)) {
+		if (!empty($this->readReceipt)) {
 			$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
 		}
 

+ 0 - 1
lib/Cake/Core/Object.php

@@ -123,7 +123,6 @@ class Object {
 				return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
 			default:
 				return call_user_func_array(array(&$this, $method), $params);
-			break;
 		}
 	}
 

+ 0 - 1
lib/Cake/Model/Datasource/Database/Mysql.php

@@ -533,7 +533,6 @@ class Mysql extends DboSource {
  * @param string $table Table to alter parameters for.
  * @param array $parameters Parameters to add & drop.
  * @return array Array of table property alteration statements.
- * @todo Implement this method.
  */
 	protected function _alterTableParameters($table, $parameters) {
 		if (isset($parameters['change'])) {

+ 0 - 3
lib/Cake/Model/Datasource/Database/Postgres.php

@@ -652,7 +652,6 @@ class Postgres extends DboSource {
 				return 'float';
 			default:
 				return 'text';
-			break;
 		}
 	}
 
@@ -894,10 +893,8 @@ class Postgres extends DboSource {
 					}
 				}
 				return "CREATE TABLE {$table} (\n\t{$columns}\n);\n{$indexes}";
-			break;
 			default:
 				return parent::renderStatement($type, $data);
-			break;
 		}
 	}
 

+ 0 - 2
lib/Cake/Model/Datasource/Database/Sqlite.php

@@ -530,10 +530,8 @@ class Sqlite extends DboSource {
 					$indexes = "\t" . join("\n\t", array_filter($indexes));
 				}
 				return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";
-			break;
 			default:
 				return parent::renderStatement($type, $data);
-			break;
 		}
 	}
 

+ 0 - 2
lib/Cake/Model/Datasource/Database/Sqlserver.php

@@ -537,10 +537,8 @@ class Sqlserver extends DboSource {
 					}
 				}
 				return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";
-			break;
 			default:
 				return parent::renderStatement($type, $data);
-			break;
 		}
 	}
 

+ 1 - 5
lib/Cake/Model/Datasource/DboSource.php

@@ -341,10 +341,8 @@ class DboSource extends DataSource {
 		switch ($column) {
 			case 'binary':
 				return $this->_connection->quote($data, PDO::PARAM_LOB);
-			break;
 			case 'boolean':
 				return $this->_connection->quote($this->boolean($data, true), PDO::PARAM_BOOL);
-			break;
 			case 'string':
 			case 'text':
 				return $this->_connection->quote($data, PDO::PARAM_STR);
@@ -362,7 +360,6 @@ class DboSource extends DataSource {
 					return $data;
 				}
 				return $this->_connection->quote($data);
-			break;
 		}
 	}
 
@@ -2029,7 +2026,6 @@ class DboSource extends DataSource {
 					$arg = $this->name($params[0]);
 				}
 				return strtoupper($func) . '(' . $arg . ') AS ' . $this->name($params[1]);
-			break;
 		}
 	}
 
@@ -2633,7 +2629,7 @@ class DboSource extends DataSource {
 		}
 		$conditions = str_replace(array($start, $end), '', $conditions);
 		$conditions = preg_replace_callback(
-			'/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9\\-_' . $start . $end . ']*\\.[a-z0-9_\\-' . $start . $end . ']*)/i',
+			'/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_][a-z0-9\\-_]*\\.[a-z0-9_][a-z0-9_\\-]*)/i',
 			array(&$this, '_quoteMatchedField'),
 			$conditions
 		);

+ 0 - 1
lib/Cake/Model/Permission.php

@@ -149,7 +149,6 @@ class Permission extends AppModel {
 							break;
 							case 1:
 								return true;
-							break;
 						}
 					}
 				}

+ 16 - 0
lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php

@@ -2028,9 +2028,25 @@ class MysqlTest extends CakeTestCase {
 		$result = $this->Dbo->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"');
 		$expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"';
 		$this->assertEquals($expected, $result);
+	}
 
+/**
+ * test that - in conditions and field names works
+ *
+ * @return void
+ */
+	public function testHypenInStringConditionsAndFieldNames() {
 		$result = $this->Dbo->conditions('I18n__title_pt-br.content = "test"');
 		$this->assertEquals(' WHERE `I18n__title_pt-br`.`content` = "test"', $result);
+
+		$result = $this->Dbo->conditions('Model.field=NOW()-3600');
+		$this->assertEquals(' WHERE `Model`.`field`=NOW()-3600', $result);
+
+		$result = $this->Dbo->conditions('NOW() - Model.created < 7200');
+		$this->assertEquals(' WHERE NOW() - `Model`.`created` < 7200', $result);
+
+		$result = $this->Dbo->conditions('NOW()-Model.created < 7200');
+		$this->assertEquals(' WHERE NOW()-`Model`.`created` < 7200', $result);
 	}
 
 /**

+ 3 - 1
lib/Cake/Test/Case/Model/ModelWriteTest.php

@@ -6794,6 +6794,7 @@ class ModelWriteTest extends BaseModelTest {
  */
 	public function testSaveAllDeepEmptyHasManyHasMany() {
 		$this->skipIf(!$this->db instanceof Mysql, 'This test is only compatible with Mysql.');
+
 		$this->loadFixtures('Article', 'Comment', 'User', 'Attachment');
 		$TestModel = new Article();
 		$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array();
@@ -6805,9 +6806,10 @@ class ModelWriteTest extends BaseModelTest {
 		$this->db->truncate(new Attachment());
 
 		$result = $TestModel->saveAll(array(
-			'Article' => array('id' => 3, 'title' => 'Comment has no data'),
+			'Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Comment has no data'),
 			'Comment' => array(
 				array(
+					'user_id' => 1,
 					'Attachment' => array(
 						array('attachment' => 'attachment should be created with comment_id'),
 						array('attachment' => 'comment should be created with article_id'),

+ 5 - 2
lib/Cake/Test/Case/Utility/DebuggerTest.php

@@ -277,8 +277,11 @@ class DebuggerTest extends CakeTestCase {
  * @return void
  */
 	public function testTrimPath() {
-		$this->assertEquals(Debugger::trimPath(APP), 'APP' . DS);
-		$this->assertEquals(Debugger::trimPath(CAKE_CORE_INCLUDE_PATH), 'CORE');
+		$this->assertEquals('APP' . DS, Debugger::trimPath(APP));
+		$this->assertEquals('CORE', Debugger::trimPath(CAKE_CORE_INCLUDE_PATH));
+		$this->assertEquals('ROOT', Debugger::trimPath(ROOT));
+		$this->assertEquals('CORE' . DS . 'Cake' . DS, Debugger::trimPath(CAKE));
+		$this->assertEquals('Some/Other/Path', Debugger::trimPath('Some/Other/Path'));
 	}
 
 /**

+ 14 - 14
lib/Cake/Test/Case/View/Helper/CacheHelperTest.php

@@ -130,7 +130,7 @@ class CacheHelperTest extends CakeTestCase {
 		$this->assertRegExp('/php echo microtime()/', $contents);
 		$this->assertRegExp('/clark kent/', $result);
 
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -156,7 +156,7 @@ class CacheHelperTest extends CakeTestCase {
 		$filename = CACHE . 'views' . DS . 'posts_view_風街ろまん.php';
 		$this->assertTrue(file_exists($filename));
 
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -190,7 +190,7 @@ class CacheHelperTest extends CakeTestCase {
 		$this->assertRegExp('/php echo microtime()/', $contents);
 		$this->assertNotRegExp('/cake:nocache/', $contents);
 
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -221,7 +221,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$contents = file_get_contents($filename);
 		$this->assertNotRegExp('/cake:nocache/', $contents);
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -266,7 +266,7 @@ class CacheHelperTest extends CakeTestCase {
 		$filename = CACHE . 'views' . DS . 'cachetest_cache_complex.php';
 		$this->assertTrue(file_exists($filename));
 		$contents = file_get_contents($filename);
-		@unlink($filename);
+		unlink($filename);
 
 		$this->assertRegExp('/A\. Layout Before Content/', $contents);
 		$this->assertNotRegExp('/B\. In Plain Element/', $contents);
@@ -313,7 +313,7 @@ class CacheHelperTest extends CakeTestCase {
 		$this->assertRegExp('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents);
 		$this->assertRegExp('/php echo \$variable/', $contents);
 
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -347,7 +347,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$this->assertRegExp('/\$controller->startupProcess\(\);/', $contents);
 
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -377,7 +377,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$filename = CACHE . 'views' . DS . 'cache_test_cache_parsing.php';
 		$this->assertTrue(file_exists($filename));
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -406,7 +406,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php';
 		$this->assertTrue(file_exists($filename));
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -440,7 +440,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$filename = CACHE . 'views' . DS . 'cache_test_cache_parsing_1_2_name_mark_ice_cream.php';
 		$this->assertTrue(file_exists($filename));
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -472,7 +472,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$filename = CACHE . 'views' . DS . 'cache_test_cache_parsing_q_cakephp.php';
 		$this->assertTrue(file_exists($filename), 'Missing cache file ' . $filename);
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -506,7 +506,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$filename = CACHE . 'views' . DS . 'en_cache_test_cache_parsing.php';
 		$this->assertTrue(file_exists($filename));
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -541,7 +541,7 @@ class CacheHelperTest extends CakeTestCase {
 
 		$filename = CACHE . 'views' . DS . 'cache_cachetest_cache_name.php';
 		$this->assertTrue(file_exists($filename));
-		@unlink($filename);
+		unlink($filename);
 	}
 
 /**
@@ -645,6 +645,6 @@ class CacheHelperTest extends CakeTestCase {
 			'<\?php \$y = 1; \?>\s*' .
 			'<\?php echo \'cached count is: \' . \$x; \?>\s*' .
 			'@', $contents);
-		@unlink($filename);
+		unlink($filename);
 	}
 }

+ 0 - 2
lib/Cake/Utility/CakeTime.php

@@ -112,10 +112,8 @@ class CakeTime {
 		switch ($name) {
 			case 'niceFormat':
 				return self::${$name};
-				break;
 			default:
 				return null;
-				break;
 		}
 	}
 

+ 0 - 10
lib/Cake/Utility/Debugger.php

@@ -250,7 +250,6 @@ class Debugger {
 			break;
 			default:
 				return;
-			break;
 		}
 
 		$data = compact(
@@ -370,9 +369,6 @@ class Debugger {
 			return str_replace(ROOT, 'ROOT', $path);
 		}
 
-		if (strpos($path, CAKE) === 0) {
-			return str_replace($corePath, 'CORE' . DS, $path);
-		}
 		return $path;
 	}
 
@@ -474,29 +470,23 @@ class Debugger {
 		switch (self::getType($var)) {
 			case 'boolean':
 				return ($var) ? 'true' : 'false';
-			break;
 			case 'integer':
 				return '(int) ' . $var;
 			case 'float':
 				return '(float) ' . $var;
-			break;
 			case 'string':
 				if (trim($var) == '') {
 					return "''";
 				}
 				return "'" . $var . "'";
-			break;
 			case 'array':
 				return self::_array($var, $depth - 1, $indent + 1);
-			break;
 			case 'resource':
 				return strtolower(gettype($var));
-			break;
 			case 'null':
 				return 'null';
 			default:
 				return self::_object($var, $depth - 1, $indent + 1);
-			break;
 		}
 	}
 

+ 0 - 3
lib/Cake/Utility/Security.php

@@ -49,14 +49,11 @@ class Security {
 		switch (Configure::read('Security.level')) {
 			case 'high':
 				return 10;
-			break;
 			case 'medium':
 				return 100;
-			break;
 			case 'low':
 			default:
 				return 300;
-				break;
 		}
 	}