Merge branch '1.3' of github.com:cakephp/cakephp into 1.3

This commit is contained in:
renan.saddam 2010-05-29 12:23:04 -03:00
commit c96d074722
32 changed files with 189 additions and 71 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * CSS helping functions
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -21,14 +21,16 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
header('HTTP/1.1 404 Not Found'); header('HTTP/1.1 404 Not Found');
exit('File Not Found'); exit('File Not Found');
} }
/** /**
* Enter description here... * Ensure required classes are available.
*/ */
if (!class_exists('File')) { if (!class_exists('File')) {
uses('file'); uses('file');
} }
/** /**
* Enter description here... * Make clean CSS
* *
* @param unknown_type $path * @param unknown_type $path
* @param unknown_type $name * @param unknown_type $name
@ -44,7 +46,7 @@ if (!class_exists('File')) {
return $output; return $output;
} }
/** /**
* Enter description here... * Write CSS cache
* *
* @param unknown_type $path * @param unknown_type $path
* @param unknown_type $content * @param unknown_type $content

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * CakePHP Console Shell
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Internationalization Management Shell
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Application level Controller
* *
* This file is application-wide controller file. You can put all * This file is application-wide controller file. You can put all
* application-wide controller-related methods here. * application-wide controller-related methods here.
@ -22,7 +22,7 @@
*/ */
/** /**
* Short description for class. * Application Controller
* *
* Add your application-wide methods in the class below, your controllers * Add your application-wide methods in the class below, your controllers
* will inherit them. * will inherit them.

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Application level View Helper
* *
* This file is application-wide helper file. You can put all * This file is application-wide helper file. You can put all
* application-wide helper-related methods here. * application-wide helper-related methods here.

View file

@ -1,7 +1,7 @@
;<?php exit() ?> ;<?php exit() ?>
; SVN FILE: $Id$ ; SVN FILE: $Id$
;/** ;/**
; * Short description for file. ; * ACL Configuration
; * ; *
; * ; *
; * PHP versions 4 and 5 ; * PHP versions 4 and 5

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Routes Configuration
* *
* In this file, you set up routes to your controllers and their actions. * In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect * Routes are very important mechanism that allows you to freely connect

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * CSS Functions
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -23,14 +23,14 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
} }
/** /**
* Enter description here... * Ensure required files are included
*/ */
if (!class_exists('File')) { if (!class_exists('File')) {
require LIBS . 'file.php'; require LIBS . 'file.php';
} }
/** /**
* Enter description here... * Make clean CSS
* *
* @param unknown_type $path * @param unknown_type $path
* @param unknown_type $name * @param unknown_type $name
@ -47,7 +47,7 @@ if (!class_exists('File')) {
} }
/** /**
* Enter description here... * Write CSS cache
* *
* @param unknown_type $path * @param unknown_type $path
* @param unknown_type $content * @param unknown_type $content

View file

@ -209,7 +209,11 @@ class FileEngine extends CacheEngine {
$now = time(); $now = time();
$threshold = $now - $this->settings['duration']; $threshold = $now - $this->settings['duration'];
} }
$prefixLength = strlen($this->settings['prefix']);
while (($entry = $dir->read()) !== false) { while (($entry = $dir->read()) !== false) {
if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
continue;
}
if ($this->_setKey($entry) === false) { if ($this->_setKey($entry) === false) {
continue; continue;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Application level Controller
* *
* This file is application-wide controller file. You can put all * This file is application-wide controller file. You can put all
* application-wide controller-related methods here. * application-wide controller-related methods here.

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Cookie Component
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Email Component
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -808,7 +808,7 @@ class EmailComponent extends Object{
$host = 'localhost'; $host = 'localhost';
} }
if (!$this->_smtpSend("HELO {$host}", '250')) { if (!$this->_smtpSend("EHLO {$host}", '250') || !$this->_smtpSend("HELO {$host}", '250')) {
return false; return false;
} }
@ -868,22 +868,34 @@ class EmailComponent extends Object{
} }
/** /**
* Private method for sending data to SMTP connection * Protected method for sending data to SMTP connection
* *
* @param string $data data to be sent to SMTP server * @param string $data data to be sent to SMTP server
* @param mixed $checkCode code to check for in server response, false to skip * @param mixed $checkCode code to check for in server response, false to skip
* @return bool Success * @return bool Success
* @access private * @access protected
*/ */
function _smtpSend($data, $checkCode = '250') { function _smtpSend($data, $checkCode = '250') {
if (!is_null($data)) { if (!is_null($data)) {
$this->__smtpConnection->write($data . "\r\n"); $this->__smtpConnection->write($data . "\r\n");
} }
if ($checkCode !== false) { while ($checkCode !== false) {
$response = $this->__smtpConnection->read(); $response = '';
$startTime = time();
while (substr($response, -2) !== "\r\n" && ((time() - $startTime) < $this->smtpOptions['timeout'])) {
$response .= $this->__smtpConnection->read();
}
if (substr($response, -2) === "\r\n") {
$this->smtpError = 'timeout';
return false;
}
$response = end(explode("\r\n", rtrim($response, "\r\n")));
if (preg_match('/^(' . $checkCode . ')/', $response, $code)) { if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {
return $code[0]; if ($code[2] === '-') {
continue;
}
return $code[1];
} }
$this->smtpError = $response; $this->smtpError = $response;
return false; return false;

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Security Component
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -18,8 +18,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Core', array('String', 'Security')); App::import('Core', array('String', 'Security'));
/** /**
* Short description for file. * SecurityComponent
* *
* @package cake * @package cake
* @subpackage cake.cake.libs.controller.components * @subpackage cake.cake.libs.controller.components

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Internationalization
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Localization
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -19,7 +19,7 @@
*/ */
/** /**
* Short description for file. * Localization
* *
* @package cake * @package cake
* @subpackage cake.cake.libs * @subpackage cake.cake.libs

View file

@ -21,7 +21,7 @@
*/ */
/** /**
* Short description for file * ACL behavior
* *
* @package cake * @package cake
* @subpackage cake.cake.libs.model.behaviors * @subpackage cake.cake.libs.model.behaviors

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Translate behavior
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -19,7 +19,7 @@
*/ */
/** /**
* Short description for file. * Translate behavior
* *
* @package cake * @package cake
* @subpackage cake.cake.libs.model.behaviors * @subpackage cake.cake.libs.model.behaviors

View file

@ -91,7 +91,7 @@ class DataSource extends Object {
var $endQuote = null; var $endQuote = null;
/** /**
* Enter description here... * Result
* *
* @var array * @var array
* @access protected * @access protected

View file

@ -19,7 +19,7 @@
*/ */
/** /**
* Short description for class. * MS SQL layer for DBO
* *
* Long description for class * Long description for class
* *

View file

@ -507,9 +507,9 @@ class DboMysqlBase extends DboSource {
class DboMysql extends DboMysqlBase { class DboMysql extends DboMysqlBase {
/** /**
* Enter description here... * Datasource description
* *
* @var unknown_type * @var string
*/ */
var $description = "MySQL DBO Driver"; var $description = "MySQL DBO Driver";

View file

@ -30,9 +30,9 @@ App::import('Datasource', 'DboMysql');
class DboMysqli extends DboMysqlBase { class DboMysqli extends DboMysqlBase {
/** /**
* Enter description here... * Datasource Description
* *
* @var unknown_type * @var string
*/ */
var $description = "Mysqli DBO Driver"; var $description = "Mysqli DBO Driver";

View file

@ -19,7 +19,7 @@
*/ */
/** /**
* Short description for class. * Oracle layer for DBO.
* *
* Long description for class * Long description for class
* *
@ -29,17 +29,17 @@
class DboOracle extends DboSource { class DboOracle extends DboSource {
/** /**
* Enter description here... * Configuration options
* *
* @var unknown_type * @var array
* @access public * @access public
*/ */
var $config = array(); var $config = array();
/** /**
* Enter description here... * Alias
* *
* @var unknown_type * @var string
*/ */
var $alias = ''; var $alias = '';
@ -56,9 +56,9 @@ class DboOracle extends DboSource {
var $__transactionStarted = false; var $__transactionStarted = false;
/** /**
* Enter description here... * Column definitions
* *
* @var unknown_type * @var array
* @access public * @access public
*/ */
var $columns = array( var $columns = array(
@ -77,25 +77,25 @@ class DboOracle extends DboSource {
'inet' => array('name' => 'inet')); 'inet' => array('name' => 'inet'));
/** /**
* Enter description here... * Connection object
* *
* @var unknown_type * @var mixed
* @access protected * @access protected
*/ */
var $connection; var $connection;
/** /**
* Enter description here... * Query limit
* *
* @var unknown_type * @var int
* @access protected * @access protected
*/ */
var $_limit = -1; var $_limit = -1;
/** /**
* Enter description here... * Query offset
* *
* @var unknown_type * @var int
* @access protected * @access protected
*/ */
var $_offset = 0; var $_offset = 0;
@ -109,25 +109,25 @@ class DboOracle extends DboSource {
var $_map; var $_map;
/** /**
* Enter description here... * Current Row
* *
* @var unknown_type * @var mixed
* @access protected * @access protected
*/ */
var $_currentRow; var $_currentRow;
/** /**
* Enter description here... * Number of rows
* *
* @var unknown_type * @var int
* @access protected * @access protected
*/ */
var $_numRows; var $_numRows;
/** /**
* Enter description here... * Query results
* *
* @var unknown_type * @var mixed
* @access protected * @access protected
*/ */
var $_results; var $_results;
@ -378,9 +378,9 @@ class DboOracle extends DboSource {
} }
/** /**
* Enter description here... * Fetch result row
* *
* @return unknown * @return array
* @access public * @access public
*/ */
function fetchRow() { function fetchRow() {
@ -444,10 +444,10 @@ class DboOracle extends DboSource {
} }
/** /**
* Enter description here... * Create trigger
* *
* @param unknown_type $table * @param string $table
* @return unknown * @return mixed
* @access public * @access public
*/ */
function createTrigger($table) { function createTrigger($table) {

View file

@ -29,9 +29,9 @@
class DboSqlite extends DboSource { class DboSqlite extends DboSource {
/** /**
* Enter description here... * Datasource Description
* *
* @var unknown_type * @var string
*/ */
var $description = "SQLite DBO Driver"; var $description = "SQLite DBO Driver";

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Dbo Source
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -2411,6 +2411,9 @@ class DboSource extends DataSource {
} }
} }
continue; continue;
} elseif (is_object($key) && isset($key->type) && $key->type === 'expression') {
$result[] = $key->value;
continue;
} }
if (preg_match('/\\x20(ASC|DESC).*/i', $key, $_dir)) { if (preg_match('/\\x20(ASC|DESC).*/i', $key, $_dir)) {

View file

@ -26,7 +26,7 @@
App::import('Model', 'App'); App::import('Model', 'App');
/** /**
* Short description for file. * ACL Node
* *
* *
* @package cake * @package cake

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Core Security
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Short description for file. * Application level View Helper
* *
* This file is application-wide helper file. You can put all * This file is application-wide helper file. You can put all
* application-wide helper-related methods here. * application-wide helper-related methods here.

View file

@ -69,7 +69,7 @@ class NumberHelper extends AppHelper {
* *
* @param float $number A floating point number. * @param float $number A floating point number.
* @param integer $precision The precision of the returned number. * @param integer $precision The precision of the returned number.
* @return float Enter description here... * @return float Formatted float.
* @access public * @access public
* @link http://book.cakephp.org/view/1454/precision * @link http://book.cakephp.org/view/1454/precision
*/ */

View file

@ -273,6 +273,34 @@ class FileEngineTest extends CakeTestCase {
Cache::config('default', array('engine' => 'File', 'path' => CACHE)); Cache::config('default', array('engine' => 'File', 'path' => CACHE));
} }
/**
* test that clear() doesn't wipe files not in the current engine's prefix.
*
* @return void
*/
function testClearWithPrefixes() {
$FileOne =& new FileEngine();
$FileOne->init(array(
'prefix' => 'prefix_one_',
'duration' => DAY
));
$FileTwo =& new FileEngine();
$FileTwo->init(array(
'prefix' => 'prefix_two_',
'duration' => DAY
));
$data1 = $data2 = $expected = 'content to cache';
$FileOne->write('key_one', $data1, DAY);
$FileTwo->write('key_two', $data2, DAY);
$this->assertEqual($FileOne->read('key_one'), $expected);
$this->assertEqual($FileTwo->read('key_two'), $expected);
$FileOne->clear(false);
$this->assertEqual($FileTwo->read('key_two'), $expected, 'secondary config was cleared by accident.');
}
/** /**
* testKeyPath method * testKeyPath method
* *

View file

@ -194,7 +194,7 @@ class IniAclTest extends IniAcl {
} }
/** /**
* Short description for class. * ACL Component Text case
* *
* @package cake * @package cake
* @subpackage cake.tests.cases.libs.controller.components * @subpackage cake.tests.cases.libs.controller.components

View file

@ -295,6 +295,61 @@ TEMPDOC;
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
} }
/**
* testSmtpEhlo method
*
* @access public
* @return void
*/
function testSmtpEhlo() {
if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
$connection =& new CakeSocket(array('protocol'=>'smtp', 'host' => 'localhost', 'port' => 25));
$this->Controller->EmailTest->setConnectionSocket($connection);
$this->assertTrue($connection->connect());
$this->assertTrue($this->Controller->EmailTest->smtpSend(null, '220') !== false);
$this->skipIf($this->Controller->EmailTest->smtpSend('EHLO locahost', '250') === false, '%s do not support EHLO.');
$connection->disconnect();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'smtp';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->Controller->EmailTest->_debug = true;
$this->Controller->EmailTest->sendAs = 'text';
$expect = <<<TEMPDOC
<pre>Host: localhost
Port: 25
Timeout: 30
To: postmaster@localhost
From: noreply@example.com
Subject: Cake SMTP test
Header:
To: postmaster@localhost
From: noreply@example.com
Reply-To: noreply@example.com
Subject: Cake SMTP test
X-Mailer: CakePHP Email Component
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bitParameters:
Message:
This is the body of the message
</pre>
TEMPDOC;
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
/** /**
* testSmtpSendMultipleTo method * testSmtpSendMultipleTo method

View file

@ -2966,6 +2966,19 @@ class DboSourceTest extends CakeTestCase {
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
/**
* test that order() will accept objects made from DboSource::expression
*
* @return void
*/
function testOrderWithExpression() {
$expression = $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col");
$result = $this->testDb->order($expression);
$expected = " ORDER BY CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col";
$this->assertEqual($result, $expected);
}
/** /**
* testMergeAssociations method * testMergeAssociations method
* *