Skip to content

Commit

Permalink
Merge branch '3.1/release/3.1.4' into 3.1/master
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed Jul 25, 2011
2 parents ed12c18 + d1eef5e commit 4419480
Show file tree
Hide file tree
Showing 26 changed files with 88 additions and 50 deletions.
4 changes: 2 additions & 2 deletions classes/kohana/core.php
Expand Up @@ -16,8 +16,8 @@
class Kohana_Core {

// Release version and codename
const VERSION = '3.1.3.1';
const CODENAME = 'araea';
const VERSION = '3.1.4';
const CODENAME = 'fasciinucha';

// Common environment type constants for consistency and convenience
const PRODUCTION = 1;
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/date.php
Expand Up @@ -277,7 +277,7 @@ public static function months($format = NULL)
{
$months = array();

if ($format === DATE::MONTHS_LONG OR $format === DATE::MONTHS_SHORT)
if ($format === Date::MONTHS_LONG OR $format === Date::MONTHS_SHORT)
{
for ($i = 1; $i <= 12; ++$i)
{
Expand Down
2 changes: 2 additions & 0 deletions classes/kohana/html.php
Expand Up @@ -174,6 +174,7 @@ public static function file_anchor($file, $title = NULL, array $attributes = NUL
* @param string string to obfuscate
* @return string
* @since 3.0.3
* @deprecated - removed in 3.2
*/
public static function obfuscate($string)
{
Expand Down Expand Up @@ -210,6 +211,7 @@ public static function obfuscate($string)
* @param string email address
* @return string
* @uses HTML::obfuscate
* @deprecated - removed in 3.2 due to removal of HTML::obfuscate
*/
public static function email($email)
{
Expand Down
4 changes: 2 additions & 2 deletions classes/kohana/http/header.php
Expand Up @@ -224,10 +224,10 @@ public function offsetSet($index, $newval)
return parent::offsetSet(strtolower($index), $newval);
elseif ( ! $newval instanceof HTTP_Header_Value)
{
$newval = new HTTP_Header_Value($newval);
$newval = new HTTP_Header_Value((string) $newval);
}

parent::offsetSet(strtolower($index), $newval);
parent::offsetSet(strtolower($index), (string) $newval);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions classes/kohana/kohana/exception.php
Expand Up @@ -48,15 +48,15 @@ public function __construct($message, array $variables = NULL, $code = 0)
Kohana_Exception::$php_errors[E_DEPRECATED] = 'Deprecated';
}

// Save the unmodified code
// @link http://bugs.php.net/39615
$this->code = $code;

// Set the message
$message = __($message, $variables);

// Pass the message and integer code to the parent
parent::__construct($message, (int) $code);

// Save the unmodified code
// @link http://bugs.php.net/39615
$this->code = $code;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/log/file.php
Expand Up @@ -65,7 +65,7 @@ public function write(array $messages)

if ( ! is_dir($directory))
{
// Create the yearly directory
// Create the monthly directory
mkdir($directory, 02777);

// Set permissions (must be manually set to fix umask issues)
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/log/stderr.php
Expand Up @@ -8,7 +8,7 @@
* @copyright (c) 2008-2011 Kohana Team
* @license http://kohanaphp.com/license
*/
class Kohana_Log_StdErr extends Kohana_Log_Writer {
class Kohana_Log_StdErr extends Log_Writer {
/**
* Writes each of the messages to STDERR.
*
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/log/stdout.php
Expand Up @@ -8,7 +8,7 @@
* @copyright (c) 2008-2011 Kohana Team
* @license http://kohanaphp.com/license
*/
class Kohana_Log_StdOut extends Kohana_Log_Writer {
class Kohana_Log_StdOut extends Log_Writer {
/**
* Writes each of the messages to STDOUT.
*
Expand Down
1 change: 1 addition & 0 deletions classes/kohana/log/writer.php
Expand Up @@ -16,6 +16,7 @@ abstract class Kohana_Log_Writer {
*/
protected $_log_levels = array(
LOG_EMERG => 'EMERGENCY',
LOG_ALERT => 'ALERT',
LOG_CRIT => 'CRITICAL',
LOG_ERR => 'ERROR',
LOG_WARNING => 'WARNING',
Expand Down
28 changes: 17 additions & 11 deletions classes/kohana/request.php
Expand Up @@ -942,23 +942,29 @@ public function send_headers()
*/
public function redirect($url = '', $code = 302)
{
$referrer = $this->uri();

if (strpos($referrer, '://') === FALSE)
{
$referrer = URL::site($referrer, TRUE, Kohana::$index_file);
}

if (strpos($url, '://') === FALSE)
{
// Make the URI into a URL
$url = URL::site($url, TRUE);
$url = URL::site($url, TRUE, Kohana::$index_file);
}

// Redirect
$response = $this->create_response();

// Set the response status
$response->status($code);

// Set the location header
$response->headers('Location', $url);
if (($response = $this->response()) === NULL)
{
$response = $this->create_response();
}

// Send headers
$response->send_headers();
echo $response->status($code)
->headers('Location', $url)
->headers('Referer', $referrer)
->send_headers()
->body();

// Stop execution
exit;
Expand Down
16 changes: 13 additions & 3 deletions classes/kohana/request/client/external.php
Expand Up @@ -169,7 +169,7 @@ public function options($key = NULL, $value = NULL)
{
$this->_options = $key;
}
elseif ( ! $value)
elseif ($value === NULL)
{
return Arr::get($this->_options, $key);
}
Expand Down Expand Up @@ -216,8 +216,15 @@ protected function _http_execute(Request $request)
$http_request->setCookies($request->cookie());

// Set the body
$http_request->setBody($request->body());

if ($request->method() == HTTP_Request::PUT)
{
$http_request->addPutData($request->body());
}
else
{
$http_request->setBody($request->body());
}

// Set the query
$http_request->setQueryData($request->query());

Expand Down Expand Up @@ -289,6 +296,9 @@ protected function _curl_execute(Request $request)
$options[CURLOPT_COOKIE] = http_build_query($cookies, NULL, '; ');
}

// Implement the default header parsing
$options[CURLOPT_HEADERFUNCTION] = array($this, '_parse_headers');

// The transfer must always be returned
$options[CURLOPT_RETURNTRANSFER] = TRUE;

Expand Down
5 changes: 4 additions & 1 deletion classes/kohana/request/client/internal.php
Expand Up @@ -146,7 +146,10 @@ public function execute(Request $request)
catch (Exception $e)
{
// Restore the previous request
Request::$current = $previous;
if ($previous instanceof Request)
{
Request::$current = $previous;
}

if (isset($benchmark))
{
Expand Down
17 changes: 11 additions & 6 deletions classes/kohana/response.php
Expand Up @@ -447,8 +447,15 @@ public function send_headers()
{
if (is_string($name))
{
// If the value is an array
if (is_array($value))
{
// Render this correctly
$value = implode(', ', $value);
}

// Combine the name and value to make a raw header
$value = $name.': '.$value;
$value = $name.': '.(string) $value;
}

// Send the raw header
Expand Down Expand Up @@ -808,9 +815,7 @@ public function check_cache($etag = NULL, Request $request = NULL)
}

/**
* Serializes the object to json - handy if you
* need to pass the response data to other
* systems
* Serializes the object
*
* @param array array of data to serialize
* @return string
Expand Down Expand Up @@ -840,9 +845,9 @@ public function serialize(array $to_serialize = array())
}

/**
* JSON encoded object
* PHP serialized object
*
* @param string json encoded object
* @param string php serialized string
* @return bool
* @throws Kohana_Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/text.php
Expand Up @@ -346,7 +346,7 @@ public static function auto_link($text)
public static function auto_link_urls($text)
{
// Find and replace all http/https/ftp/ftps links that are not part of an existing html anchor
$text = preg_replace_callback('~\b(?<!href="|">)(?:ht|f)tps?://\S+(?:/|\b)~i', 'Text::_auto_link_urls_callback1', $text);
$text = preg_replace_callback('~\b(?<!href="|">)(?:ht|f)tps?://[^<\s]+(?:/|\b)~i', 'Text::_auto_link_urls_callback1', $text);

// Find and replace all naked www.links.com (without http://)
return preg_replace_callback('~\b(?<!://|">)www(?:\.[a-z0-9][-a-z0-9]*+)+\.[a-z]{2,6}\b~i', 'Text::_auto_link_urls_callback2', $text);
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/valid.php
Expand Up @@ -224,7 +224,7 @@ public static function ip($ip, $allow_private = TRUE)
* @param integer credit card number
* @param string|array card type, or an array of card types
* @return boolean
* @uses Validate::luhn
* @uses Valid::luhn
*/
public static function credit_card($number, $type = NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/validation.php
Expand Up @@ -118,7 +118,7 @@ public function labels(array $labels)
*
* // The "username" must not be empty and have a minimum length of 4
* $validation->rule('username', 'not_empty')
* ->rule('username', 'min_length', array('username', 4));
* ->rule('username', 'min_length', array(':value', 4));
*
* // The "password" field must match the "password_repeat" field
* $validation->rule('password', 'matches', array(':validation', 'password', 'password_repeat'));
Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/validation/exception.php
Expand Up @@ -14,7 +14,7 @@ class Kohana_Validation_Exception extends Kohana_Exception {
public $array;

/**
* @param Validate Validate object
* @param Validation Validation object
* @param string error message
* @param array translation variables
* @param int the exception code
Expand Down
1 change: 1 addition & 0 deletions config/inflector.php
Expand Up @@ -67,5 +67,6 @@
'verse' => 'verses',
'hero' => 'heroes',
'purchase' => 'purchases',
'expense' => 'expenses',
),
);
2 changes: 1 addition & 1 deletion guide/kohana/conventions.md
Expand Up @@ -388,7 +388,7 @@ Use //, preferably above the line of code you're commenting on. Leave a space af
When coding regular expressions please use PCRE rather than the POSIX flavor. PCRE is considered more powerful and faster.

// Correct:
if (preg_match('/abc/i'), $str)
if (preg_match('/abc/i', $str))

// Incorrect:
if (eregi('abc', $str))
Expand Down
2 changes: 1 addition & 1 deletion guide/kohana/files/messages.md
Expand Up @@ -33,4 +33,4 @@ This will look in the `messages/forms/contact.php` for the `[foobar][bar]` key:
## Notes

* Don't use __() in your messages files, as these files can be cached and will not work properly.
* Messages are merged by the cascading file system, not overwritten like config files.
* Messages are merged by the cascading file system, not overwritten like classes and views.
4 changes: 2 additions & 2 deletions guide/kohana/flow.md
Expand Up @@ -6,9 +6,9 @@ Every application follows the same flow:
1. The application, module, and system paths are set. (`APPPATH`, `MODPATH`, and `SYSPATH`)
2. Error reporting levels are set.
3. Install file is loaded, if it exists.
4. The [Kohana] class is loaded.
5. The bootstrap file, `APPPATH/bootstrap.php`, is included.
4. The bootstrap file, `APPPATH/bootstrap.php`, is included.
2. Once we are in `bootstrap.php`:
6. The [Kohana] class is loaded.
7. [Kohana::init] is called, which sets up error handling, caching, and logging.
8. [Kohana_Config] readers and [Kohana_Log] writers are attached.
9. [Kohana::modules] is called to enable additional modules.
Expand Down
2 changes: 1 addition & 1 deletion guide/kohana/mvc.md
@@ -1,3 +1,3 @@
<http://kohanaframework.org/guide/about.mvc>

Discus the MVC pattern, as it pertains to Kohana. Perhaps have an image, etc.
Discuss the MVC pattern, as it pertains to Kohana. Perhaps have an image, etc.
6 changes: 3 additions & 3 deletions guide/kohana/security/validation.md
Expand Up @@ -2,7 +2,7 @@

*This page needs to be reviewed for accuracy by the development team. Better examples would be helpful.*

Validation can be performed on any array using the [Validation] class. Labels and rules can be attached to a Validate object by the array key, called a "field name".
Validation can be performed on any array using the [Validation] class. Labels and rules can be attached to a Validation object by the array key, called a "field name".

labels
: A label is a human-readable version of the field name.
Expand Down Expand Up @@ -32,7 +32,7 @@ Rule name | Function
[Valid::max_length] | Maximum number of characters for value
[Valid::exact_length] | Value must be an exact number of characters
[Valid::email] | An email address is required
[Validate::email_domain] | Check that the domain of the email exists
[Valid::email_domain] | Check that the domain of the email exists
[Valid::url] | Value must be a URL
[Valid::ip] | Value must be an IP address
[Valid::phone] | Value must be a phone number
Expand Down Expand Up @@ -180,7 +180,7 @@ Next, we need a controller and action to process the registration, which will be
{
$user = Model::factory('user');

$post = Validate::factory($_POST)
$post = Validation::factory($_POST)
->rule('username', 'not_empty')
->rule('username', 'regex', array(':value', '/^[a-z_.]++$/iD'))
->rule('username', array($user, 'unique_username'))
Expand Down
6 changes: 6 additions & 0 deletions tests/kohana/ExceptionTest.php
Expand Up @@ -31,8 +31,14 @@ public function provider_constructor()
array(array(':a :b', array(':a' => 'c', ':b' => 'd')), 'c d', 0),

array(array(':a', NULL, 5), ':a', 5),
// #3358
array(array(':a', NULL, '3F000'), ':a', '3F000'),
// #3404
array(array(':a', NULL, '42S22'), ':a', '42S22'),
// #3927
array(array(':a', NULL, 'b'), ':a', 'b'),
// #4039
array(array(':a', NULL, '25P01'), ':a', '25P01'),
);
}

Expand Down
9 changes: 4 additions & 5 deletions tests/kohana/ResponseTest.php
Expand Up @@ -26,11 +26,10 @@ public function test_expose()
$response = new Response;
$headers = $response->send_headers()->headers();
$this->assertArrayHasKey('x-powered-by', (array) $headers);

if (isset($headers['x-powered-by']))
{
$this->assertSame($headers['x-powered-by']->value, 'Kohana Framework '.Kohana::VERSION.' ('.Kohana::CODENAME.')');
}
$this->assertSame(
'Kohana Framework '.Kohana::VERSION.' ('.Kohana::CODENAME.')',
$headers['x-powered-by']
);

Kohana::$expose = FALSE;
$response = new Response;
Expand Down
5 changes: 5 additions & 0 deletions tests/kohana/TextTest.php
Expand Up @@ -495,6 +495,11 @@ public function provider_auto_link_urls()
'<a href="http://www.google.com/">www.google.com</a> <a href="http://www.google.com/">http://www.google.com/</a>',
'<a href="http://www.google.com/">www.google.com</a> http://www.google.com/',
),
// @issue 3436
array(
'<strong><a href="http://www.google.com/">http://www.google.com/</a></strong>',
'<strong>http://www.google.com/</strong>',
),
);
}

Expand Down

0 comments on commit 4419480

Please sign in to comment.