Skip to content

Commit fa66e19

Browse files
committed
Merge 3.3/release/3.3.3 into 3.3/master
2 parents 56e452c + 9c380c1 commit fa66e19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1985
-370
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*~
22
*.swp
3+
/composer.lock
4+
/vendor/*
5+
/koharness_bootstrap.php

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
- 5.6
8+
- hhvm
9+
10+
before_script:
11+
- COMPOSER_ROOT_VERSION=3.3.x-dev composer install --prefer-dist
12+
- vendor/bin/koharness
13+
14+
script:
15+
- cd /tmp/koharness && ./vendor/bin/phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php
16+
17+
notifications:
18+
email: false

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Kohana PHP Framework - core
2+
3+
| ver | Stable | Develop |
4+
|-------|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
5+
| 3.3.x | [![Build Status - 3.3/master](https://travis-ci.org/kohana/core.svg?branch=3.3%2Fmaster)](https://travis-ci.org/kohana/core) | [![Build Status - 3.3/develop](https://travis-ci.org/kohana/core.svg?branch=3.3%2Fdevelop)](https://travis-ci.org/kohana/core) |
6+
| 3.4.x | [![Build Status - 3.4/master](https://travis-ci.org/kohana/core.svg?branch=3.4%2Fmaster)](https://travis-ci.org/kohana/core) | [![Build Status - 3.4/develop](https://travis-ci.org/kohana/core.svg?branch=3.4%2Fdevelop)](https://travis-ci.org/kohana/core) |
7+
8+
This is the core package for the [Kohana](http://kohanaframework.org/) object oriented HMVC framework built using PHP5.
9+
It aims to be swift, secure, and small.
10+
11+
Released under a [BSD license](http://kohanaframework.org/license), Kohana can be used legally for any open source,
12+
commercial, or personal project.
13+
14+
## Documentation and installation
15+
16+
See the [sample application repository](https://github.com/kohana/kohana) for full readme and contributing information.
17+
You will usually add `kohana/core` as a dependency in your own project's composer.json to install and work with this
18+
pacakge.
19+
20+
## Installation for development
21+
22+
To work on this package, you'll want to install it with composer to get the required dependencies. Note that there are
23+
currently circular dependencies between this module and kohana/unittest. These may cause you problems if you are working
24+
on a feature branch, because composer may not be able to figure out which version of kohana core you have.
25+
26+
To work around this, run composer like: `COMPOSER_ROOT_VERSION=3.3.x-dev composer install`. This tells composer that the
27+
current checkout is a 3.3.* development version. Obviously change the argument if your branch is based on a different
28+
version.
29+
30+
After installing the dependencies, you'll need a skeleton Kohana application before you can run the unit tests etc. The
31+
simplest way to do this is to use kohana/koharness to build a bare project in `/tmp/koharness`.
32+
33+
If in doubt, check the install and test steps in the [.travis.yml](.travis.yml) file.

classes/Kohana/Arr.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@ public static function range($step = 10, $max = 100)
279279
*/
280280
public static function get($array, $key, $default = NULL)
281281
{
282-
return isset($array[$key]) ? $array[$key] : $default;
282+
if ($array instanceof ArrayObject) {
283+
// This is a workaround for inconsistent implementation of isset between PHP and HHVM
284+
// See https://github.com/facebook/hhvm/issues/3437
285+
return $array->offsetExists($key) ? $array->offsetGet($key) : $default;
286+
} else {
287+
return isset($array[$key]) ? $array[$key] : $default;
288+
}
283289
}
284290

