Skip to content

Commit 12e0652

Browse files
committed
Merge branch '1.2' of dev@code.cakephp.org:cakephp into 1.2
2 parents 6821e7c + daadac0 commit 12e0652

File tree

7 files changed

+396
-23
lines changed

7 files changed

+396
-23
lines changed

cake/console/libs/schema.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
/* SVN FILE: $Id$ */
32
/**
43
* Command-line database management utility to automate programmer chores.
54
*
@@ -9,20 +8,17 @@
98
* PHP versions 4 and 5
109
*
1110
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
12-
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
11+
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
1312
*
1413
* Licensed under The MIT License
1514
* Redistributions of files must retain the above copyright notice.
1615
*
1716
* @filesource
18-
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
17+
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
1918
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
2019
* @package cake
2120
* @subpackage cake.cake.console.libs
2221
* @since CakePHP(tm) v 1.2.0.5550
23-
* @version $Revision$
24-
* @modifiedby $LastChangedBy$
25-
* @lastmodified $Date$
2622
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
2723
*/
2824
App::import('File');
@@ -116,7 +112,7 @@ function view() {
116112
* @access public
117113
*/
118114
function generate() {
119-
$this->out('Generating Schema...');
115+
$this->out(__('Generating Schema...', true));
120116
$options = array();
121117
if (isset($this->params['f'])) {
122118
$options = array('models' => false);
@@ -131,7 +127,7 @@ function generate() {
131127
$snapshot = true;
132128
$result = strtolower($this->in("Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?", array('o', 's', 'q'), 's'));
133129
if ($result === 'q') {
134-
$this->_stop();
130+
return $this->_stop();
135131
}
136132
if ($result === 'o') {
137133
$snapshot = false;
@@ -224,7 +220,7 @@ function dump() {
224220
*/
225221
function run() {
226222
if (!isset($this->args[0])) {
227-
$this->err('command not found');
223+
$this->err(__('Command not found', true));
228224
$this->_stop();
229225
}
230226

@@ -271,8 +267,8 @@ function run() {
271267
$this->__update($Schema, $table);
272268
break;
273269
default:
274-
$this->err(__('command not found', true));
275-
$this->_stop();
270+
$this->err(__('Command not found', true));
271+
$this->_stop();
276272
}
277273
}
278274
/**
@@ -281,7 +277,7 @@ function run() {
281277
*
282278
* @access private
283279
*/
284-
function __create($Schema, $table = null) {
280+
function __create(&$Schema, $table = null) {
285281
$db =& ConnectionManager::getDataSource($this->Schema->connection);
286282

287283
$drop = $create = array();
@@ -304,15 +300,15 @@ function __create($Schema, $table = null) {
304300
$this->out(array_keys($drop));
305301

306302
if ('y' == $this->in(__('Are you sure you want to drop the table(s)?', true), array('y', 'n'), 'n')) {
307-
$this->out('Dropping table(s).');
303+
$this->out(__('Dropping table(s).', true));
308304
$this->__run($drop, 'drop', $Schema);
309305
}
310306

311307
$this->out("\n" . __('The following table(s) will be created.', true));
312308
$this->out(array_keys($create));
313309

314310
if ('y' == $this->in(__('Are you sure you want to create the table(s)?', true), array('y', 'n'), 'y')) {
315-
$this->out('Creating table(s).');
311+
$this->out(__('Creating table(s).', true));
316312
$this->__run($create, 'create', $Schema);
317313
}
318314

@@ -324,11 +320,15 @@ function __create($Schema, $table = null) {
324320
*
325321
* @access private
326322
*/
327-
function __update($Schema, $table = null) {
323+
function __update(&$Schema, $table = null) {
328324
$db =& ConnectionManager::getDataSource($this->Schema->connection);
329325

330-
$this->out('Comparing Database to Schema...');
331-
$Old = $this->Schema->read();
326+
$this->out(__('Comparing Database to Schema...', true));
327+
$options = array();
328+
if (isset($this->params['f'])) {
329+
$options['models'] = false;
330+
}
331+
$Old = $this->Schema->read($options);
332332
$compare = $this->Schema->compare($Old, $Schema);
333333

334334
$contents = array();
@@ -361,15 +361,15 @@ function __update($Schema, $table = null) {
361361
*
362362
* @access private
363363
*/
364-
function __run($contents, $event, $Schema) {
364+
function __run($contents, $event, &$Schema) {
365365
if (empty($contents)) {
366366
$this->err(__('Sql could not be run', true));
367367
return;
368368
}
369369
Configure::write('debug', 2);
370370
$db =& ConnectionManager::getDataSource($this->Schema->connection);
371371
$db->fullDebug = true;
372-
372+
373373
foreach ($contents as $table => $sql) {
374374
if (empty($sql)) {
375375
$this->out(sprintf(__('%s is up to date.', true), $table));
@@ -403,7 +403,8 @@ function __run($contents, $event, $Schema) {
403403
* @access public
404404
*/
405405
function help() {
406-
$this->out("The Schema Shell generates a schema object from \n\t\tthe database and updates the database from the schema.");
406+
$this->out("The Schema Shell generates a schema object from");
407+
$this->out("the database and updates the database from the schema.");
407408
$this->hr();
408409
$this->out("Usage: cake schema <command> <arg1> <arg2>...");
409410
$this->hr();

cake/libs/controller/components/email.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,14 @@ function __smtp() {
680680
return false;
681681
}
682682

683+
$httpHost = env('HTTP_HOST');
684+
683685
if (isset($this->smtpOptions['client'])) {
684686
$host = $this->smtpOptions['client'];
687+
} elseif (!empty($httpHost)) {
688+
$host = $httpHost;
685689
} else {
686-
$host = env('HTTP_HOST');
690+
$host = 'localhost';
687691
}
688692

689693
if (!$this->__smtpSend("HELO {$host}", '250')) {

cake/libs/model/datasources/dbo/dbo_mssql.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ function value($data, $column = null, $safe = false) {
259259
if ($data === null) {
260260
return 'NULL';
261261
}
262+
if (in_array($column, array('integer', 'float', 'binary')) && $data === '') {
263+
return 'NULL';
264+
}
262265
if ($data === '') {
263266
return "''";
264267
}

cake/libs/model/schema.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ function load($options = array()) {
172172
* - 'connection' - the db connection to use
173173
* - 'name' - name of the schema
174174
* - 'models' - a list of models to use, or false to ignore models
175+
*
175176
* @param array $options schema object properties
176177
* @return array Array indexed by name and tables
177178
* @access public

0 commit comments

Comments
 (0)