From 3e8e13bd2533ff7e3493b27c8a8587dfb65e1b26 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 23 Dec 2009 12:42:57 -0800 Subject: [PATCH] Updated Kohana to r4728 --- system/core/Kohana.php | 7 ++-- system/core/Kohana_Exception.php | 26 +++++++------- system/libraries/Input.php | 31 +--------------- system/messages/core.php | 37 ------------------- system/messages/kohana/core.php | 37 +++++++++++++++++++ system/messages/validation/default.php | 42 +++++++++++++--------- system/views/kohana/error.php | 50 +++++++++++++------------- 7 files changed, 104 insertions(+), 126 deletions(-) delete mode 100644 system/messages/core.php create mode 100644 system/messages/kohana/core.php diff --git a/system/core/Kohana.php b/system/core/Kohana.php index 740adb808c..29ca708cc7 100644 --- a/system/core/Kohana.php +++ b/system/core/Kohana.php @@ -2,7 +2,7 @@ /** * Provides Kohana-specific helper functions. This is where the magic happens! * - * $Id: Kohana.php 4724 2009-12-21 16:28:54Z isaiah $ + * $Id: Kohana.php 4726 2009-12-23 18:58:53Z isaiah $ * * @package Core * @author Kohana Team @@ -810,11 +810,8 @@ public static function find_file($directory, $filename, $required = FALSE, $ext { if ($required === TRUE) { - // Directory i18n key - $directory = 'core.'.inflector::singular($directory); - // If the file is required, throw an exception - throw new Kohana_Exception('The requested :resource:, :file:, could not be found', array(':resource:' => Kohana::message($directory), ':file:' =>$filename)); + throw new Kohana_Exception('The requested :resource:, :file:, could not be found', array(':resource:' => __($directory), ':file:' =>$filename)); } else { diff --git a/system/core/Kohana_Exception.php b/system/core/Kohana_Exception.php index 2eb28f75e1..0cbc472cd1 100644 --- a/system/core/Kohana_Exception.php +++ b/system/core/Kohana_Exception.php @@ -2,7 +2,7 @@ /** * Kohana Exceptions * - * $Id: Kohana_Exception.php 4692 2009-12-04 15:59:44Z cbandy $ + * $Id: Kohana_Exception.php 4726 2009-12-23 18:58:53Z isaiah $ * * @package Core * @author Kohana Team @@ -119,7 +119,7 @@ public static function handle(Exception $e) // Manually save logs after exceptions Kohana_Log::save(); - if (Kohana::config('core.display_errors') === FALSE) + if (Kohana::config('kohana/core.display_errors') === FALSE) { // Do not show the details $file = $line = NULL; @@ -146,7 +146,7 @@ public static function handle(Exception $e) } // Use the human-readable error name - $code = Kohana::message('core.errors.'.$code); + $code = Kohana::message('kohana/core.errors.'.$code); } else { @@ -160,7 +160,7 @@ public static function handle(Exception $e) if ($e instanceof ErrorException) { // Use the human-readable error name - $code = Kohana::message('core.errors.'.$e->getSeverity()); + $code = Kohana::message('kohana/core.errors.'.$e->getSeverity()); if (version_compare(PHP_VERSION, '5.3', '<')) { @@ -233,11 +233,12 @@ public function sendHeaders() * * @param mixed variable to dump * @param integer maximum length of strings + * @param integer maximum levels of recursion * @return string */ - public static function dump($value, $length = 128) + public static function dump($value, $length = 128, $max_level = 5) { - return Kohana_Exception::_dump($value, $length); + return Kohana_Exception::_dump($value, $length, $max_level); } /** @@ -245,10 +246,11 @@ public static function dump($value, $length = 128) * * @param mixed variable to dump * @param integer maximum length of strings - * @param integer recursion level (internal) + * @param integer maximum levels of recursion + * @param integer current recursion level (internal) * @return string */ - private static function _dump( & $var, $length = 128, $level = 0) + private static function _dump( & $var, $length = 128, $max_level = 5, $level = 0) { if ($var === NULL) { @@ -327,7 +329,7 @@ private static function _dump( & $var, $length = 128, $level = 0) { $output[] = "(\n$space$s*RECURSION*\n$space)"; } - elseif ($level < 5) + elseif ($level <= $max_level) { $output[] = "("; @@ -340,7 +342,7 @@ private static function _dump( & $var, $length = 128, $level = 0) $key = '"'.$key.'"'; } - $output[] = "$space$s$key => ".Kohana_Exception::_dump($val, $length, $level + 1); + $output[] = "$space$s$key => ".Kohana_Exception::_dump($val, $length, $max_level, $level + 1); } unset($var[$marker]); @@ -377,7 +379,7 @@ private static function _dump( & $var, $length = 128, $level = 0) { $output[] = "{\n$space$s*RECURSION*\n$space}"; } - elseif ($level < 5) + elseif ($level <= $max_level) { $output[] = "{"; @@ -397,7 +399,7 @@ private static function _dump( & $var, $length = 128, $level = 0) $access = 'public'; } - $output[] = "$space$s$access $key => ".Kohana_Exception::_dump($val, $length, $level + 1); + $output[] = "$space$s$access $key => ".Kohana_Exception::_dump($val, $length, $max_level, $level + 1); } unset($objects[$hash]); diff --git a/system/libraries/Input.php b/system/libraries/Input.php index 0440385485..7a277317e2 100644 --- a/system/libraries/Input.php +++ b/system/libraries/Input.php @@ -2,7 +2,7 @@ /** * Input library. * - * $Id: Input.php 4720 2009-12-17 21:15:03Z isaiah $ + * $Id: Input.php 4727 2009-12-23 19:03:05Z isaiah $ * * @package Core * @author Kohana Team @@ -79,35 +79,6 @@ public function __construct() Kohana_Log::add('debug', 'Disable magic_quotes_gpc! It is evil and deprecated: http://php.net/magic_quotes'); } - // register_globals is enabled - if (ini_get('register_globals')) - { - if (isset($_REQUEST['GLOBALS'])) - { - // Prevent GLOBALS override attacks - exit('Global variable overload attack.'); - } - - // Destroy the REQUEST global - $_REQUEST = array(); - - // These globals are standard and should not be removed - $preserve = array('GLOBALS', '_REQUEST', '_GET', '_POST', '_FILES', '_COOKIE', '_SERVER', '_ENV', '_SESSION'); - - // This loop has the same effect as disabling register_globals - foreach (array_diff(array_keys($GLOBALS), $preserve) as $key) - { - global $$key; - $$key = NULL; - - // Unset the global variable - unset($GLOBALS[$key], $$key); - } - - // Warn the developer about register globals - Kohana_Log::add('debug', 'Disable register_globals! It is evil and deprecated: http://php.net/register_globals'); - } - if (is_array($_GET)) { foreach ($_GET as $key => $val) diff --git a/system/messages/core.php b/system/messages/core.php deleted file mode 100644 index 64f897e80e..0000000000 --- a/system/messages/core.php +++ /dev/null @@ -1,37 +0,0 @@ - array - ( - E_KOHANA => __('Framework Error'), // __('Please check the Kohana documentation for information about the following error.'), - E_PAGE_NOT_FOUND => __('Page Not Found'), // __('The requested page was not found. It may have moved, been deleted, or archived.'), - E_DATABASE_ERROR => __('Database Error'), // __('A database error occurred while performing the requested procedure. Please review the database error below for more information.'), - E_RECOVERABLE_ERROR => __('Recoverable Error'), // __('An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator.'), - E_ERROR => __('Fatal Error'), - E_COMPILE_ERROR => __('Fatal Error'), - E_CORE_ERROR => __('Fatal Error'), - E_USER_ERROR => __('Fatal Error'), - E_PARSE => __('Syntax Error'), - E_WARNING => __('Warning Message'), - E_COMPILE_WARNING => __('Warning Message'), - E_CORE_WARNING => __('Warning Message'), - E_USER_WARNING => __('Warning Message'), - E_STRICT => __('Strict Mode Error'), - E_NOTICE => __('Runtime Message'), - E_USER_NOTICE => __('Runtime Message'), - ), - 'config' => 'config file', - 'controller' => 'controller', - 'helper' => 'helper', - 'library' => 'library', - 'driver' => 'driver', - 'model' => 'model', - 'view' => 'view', -); - -// E_DEPRECATED is only defined in PHP >= 5.3.0 -if (defined('E_DEPRECATED')) -{ - $messages['errors'][E_DEPRECATED] = __('Deprecated'); -} \ No newline at end of file diff --git a/system/messages/kohana/core.php b/system/messages/kohana/core.php new file mode 100644 index 0000000000..1361809b4b --- /dev/null +++ b/system/messages/kohana/core.php @@ -0,0 +1,37 @@ + array + ( + E_KOHANA => 'Framework Error', + E_PAGE_NOT_FOUND => 'Page Not Found', + E_DATABASE_ERROR => 'Database Error', + E_RECOVERABLE_ERROR => 'Recoverable Error', + E_ERROR => 'Fatal Error', + E_COMPILE_ERROR => 'Fatal Error', + E_CORE_ERROR => 'Fatal Error', + E_USER_ERROR => 'Fatal Error', + E_PARSE => 'Syntax Error', + E_WARNING => 'Warning Message', + E_COMPILE_WARNING => 'Warning Message', + E_CORE_WARNING => 'Warning Message', + E_USER_WARNING => 'Warning Message', + E_STRICT => 'Strict Mode Error', + E_NOTICE => 'Runtime Message', + E_USER_NOTICE => 'Runtime Message', + ), +); + +// E_DEPRECATED is only defined in PHP >= 5.3.0 +if (defined('E_DEPRECATED')) +{ + $messages['errors'][E_DEPRECATED] = 'Deprecated'; +} \ No newline at end of file diff --git a/system/messages/validation/default.php b/system/messages/validation/default.php index 2c59fa062f..88580a6bcb 100644 --- a/system/messages/validation/default.php +++ b/system/messages/validation/default.php @@ -1,17 +1,25 @@ - 'The :field field is required', - 'length' => 'The :field field must be between :param1 and :param2 characters long', - 'depends_on' => 'The :field field requires the :param1 field', - 'matches' => 'The :field field must be the same as :param1', - 'email' => 'The :field field must be a valid email address', - 'decimal' => 'The :field field must be a decimal with :param1 places', - 'digit' => 'The :field field must be a digit', - 'in_array' => 'The :field field must be one of the available options', - 'alpha_numeric' => 'The :field field must consist only of alphabetical or numeric characters', - 'alpha_dash ' => 'The :field field must consist only of alphabetical, numeric, underscore and dash characters', - 'numeric ' => 'The :field field must be a valid number', - 'url' => 'The :field field must be a valid url', - 'phone' => 'The :field field must be a valid phone number', -); + 'The :field field is required', + 'length' => 'The :field field must be between :param1 and :param2 characters long', + 'depends_on' => 'The :field field requires the :param1 field', + 'matches' => 'The :field field must be the same as :param1', + 'email' => 'The :field field must be a valid email address', + 'decimal' => 'The :field field must be a decimal with :param1 places', + 'digit' => 'The :field field must be a digit', + 'in_array' => 'The :field field must be one of the available options', + 'alpha_numeric' => 'The :field field must consist only of alphabetical or numeric characters', + 'alpha_dash ' => 'The :field field must consist only of alphabetical, numeric, underscore and dash characters', + 'numeric ' => 'The :field field must be a valid number', + 'url' => 'The :field field must be a valid url', + 'phone' => 'The :field field must be a valid phone number', +); diff --git a/system/views/kohana/error.php b/system/views/kohana/error.php index b40c0f8abc..aa6770c4c6 100644 --- a/system/views/kohana/error.php +++ b/system/views/kohana/error.php @@ -3,7 +3,7 @@ $error_id = uniqid('error'); ?>