Update Slim to 2.6.2 (shows 2.6.1 in code)
This commit is contained in:
parent
2f605d9805
commit
44561586b7
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -140,7 +140,10 @@ class Environment implements \ArrayAccess, \IteratorAggregate
|
||||
$env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes
|
||||
|
||||
// Virtual path
|
||||
$env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path
|
||||
$env['PATH_INFO'] = $requestUri;
|
||||
if (substr($requestUri, 0, strlen($physicalPath)) == $physicalPath) {
|
||||
$env['PATH_INFO'] = substr($requestUri, strlen($physicalPath)); // <-- Remove physical path
|
||||
}
|
||||
$env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string
|
||||
$env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash
|
||||
|
||||
@ -151,7 +154,8 @@ class Environment implements \ArrayAccess, \IteratorAggregate
|
||||
$env['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
|
||||
|
||||
//Number of server port that is running the script
|
||||
$env['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
|
||||
//Fixes: https://github.com/slimphp/Slim/issues/962
|
||||
$env['SERVER_PORT'] = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
|
||||
|
||||
//HTTP request headers (retains HTTP_ prefix to match $_SERVER)
|
||||
$headers = \Slim\Http\Headers::extract($_SERVER);
|
||||
@ -191,9 +195,9 @@ class Environment implements \ArrayAccess, \IteratorAggregate
|
||||
{
|
||||
if (isset($this->properties[$offset])) {
|
||||
return $this->properties[$offset];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -160,7 +160,7 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
|
||||
public function __unset($key)
|
||||
{
|
||||
return $this->remove($key);
|
||||
$this->remove($key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,8 +215,8 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Ensure a value or object will remain globally unique
|
||||
* @param string $key The value or object name
|
||||
* @param Closure The closure that defines the object
|
||||
* @param string $key The value or object name
|
||||
* @param \Closure $value The closure that defines the object
|
||||
* @return mixed
|
||||
*/
|
||||
public function singleton($key, $value)
|
||||
@ -234,8 +234,8 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Protect closure from being directly invoked
|
||||
* @param Closure $callable A closure to keep from being invoked and evaluated
|
||||
* @return Closure
|
||||
* @param \Closure $callable A closure to keep from being invoked and evaluated
|
||||
* @return \Closure
|
||||
*/
|
||||
public function protect(\Closure $callable)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -169,9 +169,9 @@ class Request
|
||||
return true;
|
||||
} elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -85,6 +85,7 @@ class Response implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
204 => '204 No Content',
|
||||
205 => '205 Reset Content',
|
||||
206 => '206 Partial Content',
|
||||
226 => '226 IM Used',
|
||||
//Redirection 3xx
|
||||
300 => '300 Multiple Choices',
|
||||
301 => '301 Moved Permanently',
|
||||
@ -116,13 +117,20 @@ class Response implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
418 => '418 I\'m a teapot',
|
||||
422 => '422 Unprocessable Entity',
|
||||
423 => '423 Locked',
|
||||
426 => '426 Upgrade Required',
|
||||
428 => '428 Precondition Required',
|
||||
429 => '429 Too Many Requests',
|
||||
431 => '431 Request Header Fields Too Large',
|
||||
//Server Error 5xx
|
||||
500 => '500 Internal Server Error',
|
||||
501 => '501 Not Implemented',
|
||||
502 => '502 Bad Gateway',
|
||||
503 => '503 Service Unavailable',
|
||||
504 => '504 Gateway Timeout',
|
||||
505 => '505 HTTP Version Not Supported'
|
||||
505 => '505 HTTP Version Not Supported',
|
||||
506 => '506 Variant Also Negotiates',
|
||||
510 => '510 Not Extended',
|
||||
511 => '511 Network Authentication Required'
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -60,9 +60,9 @@ class Util
|
||||
$strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes;
|
||||
if ($strip) {
|
||||
return self::stripSlashes($rawData);
|
||||
} else {
|
||||
return $rawData;
|
||||
}
|
||||
|
||||
return $rawData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -306,7 +306,12 @@ class Log
|
||||
if (!isset(self::$levels[$level])) {
|
||||
throw new \InvalidArgumentException('Invalid log level supplied to function');
|
||||
} else if ($this->enabled && $this->writer && $level <= $this->level) {
|
||||
$message = (string)$object;
|
||||
if (is_array($object) || (is_object($object) && !method_exists($object, "__toString"))) {
|
||||
$message = print_r($object, true);
|
||||
} else {
|
||||
$message = (string) $object;
|
||||
}
|
||||
|
||||
if (count($context) > 0) {
|
||||
if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
|
||||
$message .= ' - ' . $context['exception'];
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -116,7 +116,7 @@ class ContentTypes extends \Slim\Middleware
|
||||
{
|
||||
if (function_exists('json_decode')) {
|
||||
$result = json_decode($input, true);
|
||||
if ($result) {
|
||||
if(json_last_error() === JSON_ERROR_NONE) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -119,15 +119,10 @@ class SessionCookie extends \Slim\Middleware
|
||||
if (session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$value = $this->app->getCookie($this->settings['name']);
|
||||
|
||||
if ($value) {
|
||||
try {
|
||||
$_SESSION = unserialize($value);
|
||||
} catch (\Exception $e) {
|
||||
$this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage());
|
||||
}
|
||||
$value = json_decode($value, true);
|
||||
$_SESSION = is_array($value) ? $value : array();
|
||||
} else {
|
||||
$_SESSION = array();
|
||||
}
|
||||
@ -138,7 +133,7 @@ class SessionCookie extends \Slim\Middleware
|
||||
*/
|
||||
protected function saveSession()
|
||||
{
|
||||
$value = serialize($_SESSION);
|
||||
$value = json_encode($_SESSION);
|
||||
|
||||
if (strlen($value) > 4096) {
|
||||
$this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.');
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -232,9 +232,9 @@ class Router
|
||||
$this->getNamedRoutes();
|
||||
if ($this->hasNamedRoute($name)) {
|
||||
return $this->namedRoutes[(string) $name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -54,7 +54,7 @@ class Slim
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
const VERSION = '2.4.2';
|
||||
const VERSION = '2.6.1';
|
||||
|
||||
/**
|
||||
* @var \Slim\Helper\Set
|
||||
@ -231,22 +231,22 @@ class Slim
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->container[$name];
|
||||
return $this->container->get($name);
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->container[$name] = $value;
|
||||
$this->container->set($name, $value);
|
||||
}
|
||||
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this->container[$name]);
|
||||
return $this->container->has($name);
|
||||
}
|
||||
|
||||
public function __unset($name)
|
||||
{
|
||||
unset($this->container[$name]);
|
||||
$this->container->remove($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -906,7 +906,12 @@ class Slim
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
/*
|
||||
* transform $value to @return doc requirement.
|
||||
* \Slim\Http\Util::decodeSecureCookie - is able
|
||||
* to return false and we have to cast it to null.
|
||||
*/
|
||||
return $value === false ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1150,6 +1155,16 @@ class Slim
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all flash messages
|
||||
*/
|
||||
public function flashData()
|
||||
{
|
||||
if (isset($this->environment['slim.flash'])) {
|
||||
return $this->environment['slim.flash']->getMessages();
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* Hooks
|
||||
*******************************************************************************/
|
||||
@ -1172,10 +1187,10 @@ class Slim
|
||||
|
||||
/**
|
||||
* Invoke hook
|
||||
* @param string $name The hook name
|
||||
* @param mixed $hookArg (Optional) Argument for hooked functions
|
||||
* @param string $name The hook name
|
||||
* @param mixed ... (Optional) Argument(s) for hooked functions, can specify multiple arguments
|
||||
*/
|
||||
public function applyHook($name, $hookArg = null)
|
||||
public function applyHook($name)
|
||||
{
|
||||
if (!isset($this->hooks[$name])) {
|
||||
$this->hooks[$name] = array(array());
|
||||
@ -1185,10 +1200,14 @@ class Slim
|
||||
if (count($this->hooks[$name]) > 1) {
|
||||
ksort($this->hooks[$name]);
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
|
||||
foreach ($this->hooks[$name] as $priority) {
|
||||
if (!empty($priority)) {
|
||||
foreach ($priority as $callable) {
|
||||
call_user_func($callable, $hookArg);
|
||||
call_user_func_array($callable, $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1356,6 +1375,7 @@ class Slim
|
||||
throw $e;
|
||||
} else {
|
||||
try {
|
||||
$this->response()->write(ob_get_clean());
|
||||
$this->error($e);
|
||||
} catch (\Slim\Exception\Stop $e) {
|
||||
// Do nothing
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @copyright 2011 Josh Lockhart
|
||||
* @link http://www.slimframework.com
|
||||
* @license http://www.slimframework.com/license
|
||||
* @version 2.4.2
|
||||
* @version 2.6.1
|
||||
* @package Slim
|
||||
*
|
||||
* MIT LICENSE
|
||||
@ -152,9 +152,9 @@ class View
|
||||
{
|
||||
if (!is_null($key)) {
|
||||
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||
} else {
|
||||
return $this->data->all();
|
||||
}
|
||||
|
||||
return $this->data->all();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user