285291
/**

classes/Kohana/Config/Group.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
* @package Kohana
1212
* @category Configuration
1313
* @author Kohana Team
14-
* @copyright (c) 2012 Kohana Team
15-
* @license http://kohanaphp.com/license
14+
* @copyright (c) 2012-2014 Kohana Team
15+
* @license http://kohanaframework.org/license
1616
*/
1717
class Kohana_Config_Group extends ArrayObject {
1818

classes/Kohana/Config/Source.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @package Kohana
88
* @category Configuration
99
* @author Kohana Team
10-
* @copyright (c) 2012 Kohana Team
11-
* @license http://kohanaphp.com/license
10+
* @copyright (c) 2012-2014 Kohana Team
11+
* @license http://kohanaframework.org/license
1212
*/
1313

1414
interface Kohana_Config_Source {}

classes/Kohana/Config/Writer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*
88
* @package Kohana
99
* @author Kohana Team
10-
* @copyright (c) 2008-2012 Kohana Team
11-
* @license http://kohanaphp.com/license
10+
* @copyright (c) 2008-2014 Kohana Team
11+
* @license http://kohanaframework.org/license
1212
*/
1313
interface Kohana_Config_Writer extends Kohana_Config_Source
1414
{

classes/Kohana/Cookie.php

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public static function get($key, $default = NULL)
7171
// Separate the salt and the value
7272
list ($hash, $value) = explode('~', $cookie, 2);
7373

74-
if (Cookie::salt($key, $value) === $hash)
74+
if (Security::slow_equals(Cookie::salt($key, $value), $hash))
7575
{
7676
// Cookie signature is valid
7777
return $value;
7878
}
7979

8080
// The cookie signature is invalid, delete it
81-
Cookie::delete($key);
81+
static::delete($key);
8282
}
8383

8484
return $default;
@@ -88,33 +88,38 @@ public static function get($key, $default = NULL)
8888
* Sets a signed cookie. Note that all cookie values must be strings and no
8989
* automatic serialization will be performed!
9090
*
91+
* [!!] By default, Cookie::$expiration is 0 - if you skip/pass NULL for the optional
92+
* lifetime argument your cookies will expire immediately unless you have separately
93+
* configured Cookie::$expiration.
94+
*
95+
*
9196
* // Set the "theme" cookie
9297
* Cookie::set('theme', 'red');
9398
*
9499
* @param string $name name of cookie
95100
* @param string $value value of cookie
96-
* @param integer $expiration lifetime in seconds
101+
* @param integer $lifetime lifetime in seconds
97102
* @return boolean
98103
* @uses Cookie::salt
99104
*/
100-
public static function set($name, $value, $expiration = NULL)
105+
public static function set($name, $value, $lifetime = NULL)
101106
{
102-
if ($expiration === NULL)
107+
if ($lifetime === NULL)
103108
{
104109
// Use the default expiration
105-
$expiration = Cookie::$expiration;
110+
$lifetime = Cookie::$expiration;
106111
}
107112

108-
if ($expiration !== 0)
113+
if ($lifetime !== 0)
109114
{
110115
// The expiration is expected to be a UNIX timestamp
111-
$expiration += time();
116+
$lifetime += static::_time();
112117
}
113118

114119
// Add the salt to the cookie value
115120
$value = Cookie::salt($name, $value).'~'.$value;
116121

117-
return setcookie($name, $value, $expiration, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httponly);
122+
return static::_setcookie($name, $value, $lifetime, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httponly);
118123
}
119124

120125
/**
@@ -131,16 +136,18 @@ public static function delete($name)
131136
unset($_COOKIE[$name]);
132137

133138
// Nullify the cookie and make it expire
134-
return setcookie($name, NULL, -86400, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httponly);
139+
return static::_setcookie($name, NULL, -86400, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httponly);
135140
}
136141

137142
/**
138143
* Generates a salt string for a cookie based on the name and value.
139144
*
140145
* $salt = Cookie::salt('theme', 'red');
141146
*
142-
* @param string $name name of cookie
143-
* @param string $value value of cookie
147+
* @param string $name name of cookie
148+
* @param string $value value of cookie
149+
*
150+
* @throws Kohana_Exception if Cookie::$salt is not configured
144151
* @return string
145152
*/
146153
public static function salt($name, $value)
@@ -154,7 +161,38 @@ public static function salt($name, $value)
154161
// Determine the user agent
155162
$agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : 'unknown';
156163

157-
return sha1($agent.$name.$value.Cookie::$salt);
164+
return hash_hmac('sha1', $agent.$name.$value.Cookie::$salt, Cookie::$salt);
165+
}
166+
167+
/**
168+
* Proxy for the native setcookie function - to allow mocking in unit tests so that they do not fail when headers
169+
* have been sent.
170+
*
171+
* @param string $name
172+
* @param string $value
173+
* @param integer $expire
174+
* @param string $path
175+
* @param string $domain
176+
* @param boolean $secure
177+
* @param boolean $httponly
178+
*
179+
* @return bool
180+
* @see setcookie
181+
*/
182+
protected static function _setcookie($name, $value, $expire, $path, $domain, $secure, $httponly)
183+
{
184+
return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
185+
}
186+
187+
/**
188+
* Proxy for the native time function - to allow mocking of time-related logic in unit tests
189+
*
190+
* @return int
191+
* @see time
192+
*/
193+
protected static function _time()
194+
{
195+
return time();
158196
}
159197

160198
}

classes/Kohana/Core.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
class Kohana_Core {
1717

1818
// Release version and codename
19-
const VERSION = '3.3.2';
20-
const CODENAME = 'dryocopus';
19+
const VERSION = '3.3.3';
20+
const CODENAME = 'uluru';
2121

2222
// Common environment type constants for consistency and convenience
2323
const PRODUCTION = 10;
@@ -322,7 +322,7 @@ public static function init(array $settings = NULL)
322322
}
323323

324324
// Determine if the extremely evil magic quotes are enabled
325-
Kohana::$magic_quotes = (version_compare(PHP_VERSION, '5.4') < 0 AND get_magic_quotes_gpc());
325+
Kohana::$magic_quotes = get_magic_quotes_gpc();
326326

327327
// Sanitize all request variables
328328
$_GET = Kohana::sanitize($_GET);

classes/Kohana/Date.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,10 @@ public static function formatted_time($datetime_str = 'now', $timestamp_format =
592592
$tz = new DateTimeZone($timezone ? $timezone : date_default_timezone_get());
593593
$time = new DateTime($datetime_str, $tz);
594594

595-
if ($time->getTimeZone()->getName() !== $tz->getName())
596-
{
597-
$time->setTimeZone($tz);
598-
}
595+
// Convert the time back to the expected timezone if required (in case the datetime_str provided a timezone,
596+
// offset or unix timestamp. This also ensures that the timezone reported by the object is correct on HHVM
597+
// (see https://github.com/facebook/hhvm/issues/2302).
598+
$time->setTimeZone($tz);
599599

600600
return $time->format($timestamp_format);
601601
}

0 commit comments

Comments
 (0)