From 7eb116a33937ec32bb30208561a27b8f0c26f496 Mon Sep 17 00:00:00 2001 From: Jesse van Assen Date: Sat, 6 Jul 2013 10:42:14 +0200 Subject: The script is halted and a '500 Internal Server Error' is issued when a fatal error occurs. Signed-off-by: Jesse van Assen --- system/core/Common.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/system/core/Common.php b/system/core/Common.php index 93cd0a0ae..7553f4ae6 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -577,6 +577,19 @@ if ( ! function_exists('_exception_handler')) */ function _exception_handler($severity, $message, $filepath, $line) { + $is_error = ((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity; + + // When an error occurred, set the status header to '500 Internal Server Error' + // to indicate to the client something went wrong. + // This can't be done within the $_error->show_php_error method because + // it is only called when the display_errors flag is set (which isn't usually + // the case in a production environment) or when errors are ignored because + // they are above the error_reporting threshold. + if ($is_error) + { + set_status_header(500); + } + $_error =& load_class('Exceptions', 'core'); // Should we ignore the error? We'll get the current error_reporting @@ -593,6 +606,14 @@ if ( ! function_exists('_exception_handler')) } $_error->log_exception($severity, $message, $filepath, $line); + + // If the error is fatal, the execution of the script should be stopped because + // errors can't be recovered from. Halting the script conforms with PHP's + // default error handling. See http://www.php.net/manual/en/errorfunc.constants.php + if ($is_error) + { + exit(); + } } } -- cgit v1.2.3-24-g4f1b From 161f1935d72dadb12da1a314a91f5da75826b391 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 20 Jul 2013 20:27:35 +0200 Subject: User_agent library: robuster detection in is_referral() --- system/libraries/User_agent.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 2f6f81909..e27004e9e 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -476,8 +476,10 @@ class CI_User_agent { return FALSE; } - $referer = parse_url($_SERVER['HTTP_REFERER']); - return ! (empty($referer['host']) && strpos(config_item('base_url'), $referer['host']) !== FALSE); + $referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST); + $own_host = parse_url(config_item('base_url'), PHP_URL_HOST); + + return ($referer_host && $referer_host !== $own_host); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From c05ab73237a536802e224b6e8d3a90157eb1b51a Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 20 Jul 2013 20:27:57 +0200 Subject: Cache result of is_referral() --- system/libraries/User_agent.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index e27004e9e..50ac9be98 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -471,15 +471,24 @@ class CI_User_agent { */ public function is_referral() { - if (empty($_SERVER['HTTP_REFERER'])) + static $result; + + if ( ! isset($result)) { - return FALSE; - } + if (empty($_SERVER['HTTP_REFERER'])) + { + $result = FALSE; + } + else + { + $referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST); + $own_host = parse_url(config_item('base_url'), PHP_URL_HOST); - $referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST); - $own_host = parse_url(config_item('base_url'), PHP_URL_HOST); + $result = ($referer_host && $referer_host !== $own_host); + } + } - return ($referer_host && $referer_host !== $own_host); + return $result; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fb1917d8afa41aed76f0be091d3ce13c767e9af5 Mon Sep 17 00:00:00 2001 From: Hashem Qolami Date: Sun, 21 Jul 2013 01:26:47 +0430 Subject: Fix User Guide Search button issue Signed-off-by: Hashem Qolami --- .../source/_themes/eldocs/static/asset/css/common.css | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/_themes/eldocs/static/asset/css/common.css b/user_guide_src/source/_themes/eldocs/static/asset/css/common.css index 648e33032..197739a57 100644 --- a/user_guide_src/source/_themes/eldocs/static/asset/css/common.css +++ b/user_guide_src/source/_themes/eldocs/static/asset/css/common.css @@ -133,7 +133,7 @@ a:visited{ color: #1A5B8D; } a:hover, a:active{ color: #742CAC; } -a.headerlink{ visibility: hidden; } +a.headerlink{ visibility: hidden; margin-left: 0.4em } :hover > a.headerlink { visibility: visible; } @@ -261,12 +261,12 @@ fieldset{ border: 0; } #header form{ float: right; overflow: hidden; } #header input{ float: left; } - + #header input[type="text"]{ background-color: #FFFFFF; border: 1px solid; border-color: #033861 #13598F #13598F #033861; - font-size: inherit; + font: inherit; margin-right: 5px; padding: 5px; width: 175px; @@ -279,8 +279,9 @@ fieldset{ border: 0; } border: 1px solid #033861; color: #094776; cursor: pointer; + font: inherit; font-weight: bold; - padding: 5px 10px 4px; + padding: 5px 10px; text-transform: uppercase; } @@ -349,6 +350,4 @@ fieldset{ border: 0; } h3,h4,h5,h6{ font-size: 14px; } } -@media screen and (-webkit-min-device-pixel-ratio:0){ - #header input[type="submit"]{ padding-bottom: 7px; } -} +#header input[type="submit"], x:-moz-any-link{ padding: 4px 10px; } -- cgit v1.2.3-24-g4f1b From 1ff2c5593f0049333edec976d07f9a356d473276 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 21 Jul 2013 00:27:08 +0200 Subject: Fix too verbose error logging on default production environment issue was present on PHP < 5.4 --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index cfb003eb8..e5f570e8b 100755 --- a/index.php +++ b/index.php @@ -61,7 +61,7 @@ switch (ENVIRONMENT) case 'testing': case 'production': - error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); + error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT); ini_set('display_errors', 0); break; -- cgit v1.2.3-24-g4f1b From 90803ce9d3f9343c5f2ea37cc53a390e9c2ee8c8 Mon Sep 17 00:00:00 2001 From: Hashem Qolami Date: Sun, 21 Jul 2013 22:47:55 +0430 Subject: Fix Form Validation issue with text inputs which have array as name Signed-off-by: Hashem Qolami --- system/libraries/Form_validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 40ba01202..47c9dcaa3 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -583,7 +583,7 @@ class CI_Form_validation { // If the field is blank, but NOT required, no further tests are necessary $callback = FALSE; - if ( ! in_array('required', $rules) && $postdata === NULL) + if ( ! in_array('required', $rules) && ($postdata === NULL OR empty($postdata))) { // Before we bail out, does the rule contain a callback? if (preg_match('/(callback_\w+(\[.*?\])?)/', implode(' ', $rules), $match)) @@ -598,7 +598,7 @@ class CI_Form_validation { } // Isset Test. Typically this rule will only apply to checkboxes. - if ($postdata === NULL && $callback === FALSE) + if (($postdata === NULL OR empty($postdata)) && $callback === FALSE) { if (in_array('isset', $rules, TRUE) OR in_array('required', $rules)) { -- cgit v1.2.3-24-g4f1b From 05370bf751aa6b7885ee548de6f6f2c14571765a Mon Sep 17 00:00:00 2001 From: Hashem Qolami Date: Mon, 22 Jul 2013 01:52:04 +0430 Subject: change empty function to Identical comparison operator Signed-off-by: Hashem Qolami --- system/libraries/Form_validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 47c9dcaa3..8b9bfa897 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -583,7 +583,7 @@ class CI_Form_validation { // If the field is blank, but NOT required, no further tests are necessary $callback = FALSE; - if ( ! in_array('required', $rules) && ($postdata === NULL OR empty($postdata))) + if ( ! in_array('required', $rules) && ($postdata === NULL OR $postdata === '')) { // Before we bail out, does the rule contain a callback? if (preg_match('/(callback_\w+(\[.*?\])?)/', implode(' ', $rules), $match)) @@ -598,7 +598,7 @@ class CI_Form_validation { } // Isset Test. Typically this rule will only apply to checkboxes. - if (($postdata === NULL OR empty($postdata)) && $callback === FALSE) + if (($postdata === NULL OR $postdata === '') && $callback === FALSE) { if (in_array('isset', $rules, TRUE) OR in_array('required', $rules)) { -- cgit v1.2.3-24-g4f1b From 2d536f848dae5b1781bdfbdaf914fed1010e72bf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 10:49:59 +0300 Subject: [ci skip] Small upgrade notes fixes --- user_guide_src/source/installation/upgrade_300.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index b396d9acb..6c5f5692d 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -40,7 +40,7 @@ The Log Class is considered as a "core" class and is now located in the or extensions to work, you need to move them to **application/core/**:: application/libraries/Log.php -> application/core/Log.php - application/libraries/MY_Log.php -> application/core/MY_log.php + application/libraries/MY_Log.php -> application/core/MY_Log.php ********************************************************* Step 5: Convert your Session usage from library to driver @@ -78,9 +78,9 @@ need to rename the `$active_record` variable to `$query_builder` // $active_record = TRUE; $query_builder = TRUE; -******************************* -Step 7: Move your errors folder -******************************* +******************************************* +Step 7: Move your error templates directory +******************************************* In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*. @@ -122,7 +122,7 @@ The same goes for driver libraries and extensions and/or overrides of CodeIgnite own libraries and core classes. application/libraries/MY_email.php - application/core/MY_log.php + application/core/MY_Log.php The above files should respectively be renamed to the following: -- cgit v1.2.3-24-g4f1b From 20292311636837e120d205e470e41826820feb46 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 14:29:10 +0300 Subject: Change class filenames to Ucfirst --- application/controllers/Welcome.php | 53 ++++++++++++++ application/controllers/welcome.php | 53 -------------- index.php | 2 +- system/core/CodeIgniter.php | 12 ++-- system/core/Loader.php | 31 ++++----- system/core/Router.php | 8 +-- user_guide_src/source/general/cli.rst | 2 +- user_guide_src/source/general/controllers.rst | 10 +-- .../source/general/creating_libraries.rst | 7 +- user_guide_src/source/general/libraries.rst | 2 +- user_guide_src/source/general/models.rst | 9 ++- user_guide_src/source/general/styleguide.rst | 31 ++++++++- user_guide_src/source/general/views.rst | 2 +- user_guide_src/source/helpers/smiley_helper.rst | 4 +- user_guide_src/source/installation/upgrade_300.rst | 80 +++++++++++++--------- user_guide_src/source/libraries/file_uploading.rst | 2 +- user_guide_src/source/libraries/loader.rst | 2 +- user_guide_src/source/libraries/migration.rst | 2 +- user_guide_src/source/libraries/xmlrpc.rst | 4 +- user_guide_src/source/tutorial/news_section.rst | 4 +- user_guide_src/source/tutorial/static_pages.rst | 2 +- 21 files changed, 185 insertions(+), 137 deletions(-) create mode 100644 application/controllers/Welcome.php delete mode 100644 application/controllers/welcome.php diff --git a/application/controllers/Welcome.php b/application/controllers/Welcome.php new file mode 100644 index 000000000..31ceea948 --- /dev/null +++ b/application/controllers/Welcome.php @@ -0,0 +1,53 @@ + + * @see http://codeigniter.com/user_guide/general/urls.html + */ + public function index() + { + $this->load->view('welcome_message'); + } +} + +/* End of file welcome.php */ +/* Location: ./application/controllers/Welcome.php */ \ No newline at end of file diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php deleted file mode 100644 index 2f0e358bc..000000000 --- a/application/controllers/welcome.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @see http://codeigniter.com/user_guide/general/urls.html - */ - public function index() - { - $this->load->view('welcome_message'); - } -} - -/* End of file welcome.php */ -/* Location: ./application/controllers/welcome.php */ \ No newline at end of file diff --git a/index.php b/index.php index e5f570e8b..f93cadb9d 100755 --- a/index.php +++ b/index.php @@ -274,4 +274,4 @@ switch (ENVIRONMENT) require_once BASEPATH.'core/CodeIgniter.php'; /* End of file index.php */ -/* Location: ./index.php */ +/* Location: ./index.php */ \ No newline at end of file diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index c68266408..a026920a4 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -240,12 +240,13 @@ defined('BASEPATH') OR exit('No direct script access allowed'); // Load the local application controller // Note: The Router class automatically validates the controller path using the router->_validate_request(). // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. - if ( ! file_exists(APPPATH.'controllers/'.$RTR->directory.$RTR->class.'.php')) + $class = ucfirst($RTR->class); + if ( ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php')) { show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); } - include(APPPATH.'controllers/'.$RTR->directory.$RTR->class.'.php'); + include(APPPATH.'controllers/'.$RTR->directory.$class.'.php'); // Set a mark point for benchmarking $BM->mark('loading_time:_base_classes_end'); @@ -257,9 +258,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * * None of the methods in the app controller or the * loader class can be called via the URI, nor can - * controller functions that begin with an underscore. + * controller methods that begin with an underscore. */ - $class = $RTR->class; $method = $RTR->method; if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method)) @@ -271,6 +271,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $method = 'index'; } + $class = ucfirst($class); + if ( ! class_exists($class, FALSE)) { if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) @@ -309,6 +311,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $method = 'index'; } + $class = ucfirst($class); + if ( ! class_exists($class, FALSE)) { if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) diff --git a/system/core/Loader.php b/system/core/Loader.php index 70a6b6fa6..535c9e4db 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -261,33 +261,32 @@ class CI_Loader { show_error('The model name you are loading is the name of a resource that is already being used: '.$name); } - $model = strtolower($model); - - foreach ($this->_ci_model_paths as $mod_path) + if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE)) { - if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) + if ($db_conn === TRUE) { - continue; + $db_conn = ''; } - if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE)) - { - if ($db_conn === TRUE) - { - $db_conn = ''; - } + $CI->load->database($db_conn, FALSE, TRUE); + } - $CI->load->database($db_conn, FALSE, TRUE); - } + if ( ! class_exists('CI_Model', FALSE)) + { + load_class('Model', 'core'); + } + + $model = ucfirst(strtolower($model)); - if ( ! class_exists('CI_Model', FALSE)) + foreach ($this->_ci_model_paths as $mod_path) + { + if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) { - load_class('Model', 'core'); + continue; } require_once($mod_path.'models/'.$path.$model.'.php'); - $model = ucfirst($model); $CI->$name = new $model(); $this->_ci_models[] = $name; return; diff --git a/system/core/Router.php b/system/core/Router.php index cc3916f86..989ae542e 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -270,8 +270,7 @@ class CI_Router { return $segments; } - $test = ($this->translate_uri_dashes === TRUE) - ? str_replace('-', '_', $segments[0]) : $segments[0]; + $test = ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]); // Does the requested controller exist in the root folder? if (file_exists(APPPATH.'controllers/'.$test.'.php')) @@ -286,8 +285,7 @@ class CI_Router { $this->set_directory(array_shift($segments)); if (count($segments) > 0) { - $test = ($this->translate_uri_dashes === TRUE) - ? str_replace('-', '_', $segments[0]) : $segments[0]; + $test = ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]); // Does the requested controller exist in the sub-directory? if ( ! file_exists(APPPATH.'controllers/'.$this->directory.$test.'.php')) @@ -307,7 +305,7 @@ class CI_Router { { // Is the method being specified in the route? $segments = explode('/', $this->default_controller); - if ( ! file_exists(APPPATH.'controllers/'.$this->directory.$segments[0].'.php')) + if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($segments[0]).'.php')) { $this->directory = ''; } diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst index 998d2a907..4145d5ccc 100644 --- a/user_guide_src/source/general/cli.rst +++ b/user_guide_src/source/general/cli.rst @@ -33,7 +33,7 @@ Let's try it: Hello World! ========================== Let's create a simple controller so you can see it in action. Using your -text editor, create a file called tools.php, and put the following code +text editor, create a file called Tools.php, and put the following code in it:: 'large', 'color' => 'red'); - $this->load->library('Someclass', $params); + $this->load->library('someclass', $params); If you use this feature you must set up your class constructor to expect data:: diff --git a/user_guide_src/source/general/libraries.rst b/user_guide_src/source/general/libraries.rst index 6e1c8b6dd..9bbda51bb 100644 --- a/user_guide_src/source/general/libraries.rst +++ b/user_guide_src/source/general/libraries.rst @@ -29,4 +29,4 @@ Creating Your Own Libraries =========================== Please read the section of the user guide that discusses how to -:doc:`create your own libraries `. +:doc:`create your own libraries `. \ No newline at end of file diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst index a028a9569..c4fd12476 100644 --- a/user_guide_src/source/general/models.rst +++ b/user_guide_src/source/general/models.rst @@ -84,8 +84,7 @@ Where **Model_name** is the name of your class. Class names **must** have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class. -The file name will be a lower case version of your class name. For -example, if your class is this:: +The file name must match the class name. For example, if this is your class:: class User_model extends CI_Model { @@ -98,7 +97,7 @@ example, if your class is this:: Your file will be this:: - application/models/user_model.php + application/models/User_model.php Loading a Model =============== @@ -111,7 +110,7 @@ the following method:: If your model is located in a sub-directory, include the relative path from your models directory. For example, if you have a model located at -*application/models/blog/queries.php* you'll load it using:: +*application/models/blog/Queries.php* you'll load it using:: $this->load->model('blog/queries'); @@ -181,4 +180,4 @@ database. The following options for connecting are available to you: $config['pconnect'] = FALSE; $config['db_debug'] = TRUE; - $this->load->model('Model_name', '', $config); \ No newline at end of file + $this->load->model('model_name', '', $config); \ No newline at end of file diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst index 144b362f5..1683b04cd 100644 --- a/user_guide_src/source/general/styleguide.rst +++ b/user_guide_src/source/general/styleguide.rst @@ -71,13 +71,42 @@ identify a file as being complete and not truncated. echo "Here's my code!"; - /* End of file myfile.php */ + /* End of file Myfile.php */ /* Location: ./system/modules/mymodule/myfile.php */ .. note:: There should be no empty line or newline character(s) following the closing comments. If you happen to see one when submitting a pull request, please check your IDE settings and fix it. +File Naming +=========== + +Class files must be named in a Ucfirst-like manner, while any other file name +(configurations, views, generic scripts, etc.) should be in all lowercase. + +**INCORRECT**:: + + somelibrary.php + someLibrary.php + SOMELIBRARY.php + Some_Library.php + + Application_config.php + Application_Config.php + applicationConfig.php + +**CORRECT**:: + + SomeLibrary.php + Some_Library.php + + applicationconfig.php + application_config.php + +Furthermore, class file names should match the name of the class itself. +For example, if you have a class named `Myclass`, then its filename must +be **Myclass.php**. + Class and Method Naming ======================= diff --git a/user_guide_src/source/general/views.rst b/user_guide_src/source/general/views.rst index 4b1ab3c34..2fc0cb2ca 100644 --- a/user_guide_src/source/general/views.rst +++ b/user_guide_src/source/general/views.rst @@ -45,7 +45,7 @@ Where name is the name of your view file. .. note:: The .php file extension does not need to be specified unless you use something other than .php. -Now, open the controller file you made earlier called blog.php, and +Now, open the controller file you made earlier called Blog.php, and replace the echo statement with the view loading method:: `:: } -In your `application/views/` folder, create a file called `smiley_view.php` +In your **application/views/** folder, create a file called **smiley_view.php** and place this code in it:: diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 6c5f5692d..3e8307cfc 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -17,22 +17,63 @@ they will need to be made fresh in this new one. .. note:: If you have any custom developed files in these folders please make copies of them first. +************************************** +Step 2: Update your classes file names +************************************** + +Starting with CodeIgniter 3.0, all class filenames (libraries, drivers, controllers +and models) must be named in a Ucfirst-like manner or in other words - they must +start with a capital letter. + +For example, if you have the following library file: + + application/libraries/mylibrary.php + +... then you'll have to rename it to: + + application/libraries/Mylibrary.php + +The same goes for driver libraries and extensions and/or overrides of CodeIgniter's +own libraries and core classes. + + application/libraries/MY_email.php + application/core/MY_log.php + +The above files should respectively be renamed to the following: + + application/libraries/MY_Email.php + application/core/MY_Log.php + +Controllers: + + application/controllers/welcome.php -> application/controllers/Welcome.php + +Models: + + application/models/misc_model.php -> application/models/Misc_model.php + +Please note that this DOES NOT affect directories, configuration files, views, +helpers, hooks and anything else - it is only applied to classes. + +You must now follow just one simple rule - class names in Ucfirst and everything else +in lowercase. + ******************************** -Step 2: Replace config/mimes.php +Step 3: Replace config/mimes.php ******************************** This config file has been updated to contain more user mime-types, please copy it to _application/config/mimes.php*. ************************************************************** -Step 3: Remove $autoload['core'] from your config/autoload.php +Step 4: Remove $autoload['core'] from your config/autoload.php ************************************************************** Use of the ``$autoload['core']`` config array has been deprecated as of CodeIgniter 1.4.1 and is now removed. Move any entries that you might have listed there to ``$autoload['libraries']`` instead. *************************************************** -Step 4: Move your Log class overrides or extensions +Step 5: Move your Log class overrides or extensions *************************************************** The Log Class is considered as a "core" class and is now located in the @@ -43,7 +84,7 @@ or extensions to work, you need to move them to **application/core/**:: application/libraries/MY_Log.php -> application/core/MY_Log.php ********************************************************* -Step 5: Convert your Session usage from library to driver +Step 6: Convert your Session usage from library to driver ********************************************************* When you load (or autoload) the Session library, you must now load it as a driver instead of a library. This means @@ -67,7 +108,7 @@ standard for Drivers. Also beware that some functions which are not part of the the drivers, so your extension may have to be broken down into separate library and driver class extensions. *************************************** -Step 6: Update your config/database.php +Step 7: Update your config/database.php *************************************** Due to 3.0.0's renaming of Active Record to Query Builder, inside your `config/database.php`, you will @@ -79,13 +120,13 @@ need to rename the `$active_record` variable to `$query_builder` $query_builder = TRUE; ******************************************* -Step 7: Move your error templates directory +Step 8: Move your error templates directory ******************************************* In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*. ******************************************************* -Step 8: Update your config/routes.php containing (:any) +Step 9: Update your config/routes.php containing (:any) ******************************************************* Historically, CodeIgniter has always provided the **:any** wildcard in routing, @@ -104,31 +145,6 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' -***************************************** -Step 9: Update your libraries' file names -***************************************** - -CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner -(meaning that the first letter of the class name must be a capital). For example, -if you have the following library file: - - application/libraries/mylibrary.php - -... then you'll have to rename it to: - - application/libraries/Mylibrary.php - -The same goes for driver libraries and extensions and/or overrides of CodeIgniter's -own libraries and core classes. - - application/libraries/MY_email.php - application/core/MY_Log.php - -The above files should respectively be renamed to the following: - - application/libraries/MY_Email.php - application/core/MY_Log.php - ***************************************************************************** Step 10: Check the calls to Array Helper's element() and elements() functions ***************************************************************************** diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index a92d3af34..a295d7427 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -83,7 +83,7 @@ place this code and save it to your **application/views/** directory:: The Controller ============== -Using a text editor, create a controller called upload.php. In it, place +Using a text editor, create a controller called Upload.php. In it, place this code and save it to your **application/controllers/** directory:: load->model('model_name'); If your model is located in a subdirectory, include the relative path from your models directory. For example, if you have a model located at -application/models/blog/queries.php you'll load it using:: +application/models/blog/Queries.php you'll load it using:: $this->load->model('blog/queries'); diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index b734f5c34..9dc3c08da 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -86,7 +86,7 @@ Then in **application/config/migration.php** set **$config['migration_version'] Usage Example ************* -In this example some simple code is placed in **application/controllers/migrate.php** +In this example some simple code is placed in **application/controllers/Migrate.php** to update the schema.:: `_. @@ -85,7 +85,7 @@ Now that the queries are written, the model should be tied to the views that are going to display the news items to the user. This could be done in our pages controller created earlier, but for the sake of clarity, a new "news" controller is defined. Create the new controller at -application/controllers/news.php. +application/controllers/News.php. :: diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst index 97c74601d..330a50ecf 100644 --- a/user_guide_src/source/tutorial/static_pages.rst +++ b/user_guide_src/source/tutorial/static_pages.rst @@ -20,7 +20,7 @@ match: As URL schemes become more complex, this may change. But for now, this is all we will need to know. -Create a file at application/controllers/pages.php with the following +Create a file at application/controllers/Pages.php with the following code. :: -- cgit v1.2.3-24-g4f1b From 924a75521ba8810a2afb36e4da7e04dfec8711ae Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 14:35:02 +0300 Subject: Fix CI_Loader::model() tests --- tests/codeigniter/core/Loader_test.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index ac2656e75..d7c393d61 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -181,16 +181,16 @@ class Loader_test extends CI_TestCase { $this->ci_set_core_class('model', 'CI_Model'); // Create model in VFS - $model = 'unit_test_model'; - $class = ucfirst($model); - $content = 'ci_vfs_create($model, $content, $this->ci_app_root, 'models'); // Load model $this->assertNull($this->load->model($model)); // Was the model class instantiated. - $this->assertTrue(class_exists($class)); + $this->assertTrue(class_exists($model)); + $this->assertObjectHasAttribute($model, $this->ci_obj); // Test no model given $this->assertNull($this->load->model('')); @@ -204,11 +204,10 @@ class Loader_test extends CI_TestCase { $this->ci_core_class('model'); // Create modelin VFS - $model = 'test_sub_model'; + $model = 'Test_sub_model'; $base = 'CI_Model'; - $class = ucfirst($model); $subdir = 'cars'; - $this->ci_vfs_create($model, 'ci_app_root, + $this->ci_vfs_create($model, 'ci_app_root, array('models', $subdir)); // Load model @@ -216,10 +215,10 @@ class Loader_test extends CI_TestCase { $this->assertNull($this->load->model($subdir.'/'.$model, $name)); // Was the model class instantiated? - $this->assertTrue(class_exists($class)); + $this->assertTrue(class_exists($model)); $this->assertObjectHasAttribute($name, $this->ci_obj); $this->assertAttributeInstanceOf($base, $name, $this->ci_obj); - $this->assertAttributeInstanceOf($class, $name, $this->ci_obj); + $this->assertAttributeInstanceOf($model, $name, $this->ci_obj); // Test name conflict $obj = 'conflict'; @@ -481,9 +480,8 @@ class Loader_test extends CI_TestCase { // Create model in VFS package path $dir = 'testdir'; $path = APPPATH.$dir.'/'; - $model = 'automod'; - $mod_class = ucfirst($model); - $this->ci_vfs_create($model, 'ci_app_root, array($dir, 'models')); + $model = 'Automod'; + $this->ci_vfs_create($model, 'ci_app_root, array($dir, 'models')); // Create autoloader config $cfg = array( @@ -513,8 +511,8 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($drv_class, $drv, $this->ci_obj); // Verify model - $this->assertTrue(class_exists($mod_class), $mod_class.' does not exist'); - $this->assertAttributeInstanceOf($mod_class, $model, $this->ci_obj); + $this->assertTrue(class_exists($model), $model.' does not exist'); + $this->assertAttributeInstanceOf($model, $model, $this->ci_obj); // Verify config calls $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded); -- cgit v1.2.3-24-g4f1b From 20b0b2047c5b9ba363daaf46616fb43dc5d5bd02 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 14:39:18 +0300 Subject: Fix Loader_test::test_non_existent_model() --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index d7c393d61..18486cd05 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -236,7 +236,7 @@ class Loader_test extends CI_TestCase { { $this->setExpectedException( 'RuntimeException', - 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php' + 'CI Error: Unable to locate the model you have specified: Ci_test_nonexistent_model.php' ); $this->load->model('ci_test_nonexistent_model.php'); -- cgit v1.2.3-24-g4f1b From 025e6623f15a00572e63c2056ec6364e42a0eac9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 14:46:17 +0300 Subject: [ci skip] Add a changelog entry for class file naming rule change --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index efbe86069..2bd34c33b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -19,6 +19,7 @@ Release Date: Not Released - General Changes - PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4. + - Changed filenaming convention (class file names now must be Ucfirst and everything else in lowercase). - ``$_SERVER['CI_ENV']`` can now be set to control the ``ENVIRONMENT`` constant. - Added an optional backtrace to php-error template. - Added Android to the list of user agents. -- cgit v1.2.3-24-g4f1b From e3e2c69bb7a58b966ec550c18d1cb845af30d7d9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jul 2013 16:25:44 +0300 Subject: [ci skip] Fix style guide typos --- user_guide_src/source/general/styleguide.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst index 1683b04cd..5613eabec 100644 --- a/user_guide_src/source/general/styleguide.rst +++ b/user_guide_src/source/general/styleguide.rst @@ -97,8 +97,8 @@ Class files must be named in a Ucfirst-like manner, while any other file name **CORRECT**:: - SomeLibrary.php - Some_Library.php + Somelibrary.php + Some_library.php applicationconfig.php application_config.php -- cgit v1.2.3-24-g4f1b From 9ab70a89b3ba7ee26faaae47410259e74391b593 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 23 Jul 2013 00:09:26 +0300 Subject: Give Drivers a higher priority in the autoloader --- system/core/Loader.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 535c9e4db..4d0cd09a2 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1197,6 +1197,15 @@ class CI_Loader { } } + // Autoload drivers + if (isset($autoload['drivers'])) + { + foreach ($autoload['drivers'] as $item) + { + $this->driver($item); + } + } + // Load libraries if (isset($autoload['libraries']) && count($autoload['libraries']) > 0) { @@ -1214,15 +1223,6 @@ class CI_Loader { } } - // Autoload drivers - if (isset($autoload['drivers'])) - { - foreach ($autoload['drivers'] as $item) - { - $this->driver($item); - } - } - // Autoload models if (isset($autoload['model'])) { -- cgit v1.2.3-24-g4f1b From 519f87a07bd1fe3a9ec037f727628bb6c7c8e251 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 23 Jul 2013 17:16:10 +0300 Subject: Loader changes & optimizations related to issue #2551 --- system/core/Loader.php | 63 +++++++++++++++--------------- system/helpers/form_helper.php | 2 +- tests/codeigniter/core/Loader_test.php | 4 +- user_guide_src/source/changelog.rst | 3 ++ user_guide_src/source/libraries/loader.rst | 26 ++++++++++++ 5 files changed, 63 insertions(+), 35 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 4d0cd09a2..1709c2db1 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -75,13 +75,6 @@ class CI_Loader { */ protected $_ci_helper_paths = array(APPPATH, BASEPATH); - /** - * List of loaded base classes - * - * @var array - */ - protected $_base_classes = array(); // Set by the controller class - /** * List of cached variables * @@ -120,6 +113,8 @@ class CI_Loader { 'user_agent' => 'agent' ); + // -------------------------------------------------------------------- + /** * Class constructor * @@ -129,7 +124,8 @@ class CI_Loader { */ public function __construct() { - $this->_ci_ob_level = ob_get_level(); + $this->_ci_ob_level = ob_get_level(); + $this->_ci_classes =& is_loaded(); log_message('debug', 'Loader Class Initialized'); } @@ -147,7 +143,6 @@ class CI_Loader { */ public function initialize() { - $this->_base_classes =& is_loaded(); $this->_ci_autoloader(); } @@ -165,7 +160,7 @@ class CI_Loader { */ public function is_loaded($class) { - return isset($this->_ci_classes[$class]) ? $this->_ci_classes[$class] : FALSE; + return array_search(ucfirst($class), $this->_ci_classes, TRUE); } // -------------------------------------------------------------------- @@ -183,7 +178,11 @@ class CI_Loader { */ public function library($library = '', $params = NULL, $object_name = NULL) { - if (is_array($library)) + if (empty($library)) + { + return; + } + elseif (is_array($library)) { foreach ($library as $class) { @@ -193,11 +192,6 @@ class CI_Loader { return; } - if ($library === '' OR isset($this->_base_classes[$library])) - { - return; - } - if ($params !== NULL && ! is_array($params)) { $params = NULL; @@ -1117,30 +1111,35 @@ class CI_Loader { // Set the variable name we will assign the class to // Was a custom class name supplied? If so we'll use it - $class = strtolower($class); - - if ($object_name === NULL) + if (empty($object_name)) { - $classvar = isset($this->_ci_varmap[$class]) ? $this->_ci_varmap[$class] : $class; + $object_name = strtolower($class); + if (isset($this->_ci_varmap[$object_name])) + { + $object_name = $this->_ci_varmap[$object_name]; + } } - else + + // Don't overwrite existing properties + $CI =& get_instance(); + if (isset($CI->$object_name)) { - $classvar = $object_name; + if ($CI->$object_name instanceof $name) + { + log_message('debug', $class." has already been instantiated as '".$object_name."'. Second attempt aborted."); + return; + } + + show_error("Resource '".$object_name."' already exists and is not a ".$class." instance."); } // Save the class name and object name - $this->_ci_classes[$class] = $classvar; + $this->_ci_classes[$object_name] = $class; // Instantiate the class - $CI =& get_instance(); - if ($config !== NULL) - { - $CI->$classvar = new $name($config); - } - else - { - $CI->$classvar = new $name(); - } + $CI->$object_name = isset($config) + ? new $name($config) + : new $name(); } // -------------------------------------------------------------------- diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 2002d4269..bc14df221 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -988,7 +988,7 @@ if ( ! function_exists('_get_validation_object')) // We set this as a variable since we're returning by reference. $return = FALSE; - if (FALSE !== ($object = $CI->load->is_loaded('form_validation'))) + if (FALSE !== ($object = $CI->load->is_loaded('Form_validation'))) { if ( ! isset($CI->$object) OR ! is_object($CI->$object)) { diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 18486cd05..9ad3ca6b9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -28,7 +28,7 @@ class Loader_test extends CI_TestCase { $this->ci_vfs_create(ucfirst($lib), 'ci_base_root, 'libraries'); // Test is_loaded fail - $this->assertFalse($this->load->is_loaded($lib)); + $this->assertFalse($this->load->is_loaded(ucfirst($lib))); // Test loading as an array. $this->assertNull($this->load->library(array($lib))); @@ -123,7 +123,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($cfg, $this->ci_obj->$obj->config); // Test is_loaded - $this->assertEquals($obj, $this->load->is_loaded($lib)); + $this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib))); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2bd34c33b..08a8f0b38 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -375,6 +375,8 @@ Release Date: Not Released - ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``` changes include: @@ -596,6 +598,7 @@ Bug fixes for 3.0 - Fixed a bug (#2490) - :doc:`Database Class ` method ``query()`` returning boolean instead of a result object for PostgreSQL-specific *INSERT INTO ... RETURNING* statements. - Fixed a bug (#249) - :doc:`Cache Library ` didn't properly handle Memcache(d) configurations with missing options. - Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. +- Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exits. Version 2.1.4 ============= diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 1597bf1c8..19446a9c8 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -261,6 +261,32 @@ $this->load->config('file_name') This method is an alias of the :doc:`config file loading method `: ``$this->config->load()`` +$this->load->is_loaded('library_name') +====================================== + +The ``is_loaded()`` method allows you to check if a class has already +been loaded or not. + +.. note:: The word "class" here refers to libraries and drivers. + +If the requested class has been loaded, the method returns its assigned +name in the CI Super-object and FALSE if it's not:: + + $this->load->library('form_validation'); + $this->load->is_loaded('Form_validation'); // returns 'form_validation' + + $this->load->is_loaded('Nonexistent_library'); // returns FALSE + +.. important:: If you have more than one instance of a class (assigned to + different properties), then the first one will be returned. + +:: + + $this->load->library('form_validation', $config, 'fv'); + $this->load->library('form_validation'); + + $this->load->is_loaded('Form_validation'); // returns 'fv' + Application "Packages" ====================== -- cgit v1.2.3-24-g4f1b From cd920b169f0c9beb8dc413837f3832f22d2a096a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 23 Jul 2013 18:29:07 +0300 Subject: [ci skip] Alter the welcome page --- application/views/welcome_message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php index 3cc8b80aa..2466a83fc 100644 --- a/application/views/welcome_message.php +++ b/application/views/welcome_message.php @@ -104,7 +104,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); application/views/welcome_message.php

The corresponding controller for this page is found at:

- application/controllers/welcome.php + application/controllers/Welcome.php

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

-- cgit v1.2.3-24-g4f1b From 1eb59c99a4097f9cfdb99434a88a73535a5fbb57 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 24 Jul 2013 03:39:45 +0200 Subject: Add a changelog entry about changes in Array helper's element() and elements() --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 08a8f0b38..2ecbcb3da 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -130,6 +130,7 @@ Release Date: Not Released - Added *colors* configuration to allow customization for the *background*, *border*, *text* and *grid* colors. - :doc:`Directory Helper ` :php:func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array. + - :doc:`Array Helper ` :php:func:`element()` and :php:func:`elements()` now return NULL instead of FALSE when the required elements don't exist. - :doc:`Language Helper ` :php:func:`lang()` now accepts an optional list of additional HTML attributes. - Deprecated the :doc:`Email Helper ` as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively. -- cgit v1.2.3-24-g4f1b From 184cf1b5a719f4559767a221520d5ba96d1e4d8b Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 24 Jul 2013 03:43:39 +0200 Subject: config->item() now returns NULL instead of FALSE when the required item doesn't exist. Uniformization with other functions. This also brings the ability to properly use booleans in configuration. --- system/core/Config.php | 6 +++--- user_guide_src/source/changelog.rst | 3 ++- user_guide_src/source/installation/upgrade_300.rst | 19 +++++++++++++------ user_guide_src/source/libraries/config.rst | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index 7e64444bc..14ade7248 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -184,16 +184,16 @@ class CI_Config { * * @param string $item Config item name * @param string $index Index name - * @return string|bool The configuration item or FALSE on failure + * @return string|null The configuration item or NULL on failure */ public function item($item, $index = '') { if ($index == '') { - return isset($this->config[$item]) ? $this->config[$item] : FALSE; + return isset($this->config[$item]) ? $this->config[$item] : NULL; } - return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : FALSE; + return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2ecbcb3da..71f53059d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -407,7 +407,8 @@ Release Date: Not Released - :doc:`Config Library ` changes include: - Changed ``site_url()`` method to accept an array as well. - - Removed internal method ``_assign_to_config()`` and moved it's implementation in *CodeIgniter.php* instead. + - Removed internal method ``_assign_to_config()`` and moved its implementation to *CodeIgniter.php* instead. + - ``item()`` now returns NULL instead of FALSE when the required config item doesn't exist. - :doc:`Security Library ` changes include: diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 3e8307cfc..0eafaf9cd 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -145,22 +145,29 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' +************************************************* +Step 10: Check the calls to config->item() method +************************************************* + +This method now returns NULL instead of FALSE when the required config +item doesn't exist. + ***************************************************************************** -Step 10: Check the calls to Array Helper's element() and elements() functions +Step 11: Check the calls to Array Helper's element() and elements() functions ***************************************************************************** The default return value of these functions, when the required elements don't exist, has been changed from FALSE to NULL. *********************************************************************** -Step 11: Check the calls to Directory Helper's directory_map() function +Step 12: Check the calls to Directory Helper's directory_map() function *********************************************************************** In the resulting array, directories now end with a trailing directory separator (i.e. a slash, usually). ************************************************************* -Step 12: Update usage of Database Forge's drop_table() method +Step 13: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -182,7 +189,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 13: Change usage of Email library with multiple emails +Step 14: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -197,7 +204,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 14: Update your Form_validation language lines +Step 15: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -228,7 +235,7 @@ files and error messages format: later. **************************************************************** -Step 15: Remove usage of (previously) deprecated functionalities +Step 16: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 08d9c2905..654dc4ded 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -90,7 +90,7 @@ example, to fetch your language choice you'll do this:: $lang = $this->config->item('language'); -The function returns FALSE (boolean) if the item you are trying to fetch +The function returns NULL if the item you are trying to fetch does not exist. If you are using the second parameter of the $this->config->load -- cgit v1.2.3-24-g4f1b From 516527c1dc03de4192966c79086d4ca8eaacc77c Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Wed, 24 Jul 2013 10:51:04 -0400 Subject: Cache Driver - Backup Never Loaded The condition that checks to see if the backup driver input is valid was prefixing the input with "cache_". Since the valid driver values don't have this prefix, the condition was always returning FALSE and the backup drivers were never being loaded. I've removed the prefix in the condition and added a debug log message for when the backup driver is used. --- system/libraries/Cache/Cache.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index e1089f755..537897eaf 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -106,7 +106,7 @@ class CI_Cache extends CI_Driver_Library { isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; - if (isset($config['backup']) && in_array('cache_'.$config['backup'], $this->valid_drivers)) + if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) { $this->_backup_driver = $config['backup']; } @@ -123,6 +123,7 @@ class CI_Cache extends CI_Driver_Library { else { // Backup is supported. Set it to primary. + log_message('debug', 'Cache adapter "'.$this->_adapter.'" is unavailable. Falling back to "'.$this->_backup_driver.'" backup adapter.'); $this->_adapter = $this->_backup_driver; } } -- cgit v1.2.3-24-g4f1b From 3b8b892d8093bfc5f6b6b54c77878eb591eaf6c4 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 24 Jul 2013 22:41:00 +0200 Subject: Fixes in JavaScript Library --- system/libraries/Javascript.php | 4 ++-- system/libraries/Javascript/Jquery.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 090f4c90e..26a16850c 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -172,7 +172,7 @@ class CI_Javascript { */ public function focus($element = 'this', $js = '') { - return $this->js->__add_event($element, $js); + return $this->js->_focus($element, $js); } // -------------------------------------------------------------------- @@ -189,7 +189,7 @@ class CI_Javascript { */ public function hover($element = 'this', $over = '', $out = '') { - return $this->js->__hover($element, $over, $out); + return $this->js->_hover($element, $over, $out); } // -------------------------------------------------------------------- diff --git a/system/libraries/Javascript/Jquery.php b/system/libraries/Javascript/Jquery.php index f5fa72d30..ab78e8b2e 100644 --- a/system/libraries/Javascript/Jquery.php +++ b/system/libraries/Javascript/Jquery.php @@ -923,7 +923,6 @@ class CI_Jquery extends CI_Javascript { if (is_array($js)) { $js = implode("\n\t\t", $js); - } $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n"; @@ -937,7 +936,7 @@ class CI_Jquery extends CI_Javascript { * Compile * * As events are specified, they are stored in an array - * This funciton compiles them all for output on a page + * This function compiles them all for output on a page * * @param string $view_var * @param bool $script_tags -- cgit v1.2.3-24-g4f1b From 90f316a8615fbbbc0810d945dd1a237662c6bfbf Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 25 Jul 2013 04:33:56 +0200 Subject: Adjustments to the previous commit --- system/core/Config.php | 2 +- tests/codeigniter/core/Config_test.php | 8 ++++---- user_guide_src/source/changelog.rst | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index 14ade7248..e7cbe5624 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -184,7 +184,7 @@ class CI_Config { * * @param string $item Config item name * @param string $index Index name - * @return string|null The configuration item or NULL on failure + * @return string|null The configuration item or NULL if the item doesn't exist */ public function item($item, $index = '') { diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index e3be8a3fc..72f47cd51 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -24,18 +24,18 @@ class Config_test extends CI_TestCase { $this->assertEquals($this->cfg['base_url'], $this->config->item('base_url')); // Bad Config value - $this->assertFalse($this->config->item('no_good_item')); + $this->assertNull($this->config->item('no_good_item')); // Index - $this->assertFalse($this->config->item('no_good_item', 'bad_index')); - $this->assertFalse($this->config->item('no_good_item', 'default')); + $this->assertNull($this->config->item('no_good_item', 'bad_index')); + $this->assertNull($this->config->item('no_good_item', 'default')); } // -------------------------------------------------------------------- public function test_set_item() { - $this->assertFalse($this->config->item('not_yet_set')); + $this->assertNull($this->config->item('not_yet_set')); $this->config->set_item('not_yet_set', 'is set'); $this->assertEquals('is set', $this->config->item('not_yet_set')); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 71f53059d..77cd39de3 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -408,7 +408,7 @@ Release Date: Not Released - Changed ``site_url()`` method to accept an array as well. - Removed internal method ``_assign_to_config()`` and moved its implementation to *CodeIgniter.php* instead. - - ``item()`` now returns NULL instead of FALSE when the required config item doesn't exist. + - ``item()`` now returns NULL instead of FALSE when the required config item doesn't exist. - :doc:`Security Library ` changes include: -- cgit v1.2.3-24-g4f1b From c1044cb62e39709aa14f86a56bc950a78cfc713c Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 25 Jul 2013 12:18:43 +0200 Subject: Uniformize slash_item() with item() --- system/core/Config.php | 4 ++-- tests/codeigniter/core/Config_test.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index e7cbe5624..109ee6424 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -202,13 +202,13 @@ class CI_Config { * Fetch a config file item with slash appended (if not empty) * * @param string $item Config item name - * @return string|bool The configuration item or FALSE on failure + * @return string|null The configuration item or NULL if the item doesn't exist */ public function slash_item($item) { if ( ! isset($this->config[$item])) { - return FALSE; + return NULL; } elseif (trim($this->config[$item]) === '') { diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index 72f47cd51..ba9a2c070 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -46,7 +46,7 @@ class Config_test extends CI_TestCase { public function test_slash_item() { // Bad Config value - $this->assertFalse($this->config->slash_item('no_good_item')); + $this->assertNull($this->config->slash_item('no_good_item')); $this->assertEquals($this->cfg['base_url'], $this->config->slash_item('base_url')); $this->assertEquals($this->cfg['subclass_prefix'].'/', $this->config->slash_item('subclass_prefix')); -- cgit v1.2.3-24-g4f1b From 53fd68860df9ce813a9c07e4dfd34fbb96dffbb1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 26 Jul 2013 02:14:09 +0300 Subject: Fix #2558 --- system/helpers/captcha_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 2d2ae7751..29911dc17 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -142,7 +142,7 @@ if ( ! function_exists('create_captcha')) is_array($colors) OR $colors = $defaults['colors']; - foreach (array_keys($default['colors']) as $key) + foreach (array_keys($defaults['colors']) as $key) { // Check for a possible missing value is_array($colors[$key]) OR $colors[$key] = $defaults['colors'][$key]; -- cgit v1.2.3-24-g4f1b From 122ca9bd8b055eaabee2ec54f476749107533565 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 26 Jul 2013 18:16:26 +0300 Subject: Fix #2560 --- system/helpers/form_helper.php | 12 ++++++++++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index bc14df221..7f4276bc7 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -54,10 +54,18 @@ if ( ! function_exists('form_open')) { $CI =& get_instance(); - if ($attributes === '') + if (empty($attributes)) { $attributes = 'method="post"'; } + elseif (is_array($attributes) && ! isset($attributes['method'])) + { + $attributes['method'] = 'post'; + } + elseif (stripos($attributes, 'method=') === FALSE) + { + $attributes .= ' method="post"'; + } // If an action is not a full URL then turn it into one if ($action && strpos($action, '://') === FALSE) @@ -73,7 +81,7 @@ if ( ! function_exists('form_open')) $form = '
\n"; // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites - if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) + if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR stripos($form, 'method="get"'))) { $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 08a8f0b38..5eda25e15 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -599,6 +599,7 @@ Bug fixes for 3.0 - Fixed a bug (#249) - :doc:`Cache Library ` didn't properly handle Memcache(d) configurations with missing options. - Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. - Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exits. +- Fixed a bug (#2560) - :doc:`Form Helper ` function :php:func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From ea19bc4f8fea2a7b6d0b1d85c279369ec8fce06e Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 27 Jul 2013 10:07:43 +0200 Subject: Form helper: refactor form_open() and _attributes_to_string() --- system/helpers/form_helper.php | 56 ++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 7f4276bc7..f28296c2e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -50,21 +50,20 @@ if ( ! function_exists('form_open')) * @param array a key/value pair hidden data * @return string */ - function form_open($action = '', $attributes = '', $hidden = array()) + function form_open($action = '', $attributes = array(), $hidden = array()) { $CI =& get_instance(); - if (empty($attributes)) - { - $attributes = 'method="post"'; - } - elseif (is_array($attributes) && ! isset($attributes['method'])) + $attributes = _attributes_to_string($attributes); + + if (stripos($attributes, 'method=') === FALSE) { - $attributes['method'] = 'post'; + $attributes .= ' method="post"'; } - elseif (stripos($attributes, 'method=') === FALSE) + + if (stripos($attributes, 'accept-charset=') === FALSE) { - $attributes .= ' method="post"'; + $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"'; } // If an action is not a full URL then turn it into one @@ -78,7 +77,7 @@ if ( ! function_exists('form_open')) $action = $CI->config->site_url($CI->uri->uri_string()); } - $form = '\n"; + $form = '\n"; // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR stripos($form, 'method="get"'))) @@ -550,12 +549,12 @@ if ( ! function_exists('form_fieldset')) * use form_fieldset_close() * * @param string The legend text - * @param string Additional attributes + * @param array Additional attributes * @return string */ function form_fieldset($legend_text = '', $attributes = array()) { - $fieldset = '\n"; + $fieldset = '\n"; if ($legend_text !== '') { return $fieldset.''.$legend_text."\n"; @@ -928,45 +927,24 @@ if ( ! function_exists('_attributes_to_string')) * Helper function used by some of the form helpers * * @param mixed - * @param bool * @return string */ - function _attributes_to_string($attributes, $formtag = FALSE) + function _attributes_to_string($attributes) { - if (is_string($attributes) && strlen($attributes) > 0) + if (is_string($attributes)) { - if ($formtag === TRUE && strpos($attributes, 'method=') === FALSE) - { - $attributes .= ' method="post"'; - } - - if ($formtag === TRUE && strpos($attributes, 'accept-charset=') === FALSE) - { - $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"'; - } - - return ' '.$attributes; + return ($attributes === '' ? '' : ' '.$attributes); } - if (is_object($attributes) && count($attributes) > 0) + if (is_object($attributes)) { $attributes = (array) $attributes; } - if (is_array($attributes) && ($formtag === TRUE OR count($attributes) > 0)) + if (is_array($attributes)) { $atts = ''; - if ( ! isset($attributes['method']) && $formtag === TRUE) - { - $atts .= ' method="post"'; - } - - if ( ! isset($attributes['accept-charset']) && $formtag === TRUE) - { - $atts .= ' accept-charset="'.strtolower(config_item('charset')).'"'; - } - foreach ($attributes as $key => $val) { $atts .= ' '.$key.'="'.$val.'"'; @@ -974,6 +952,8 @@ if ( ! function_exists('_attributes_to_string')) return $atts; } + + return FALSE; } } -- cgit v1.2.3-24-g4f1b From c4f9c62a604079fe3c2ab7637ffad894188fb429 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 27 Jul 2013 10:08:00 +0200 Subject: More logical order --- system/helpers/form_helper.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index f28296c2e..6fca73f85 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -54,6 +54,17 @@ if ( ! function_exists('form_open')) { $CI =& get_instance(); + // If an action is not a full URL then turn it into one + if ($action && strpos($action, '://') === FALSE) + { + $action = $CI->config->site_url($action); + } + elseif ( ! $action) + { + // If no action is provided then set to the current url + $action = $CI->config->site_url($CI->uri->uri_string()); + } + $attributes = _attributes_to_string($attributes); if (stripos($attributes, 'method=') === FALSE) @@ -66,17 +77,6 @@ if ( ! function_exists('form_open')) $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"'; } - // If an action is not a full URL then turn it into one - if ($action && strpos($action, '://') === FALSE) - { - $action = $CI->config->site_url($action); - } - elseif ( ! $action) - { - // If no action is provided then set to the current url - $action = $CI->config->site_url($CI->uri->uri_string()); - } - $form = '\n"; // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites -- cgit v1.2.3-24-g4f1b From 69d2cf5dd3dfa20be849bc5c2ccafa1042817850 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 27 Jul 2013 18:09:28 +0200 Subject: Complete 3.0 upgrade notes about NULL returned on missing items --- user_guide_src/source/installation/upgrade_300.rst | 52 +++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 0eafaf9cd..2e73ad1ce 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -145,29 +145,51 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' -************************************************* -Step 10: Check the calls to config->item() method -************************************************* +************************************************************************* +Step 10: Many functions now return NULL instead of FALSE on missing items +************************************************************************* -This method now returns NULL instead of FALSE when the required config -item doesn't exist. +Many methods and functions now return NULL instead of FALSE when the required items don't exist: -***************************************************************************** -Step 11: Check the calls to Array Helper's element() and elements() functions -***************************************************************************** + - :doc:`Config Class <../libraries/config>` -The default return value of these functions, when the required elements -don't exist, has been changed from FALSE to NULL. + - config->item() + - config->slash_item() + + - :doc:`Input Class <../libraries/input>` + + - input->get() + - input->post() + - input->get_post() + - input->cookie() + - input->server() + - input->input_stream() + - input->get_request_header() + + - :doc:`Session Class <../libraries/sessions>` + + - session->userdata() + - session->flashdata() + + - :doc:`URI Class <../libraries/uri>` + + - uri->segment() + - uri->rsegment() + + - :doc:`Array Helper <../helpers/array_helper>` + + - element() + - elements() *********************************************************************** -Step 12: Check the calls to Directory Helper's directory_map() function +Step 11: Check the calls to Directory Helper's directory_map() function *********************************************************************** In the resulting array, directories now end with a trailing directory separator (i.e. a slash, usually). ************************************************************* -Step 13: Update usage of Database Forge's drop_table() method +Step 12: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -189,7 +211,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 14: Change usage of Email library with multiple emails +Step 13: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -204,7 +226,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 15: Update your Form_validation language lines +Step 14: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -235,7 +257,7 @@ files and error messages format: later. **************************************************************** -Step 16: Remove usage of (previously) deprecated functionalities +Step 15: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a -- cgit v1.2.3-24-g4f1b From f746475e80a2734277eb1e76bb916ae3b2863423 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 28 Jul 2013 22:23:21 +0200 Subject: Form helper _attributes_to_string() micro-optimization As $attributes should be most of the times an array, let's save an is_string() call. --- system/helpers/form_helper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 6fca73f85..5ba5b556c 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -931,11 +931,6 @@ if ( ! function_exists('_attributes_to_string')) */ function _attributes_to_string($attributes) { - if (is_string($attributes)) - { - return ($attributes === '' ? '' : ' '.$attributes); - } - if (is_object($attributes)) { $attributes = (array) $attributes; @@ -953,6 +948,11 @@ if ( ! function_exists('_attributes_to_string')) return $atts; } + if (is_string($attributes)) + { + return ($attributes === '' ? '' : ' '.$attributes); + } + return FALSE; } } -- cgit v1.2.3-24-g4f1b From bb8b08982369dd6a2d321844dced488f92134f20 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 28 Jul 2013 22:35:04 +0200 Subject: Polishing Form helper --- system/helpers/form_helper.php | 7 ++++++- user_guide_src/source/helpers/form_helper.rst | 26 +++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 5ba5b556c..146c0f588 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -931,6 +931,11 @@ if ( ! function_exists('_attributes_to_string')) */ function _attributes_to_string($attributes) { + if (empty($attributes)) + { + return ''; + } + if (is_object($attributes)) { $attributes = (array) $attributes; @@ -950,7 +955,7 @@ if ( ! function_exists('_attributes_to_string')) if (is_string($attributes)) { - return ($attributes === '' ? '' : ' '.$attributes); + return ' '.$attributes; } return FALSE; diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index b2a9b6f0f..8f7515788 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -22,7 +22,7 @@ form_open() .. php:function:: form_open($action = '', $attributes = '', $hidden = array()) :param string $action: Form action/target URI string - :param string $attributes: HTML attributes + :param array $attributes: HTML attributes :param array $hidden: An array of hidden fields' definitions :returns: string @@ -41,7 +41,7 @@ Here's a simple example:: The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:: - + Adding Attributes ^^^^^^^^^^^^^^^^^ @@ -52,9 +52,13 @@ parameter, like this:: $attributes = array('class' => 'email', 'id' => 'myform'); echo form_open('email/send', $attributes); -The above example would create a form similar to this:: +Alternatively, you can specify the second parameter as a string:: + + echo form_open('email/send', 'class="email" id="myform"'); + +The above examples would create a form similar to this:: - + Adding Hidden Input Fields ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,6 +69,8 @@ third parameter, like this:: $hidden = array('username' => 'Joe', 'member_id' => '234'); echo form_open('email/send', '', $hidden); +You can skip the second parameter by passing any falsy value to it. + The above example would create a form similar to this:: @@ -77,7 +83,7 @@ form_open_multipart() .. php:function:: form_open_multipart($action = '', $attributes = array(), $hidden = array()) :param string $action: Form action/target URI string - :param string $attributes: HTML attributes + :param array $attributes: HTML attributes :param array $hidden: An array of hidden fields' definitions :returns: string @@ -407,16 +413,14 @@ The third parameter contains a boolean TRUE/FALSE to determine whether the box should be checked or not. Similar to the other form functions in this helper, you can also pass an -array of attributes to the function - -:: +array of attributes to the function:: $data = array( 'name' => 'newsletter', - 'id'ย ย ย ย ย ย => 'newsletter', - 'value'ย ย ย => 'accept', + 'id' => 'newsletter', + 'value' => 'accept', 'checked' => TRUE, - 'style'ย ย ย => 'margin:10px' + 'style' => 'margin:10px' ); echo form_checkbox($data); -- cgit v1.2.3-24-g4f1b From ed670246fa70d0156b561c56291b8bd58aa9df34 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 29 Jul 2013 08:31:51 +0200 Subject: Change spaces to tabs --- user_guide_src/source/helpers/form_helper.rst | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 8f7515788..f49027baa 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -264,10 +264,10 @@ multiple select for you. Example:: $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', ); $shirts_on_sale = array('small', 'large'); @@ -416,11 +416,11 @@ Similar to the other form functions in this helper, you can also pass an array of attributes to the function:: $data = array( - 'name' => 'newsletter', - 'id' => 'newsletter', - 'value' => 'accept', - 'checked' => TRUE, - 'style' => 'margin:10px' + 'name' => 'newsletter', + 'id' => 'newsletter', + 'value' => 'accept', + 'checked' => TRUE, + 'style' => 'margin:10px' ); echo form_checkbox($data); @@ -527,11 +527,11 @@ Or you can pass an associative array containing any data you wish your form to contain:: $data = array( - 'name' => 'button', - 'id' => 'button', - 'value' => 'true', - 'type' => 'reset', - 'content' => 'Reset' + 'name' => 'button', + 'id' => 'button', + 'value' => 'true', + 'type' => 'reset', + 'content' => 'Reset' ); echo form_button($data); -- cgit v1.2.3-24-g4f1b From 42113449a6942236236bab80328e6dc541a32585 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 29 Jul 2013 09:55:29 +0300 Subject: Fix #2568 --- system/database/drivers/pdo/pdo_driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index fa89661b1..184a8df33 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -69,7 +69,7 @@ class CI_DB_pdo_driver extends CI_DB { { parent::__construct($params); - if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) === 2) + if (preg_match('/([^:]+):/', $this->dsn, $match) && count($match) === 2) { // If there is a minimum valid dsn string pattern found, we're done // This is for general PDO users, who tend to have a full DSN string. @@ -77,7 +77,7 @@ class CI_DB_pdo_driver extends CI_DB { return; } // Legacy support for DSN specified in the hostname field - elseif (preg_match('/([^;]+):/', $this->hostname, $match) && count($match) === 2) + elseif (preg_match('/([^:]+):/', $this->hostname, $match) && count($match) === 2) { $this->dsn = $this->hostname; $this->hostname = NULL; -- cgit v1.2.3-24-g4f1b From d967f7216253d17df0a7154c49303fb560b70e04 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Mon, 29 Jul 2013 19:06:52 -0400 Subject: Cache Log Error Levels The log messages in the cache drvier's is_supported calls are more suited for the debug level. --- system/libraries/Cache/drivers/Cache_apc.php | 2 +- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- system/libraries/Cache/drivers/Cache_redis.php | 2 +- system/libraries/Cache/drivers/Cache_wincache.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index 127a220a7..a84e7d2d3 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -150,7 +150,7 @@ class CI_Cache_apc extends CI_Driver { { if ( ! extension_loaded('apc') OR ! (bool) @ini_get('apc.enabled')) { - log_message('error', 'The APC PHP extension must be loaded to use APC Cache.'); + log_message('debug', 'The APC PHP extension must be loaded to use APC Cache.'); return FALSE; } diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 35d91049a..d2a3a489d 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -240,7 +240,7 @@ class CI_Cache_memcached extends CI_Driver { { if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) { - log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); + log_message('debug', 'The Memcached Extension must be loaded to use Memcached Cache.'); return FALSE; } diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 484f284f1..40823fcb4 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -168,7 +168,7 @@ class CI_Cache_redis extends CI_Driver } else { - log_message('error', 'The Redis extension must be loaded to use Redis cache.'); + log_message('debug', 'The Redis extension must be loaded to use Redis cache.'); return FALSE; } } diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index d749978f5..80d3ac13d 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -150,7 +150,7 @@ class CI_Cache_wincache extends CI_Driver { { if ( ! extension_loaded('wincache')) { - log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); + log_message('debug', 'The Wincache PHP extension must be loaded to use Wincache Cache.'); return FALSE; } -- cgit v1.2.3-24-g4f1b From 530a3daec00186562e7e081ba77173b5ad065935 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Tue, 30 Jul 2013 10:20:50 -0400 Subject: Updated Changelog Cache Log Level - Updated the changelog to include the log level updates in the cache drivers. --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1e463db8d..4cef0e683 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -311,6 +311,7 @@ Release Date: Not Released - Added Wincache driver. - Added Redis driver. - Added a *key_prefix* option for cache IDs. + - Updated driver ``is_supported()`` methods to log at the "debug" level. - :doc:`Email library ` changes include: -- cgit v1.2.3-24-g4f1b From c958eebea2525133bcef9fe47a5dfab9e23128dd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 31 Jul 2013 14:28:50 +0300 Subject: Optimize CI_Session::__construct() routines and make driver validity check stricter --- system/libraries/Session/Session.php | 39 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index c7f6f828c..659a0269e 100644 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -59,12 +59,19 @@ class CI_Session extends CI_Driver_Library { */ public $params = array(); + /** + * Valid drivers list + * + * @var array + */ + public $valid_drivers = array('native', 'cookie'); + /** * Current driver in use * * @var string */ - protected $current = NULL; + public $current = NULL; /** * User data @@ -105,36 +112,26 @@ class CI_Session extends CI_Driver_Library { log_message('debug', 'CI_Session Class Initialized'); - // Get valid drivers list - $this->valid_drivers = array( - 'native', - 'cookie' - ); - $key = 'sess_valid_drivers'; - $drivers = isset($params[$key]) ? $params[$key] : $CI->config->item($key); - if ($drivers) + // Add possible extra entries to our valid drivers list + $drivers = isset($params['sess_valid_drivers']) ? $params['sess_valid_drivers'] : $CI->config->item('sess_valid_drivers'); + if ( ! empty($drivers)) { - // Add driver names to valid list - foreach ((array) $drivers as $driver) - { - if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers))) - { - $this->valid_drivers[] = $driver; - } - } + $drivers = array_map('strtolower', (array) $drivers); + $this->valid_drivers = array_merge($this->valid_drivers, array_diff($drivers, $this->valid_drivers)); } // Get driver to load - $key = 'sess_driver'; - $driver = isset($params[$key]) ? $params[$key] : $CI->config->item($key); + $driver = isset($params['sess_driver']) ? $params['sess_driver'] : $CI->config->item('sess_driver'); if ( ! $driver) { + log_message('debug', "Session: No driver name is configured, defaulting to 'cookie'."); $driver = 'cookie'; } - if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers))) + if ( ! in_array($driver, $this->valid_drivers)) { - $this->valid_drivers[] = $driver; + log_message('error', 'Session: Configured driver name is not valid, aborting.'); + return; } // Save a copy of parameters in case drivers need access -- cgit v1.2.3-24-g4f1b From 23719ab569c9c8d6b791f65d7861daba3895ddcb Mon Sep 17 00:00:00 2001 From: Hunter Wu Date: Thu, 1 Aug 2013 23:15:13 +0800 Subject: Add windows filename rule as an option for upload files --- system/core/Security.php | 51 ++++++++++++++++++++++++++++----------------- system/libraries/Upload.php | 12 +++++++++-- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index 196d61144..cd1cb1ab4 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -114,6 +114,36 @@ class CI_Security { "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?" ); + /** + * List of bad chars for sanitize filename + * + * @var array + */ + private $_filename_bad_str_rules = array( + 'default' => array( + '../', '', '<', '>', + "'", '"', '&', '$', '#', + '{', '}', '[', ']', '=', + ';', '?', '%20', '%22', + '%3c', // < + '%253c', // < + '%3e', // > + '%0e', // > + '%28', // ( + '%29', // ) + '%2528', // ( + '%26', // & + '%24', // $ + '%3f', // ? + '%3b', // ; + '%3d' // = + ), + 'windows' => array( + '\\', '/', ':', '*', '?', + '"', '<', '>', '|', + ), + ); + /** * Class constructor * @@ -547,26 +577,9 @@ class CI_Security { * @param bool $relative_path Whether to preserve paths * @return string */ - public function sanitize_filename($str, $relative_path = FALSE) + public function sanitize_filename($str, $relative_path = FALSE, $rule = 'default') { - $bad = array( - '../', '', '<', '>', - "'", '"', '&', '$', '#', - '{', '}', '[', ']', '=', - ';', '?', '%20', '%22', - '%3c', // < - '%253c', // < - '%3e', // > - '%0e', // > - '%28', // ( - '%29', // ) - '%2528', // ( - '%26', // & - '%24', // $ - '%3f', // ? - '%3b', // ; - '%3d' // = - ); + $bad = $this->_filename_bad_str_rules[$rule]; if ( ! $relative_path) { diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 85428044d..62eca6fdb 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -142,6 +142,13 @@ class CI_Upload { */ public $file_ext_tolower = FALSE; + /** + * Filename Rule + * + * @var string + */ + public $filename_rule = 'default'; + /** * Upload path * @@ -315,7 +322,8 @@ class CI_Upload { 'detect_mime' => TRUE, 'xss_clean' => FALSE, 'temp_prefix' => 'temp_file_', - 'client_name' => '' + 'client_name' => '', + 'filename_rule' => 'default', ); foreach ($defaults as $key => $val) @@ -472,7 +480,7 @@ class CI_Upload { // Sanitize the file name for security $CI =& get_instance(); - $this->file_name = $CI->security->sanitize_filename($this->file_name); + $this->file_name = $CI->security->sanitize_filename($this->file_name, FALSE, $this->filename_rule); // Truncate the file name if it's too long if ($this->max_filename > 0) -- cgit v1.2.3-24-g4f1b From 8df3352dff5f734c1b3831fdc131f676a9850d51 Mon Sep 17 00:00:00 2001 From: Hunter Wu Date: Sat, 3 Aug 2013 22:36:05 +0800 Subject: Revert "Add windows filename rule as an option for upload files" This reverts commit 23719ab569c9c8d6b791f65d7861daba3895ddcb. --- system/core/Security.php | 51 +++++++++++++++++---------------------------- system/libraries/Upload.php | 12 ++--------- 2 files changed, 21 insertions(+), 42 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index cd1cb1ab4..196d61144 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -114,36 +114,6 @@ class CI_Security { "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?" ); - /** - * List of bad chars for sanitize filename - * - * @var array - */ - private $_filename_bad_str_rules = array( - 'default' => array( - '../', '', '<', '>', - "'", '"', '&', '$', '#', - '{', '}', '[', ']', '=', - ';', '?', '%20', '%22', - '%3c', // < - '%253c', // < - '%3e', // > - '%0e', // > - '%28', // ( - '%29', // ) - '%2528', // ( - '%26', // & - '%24', // $ - '%3f', // ? - '%3b', // ; - '%3d' // = - ), - 'windows' => array( - '\\', '/', ':', '*', '?', - '"', '<', '>', '|', - ), - ); - /** * Class constructor * @@ -577,9 +547,26 @@ class CI_Security { * @param bool $relative_path Whether to preserve paths * @return string */ - public function sanitize_filename($str, $relative_path = FALSE, $rule = 'default') + public function sanitize_filename($str, $relative_path = FALSE) { - $bad = $this->_filename_bad_str_rules[$rule]; + $bad = array( + '../', '', '<', '>', + "'", '"', '&', '$', '#', + '{', '}', '[', ']', '=', + ';', '?', '%20', '%22', + '%3c', // < + '%253c', // < + '%3e', // > + '%0e', // > + '%28', // ( + '%29', // ) + '%2528', // ( + '%26', // & + '%24', // $ + '%3f', // ? + '%3b', // ; + '%3d' // = + ); if ( ! $relative_path) { diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 62eca6fdb..85428044d 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -142,13 +142,6 @@ class CI_Upload { */ public $file_ext_tolower = FALSE; - /** - * Filename Rule - * - * @var string - */ - public $filename_rule = 'default'; - /** * Upload path * @@ -322,8 +315,7 @@ class CI_Upload { 'detect_mime' => TRUE, 'xss_clean' => FALSE, 'temp_prefix' => 'temp_file_', - 'client_name' => '', - 'filename_rule' => 'default', + 'client_name' => '' ); foreach ($defaults as $key => $val) @@ -480,7 +472,7 @@ class CI_Upload { // Sanitize the file name for security $CI =& get_instance(); - $this->file_name = $CI->security->sanitize_filename($this->file_name, FALSE, $this->filename_rule); + $this->file_name = $CI->security->sanitize_filename($this->file_name); // Truncate the file name if it's too long if ($this->max_filename > 0) -- cgit v1.2.3-24-g4f1b From a8d6d3b13a0086c86e3dd69f0376be3a6982bc16 Mon Sep 17 00:00:00 2001 From: Hunter Wu Date: Sat, 3 Aug 2013 23:17:45 +0800 Subject: Make the bad filename array public in Security library --- system/core/Security.php | 56 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index 196d61144..3d04d5e12 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -37,6 +37,30 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_Security { + /** + * List of sanitize filename strings + * + * @var array + */ + public $sanitize_filename_str = array( + '../', '', '<', '>', + "'", '"', '&', '$', '#', + '{', '}', '[', ']', '=', + ';', '?', '%20', '%22', + '%3c', // < + '%253c', // < + '%3e', // > + '%0e', // > + '%28', // ( + '%29', // ) + '%2528', // ( + '%26', // & + '%24', // $ + '%3f', // ? + '%3b', // ; + '%3d' // = + ); + /** * XSS Hash * @@ -540,6 +564,19 @@ class CI_Security { // -------------------------------------------------------------------- + /** + * Set Sanitize Filename Strings + * + * @param array $strings + * @return void + */ + public function set_sanitize_filename_str($strings) + { + $this->sanitize_filename_str = $strings; + } + + // -------------------------------------------------------------------- + /** * Sanitize Filename * @@ -549,24 +586,7 @@ class CI_Security { */ public function sanitize_filename($str, $relative_path = FALSE) { - $bad = array( - '../', '', '<', '>', - "'", '"', '&', '$', '#', - '{', '}', '[', ']', '=', - ';', '?', '%20', '%22', - '%3c', // < - '%253c', // < - '%3e', // > - '%0e', // > - '%28', // ( - '%29', // ) - '%2528', // ( - '%26', // & - '%24', // $ - '%3f', // ? - '%3b', // ; - '%3d' // = - ); + $bad = $this->sanitize_filename_str; if ( ! $relative_path) { -- cgit v1.2.3-24-g4f1b From 4495cc740c1c0e382cc62d3d174abd17c0b4d84f Mon Sep 17 00:00:00 2001 From: Hunter Wu Date: Sun, 4 Aug 2013 12:31:52 +0800 Subject: Rename bad chars property to filename_bad_chars, remove the setter and add changelog entry --- system/core/Security.php | 17 ++--------------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index 3d04d5e12..70cf3e013 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -42,7 +42,7 @@ class CI_Security { * * @var array */ - public $sanitize_filename_str = array( + public $filename_bad_chars = array( '../', '', '<', '>', "'", '"', '&', '$', '#', '{', '}', '[', ']', '=', @@ -564,19 +564,6 @@ class CI_Security { // -------------------------------------------------------------------- - /** - * Set Sanitize Filename Strings - * - * @param array $strings - * @return void - */ - public function set_sanitize_filename_str($strings) - { - $this->sanitize_filename_str = $strings; - } - - // -------------------------------------------------------------------- - /** * Sanitize Filename * @@ -586,7 +573,7 @@ class CI_Security { */ public function sanitize_filename($str, $relative_path = FALSE) { - $bad = $this->sanitize_filename_str; + $bad = $this->filename_bad_chars; if ( ! $relative_path) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4cef0e683..fd1ce2dc0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -416,6 +416,7 @@ Release Date: Not Released - Added method ``strip_image_tags()``. - Added ``$config['csrf_regeneration']``, which makes token regeneration optional. - Added ``$config['csrf_exclude_uris']``, which allows you list URIs which will not have the CSRF validation methods run. + - Changed ``sanitize_filename()``, makes filename_bad_chars a public property. - :doc:`URI Routing ` changes include: -- cgit v1.2.3-24-g4f1b From e265097c7ffd2ea59e4f972346ea0a87ac75edb2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Aug 2013 12:38:38 +0300 Subject: [ci skip] Alter a changelog line --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index fd1ce2dc0..81d92f755 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -416,7 +416,7 @@ Release Date: Not Released - Added method ``strip_image_tags()``. - Added ``$config['csrf_regeneration']``, which makes token regeneration optional. - Added ``$config['csrf_exclude_uris']``, which allows you list URIs which will not have the CSRF validation methods run. - - Changed ``sanitize_filename()``, makes filename_bad_chars a public property. + - Modified method ``sanitize_filename()`` to read a public ``$filename_bad_chars`` property for getting the invalid characters list. - :doc:`URI Routing ` changes include: -- cgit v1.2.3-24-g4f1b From 79f888b27bd67724b30aa6dd30e2ae5162b1fea8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Aug 2013 13:59:23 +0300 Subject: Fix #2501 & another -related bug --- system/database/DB_driver.php | 4 +++- system/database/DB_query_builder.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 425657e17..53decf014 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1375,7 +1375,9 @@ abstract class CI_DB_driver { $fields[$this->protect_identifiers($key)] = $this->escape($val); } - return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields); + $sql = $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields); + $this->_reset_write(); + return $sql; } // -------------------------------------------------------------------- diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 292621b66..355613c6f 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1846,6 +1846,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, 100), $this->protect_identifiers($index))); $affected_rows += $this->affected_rows(); + $this->qb_where = array(); } $this->_reset_write(); -- cgit v1.2.3-24-g4f1b From 5b55c15f24b518aa4775a0c15382c7b4bf72e1bc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Aug 2013 14:14:32 +0300 Subject: Fix #2585 --- system/database/DB_query_builder.php | 2 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 355613c6f..e6a108209 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -385,7 +385,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $alias = $this->_create_alias_from_table(trim($select)); } - $sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->escape_identifiers(trim($alias)); + $sql = $type.'('.$this->protect_identifiers(trim($select)).') AS '.$this->escape_identifiers(trim($alias)); $this->qb_select[] = $sql; $this->qb_no_escape[] = NULL; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 81d92f755..8b5798751 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -604,6 +604,7 @@ Bug fixes for 3.0 - Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. - Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exits. - Fixed a bug (#2560) - :doc:`Form Helper ` function :php:func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. +- Fixed a bug (#2585) - :doc:`Query Builder ` methods ``min()``, ``max()``, ``avg()``, ``sum()`` didn't escape field names. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From c941d855dc32ec44107cb863596fa385c7aed015 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 6 Aug 2013 14:44:40 +0200 Subject: Various typos and tabs adjustments --- application/config/doctypes.php | 12 ++++++------ application/config/smileys.php | 4 ++-- application/config/user_agents.php | 2 +- index.php | 2 +- system/core/Common.php | 4 ++-- system/core/Input.php | 2 +- system/core/Router.php | 4 ++-- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_result.php | 2 +- system/libraries/Upload.php | 2 +- user_guide_src/source/changelog.rst | 10 +++++----- user_guide_src/source/helpers/smiley_helper.rst | 6 +++--- user_guide_src/source/installation/upgrade_300.rst | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/application/config/doctypes.php b/application/config/doctypes.php index fe5420263..b1a8959c2 100644 --- a/application/config/doctypes.php +++ b/application/config/doctypes.php @@ -26,19 +26,19 @@ */ $_doctypes = array( - 'xhtml11' => '', + 'xhtml11' => '', 'xhtml1-strict' => '', 'xhtml1-trans' => '', 'xhtml1-frame' => '', 'xhtml-basic11' => '', - 'html5' => '', + 'html5' => '', 'html4-strict' => '', 'html4-trans' => '', 'html4-frame' => '', - 'mathml1' => '', - 'mathml2' => '', - 'svg10' => '', - 'svg11' => '', + 'mathml1' => '', + 'mathml2' => '', + 'svg10' => '', + 'svg11' => '', 'svg11-basic' => '', 'svg11-tiny' => '', 'xhtml-math-svg-xh' => '', diff --git a/application/config/smileys.php b/application/config/smileys.php index 4b253098b..3c49c469e 100644 --- a/application/config/smileys.php +++ b/application/config/smileys.php @@ -30,7 +30,7 @@ | SMILEYS | ------------------------------------------------------------------- | This file contains an array of smileys for use with the emoticon helper. -| Individual images can be used to replace multiple simileys. For example: +| Individual images can be used to replace multiple smileys. For example: | :-) and :) use the same image replacement. | | Please see user guide for more info: @@ -84,7 +84,7 @@ $smileys = array( ':vampire:' => array('vampire.gif', '19', '19', 'vampire'), ':snake:' => array('snake.gif', '19', '19', 'snake'), ':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'), - ':question:' => array('question.gif', '19', '19', 'question') // no comma after last item + ':question:' => array('question.gif', '19', '19', 'question') ); diff --git a/application/config/user_agents.php b/application/config/user_agents.php index 88ab06358..0c8605820 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -182,7 +182,7 @@ $mobiles = array( 'operamini' => 'Opera Mini', 'opera mini' => 'Opera Mini', 'opera mobi' => 'Opera Mobile', - 'fennec' => 'Firefox Mobile', + 'fennec' => 'Firefox Mobile', // Other 'digital paths' => 'Digital Paths', diff --git a/index.php b/index.php index f93cadb9d..3040ef080 100755 --- a/index.php +++ b/index.php @@ -77,7 +77,7 @@ switch (ENVIRONMENT) *--------------------------------------------------------------- * * This variable must contain the name of your "system" folder. - * Include the path if the folder is not in the same directory + * Include the path if the folder is not in the same directory * as this file. */ $system_path = 'system'; diff --git a/system/core/Common.php b/system/core/Common.php index b95a05db9..b9e318394 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -556,8 +556,8 @@ if ( ! function_exists('_exception_handler')) /** * Exception Handler * - * This is the custom exception handler that is declaired at the top - * of Codeigniter.php. The main reason we use this is to permit + * This is the custom exception handler that is declared at the top + * of CodeIgniter.php. The main reason we use this is to permit * PHP errors to be logged in our own log files since the user may * not have access to server logs. Since this function * effectively intercepts PHP errors, however, we also need diff --git a/system/core/Input.php b/system/core/Input.php index 0ef81128e..6f184a3ca 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -47,7 +47,7 @@ class CI_Input { public $ip_address = FALSE; /** - * User agent strin + * User agent string * * @var string */ diff --git a/system/core/Router.php b/system/core/Router.php index 989ae542e..0f7278ae6 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -351,10 +351,10 @@ class CI_Router { return $this->_set_request(explode('/', $this->routes[$uri])); } - // Loop through the route array looking for wild-cards + // Loop through the route array looking for wildcards foreach ($this->routes as $key => $val) { - // Convert wild-cards to RegEx + // Convert wildcards to RegEx $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key); // Does the RegEx match? diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 93e62b4dd..020a3a4ba 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index fd1d28787..ce09b62bc 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 85428044d..15eb74bd5 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -463,7 +463,7 @@ class CI_Upload { } // Are the image dimensions within the allowed size? - // Note: This can fail if the server has an open_basdir restriction. + // Note: This can fail if the server has an open_basedir restriction. if ( ! $this->is_allowed_dimensions()) { $this->set_error('upload_invalid_dimensions'); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8b5798751..a987c507d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -75,7 +75,7 @@ Release Date: Not Released - :php:func:`anchor_popup()` will now fill the *href* attribute with the URL and its JS code will return FALSE instead. - Added JS window name support to the :php:func:`anchor_popup()` function. - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`. - - Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). + - Changed :php:func:`redirect()` to choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). - Added an optional second parameter to both :php:func:`base_url()` and :php:func:`site_url()` that allows enforcing of a protocol different than the one in the *base_url* configuration setting. @@ -515,7 +515,7 @@ Bug fixes for 3.0 - Fixed a bug (#784, #861) - :doc:`Database Forge ` method ``create_table()`` used to accept constraints for MSSQL/SQLSRV integer-type columns. - Fixed a bug (#706) - SQLSRV/MSSSQL didn't escape field names. - Fixed a bug (#1452) - ``protect_identifiers()`` didn't properly detect identifiers with spaces in their names. -- Fixed a bug where ``protect_identifiers()`` ignored it's extra arguments when the value passed to it is an array. +- Fixed a bug where ``protect_identifiers()`` ignored its extra arguments when the value passed to it is an array. - Fixed a bug where ``_has_operator()`` didn't detect BETWEEN. - Fixed a bug in :doc:`Query Builder `'s ``join()`` method where it failed with identifiers containing dashes. - Fixed a bug (#1264) - :doc:`Database Forge ` and :doc:`Database Utilities ` didn't update/reset the databases and tables list cache when a table or a database is created, dropped or renamed. @@ -555,7 +555,7 @@ Bug fixes for 3.0 - Fixed a bug where the :doc:`Session Library ` accepted cookies with *last_activity* values being in the future. - Fixed a bug (#1897) - :doc:`Email Library ` triggered PHP E_WARNING errors when *mail* protocol used and ``to()`` is never called. - Fixed a bug (#1409) - :doc:`Email Library ` didn't properly handle multibyte characters when applying Q-encoding to headers. -- Fixed a bug where :doc:`Email Library ` didn't honor it's *wordwrap* setting while handling alternative messages. +- Fixed a bug where :doc:`Email Library ` didn't honor its *wordwrap* setting while handling alternative messages. - Fixed a bug (#1476, #1909) - :doc:`Pagination Library ` didn't take into account actual routing when determining the current page. - Fixed a bug (#1766) - :doc:`Query Builder ` didn't always take into account the *dbprefix* setting. - Fixed a bug (#779) - :doc:`URI Class ` didn't always trim slashes from the *uri_string* as shown in the documentation. @@ -602,7 +602,7 @@ Bug fixes for 3.0 - Fixed a bug (#2490) - :doc:`Database Class ` method ``query()`` returning boolean instead of a result object for PostgreSQL-specific *INSERT INTO ... RETURNING* statements. - Fixed a bug (#249) - :doc:`Cache Library ` didn't properly handle Memcache(d) configurations with missing options. - Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. -- Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exits. +- Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exists. - Fixed a bug (#2560) - :doc:`Form Helper ` function :php:func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. - Fixed a bug (#2585) - :doc:`Query Builder ` methods ``min()``, ``max()``, ``avg()``, ``sum()`` didn't escape field names. @@ -684,7 +684,7 @@ Bug fixes for 2.1.1 - Fixed a bug (#538) - Windows paths were ignored when using the :doc:`Image Manipulation Library ` to create a new file. - Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found. - Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk. -- Fixed a bug (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite. +- Fixed a bug (#726) - PDO put a 'dbname' argument in its connection string regardless of the database platform in use, which made it impossible to use SQLite. - Fixed a bug - ``CI_DB_pdo_driver::num_rows()`` was not returning properly value with SELECT queries, cause it was relying on ``PDOStatement::rowCount()``. - Fixed a bug (#1059) - ``CI_Image_lib::clear()`` was not correctly clearing all necessary object properties, namely width and height. diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst index 3925f8b1a..cfd52ffbc 100644 --- a/user_guide_src/source/helpers/smiley_helper.rst +++ b/user_guide_src/source/helpers/smiley_helper.rst @@ -17,7 +17,7 @@ This helper is loaded using the following code:: Overview ======== -The Smiley helper has a renderer that takes plain text simileys, like +The Smiley helper has a renderer that takes plain text smileys, like :-) and turns them into a image representation, like |smile!| It also lets you display a set of smiley images that when clicked will @@ -44,7 +44,7 @@ The Controller -------------- In your **application/controllers/** directory, create a file called -smileys.php and place the code below in it. +Smileys.php and place the code below in it. .. important:: Change the URL in the :php:func:`get_clickable_smileys()` function below so that it points to your smiley folder. @@ -156,7 +156,7 @@ string, the second must contain the URL to your smiley folder Example:: - $str = 'Here are some simileys: :-) ;-)'; + $str = 'Here are some smileys: :-) ;-)'; $str = parse_smileys($str, "http://example.com/images/smileys/"); echo $str; diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 2e73ad1ce..89835585c 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -207,7 +207,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. // Produces DROP TABLE IF EXISTS `table_name` $this->dbforge->drop_table('table_name', TRUE); -.. note:: The given example users MySQL-specific syntax, but it should work across +.. note:: The given example uses MySQL-specific syntax, but it should work across all drivers with the exception of ODBC. *********************************************************** -- cgit v1.2.3-24-g4f1b From 40d124924ea331c6a57ab1b3f743299a41eb3f0c Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 6 Aug 2013 14:46:00 +0200 Subject: Replace php_sapi_name() function with PHP_SAPI constant exact same behavior but faster, shorter --- system/core/Common.php | 2 +- system/core/Input.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index b9e318394..28c60832c 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -538,7 +538,7 @@ if ( ! function_exists('set_status_header')) $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; - if (strpos(php_sapi_name(), 'cgi') === 0) + if (strpos(PHP_SAPI, 'cgi') === 0) { header('Status: '.$code.' '.$text, TRUE); } diff --git a/system/core/Input.php b/system/core/Input.php index 6f184a3ca..1e67ce183 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -872,7 +872,7 @@ class CI_Input { */ public function is_cli_request() { - return (php_sapi_name() === 'cli' OR defined('STDIN')); + return (PHP_SAPI === 'cli' OR defined('STDIN')); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 61f1aa0c4d22e1ab5a10e906f25d7e4ee24b225c Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 7 Aug 2013 11:29:17 +0200 Subject: Fix noneffective static variable cache in log_message() --- system/core/Common.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 28c60832c..98a3fcb35 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -453,10 +453,11 @@ if ( ! function_exists('log_message')) if ($_log === NULL) { - $_log =& load_class('Log', 'core'); + // references cannot be directly assigned to static variables, so we use an array + $_log[0] =& load_class('Log', 'core'); } - $_log->write_log($level, $message, $php_error); + $_log[0]->write_log($level, $message, $php_error); } } -- cgit v1.2.3-24-g4f1b From 2b956af4588eb64a7a4f9c72e1d223a33b65e8c6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 7 Aug 2013 14:32:56 +0300 Subject: An improved version of PR #2584, fixes #2583 --- system/libraries/Email.php | 24 +++++++++++++----------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 46ffaa1d4..082629a4c 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1265,7 +1265,7 @@ class CI_Email { } else { - $this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body; + $this->_finalbody = $hdr.$this->newline.$this->newline.$this->_body; } return; @@ -1275,11 +1275,11 @@ class CI_Email { if ($this->send_multipart === FALSE) { $hdr .= 'Content-Type: text/html; charset='.$this->charset.$this->newline - .'Content-Transfer-Encoding: quoted-printable'.$this->newline.$this->newline; + .'Content-Transfer-Encoding: quoted-printable'; } else { - $hdr .= 'Content-Type: multipart/alternative; boundary="'.$this->_alt_boundary.'"'.$this->newline.$this->newline; + $hdr .= 'Content-Type: multipart/alternative; boundary="'.$this->_alt_boundary.'"'; $body .= $this->_get_mime_message().$this->newline.$this->newline .'--'.$this->_alt_boundary.$this->newline @@ -1300,7 +1300,7 @@ class CI_Email { } else { - $this->_finalbody = $hdr.$this->_finalbody; + $this->_finalbody = $hdr.$this->newline.$this->newline.$this->_finalbody; } if ($this->send_multipart !== FALSE) @@ -1312,25 +1312,25 @@ class CI_Email { case 'plain-attach' : - $hdr .= 'Content-Type: multipart/'.$this->multipart.'; boundary="'.$this->_atc_boundary.'"'.$this->newline.$this->newline; + $hdr .= 'Content-Type: multipart/'.$this->multipart.'; boundary="'.$this->_atc_boundary.'"'; if ($this->_get_protocol() === 'mail') { $this->_header_str .= $hdr; } - $body .= $this->_get_mime_message().$this->newline.$this->newline + $body .= $this->_get_mime_message().$this->newline + .$this->newline .'--'.$this->_atc_boundary.$this->newline - .'Content-Type: text/plain; charset='.$this->charset.$this->newline - .'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline.$this->newline - + .'Content-Transfer-Encoding: '.$this->_get_encoding().$this->newline + .$this->newline .$this->_body.$this->newline.$this->newline; break; case 'html-attach' : - $hdr .= 'Content-Type: multipart/'.$this->multipart.'; boundary="'.$this->_atc_boundary.'"'.$this->newline.$this->newline; + $hdr .= 'Content-Type: multipart/'.$this->multipart.'; boundary="'.$this->_atc_boundary.'"'; if ($this->_get_protocol() === 'mail') { @@ -1400,7 +1400,9 @@ class CI_Email { } $body .= implode($this->newline, $attachment).$this->newline.'--'.$this->_atc_boundary.'--'; - $this->_finalbody = ($this->_get_protocol() === 'mail') ? $body : $hdr.$body; + $this->_finalbody = ($this->_get_protocol() === 'mail') + ? $body + : $hdr.$this->newline.$this->newline.$body; return TRUE; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a987c507d..8b73e7a98 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -605,6 +605,7 @@ Bug fixes for 3.0 - Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exists. - Fixed a bug (#2560) - :doc:`Form Helper ` function :php:func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. - Fixed a bug (#2585) - :doc:`Query Builder ` methods ``min()``, ``max()``, ``avg()``, ``sum()`` didn't escape field names. +- Fixed an edge case (#2583) in the :doc:`Email Library ` where `Suhosin ` blocked messages sent via ``mail()`` due to trailing newspaces in headers. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From 2f8d2d381ef4a2fd9ea8f67a36a731aae8b14064 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 7 Aug 2013 15:54:47 +0300 Subject: Add a changelog entry for PR #2590 and further optimize log_message() CI_Log::write_log() already checks the log threshold, so there's no point in doing it in log_message() as well. --- system/core/Common.php | 12 +----------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 98a3fcb35..21e1df9c6 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -439,17 +439,7 @@ if ( ! function_exists('log_message')) */ function log_message($level, $message, $php_error = FALSE) { - static $_log, $_log_threshold; - - if ($_log_threshold === NULL) - { - $_log_threshold = config_item('log_threshold'); - } - - if ($_log_threshold === 0) - { - return; - } + static $_log; if ($_log === NULL) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8b73e7a98..4a45a71b0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -606,6 +606,7 @@ Bug fixes for 3.0 - Fixed a bug (#2560) - :doc:`Form Helper ` function :php:func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. - Fixed a bug (#2585) - :doc:`Query Builder ` methods ``min()``, ``max()``, ``avg()``, ``sum()`` didn't escape field names. - Fixed an edge case (#2583) in the :doc:`Email Library ` where `Suhosin ` blocked messages sent via ``mail()`` due to trailing newspaces in headers. +- Fixed a bug (#2590) - :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From e23ba1373b347ecca61c371c96f0e33da443e915 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 8 Aug 2013 13:27:48 +0300 Subject: [ci skip] Add MD5 checksums to download page (rel: #991) --- user_guide_src/source/installation/downloads.rst | 60 ++++++++++++------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst index 8d47ba3a5..93c5cc21b 100644 --- a/user_guide_src/source/installation/downloads.rst +++ b/user_guide_src/source/installation/downloads.rst @@ -3,35 +3,37 @@ Downloading CodeIgniter ####################### - `CodeIgniter v3.0.0 (Current version) `_ -- `CodeIgniter v2.1.4 `_ -- `CodeIgniter v2.1.3 `_ -- `CodeIgniter v2.1.2 `_ -- `CodeIgniter v2.1.1 `_ -- `CodeIgniter v2.1.0 `_ -- `CodeIgniter v2.0.3 `_ -- `CodeIgniter v2.0.2 `_ -- `CodeIgniter v2.0.1 `_ -- `CodeIgniter v2.0.0 `_ -- `CodeIgniter v1.7.3 `_ -- `CodeIgniter v1.7.2 `_ -- `CodeIgniter v1.7.1 `_ -- `CodeIgniter v1.7.0 `_ -- `CodeIgniter v1.6.3 `_ -- `CodeIgniter v1.6.2 `_ -- `CodeIgniter v1.6.1 `_ -- `CodeIgniter v1.6.0 `_ -- `CodeIgniter v1.5.4 `_ -- `CodeIgniter v1.5.3 `_ -- `CodeIgniter v1.5.2 `_ -- `CodeIgniter v1.5.1 `_ -- `CodeIgniter v1.4.1 `_ -- `CodeIgniter v1.3.3 `_ -- `CodeIgniter v1.3.2 `_ -- `CodeIgniter v1.3.1 `_ -- `CodeIgniter v1.3 `_ -- `CodeIgniter v1.2 `_ -- `CodeIgniter v1.1 `_ -- `CodeIgniter v1.0 `_ +- `CodeIgniter v2.1.4 `_ (MD5 Checksum: e74a296c1d412a855c025b9cd468a513) +- `CodeIgniter v2.1.3 `_ (MD5 Checksum: 781d06be06eaa36f10759ef82c8594d5) +- `CodeIgniter v2.1.2 `_ (MD5 Checksum: c7a2980dff2774c97bd38bfbf450d8d5) +- `CodeIgniter v2.1.1 `_ (MD5 Checksum: c4aa5f188f4ff16f919607b46a16c76c) +- `CodeIgniter v2.1.0 `_ (MD5 Checksum: 8cb676b0f831114935d7dd1ae2e0d490) +- `CodeIgniter v2.0.3 `_ (MD5 Checksum: 910475d50daf088bdd949c3d35b444d9) +- `CodeIgniter v2.0.2 `_ (MD5 Checksum: e75bab8cf27d2fb2483c5bb61b85a524) +- `CodeIgniter v2.0.1 `_ (MD5 Checksum: 675aa95896bfb16467436c0484f15f1f) +- `CodeIgniter v2.0.0 `_ (MD5 Checksum: bd657863de45dbb397f3b3dbc4f13abb) +- `CodeIgniter v1.7.3 `_ (MD5 Checksum: 16f50e7df4f44c1defe18355131049e9) +- `CodeIgniter v1.7.2 `_ (MD5 Checksum: ff2f4d1b3ab921f91e006f38b3ae6540) +- `CodeIgniter v1.7.1 `_ (MD5 Checksum: deca9709cf21b26dc0e4ec040b37e866) +- `CodeIgniter v1.7.0 `_ (MD5 Checksum: 28037f2071f940d8756864460d949045) +- `CodeIgniter v1.6.3 `_ (MD5 Checksum: 5ffab52b39b235ed6bd08ee5dd64d2f6) +- `CodeIgniter v1.6.2 `_ (MD5 Checksum: 0922830f96dfd40874b39ad018a49206) +- `CodeIgniter v1.6.1 `_ (MD5 Checksum: cc3f0b566e3654d351fa067aeee9bced) +- `CodeIgniter v1.6.0 `_ (MD5 Checksum: 89efabb8c1d57bb51071e6a20bb5590d) +- `CodeIgniter v1.5.4 `_ (MD5 Checksum: 0d6cc66b01d5ddecde483b3d5f51e4f8) +- `CodeIgniter v1.5.3 `_ (MD5 Checksum: f44dd21d34a2842bd052879ca5de6630) +- `CodeIgniter v1.5.2 `_ (MD5 Checksum: 78e7106b271f75af48e626f6e923c1aa) +- `CodeIgniter v1.5.1 `_ (MD5 Checksum: 9dfd0dbed4f283a42a817e1e88f97481) +- `CodeIgniter v1.5.0 `_ (MD5 Checksum: 116b805eae4b7e78ddd43a8aee733632) +- `CodeIgniter v1.4.1 `_ (MD5 Checksum: 470005a83772e9d2e99dec2b4058e584) +- `CodeIgniter v1.4.0 `_ (MD5 Checksum: 43ca6ff3447d6b5681f98a328b386338) +- `CodeIgniter v1.3.3 `_ (MD5 Checksum: 55692ba4b55b53b58e4514e310288981) +- `CodeIgniter v1.3.2 `_ (MD5 Checksum: 7dace6e1d6245b569943e8df952c7637) +- `CodeIgniter v1.3.1 `_ (MD5 Checksum: f6c6f00830c60d7f98b948269ee81069) +- `CodeIgniter v1.3 `_ (MD5 Checksum: 03b2f796df6af808ecff3a18b6000477) +- `CodeIgniter v1.2 `_ (MD5 Checksum: f9289814fabe102bc35beb791d0c0f62) +- `CodeIgniter v1.1 `_ (MD5 Checksum: bf4cabb6a3ea3122a974270b8044befb) +- `CodeIgniter v1.0 `_ (MD5 Checksum: 427ca4255e2bdaacee976de1aa143ea0) ****** -- cgit v1.2.3-24-g4f1b From 441fd264267ac526730d06183bd3cfebfd26df01 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 11 Aug 2013 20:36:41 +0200 Subject: Input class: change behavior of get_post() method, add post_get() method followup to PR #2522 --- system/core/Input.php | 18 +++++++++++++++++- tests/codeigniter/core/Input_test.php | 12 +++++++++++- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/installation/upgrade_300.rst | 21 ++++++++++++++++----- user_guide_src/source/libraries/input.rst | 16 ++++++++++++---- 5 files changed, 57 insertions(+), 11 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index 1e67ce183..24e21ea08 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -261,7 +261,7 @@ class CI_Input { * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ - public function get_post($index = '', $xss_clean = FALSE) + public function post_get($index = '', $xss_clean = FALSE) { return isset($_POST[$index]) ? $this->post($index, $xss_clean) @@ -270,6 +270,22 @@ class CI_Input { // -------------------------------------------------------------------- + /** + * Fetch an item from GET data with fallback to POST + * + * @param string $index Index for item to be fetched from $_GET or $_POST + * @param bool $xss_clean Whether to apply XSS filtering + * @return mixed + */ + public function get_post($index = '', $xss_clean = FALSE) + { + return isset($_GET[$index]) + ? $this->get($index, $xss_clean) + : $this->post($index, $xss_clean); + } + + // -------------------------------------------------------------------- + /** * Fetch an item from the COOKIE array * diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 5cf25fefa..0a98e556c 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -82,11 +82,21 @@ class Input_test extends CI_TestCase { // -------------------------------------------------------------------- - public function test_get_post() + public function test_post_get() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_POST['foo'] = 'bar'; + $this->assertEquals('bar', $this->input->post_get('foo')); + } + + // -------------------------------------------------------------------- + + public function test_get_post() + { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_GET['foo'] = 'bar'; + $this->assertEquals('bar', $this->input->get_post('foo')); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4a45a71b0..ba104bb72 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -388,6 +388,7 @@ Release Date: Not Released - Changed method ``valid_ip()`` to use PHP's native ``filter_var()`` function. - Changed internal method ``_sanitize_globals()`` to skip enforcing reversal of *register_globals* in PHP 5.4+, where this functionality no longer exists. - Changed methods ``get()``, ``post()``, ``get_post()``, ``cookie()``, ``server()``, ``user_agent()`` to return NULL instead of FALSE when no value is found. + - Changed method ``get_post()`` to check in GET then in POST. Added method ``post_get()`` which checks in POST then in GET, as ``get_post()`` was doing before. - Changed method ``_fetch_from_array()`` to parse array notation in field name. - :doc:`Common functions ` changes include: diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 89835585c..21bdd188f 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -181,15 +181,26 @@ Many methods and functions now return NULL instead of FALSE when the required it - element() - elements() +******************************************************** +Step 11: Update usage of Input Class's get_post() method +******************************************************** + +Previously, the :doc:`Input Class <../libraries/input>` method ``get_post()`` +was checking first in POST data, then in GET data. This method has been modified +so that it checks in GET then in POST, as its name suggests. + +A method has been added, ``post_get()``, which checks in POST then in GET, as +``get_post()`` was doing before. + *********************************************************************** -Step 11: Check the calls to Directory Helper's directory_map() function +Step 12: Update usage of Directory Helper's directory_map() function *********************************************************************** In the resulting array, directories now end with a trailing directory separator (i.e. a slash, usually). ************************************************************* -Step 12: Update usage of Database Forge's drop_table() method +Step 13: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -211,7 +222,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 13: Change usage of Email library with multiple emails +Step 14: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -226,7 +237,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 14: Update your Form_validation language lines +Step 15: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -257,7 +268,7 @@ files and error messages format: later. **************************************************************** -Step 15: Remove usage of (previously) deprecated functionalities +Step 16: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 177f5cb64..fb245d7cd 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -98,7 +98,7 @@ The method returns NULL if there are no items in the POST. $this->input->get() =================== -This method is identical to the post method, only it fetches get data +This method is identical to the POST method, only it fetches GET data :: $this->input->get('some_data', TRUE); @@ -116,18 +116,26 @@ The method returns NULL if there are no items in the GET. $this->input->get(); // returns all GET items without XSS filtering +$this->input->post_get() +======================== + +This method will search through both the POST and GET streams for +data, looking first in POST, and then in GET:: + + $this->input->post_get('some_data', TRUE); + $this->input->get_post() ======================== -This method will search through both the post and get streams for -data, looking first in post, and then in get:: +This method will search through both the POST and GET streams for +data, looking first in GET, and then in POST:: $this->input->get_post('some_data', TRUE); $this->input->cookie() ====================== -This method is identical to the post method, only it fetches cookie data +This method is identical to the POST method, only it fetches cookie data :: $this->input->cookie('some_cookie'); -- cgit v1.2.3-24-g4f1b From e8e56d7be01177b3f6c2be5a3c43d21e4a472558 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 12 Aug 2013 01:36:39 +0200 Subject: Improve changelog entry --- user_guide_src/source/changelog.rst | 2 +- user_guide_src/source/installation/upgrade_300.rst | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ba104bb72..84989189d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -388,7 +388,7 @@ Release Date: Not Released - Changed method ``valid_ip()`` to use PHP's native ``filter_var()`` function. - Changed internal method ``_sanitize_globals()`` to skip enforcing reversal of *register_globals* in PHP 5.4+, where this functionality no longer exists. - Changed methods ``get()``, ``post()``, ``get_post()``, ``cookie()``, ``server()``, ``user_agent()`` to return NULL instead of FALSE when no value is found. - - Changed method ``get_post()`` to check in GET then in POST. Added method ``post_get()`` which checks in POST then in GET, as ``get_post()`` was doing before. + - Added method ``post_get()`` and changed ``get_post()`` to search in GET data first. Both methods' names now properly match their GET/POST data search priorities. - Changed method ``_fetch_from_array()`` to parse array notation in field name. - :doc:`Common functions ` changes include: diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 21bdd188f..e8fdd0b15 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -186,10 +186,10 @@ Step 11: Update usage of Input Class's get_post() method ******************************************************** Previously, the :doc:`Input Class <../libraries/input>` method ``get_post()`` -was checking first in POST data, then in GET data. This method has been modified -so that it checks in GET then in POST, as its name suggests. +was searching first in POST data, then in GET data. This method has been +modified so that it searches in GET then in POST, as its name suggests. -A method has been added, ``post_get()``, which checks in POST then in GET, as +A method has been added, ``post_get()``, which searches in POST then in GET, as ``get_post()`` was doing before. *********************************************************************** -- cgit v1.2.3-24-g4f1b From ce3053792fd2af643563906d1be88be88f9c3a6f Mon Sep 17 00:00:00 2001 From: Zaki Akhmad Date: Wed, 14 Aug 2013 15:38:51 +0700 Subject: add '$' at news_section.rst file --- user_guide_src/source/tutorial/news_section.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst index c21f4e6de..ad9ed41d3 100644 --- a/user_guide_src/source/tutorial/news_section.rst +++ b/user_guide_src/source/tutorial/news_section.rst @@ -127,7 +127,7 @@ the views. public function index() { - data['news'] = $this->news_model->get_news(); + $data['news'] = $this->news_model->get_news(); $data['title'] = 'News archive'; $this->load->view('templates/header', $data); -- cgit v1.2.3-24-g4f1b From 335fed9c5c70b94264db7daf02edb7cf08cceba0 Mon Sep 17 00:00:00 2001 From: msegers Date: Wed, 14 Aug 2013 10:46:25 +0200 Subject: Detect Windows Phones Added 1 line to the platforms 'windows phone' => 'Windows Phone', This will return the OS of the "new" generation of windows phones instead of "Unknown windows Os" --- application/config/user_agents.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/config/user_agents.php b/application/config/user_agents.php index 0c8605820..bb135164f 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -50,6 +50,7 @@ $platforms = array( 'win98' => 'Windows 98', 'windows 95' => 'Windows 95', 'win95' => 'Windows 95', + 'windows phone' => 'Windows Phone', 'windows' => 'Unknown Windows OS', 'android' => 'Android', 'blackberry' => 'BlackBerry', @@ -221,4 +222,4 @@ $robots = array( ); /* End of file user_agents.php */ -/* Location: ./application/config/user_agents.php */ \ No newline at end of file +/* Location: ./application/config/user_agents.php */ -- cgit v1.2.3-24-g4f1b From 8d70c0af8f395cfa6354e4e586b156f65954fca3 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 17 Aug 2013 07:31:29 +0200 Subject: Fix $replace parameter handling in get_config() Code was reached only on first function call, then short-circuited because of the reference cache. --- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 58 ++++++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index a026920a4..c962fda20 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -88,7 +88,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * The subclass prefix allows CI to know if a core class is * being extended via a library in the local application * "libraries" folder. Since CI allows config items to be - * overriden via data set in the main index. php file, + * overriden via data set in the main index.php file, * before proceeding we need to know if a subclass_prefix * override exists. If so, we will set this value now, * before any classes are loaded diff --git a/system/core/Common.php b/system/core/Common.php index 21e1df9c6..a90a3ab70 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -230,39 +230,43 @@ if ( ! function_exists('get_config')) if (isset($_config)) { - return $_config[0]; + $config =& $_config[0]; } - - $file_path = APPPATH.'config/config.php'; - $found = FALSE; - if (file_exists($file_path)) + else { - $found = TRUE; - require($file_path); - } + $file_path = APPPATH.'config/config.php'; + $found = FALSE; + if (file_exists($file_path)) + { + $found = TRUE; + require($file_path); + } - // Is the config file in the environment folder? - if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) - { - require($file_path); - } - elseif ( ! $found) - { - set_status_header(503); - echo 'The configuration file does not exist.'; - exit(EXIT_CONFIG); - } + // Is the config file in the environment folder? + if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + { + require($file_path); + } + elseif ( ! $found) + { + set_status_header(503); + echo 'The configuration file does not exist.'; + exit(EXIT_CONFIG); + } - // Does the $config array exist in the file? - if ( ! isset($config) OR ! is_array($config)) - { - set_status_header(503); - echo 'Your config file does not appear to be formatted correctly.'; - exit(EXIT_CONFIG); + // Does the $config array exist in the file? + if ( ! isset($config) OR ! is_array($config)) + { + set_status_header(503); + echo 'Your config file does not appear to be formatted correctly.'; + exit(EXIT_CONFIG); + } + + $_config[0] =& $config; } // Are any values being dynamically replaced? - if (count($replace) > 0) + if (!empty($replace)) { foreach ($replace as $key => $val) { @@ -273,7 +277,7 @@ if ( ! function_exists('get_config')) } } - return $_config[0] =& $config; + return $config; } } -- cgit v1.2.3-24-g4f1b From 2f7810a36b488a1b3d3dfd3ba8eb6bfbbe91f9ff Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 19 Aug 2013 04:46:26 +0200 Subject: Ensure get_config() optional argument is an array, remove useless test --- system/core/Common.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index a90a3ab70..50bcd9278 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -224,7 +224,7 @@ if ( ! function_exists('get_config')) * @param array * @return array */ - function &get_config($replace = array()) + function &get_config(array $replace = array()) { static $_config; @@ -266,14 +266,11 @@ if ( ! function_exists('get_config')) } // Are any values being dynamically replaced? - if (!empty($replace)) + foreach ($replace as $key => $val) { - foreach ($replace as $key => $val) + if (isset($config[$key])) { - if (isset($config[$key])) - { - $config[$key] = $val; - } + $config[$key] = $val; } } -- cgit v1.2.3-24-g4f1b From 67e5ca678a43a00aecd46cb6d02cfbf9c36d666b Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 19 Aug 2013 04:52:00 +0200 Subject: Allow items to be set even if they were not present yet --- system/core/Common.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 50bcd9278..6b3d73100 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -265,13 +265,10 @@ if ( ! function_exists('get_config')) $_config[0] =& $config; } - // Are any values being dynamically replaced? + // Are any values being dynamically added or replaced? foreach ($replace as $key => $val) { - if (isset($config[$key])) - { - $config[$key] = $val; - } + $config[$key] = $val; } return $config; -- cgit v1.2.3-24-g4f1b From 05d043b38896570004fadbed8495fc99c6ef3da6 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 19 Aug 2013 04:55:34 +0200 Subject: Adjustments in static reference handling --- system/core/Common.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 6b3d73100..cf9cd846d 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -228,11 +228,7 @@ if ( ! function_exists('get_config')) { static $_config; - if (isset($_config)) - { - $config =& $_config[0]; - } - else + if (empty($_config)) { $file_path = APPPATH.'config/config.php'; $found = FALSE; @@ -262,16 +258,17 @@ if ( ! function_exists('get_config')) exit(EXIT_CONFIG); } + // references cannot be directly assigned to static variables, so we use an array $_config[0] =& $config; } // Are any values being dynamically added or replaced? foreach ($replace as $key => $val) { - $config[$key] = $val; + $_config[0][$key] = $val; } - return $config; + return $_config[0]; } } @@ -439,7 +436,7 @@ if ( ! function_exists('log_message')) { static $_log; - if ($_log === NULL) + if (empty($_log)) { // references cannot be directly assigned to static variables, so we use an array $_log[0] =& load_class('Log', 'core'); -- cgit v1.2.3-24-g4f1b From 49890a95da8438910b6f6b8da43ec5e5cd10f53c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Aug 2013 19:56:18 +0300 Subject: Kill the damn kitten --- application/config/user_agents.php | 2 +- system/core/Common.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/config/user_agents.php b/application/config/user_agents.php index bb135164f..5887a15be 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -222,4 +222,4 @@ $robots = array( ); /* End of file user_agents.php */ -/* Location: ./application/config/user_agents.php */ +/* Location: ./application/config/user_agents.php */ \ No newline at end of file diff --git a/system/core/Common.php b/system/core/Common.php index cf9cd846d..7f296b133 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -224,7 +224,7 @@ if ( ! function_exists('get_config')) * @param array * @return array */ - function &get_config(array $replace = array()) + function &get_config(Array $replace = array()) { static $_config; @@ -436,7 +436,7 @@ if ( ! function_exists('log_message')) { static $_log; - if (empty($_log)) + if ($_log === NULL) { // references cannot be directly assigned to static variables, so we use an array $_log[0] =& load_class('Log', 'core'); -- cgit v1.2.3-24-g4f1b From a1553a9a49b8d355de7892204759651aa3532dad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Aug 2013 20:12:19 +0300 Subject: Lower precision for the CI_Benchmark::elapsed_time() test - there's no way to reliably test it --- tests/codeigniter/core/Benchmark_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php index a239ba51d..aff736a40 100644 --- a/tests/codeigniter/core/Benchmark_test.php +++ b/tests/codeigniter/core/Benchmark_test.php @@ -30,7 +30,7 @@ class Benchmark_test extends CI_TestCase { sleep(1); $this->benchmark->mark('code_end'); - $this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1)); + $this->assertEquals('1', $this->benchmark->elapsed_time('code_start', 'code_end', 0)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3b96a17ba85d34186dfc9aa32b761eb4be642d91 Mon Sep 17 00:00:00 2001 From: James Swift Date: Fri, 23 Aug 2013 23:13:07 +0100 Subject: Made "Release Information" more readable. The first time I read that paragraph it made no sense. The addition of a hyphen makes it easier to read at a glance. --- readme.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.rst b/readme.rst index d76816237..5857558c2 100644 --- a/readme.rst +++ b/readme.rst @@ -14,7 +14,7 @@ for a given task. Release Information ******************* -This repo contains in development code for future releases. To download the +This repo contains in-development code for future releases. To download the latest stable release please visit the `CodeIgniter Downloads `_ page. -- cgit v1.2.3-24-g4f1b From cf524a6958662d8848fdd7597e6adf90c97533d2 Mon Sep 17 00:00:00 2001 From: Sergey Noskov Date: Sun, 25 Aug 2013 13:52:48 +0300 Subject: Better transliteration for Russian and Ukrainian languages --- application/config/foreign_chars.php | 60 ++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php index b0c32cf96..ab98224f7 100644 --- a/application/config/foreign_chars.php +++ b/application/config/foreign_chars.php @@ -50,16 +50,16 @@ $foreign_characters = array( '/ะด/' => 'd', '/ร|ฤŽ|ฤ|ฮ”/' => 'Dj', '/รฐ|ฤ|ฤ‘|ฮด/' => 'dj', - '/รˆ|ร‰|รŠ|ร‹|ฤ’|ฤ”|ฤ–|ฤ˜|ฤš|ฮ•|ฮˆ|แบผ|แบบ|แบธ|แป€|แบพ|แป„|แป‚|แป†|ะ•|ะ|ะญ/' => 'E', - '/รจ|รฉ|รช|รซ|ฤ“|ฤ•|ฤ—|ฤ™|ฤ›|ฮญ|ฮต|แบฝ|แบป|แบน|แป|แบฟ|แป…|แปƒ|แป‡|ะต|ั‘|ั/' => 'e', + '/รˆ|ร‰|รŠ|ร‹|ฤ’|ฤ”|ฤ–|ฤ˜|ฤš|ฮ•|ฮˆ|แบผ|แบบ|แบธ|แป€|แบพ|แป„|แป‚|แป†|ะ•|ะญ/' => 'E', + '/รจ|รฉ|รช|รซ|ฤ“|ฤ•|ฤ—|ฤ™|ฤ›|ฮญ|ฮต|แบฝ|แบป|แบน|แป|แบฟ|แป…|แปƒ|แป‡|ะต|ั/' => 'e', '/ะค/' => 'F', '/ั„/' => 'f', - '/ฤœ|ฤž|ฤ |ฤข|ฮ“|ะ“/' => 'G', - '/ฤ|ฤŸ|ฤก|ฤฃ|ฮณ|ะณ/' => 'g', + '/ฤœ|ฤž|ฤ |ฤข|ฮ“|ะ“|า/' => 'G', + '/ฤ|ฤŸ|ฤก|ฤฃ|ฮณ|ะณ|า‘/' => 'g', '/ฤค|ฤฆ/' => 'H', '/ฤฅ|ฤง/' => 'h', - '/รŒ|ร|รŽ|ร|ฤจ|ฤช|ฤฌ|ว|ฤฎ|ฤฐ|ฮ—|ฮ‰|ฮŠ|ฮ™|ฮช|แปˆ|แปŠ|ะ˜|ะ™/' => 'I', - '/รฌ|รญ|รฎ|รฏ|ฤฉ|ฤซ|ฤญ|ว|ฤฏ|ฤฑ|ฮท|ฮฎ|ฮฏ|ฮน|ฯŠ|แป‰|แป‹|ะธ|ะน/' => 'i', + '/รŒ|ร|รŽ|ร|ฤจ|ฤช|ฤฌ|ว|ฤฎ|ฤฐ|ฮ—|ฮ‰|ฮŠ|ฮ™|ฮช|แปˆ|แปŠ|ะ˜|ะซ/' => 'I', + '/รฌ|รญ|รฎ|รฏ|ฤฉ|ฤซ|ฤญ|ว|ฤฏ|ฤฑ|ฮท|ฮฎ|ฮฏ|ฮน|ฯŠ|แป‰|แป‹|ะธ|ั‹|ั—/' => 'i', '/ฤด/' => 'J', '/ฤต/' => 'j', '/ฤถ|ฮš|ะš/' => 'K', @@ -80,10 +80,10 @@ $foreign_characters = array( '/ล›|ล|ลŸ|ศ™|ลก|ลฟ|ฯƒ|ฯ‚|ั/' => 's', '/ศš|ลข|ลค|ลฆ|ฯ„|ะข/' => 'T', '/ศ›|ลฃ|ลฅ|ลง|ั‚/' => 't', - '/ร™|รš|ร›|ลจ|ลช|ลฌ|ลฎ|ลฐ|ลฒ|ฦฏ|ว“|ว•|ว—|ว™|ว›|ลจ|แปฆ|แปค|แปช|แปจ|แปฎ|แปฌ|แปฐ|ะฃ|ะช/' => 'U', - '/รน|รบ|รป|ลฉ|ลซ|ลญ|ลฏ|ลฑ|ลณ|ฦฐ|ว”|ว–|ว˜|วš|วœ|ฯ…|ฯ|ฯ‹|แปง|แปฅ|แปซ|แปฉ|แปฏ|แปญ|แปฑ|ัƒ|ัŠ/' => 'u', - '/ร|ลธ|ลถ|ฮฅ|ฮŽ|ฮซ|แปฒ|แปธ|แปถ|แปด/' => 'Y', - '/รฝ|รฟ|ลท|แปณ|แปน|แปท|แปต/' => 'y', + '/ร™|รš|ร›|ลจ|ลช|ลฌ|ลฎ|ลฐ|ลฒ|ฦฏ|ว“|ว•|ว—|ว™|ว›|ลจ|แปฆ|แปค|แปช|แปจ|แปฎ|แปฌ|แปฐ|ะฃ/' => 'U', + '/รน|รบ|รป|ลฉ|ลซ|ลญ|ลฏ|ลฑ|ลณ|ฦฐ|ว”|ว–|ว˜|วš|วœ|ฯ…|ฯ|ฯ‹|แปง|แปฅ|แปซ|แปฉ|แปฏ|แปญ|แปฑ|ัƒ/' => 'u', + '/ร|ลธ|ลถ|ฮฅ|ฮŽ|ฮซ|แปฒ|แปธ|แปถ|แปด|ะ™/' => 'Y', + '/รฝ|รฟ|ลท|แปณ|แปน|แปท|แปต|ะน/' => 'y', '/ะ’/' => 'V', '/ะฒ/' => 'v', '/ลด/' => 'W', @@ -91,7 +91,7 @@ $foreign_characters = array( '/ลน|ลป|ลฝ|ฮ–|ะ—/' => 'Z', '/ลบ|ลผ|ลพ|ฮถ|ะท/' => 'z', '/ร†|วผ/' => 'AE', - '/รŸ/'=> 'ss', + '/รŸ/' => 'ss', '/ฤฒ/' => 'IJ', '/ฤณ/' => 'ij', '/ล’/' => 'OE', @@ -101,22 +101,28 @@ $foreign_characters = array( '/ฮฒ/' => 'v', '/ฮผ/' => 'm', '/ฯˆ/' => 'ps', - '/ะ–/'=>'Zh', - '/ะถ/'=>'zh', - '/ะฅ/'=>'Kh', - '/ั…/'=>'kh', - '/ะฆ/'=>'Tc', - '/ั†/'=>'tc', - '/ะง/'=>'Ch', - '/ั‡/'=>'ch', - '/ะจ/'=>'Sh', - '/ัˆ/'=>'sh', - '/ะฉ/'=>'Shch', - '/ั‰/'=>'shch', - '/ะฎ/'=>'Iu', - '/ัŽ/'=>'iu', - '/ะฏ/'=>'Ia', - '/ั/'=>'ia' + '/ะ/' => 'Yo', + '/ั‘/' => 'yo', + '/ะ„/' => 'Ye', + '/ั”/' => 'ye', + '/ะ‡/' => 'Yi', + '/ะ–/' => 'Zh', + '/ะถ/' => 'zh', + '/ะฅ/' => 'Kh', + '/ั…/' => 'kh', + '/ะฆ/' => 'Ts', + '/ั†/' => 'ts', + '/ะง/' => 'Ch', + '/ั‡/' => 'ch', + '/ะจ/' => 'Sh', + '/ัˆ/' => 'sh', + '/ะฉ/' => 'Shch', + '/ั‰/' => 'shch', + '/ะช|ัŠ|ะฌ|ัŒ/' => '', + '/ะฎ/' => 'Yu', + '/ัŽ/' => 'yu', + '/ะฏ/' => 'Ya', + '/ั/' => 'ya' ); /* End of file foreign_chars.php */ -- cgit v1.2.3-24-g4f1b From ac23e210c71807858e98ecdb62185adc5cb75111 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Aug 2013 13:07:05 +0300 Subject: [ci skip] Fix a documentation error --- user_guide_src/source/libraries/form_validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 8b35fdc75..032cff23b 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -431,7 +431,7 @@ Here's how your controller should now look:: } } - protected function username_check($str) + public function username_check($str) { if ($str == 'test') { -- cgit v1.2.3-24-g4f1b From 967eea59ab1abf5c1237ec802c2f85c19cfb7e11 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 2 Sep 2013 02:15:45 +0200 Subject: Add changelog entry for #2609 --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 84989189d..4f30a9aa7 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -608,6 +608,7 @@ Bug fixes for 3.0 - Fixed a bug (#2585) - :doc:`Query Builder ` methods ``min()``, ``max()``, ``avg()``, ``sum()`` didn't escape field names. - Fixed an edge case (#2583) in the :doc:`Email Library ` where `Suhosin ` blocked messages sent via ``mail()`` due to trailing newspaces in headers. - Fixed a bug (#2590) - :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. +- Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From e6c4d5bcd1a65cfa2397457a6de771dc45800bfb Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 8 Sep 2013 13:54:57 +0200 Subject: Code cleanup in db->order_by() --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index e6a108209..b7b568b10 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1152,7 +1152,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Do we have a seed value? $orderby = ctype_digit((string) $orderby) - ? $orderby = sprintf($this->_random_keyword[1], $orderby) + ? sprintf($this->_random_keyword[1], $orderby) : $this->_random_keyword[0]; } elseif (empty($orderby)) -- cgit v1.2.3-24-g4f1b From 9f8e29913996168971cb690fd319bdd0eaa6c29a Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 8 Sep 2013 14:05:04 +0200 Subject: Adjust a few phpdoc in query builder code --- system/database/DB_query_builder.php | 2 +- system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index e6a108209..fb314e559 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1138,7 +1138,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * ORDER BY * * @param string $orderby - * @param string $direction ASC or DESC + * @param string $direction ASC, DESC or RANDOM * @param bool $escape * @return CI_DB_query_builder */ diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php index d0cdde2e2..83daee9f6 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php @@ -166,7 +166,7 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver { * ORDER BY * * @param string $orderby - * @param string $direction ASC or DESC + * @param string $direction ASC, DESC or RANDOM * @param bool $escape * @return object */ diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index ac7345ad6..f24db46b4 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -512,7 +512,7 @@ class CI_DB_postgre_driver extends CI_DB { * ORDER BY * * @param string $orderby - * @param string $direction ASC or DESC + * @param string $direction ASC, DESC or RANDOM * @param bool $escape * @return object */ -- cgit v1.2.3-24-g4f1b From 67e643a475a37c53267d0f43b2c2d67efd907014 Mon Sep 17 00:00:00 2001 From: judge Date: Tue, 10 Sep 2013 13:59:46 +0200 Subject: fixed error in finding closing tag --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Output.php b/system/core/Output.php index 06d7a866b..7bfb8cebe 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -841,7 +841,7 @@ class CI_Output { $output = substr_replace($output, '', 0, $pos); // Remove closing tag and save it for later - $pos = strpos($output, ' Date: Tue, 10 Sep 2013 14:54:47 +0200 Subject: Removed unnecessary parameter --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Output.php b/system/core/Output.php index 7bfb8cebe..e323385ba 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -842,7 +842,7 @@ class CI_Output { // Remove closing tag and save it for later $pos = strrpos($output, ' Date: Tue, 10 Sep 2013 16:13:27 +0200 Subject: Improved detecting whether the pointer is in a string or not --- system/core/Output.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index e323385ba..5272ba662 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -849,6 +849,26 @@ class CI_Output { // Remove CSS comments $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output); + // Remove Javascript inline comments + if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) { + $lines = preg_split('/((\r?\n)|(\n?\r))/',$output); + foreach ($lines as &$line){ + $in_string = $in_dstring = FALSE; + $len = strlen($line); + for ($i=0; $i<$len; $i++){ + if ( !$in_string && !$in_dstring && substr($line,$i,2)==='//'){ + $line = substr($line,0,$i); + break; + } + if ( $line[$i]==='"' ) + $in_dstring = ! $in_dstring; + if ( $line[$i]==="'" ) + $in_string = ! $in_string; + } + } + $output = implode("\n",$lines); + } + // Remove spaces around curly brackets, colons, // semi-colons, parenthesis, commas $chunks = preg_split('/([\'|"]).+(?![^\\\]\\1)\\1/iU', $output, -1, PREG_SPLIT_OFFSET_CAPTURE); @@ -899,11 +919,11 @@ class CI_Output { } } - if ($value === "'") + if ($value === "'" && ! $in_dstring) { $in_string = ! $in_string; } - elseif ($value === '"') + elseif ($value === '"' && ! $in_string) { $in_dstring = ! $in_dstring; } -- cgit v1.2.3-24-g4f1b From f57ecc141e072473c73630af29ffe06be25e850c Mon Sep 17 00:00:00 2001 From: judge Date: Tue, 10 Sep 2013 16:18:14 +0200 Subject: Remove Javascript inline comments + improved detecting whether the pointer is in a string or not --- system/core/Output.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 5272ba662..ec82ae7e8 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -856,14 +856,14 @@ class CI_Output { $in_string = $in_dstring = FALSE; $len = strlen($line); for ($i=0; $i<$len; $i++){ - if ( !$in_string && !$in_dstring && substr($line,$i,2)==='//'){ + if ( ! $in_string && ! $in_dstring && substr($line,$i,2) === '//'){ $line = substr($line,0,$i); break; } - if ( $line[$i]==='"' ) - $in_dstring = ! $in_dstring; - if ( $line[$i]==="'" ) + if ( $line[$i]==="'" && ! $in_dstring ) $in_string = ! $in_string; + else if ( $line[$i]==='"' && ! $in_string ) + $in_dstring = ! $in_dstring; } } $output = implode("\n",$lines); -- cgit v1.2.3-24-g4f1b From c7df348233227ecf490ef26795022af6cd26807c Mon Sep 17 00:00:00 2001 From: judge Date: Tue, 10 Sep 2013 16:24:07 +0200 Subject: Fixed coding style --- system/core/Output.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index ec82ae7e8..355a139d5 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -850,23 +850,27 @@ class CI_Output { $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output); // Remove Javascript inline comments - if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) { - $lines = preg_split('/((\r?\n)|(\n?\r))/',$output); - foreach ($lines as &$line){ + if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) + { + $lines = preg_split('/((\r?\n)|(\n?\r))/', $output); + foreach ($lines as &$line) + { $in_string = $in_dstring = FALSE; $len = strlen($line); - for ($i=0; $i<$len; $i++){ - if ( ! $in_string && ! $in_dstring && substr($line,$i,2) === '//'){ - $line = substr($line,0,$i); + for ($i=0; $i<$len; $i++) + { + if ( ! $in_string && ! $in_dstring && substr($line, $i, 2) === '//') + { + $line = substr($line, 0, $i); break; } - if ( $line[$i]==="'" && ! $in_dstring ) + if ($line[$i] === "'" && ! $in_dstring) $in_string = ! $in_string; - else if ( $line[$i]==='"' && ! $in_string ) + elseif ($line[$i] === '"' && ! $in_string) $in_dstring = ! $in_dstring; } } - $output = implode("\n",$lines); + $output = implode("\n", $lines); } // Remove spaces around curly brackets, colons, -- cgit v1.2.3-24-g4f1b From 4013be3d0953612ce081802bb6cc331338d8f58a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 10 Sep 2013 19:31:04 +0300 Subject: Add support for UPDATE ... RETURNING statements in PostgreSQL An improved version of PR #2629. Also removes REPLACE from the regular expression, as it is not supported by PostgreSQL. --- system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 2 +- user_guide_src/source/changelog.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php index 83daee9f6..285fca514 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php @@ -137,7 +137,7 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index f24db46b4..010518ed3 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -318,7 +318,7 @@ class CI_DB_postgre_driver extends CI_DB { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4f30a9aa7..3e36d88f5 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -600,7 +600,7 @@ Bug fixes for 3.0 - Fixed a bug (#2388) - :doc:`Email Library ` used to ignore attachment errors, resulting in broken emails being sent. - Fixed a bug (#2498) - :doc:`Form Validation Library ` rule **valid_base64** only checked characters instead of actual validity. - Fixed a bug (#2425) - OCI8 :doc:`database ` driver's method ``stored_procedure()`` didn't log an error unless **db_debug** was set to TRUE. -- Fixed a bug (#2490) - :doc:`Database Class ` method ``query()`` returning boolean instead of a result object for PostgreSQL-specific *INSERT INTO ... RETURNING* statements. +- Fixed a bug (#2490) - :doc:`Database Class ` method ``query()`` returning boolean instead of a result object when the PostgreSQL-specific *RETURNING* clause is used. - Fixed a bug (#249) - :doc:`Cache Library ` didn't properly handle Memcache(d) configurations with missing options. - Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. - Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exists. -- cgit v1.2.3-24-g4f1b From 21fe9daf1cdc86cbd8800515166e19b2f8879b71 Mon Sep 17 00:00:00 2001 From: Kaiwang Chen Date: Wed, 11 Sep 2013 13:09:41 +0800 Subject: Simulate a complete custom exception handler by redirecting uncaught events. --- index.php | 12 ++++++++++++ system/core/CodeIgniter.php | 1 + system/core/Common.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/index.php b/index.php index 3040ef080..a38ea991c 100755 --- a/index.php +++ b/index.php @@ -195,6 +195,18 @@ switch (ENVIRONMENT) exit(3); // EXIT_* constants not yet defined; 3 is EXIT_CONFIG. } +/* + *--------------------------------------------------------------- + * WORKING DIRECTORY FOR SHUTDOWN HANDLER + *--------------------------------------------------------------- + * + * CI assumes the directory containing index.php, while shutdown + * handlers execute in process's initial working directory. To make + * logging work, we need to change directory in the shutdown handler. + * + */ + define('CIPATH', getcwd()); + /* * ------------------------------------------------------------------- * Now that we know the path, set the main path constants diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index c962fda20..67c94cfd1 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -73,6 +73,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * ------------------------------------------------------ */ set_error_handler('_exception_handler'); + register_shutdown_function('_shutdown_handler'); if ( ! is_php('5.4')) { diff --git a/system/core/Common.php b/system/core/Common.php index 7f296b133..0353a9d10 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -577,6 +577,35 @@ if ( ! function_exists('_exception_handler')) } } +// ------------------------------------------------------------------------ + +if ( ! function_exists('_shutdown_handler')) +{ + /** + * Shutdown Handler + * + * This is the shutdown handler that is declared at the top + * of CodeIgniter.php. The main reason we use this is to simulate + * a complete custom exception handler. + * + * E_STRICT is purposivly neglected because such events may have + * been caught. Duplication or none? None is preferred for now. + * + * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a + * @return void + */ + function _shutdown_handler() + { + $last_error = function_exists('error_get_last') ? error_get_last() : NULL; + if (isset($last_error) && + ($last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) + { + chdir(CIPATH); + _exception_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']); + } + } +} + // -------------------------------------------------------------------- if ( ! function_exists('remove_invisible_characters')) -- cgit v1.2.3-24-g4f1b From 2d54a3a90164ede4fdaafc7f81e6bba6045a8727 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 11 Sep 2013 14:59:10 +0300 Subject: Really fix #2490, rel: #2629 --- system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php index 285fca514..fda3f238b 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php @@ -137,7 +137,7 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', str_replace(array("\r\n", "\r", "\n"), ' ', $sql)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 010518ed3..dbf7c6b95 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -318,7 +318,7 @@ class CI_DB_postgre_driver extends CI_DB { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', str_replace(array("\r\n", "\r", "\n"), ' ', $sql)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5f0ee055ddf0624017bfcd1748445d8854c0b5ea Mon Sep 17 00:00:00 2001 From: Kaiwang Chen Date: Thu, 12 Sep 2013 11:54:44 +0800 Subject: Remove unnecessary chdir() in the shutdown handler. --- index.php | 12 ------------ system/core/Common.php | 1 - 2 files changed, 13 deletions(-) diff --git a/index.php b/index.php index a38ea991c..3040ef080 100755 --- a/index.php +++ b/index.php @@ -195,18 +195,6 @@ switch (ENVIRONMENT) exit(3); // EXIT_* constants not yet defined; 3 is EXIT_CONFIG. } -/* - *--------------------------------------------------------------- - * WORKING DIRECTORY FOR SHUTDOWN HANDLER - *--------------------------------------------------------------- - * - * CI assumes the directory containing index.php, while shutdown - * handlers execute in process's initial working directory. To make - * logging work, we need to change directory in the shutdown handler. - * - */ - define('CIPATH', getcwd()); - /* * ------------------------------------------------------------------- * Now that we know the path, set the main path constants diff --git a/system/core/Common.php b/system/core/Common.php index 0353a9d10..edfad99c5 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -600,7 +600,6 @@ if ( ! function_exists('_shutdown_handler')) if (isset($last_error) && ($last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) { - chdir(CIPATH); _exception_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']); } } -- cgit v1.2.3-24-g4f1b From 488ef2119e75ce6c299a193aed035218256eebd3 Mon Sep 17 00:00:00 2001 From: Kaiwang Chen Date: Thu, 12 Sep 2013 11:55:45 +0800 Subject: Add changelog entry for #2633. --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 3e36d88f5..a681cf3cf 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -436,6 +436,7 @@ Release Date: Not Released - Added support for HTTP-Only cookies with new config option *cookie_httponly* (default FALSE). - Renamed method ``_call_hook()`` to ``call_hook()`` in the :doc:`Hooks Library `. - ``$config['time_reference']`` now supports all timezone strings supported by PHP. + - Made the exception handler complete by registering a shutdown handler to redirect critical events to it. Bug fixes for 3.0 -- cgit v1.2.3-24-g4f1b From c5768dbab1f026db1bc3aa3908454eaecbc9006c Mon Sep 17 00:00:00 2001 From: judge Date: Thu, 12 Sep 2013 14:43:43 +0200 Subject: Fixed coding style --- system/core/Output.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 355a139d5..7c2a64d24 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -852,24 +852,29 @@ class CI_Output { // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) { - $lines = preg_split('/((\r?\n)|(\n?\r))/', $output); + $lines = preg_split('/\r?\n|\n?\r/', $output); foreach ($lines as &$line) { $in_string = $in_dstring = FALSE; - $len = strlen($line); - for ($i=0; $i<$len; $i++) + for ($i = 0, $len = strlen($line); $i < $len; $i++) { if ( ! $in_string && ! $in_dstring && substr($line, $i, 2) === '//') { $line = substr($line, 0, $i); break; } + if ($line[$i] === "'" && ! $in_dstring) + { $in_string = ! $in_string; + } elseif ($line[$i] === '"' && ! $in_string) + { $in_dstring = ! $in_dstring; + } } } + $output = implode("\n", $lines); } -- cgit v1.2.3-24-g4f1b From 8ce3134e739c688f2a3ade0d8c792d05d7879a78 Mon Sep 17 00:00:00 2001 From: Kaiwang Chen Date: Thu, 12 Sep 2013 22:55:58 +0800 Subject: Make the changelog entry for #2633 more descriptive. --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a681cf3cf..c99afc112 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -436,7 +436,7 @@ Release Date: Not Released - Added support for HTTP-Only cookies with new config option *cookie_httponly* (default FALSE). - Renamed method ``_call_hook()`` to ``call_hook()`` in the :doc:`Hooks Library `. - ``$config['time_reference']`` now supports all timezone strings supported by PHP. - - Made the exception handler complete by registering a shutdown handler to redirect critical events to it. + - Made the exception handler complete by registering a shutdown handler to redirect critical events such as PHP parse errors to it, so that they can be displayed and logged without the help of the standard PHP error handler. Bug fixes for 3.0 -- cgit v1.2.3-24-g4f1b From 9b34448a295cac42273439e7cadb284bd3fe1a4d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 12 Sep 2013 20:13:07 +0300 Subject: [ci skip] Simplify changelog message for PR #2633 --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index c99afc112..69f88a8a8 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -436,7 +436,7 @@ Release Date: Not Released - Added support for HTTP-Only cookies with new config option *cookie_httponly* (default FALSE). - Renamed method ``_call_hook()`` to ``call_hook()`` in the :doc:`Hooks Library `. - ``$config['time_reference']`` now supports all timezone strings supported by PHP. - - Made the exception handler complete by registering a shutdown handler to redirect critical events such as PHP parse errors to it, so that they can be displayed and logged without the help of the standard PHP error handler. + - Fatal PHP errors are now also passed to ``_exception_handler()``, so they can be logged. Bug fixes for 3.0 -- cgit v1.2.3-24-g4f1b From 4005e3c06e362f90dde1dff1564bd91adca52e9f Mon Sep 17 00:00:00 2001 From: Ahmad Anbar Date: Thu, 12 Sep 2013 23:33:28 +0300 Subject: Fixed issue #2638 which prevented loading models in sub-folders by passing an array. --- system/core/Loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 1709c2db1..a218e79fb 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -222,7 +222,7 @@ class CI_Loader { { foreach ($model as $key => $value) { - $this->model(is_int($key) ? $value : $key, $value); + is_int($key) ? $this->model($value, '', $db_conn) : $this->model($key, $value, $db_conn); } return; } @@ -1293,4 +1293,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ \ No newline at end of file +/* Location: ./system/core/Loader.php */ -- cgit v1.2.3-24-g4f1b From ed3fd58f97c496d40357ab931fd2d8cdb821a0a8 Mon Sep 17 00:00:00 2001 From: Ahmad Anbar Date: Fri, 13 Sep 2013 00:23:37 +0300 Subject: Removed new line from the end of the file. --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index a218e79fb..2eef9979c 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1293,4 +1293,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 838c9a96f645aac24daa31285efa1051535c4219 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 14:05:13 +0300 Subject: Drop the unused parameter from log_message() / CI_Log::write_log() --- system/core/Common.php | 4 ++-- system/core/Exceptions.php | 2 +- system/core/Log.php | 2 +- tests/mocks/core/common.php | 2 +- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/general/common_functions.rst | 3 +-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index edfad99c5..cf81e3fb5 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -432,7 +432,7 @@ if ( ! function_exists('log_message')) * @param bool whether the error is a native PHP error * @return void */ - function log_message($level, $message, $php_error = FALSE) + function log_message($level, $message) { static $_log; @@ -442,7 +442,7 @@ if ( ! function_exists('log_message')) $_log[0] =& load_class('Log', 'core'); } - $_log[0]->write_log($level, $message, $php_error); + $_log[0]->write_log($level, $message); } } diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 9c68d06a5..d7e5ed4d9 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -91,7 +91,7 @@ class CI_Exceptions { public function log_exception($severity, $message, $filepath, $line) { $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity; - log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE); + log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line); } // -------------------------------------------------------------------- diff --git a/system/core/Log.php b/system/core/Log.php index e4d72b544..20bc55986 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -143,7 +143,7 @@ class CI_Log { * @param bool whether the error is a native PHP error * @return bool */ - public function write_log($level, $msg, $php_error = FALSE) + public function write_log($level, $msg) { if ($this->_enabled === FALSE) { diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index 0ccfe1ea4..e5dc29c86 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -178,7 +178,7 @@ if ( ! function_exists('is_loaded')) if ( ! function_exists('log_message')) { - function log_message($level, $message, $php_error = FALSE) + function log_message($level, $message) { return TRUE; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 69f88a8a8..3bf2d708f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -399,6 +399,7 @@ Release Date: Not Released - Changed ``_exception_handler()`` to respect php.ini *display_errors* setting. - Added function :php:func:`is_https()` to check if a secure connection is used. - Added function :php:func:`function_usable()` to check if a function exists and is not disabled by `Suhosin `. + - Removed the third (`$php_error`) from function :php:func:`log_message()`. - :doc:`Output Library ` changes include: diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 32e8a8be0..e085ef808 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -96,11 +96,10 @@ please see the :doc:`Error Handling ` documentation. log_message() ============= -.. php:function:: log_message($level, $message, $php_error = FALSE) +.. php:function:: log_message($level, $message) :param string $level: Log level: 'error', 'debug' or 'info' :param string $message: Message to log - :param bool $php_error: Whether we're logging a native PHP error message :returns: void This function is an alias for ``CI_Log::write_log()``. For more info, -- cgit v1.2.3-24-g4f1b From 5932a7354bf46fb0a86794af37da42f715c355bf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 14:45:53 +0300 Subject: Improvements to safe_mode detection (it doesn't exist in PHP 5.4) --- system/core/CodeIgniter.php | 6 ++---- system/core/Common.php | 2 +- system/libraries/Email.php | 3 +-- system/libraries/Upload.php | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 67c94cfd1..c12116236 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -75,10 +75,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); set_error_handler('_exception_handler'); register_shutdown_function('_shutdown_handler'); - if ( ! is_php('5.4')) - { - @ini_set('magic_quotes_runtime', 0); // Kill magic quotes - } + // Kill magic quotes + is_php('5.4') OR @ini_set('magic_quotes_runtime', 0); /* * ------------------------------------------------------ diff --git a/system/core/Common.php b/system/core/Common.php index cf81e3fb5..286deccda 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -82,7 +82,7 @@ if ( ! function_exists('is_really_writable')) function is_really_writable($file) { // If we're on a Unix server with safe_mode off we call is_writable - if (DIRECTORY_SEPARATOR === '/' && (bool) @ini_get('safe_mode') === FALSE) + if (DIRECTORY_SEPARATOR === '/' && (is_php('5.4') OR (bool) @ini_get('safe_mode') === FALSE)) { return is_writable($file); } diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 082629a4c..efdbfd7c1 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -399,9 +399,9 @@ class CI_Email { else { $this->_smtp_auth = ! ($this->smtp_user === '' && $this->smtp_pass === ''); - $this->_safe_mode = (bool) @ini_get('safe_mode'); } + $this->_safe_mode = ( ! is_php('5.4') && (bool) @ini_get('safe_mode')); $this->charset = strtoupper($this->charset); log_message('debug', 'Email Class Initialized'); @@ -451,7 +451,6 @@ class CI_Email { $this->clear(); $this->_smtp_auth = ! ($this->smtp_user === '' && $this->smtp_pass === ''); - $this->_safe_mode = (bool) @ini_get('safe_mode'); return $this; } diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 15eb74bd5..060973847 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1245,7 +1245,7 @@ class CI_Upload { } } - if ( (bool) @ini_get('safe_mode') === FALSE && function_usable('shell_exec')) + if ((bool) @ini_get('safe_mode') === FALSE && function_usable('shell_exec')) { $mime = @shell_exec($cmd); if (strlen($mime) > 0) -- cgit v1.2.3-24-g4f1b From 3c5ec85c6a6303dfed8cefbbb77f5ce7571967bb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 15:01:08 +0300 Subject: Update MySQLi to use the PHP API for transactions, where possible --- system/database/drivers/mysqli/mysqli_driver.php | 27 ++++++++++++++++-------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index ef2cb8a8d..0f3c6fc62 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -241,9 +241,10 @@ class CI_DB_mysqli_driver extends CI_DB { // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE); - $this->simple_query('SET AUTOCOMMIT=0'); - $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK - return TRUE; + $this->conn_id->autocommit(FALSE); + return is_php('5.5') + ? $this->conn_id->begin_transaction() + : $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK } // -------------------------------------------------------------------- @@ -261,9 +262,13 @@ class CI_DB_mysqli_driver extends CI_DB { return TRUE; } - $this->simple_query('COMMIT'); - $this->simple_query('SET AUTOCOMMIT=1'); - return TRUE; + if ($this->conn_id->commit()) + { + $this->conn_id->autocommit(TRUE); + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- @@ -281,9 +286,13 @@ class CI_DB_mysqli_driver extends CI_DB { return TRUE; } - $this->simple_query('ROLLBACK'); - $this->simple_query('SET AUTOCOMMIT=1'); - return TRUE; + if ($this->conn_id->rollback()) + { + $this->conn_id->autocommit(TRUE); + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 3bf2d708f..98036659f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -181,6 +181,7 @@ Release Date: Not Released - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. - Added persistent connections support for PHP >= 5.3. - Added support for ``backup()`` in :doc:`Database Utilities `. + - Changed methods ``trans_being()``, ``trans_commit()`` and ``trans_rollback()`` to use the PHP API instead of sending queries. - Improved support of the PDO driver, including: -- cgit v1.2.3-24-g4f1b From a9346aa754f5488f7535f580dd744477f52d5063 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 16:03:07 +0300 Subject: Fix a PostgreSQL string escaping bug and use pg_escape_literal() when possible --- system/database/drivers/postgre/postgre_driver.php | 8 ++++++-- user_guide_src/source/changelog.rst | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index dbf7c6b95..b72fb873a 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -331,7 +331,7 @@ class CI_DB_postgre_driver extends CI_DB { */ protected function _escape_str($str) { - return pg_escape_string($str); + return pg_escape_string($this->conn_id, $str); } // -------------------------------------------------------------------- @@ -346,7 +346,11 @@ class CI_DB_postgre_driver extends CI_DB { */ public function escape($str) { - if (is_bool($str)) + if (is_php('5.4.4') && (is_string($str) OR (is_object($str) && method_exists($str, '__toString')))) + { + return pg_escape_literal($this->conn_id, $str); + } + elseif (is_bool($str)) { return ($str) ? 'TRUE' : 'FALSE'; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 98036659f..357ecc12e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -199,6 +199,7 @@ Release Date: Not Released - Removed ``limit()`` and ``order_by()`` support for *UPDATE* and *DELETE* queries as PostgreSQL does not support those features. - Added a work-around for dead persistent connections to be re-created after a database restart. - Changed ``db_connect()`` to include the (new) **schema** value into Postgre's **search_path** session variable. + - ``pg_escape_literal()`` is now used for escaping strings, if available. - Improved support of the CUBRID driver, including: @@ -612,6 +613,7 @@ Bug fixes for 3.0 - Fixed an edge case (#2583) in the :doc:`Email Library ` where `Suhosin ` blocked messages sent via ``mail()`` due to trailing newspaces in headers. - Fixed a bug (#2590) - :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. - Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. +- Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From ae50f5537718431af05037c857d1c303e25a76f6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 16:17:41 +0300 Subject: Fix #2639 --- system/helpers/form_helper.php | 79 +++++++++---------------------------- user_guide_src/source/changelog.rst | 3 +- 2 files changed, 21 insertions(+), 61 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 146c0f588..424bb7e64 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -726,37 +726,18 @@ if ( ! function_exists('set_checkbox')) */ function set_checkbox($field = '', $value = '', $default = FALSE) { - $OBJ =& _get_validation_object(); + $CI =& get_instance(); - if ($OBJ === FALSE) + if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field)) { - if ( ! isset($_POST[$field])) - { - if (count($_POST) === 0 && $default === TRUE) - { - return ' checked="checked"'; - } - return ''; - } - - $field = $_POST[$field]; - - if (is_array($field)) - { - if ( ! in_array($value, $field)) - { - return ''; - } - } - elseif (($field == '' OR $value == '') OR $field !== $value) - { - return ''; - } - - return ' checked="checked"'; + return $CI->form_validation->set_checkbox($field, $value, $default); + } + elseif (($input = $CI->input->post($field, FALSE)) === NULL) + { + return ($default === TRUE) ? ' checked="checked"' : ''; } - return $OBJ->set_checkbox($field, $value, $default); + return ($input === $value) ? ' checked="checked"' : ''; } } @@ -770,47 +751,25 @@ if ( ! function_exists('set_radio')) * Let's you set the selected value of a radio field via info in the POST array. * If Form Validation is active it retrieves the info from the validation class * - * @param string - * @param string - * @param bool + * @param string $field + * @param string $value + * @param bool $default * @return string */ function set_radio($field = '', $value = '', $default = FALSE) { - $OBJ =& _get_validation_object(); + $CI =& get_instance(); - if ($OBJ === FALSE) + if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field)) { - if ( ! isset($_POST[$field])) - { - if (count($_POST) === 0 && $default === TRUE) - { - return ' checked="checked"'; - } - return ''; - } - - $field = $_POST[$field]; - - if (is_array($field)) - { - if ( ! in_array($value, $field)) - { - return ''; - } - } - else - { - if (($field == '' OR $value == '') OR $field !== $value) - { - return ''; - } - } - - return ' checked="checked"'; + return $CI->form_validation->set_radio($field, $value, $default); + } + elseif (($input = $CI->input->post($field, FALSE)) === NULL) + { + return ($default === TRUE) ? ' checked="checked"' : ''; } - return $OBJ->set_radio($field, $value, $default); + return ($input === $value) ? ' checked="checked"' : ''; } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 357ecc12e..f6207750e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -468,7 +468,7 @@ Bug fixes for 3.0 - Fixed a possible bug in ``CI_Input::is_ajax_request()`` where some clients might not send the X-Requested-With HTTP header value exactly as 'XmlHttpRequest'. - Fixed a bug (#1039) - MySQL's _backup() method failed due to a table name not being escaped. - Fixed a bug (#1070) - CI_DB_driver::initialize() didn't set a character set if a database is not selected. -- Fixed a bug (#177) - CI_Form_validation::set_value() didn't set the default value if POST data is NULL. +- Fixed a bug (#177) - ``CI_Form_validation::set_value()`` didn't set the default value if POST data is NULL. - Fixed a bug (#68, #414) - Oracle's escape_str() didn't properly escape LIKE wild characters. - Fixed a bug (#81) - ODBC's list_fields() and field_data() methods skipped the first column due to odbc_field_*() functions' index starting at 1 instead of 0. - Fixed a bug (#129) - ODBC's num_rows() returned -1 in some cases, due to not all subdrivers supporting the odbc_num_rows() function. @@ -614,6 +614,7 @@ Bug fixes for 3.0 - Fixed a bug (#2590) - :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. - Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. - Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. +- Fixed a bug (#2639) - :doc:`Form Helper ` functions :php:func:`set_radio()` and :php:func:`set_checkbox()` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library `. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From 67f6a5e0321cc5d71dc2adc8dc72c71e96408dac Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 16:21:31 +0300 Subject: Fix array notation fields for set_select() as well --- system/helpers/form_helper.php | 35 ++++++++--------------------------- user_guide_src/source/changelog.rst | 3 +-- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 424bb7e64..20379efa7 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -675,37 +675,18 @@ if ( ! function_exists('set_select')) */ function set_select($field = '', $value = '', $default = FALSE) { - $OBJ =& _get_validation_object(); + $CI =& get_instance(); - if ($OBJ === FALSE) + if (isset($CI->form_validation) && is_object($CI->form_validation) && $CI->form_validation->has_rule($field)) { - if ( ! isset($_POST[$field])) - { - if (count($_POST) === 0 && $default === TRUE) - { - return ' selected="selected"'; - } - return ''; - } - - $field = $_POST[$field]; - - if (is_array($field)) - { - if ( ! in_array($value, $field)) - { - return ''; - } - } - elseif (($field == '' OR $value == '') OR $field !== $value) - { - return ''; - } - - return ' selected="selected"'; + return $CI->form_validation->set_select($field, $value, $default); + } + elseif (($input = $CI->input->post($field, FALSE)) === NULL) + { + return ($default === TRUE) ? ' selected="selected"' : ''; } - return $OBJ->set_select($field, $value, $default); + return ($input === $value) ? ' checked="selected"' : ''; } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f6207750e..61293a3b3 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -596,7 +596,7 @@ Bug fixes for 3.0 - Fixed a bug (#2239) - :doc:`Email Library ` improperly handled the Subject when used with ``bcc_batch_mode`` resulting in E_WARNING messages and an empty Subject. - Fixed a bug (#2234) - :doc:`Query Builder ` didn't reset JOIN cache for write-type queries. - Fixed a bug (#2298) - :doc:`Database Results ` method ``next_row()`` kept returning the last row, allowing for infinite loops. -- Fixed a bug (#2236) - :doc:`Form Helper ` function ``set_value()`` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library `. +- Fixed a bug (#2236, #2639) - :doc:`Form Helper ` functions :func:`set_value()`, :func:`set_select()`, :func:`set_radio()`, :func:`set_checkbox()` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library `. - Fixed a bug (#2353) - :doc:`Query Builder ` erroneously prefixed literal strings with **dbprefix**. - Fixed a bug (#78) - :doc:`Cart Library ` didn't allow non-English letters in product names. - Fixed a bug (#77) - :doc:`Database Class ` didn't properly handle the transaction "test mode" flag. @@ -614,7 +614,6 @@ Bug fixes for 3.0 - Fixed a bug (#2590) - :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. - Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. - Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. -- Fixed a bug (#2639) - :doc:`Form Helper ` functions :php:func:`set_radio()` and :php:func:`set_checkbox()` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library `. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From f4bfb16b5fdcd042d3751cab2626df678b8d59c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 18:14:29 +0300 Subject: [ci skip] Fix a changelog message --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 61293a3b3..6b82f2dde 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -181,7 +181,7 @@ Release Date: Not Released - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. - Added persistent connections support for PHP >= 5.3. - Added support for ``backup()`` in :doc:`Database Utilities `. - - Changed methods ``trans_being()``, ``trans_commit()`` and ``trans_rollback()`` to use the PHP API instead of sending queries. + - Changed methods ``trans_begin()``, ``trans_commit()`` and ``trans_rollback()`` to use the PHP API instead of sending queries. - Improved support of the PDO driver, including: -- cgit v1.2.3-24-g4f1b From e8a23a532a4974773067903bf96200fa12fa4d41 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 18:29:29 +0300 Subject: An update to the #2639 fix --- system/helpers/form_helper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 20379efa7..7112a99b7 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -717,6 +717,10 @@ if ( ! function_exists('set_checkbox')) { return ($default === TRUE) ? ' checked="checked"' : ''; } + elseif (is_array($input) && in_array($value, $input, TRUE)) + { + return ' checked="checked"'; + } return ($input === $value) ? ' checked="checked"' : ''; } -- cgit v1.2.3-24-g4f1b From d3b7e24b708623be425dc03c3bb429bf0e4741c8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Sep 2013 18:36:29 +0300 Subject: Another one following #2639 --- system/helpers/form_helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 7112a99b7..0cc5bd157 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -685,8 +685,12 @@ if ( ! function_exists('set_select')) { return ($default === TRUE) ? ' selected="selected"' : ''; } + elseif (is_array($input) && in_array($value, $input, TRUE)) + { + return ' selected="selected"'; + } - return ($input === $value) ? ' checked="selected"' : ''; + return ($input === $value) ? ' selected="selected"' : ''; } } -- cgit v1.2.3-24-g4f1b From 02a16129a23409af956392a5a36755489290a2e8 Mon Sep 17 00:00:00 2001 From: brenjt Date: Sat, 14 Sep 2013 11:10:25 -0600 Subject: Updated config to include list of valid characters to `sess_cookie_name` Added list of valid characters to sess_cookie_name --- application/config/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 0608348c6..3114f417b 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -282,7 +282,7 @@ $config['encryption_key'] = ''; | 'sess_driver' = the driver to load: cookie (Classic), native (PHP sessions), | or your custom driver name | 'sess_valid_drivers' = additional valid drivers which may be loaded -| 'sess_cookie_name' = the name you want for the cookie +| 'sess_cookie_name' = the name you want for the cookie, must contain only [0-9a-z_-] characters | 'sess_expiration' = the number of SECONDS you want the session to last. | by default sessions last 7200 seconds (two hours). Set to zero for no expiration. | 'sess_expire_on_close' = Whether to cause the session to expire automatically @@ -435,4 +435,4 @@ $config['proxy_ips'] = ''; /* End of file config.php */ -/* Location: ./application/config/config.php */ \ No newline at end of file +/* Location: ./application/config/config.php */ -- cgit v1.2.3-24-g4f1b -- cgit v1.2.3-24-g4f1b From 9c98991705432d9c179715bc7f3b4fb0c6d51b4b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 14 Sep 2013 20:55:12 +0300 Subject: [ci skip] Remove empty line at application/config/config.php EOF --- application/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/config.php b/application/config/config.php index 3114f417b..8d08a7401 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -435,4 +435,4 @@ $config['proxy_ips'] = ''; /* End of file config.php */ -/* Location: ./application/config/config.php */ +/* Location: ./application/config/config.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e890ecf4403fe6be6dea9809ba51a3a8f66b0b2e Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 14 Sep 2013 21:38:05 +0300 Subject: No need of this anymore --- system/core/Log.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/core/Log.php b/system/core/Log.php index 20bc55986..0390aba0b 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -140,7 +140,6 @@ class CI_Log { * * @param string the error level: 'error', 'debug' or 'info' * @param string the error message - * @param bool whether the error is a native PHP error * @return bool */ public function write_log($level, $msg) @@ -194,4 +193,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/core/Log.php */ \ No newline at end of file +/* Location: ./system/core/Log.php */ -- cgit v1.2.3-24-g4f1b From d6f3d315e543a6c81917c1c2719748e018e43a5f Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 14 Sep 2013 21:39:49 +0300 Subject: No need of this anymore --- system/core/Common.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 286deccda..e24f8854d 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -429,7 +429,6 @@ if ( ! function_exists('log_message')) * * @param string the error level: 'error', 'debug' or 'info' * @param string the error message - * @param bool whether the error is a native PHP error * @return void */ function log_message($level, $message) @@ -588,7 +587,7 @@ if ( ! function_exists('_shutdown_handler')) * of CodeIgniter.php. The main reason we use this is to simulate * a complete custom exception handler. * - * E_STRICT is purposivly neglected because such events may have + * E_STRICT is purposivly neglected because such events may have * been caught. Duplication or none? None is preferred for now. * * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a @@ -753,4 +752,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ \ No newline at end of file +/* Location: ./system/core/Common.php */ -- cgit v1.2.3-24-g4f1b From 13c818ee2f7424050cf363dceac7512bf9f9f943 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 14 Sep 2013 21:44:36 +0300 Subject: [ci skip] Remove empty lines --- system/core/Common.php | 2 +- system/core/Log.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index e24f8854d..c25707e50 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -752,4 +752,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file diff --git a/system/core/Log.php b/system/core/Log.php index 0390aba0b..b2327b8f0 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -193,4 +193,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/core/Log.php */ +/* Location: ./system/core/Log.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3914c0eff4414dc8997e6866276c5eefe6103ff3 Mon Sep 17 00:00:00 2001 From: AdwinTrave Date: Sun, 15 Sep 2013 13:21:38 -0400 Subject: Adding missing reference to min_length in rules reference --- user_guide_src/source/libraries/form_validation.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 032cff23b..8534175bb 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -866,6 +866,7 @@ Rule Parameter Description **is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be enabled in order to work. +**min_length** Yes Returns FALSE if the form element is shorter then the parameter value. min_length[3] **max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] **exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] **greater_than** Yes Returns FALSE if the form element is less than or equal to the parameter value or not greater_than[8] -- cgit v1.2.3-24-g4f1b From 130b055d085bb0a01fa3dcfd9ffba3125c6bd2d0 Mon Sep 17 00:00:00 2001 From: vkeranov Date: Fri, 20 Sep 2013 17:51:38 +0300 Subject: Update mimes.php Added mime type for tar.Z archives --- application/config/mimes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 32d10f6c1..0a6b9006a 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -78,6 +78,7 @@ return array( 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'), + 'z' => 'application/x-compress', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'), @@ -176,4 +177,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ \ No newline at end of file +/* Location: ./application/config/mimes.php */ -- cgit v1.2.3-24-g4f1b From 0c23a2712b07a53041cf808c280e71c623df3c8a Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 20 Sep 2013 22:09:20 +0200 Subject: Fix duplicate changelog entry --- user_guide_src/source/changelog.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 69f88a8a8..e36be29f6 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -766,7 +766,6 @@ Bug fixes for 2.1.0 but the requested method did not. - Fixed a bug (Reactor #89) where MySQL export would fail if the table had hyphens or other non alphanumeric/underscore characters. -- Fixed a bug (#200) where MySQL queries would be malformed after calling $this->db->count_all() then $this->db->get() - Fixed a bug (#105) that stopped query errors from being logged unless database debugging was enabled - Fixed a bug (#160) - Removed unneeded array copy in the file cache driver. @@ -787,7 +786,7 @@ Bug fixes for 2.1.0 - Fixed a bug (#537) - Support for all wav type in browser. - Fixed a bug (#576) - Using ini_get() function to detect if apc is enabled or not. - Fixed invalid date time format in :doc:`Date helper ` and :doc:`XMLRPC library `. -- Fixed a bug (#200) - MySQL queries would be malformed after calling count_all() then db->get(). +- Fixed a bug (#200) - MySQL queries would be malformed after calling db->count_all() then db->get(). Version 2.0.3 ============= -- cgit v1.2.3-24-g4f1b From 461acc4b5eee836b99466107e40d7dd59b13e12d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 21 Sep 2013 13:43:09 +0300 Subject: [ci skip] Remove an EOF empty line --- application/config/mimes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 0a6b9006a..ad3602126 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -177,4 +177,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ +/* Location: ./application/config/mimes.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0bba6434f0ba3d6b1f677233c2e3c8f37b3195cc Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Sun, 22 Sep 2013 02:09:36 -0400 Subject: Fixes Issue 2637 more elegant way to make sure that the comment is not in a js string var --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Output.php b/system/core/Output.php index 7c2a64d24..b5955c008 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -847,7 +847,7 @@ class CI_Output { } // Remove CSS comments - $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output); + $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/(?!.*?("|\'))!i', '', $output); // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) -- cgit v1.2.3-24-g4f1b From fd0aabb1e6f3db088ad9b3079adc0f9bba9b6c2b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 23 Sep 2013 13:18:20 +0300 Subject: Fix issue #33 --- system/core/Input.php | 31 ++++++++++++++++++++++++------- user_guide_src/source/changelog.rst | 2 ++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index 24e21ea08..8c32e459e 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -693,7 +693,14 @@ class CI_Input { foreach ($_COOKIE as $key => $val) { - $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE) + { + $_COOKIE[$cookie_key] = $this->_clean_input_data($val); + } + else + { + unset($_COOKIE[$key]); + } } } @@ -706,7 +713,7 @@ class CI_Input { $this->security->csrf_verify(); } - log_message('debug', 'Global POST and COOKIE data sanitized'); + log_message('debug', 'Global POST, GET and COOKIE data sanitized'); } // -------------------------------------------------------------------- @@ -776,15 +783,25 @@ class CI_Input { * only named with alpha-numeric text and a few other items. * * @param string $str Input string - * @return string + * @param string $fatal Whether to terminate script exection + * or to return FALSE if an invalid + * key is encountered + * @return string|bool */ - protected function _clean_input_keys($str) + protected function _clean_input_keys($str, $fatal = TRUE) { if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str)) { - set_status_header(503); - echo 'Disallowed Key Characters.'; - exit(EXIT_USER_INPUT); + if ($fatal === TRUE) + { + return FALSE; + } + else + { + set_status_header(503); + echo 'Disallowed Key Characters.'; + exit(EXIT_USER_INPUT); + } } // Clean UTF-8 if supported diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d804cc532..a66fb265f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -392,6 +392,7 @@ Release Date: Not Released - Changed methods ``get()``, ``post()``, ``get_post()``, ``cookie()``, ``server()``, ``user_agent()`` to return NULL instead of FALSE when no value is found. - Added method ``post_get()`` and changed ``get_post()`` to search in GET data first. Both methods' names now properly match their GET/POST data search priorities. - Changed method ``_fetch_from_array()`` to parse array notation in field name. + - Added an option for ``_clean_input_keys()`` to return FALSE instead of terminating the whole script. - :doc:`Common functions ` changes include: @@ -614,6 +615,7 @@ Bug fixes for 3.0 - Fixed a bug (#2590) - :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. - Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. - Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. +- Fixed a bug (#33) - Script execution was terminated when an invalid cookie key was encountered. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From 0760a44871e1d0d5dd54d70baa7f8f7129fbdb34 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 23 Sep 2013 13:59:46 +0300 Subject: [ci skip] Remove some whitespaces --- application/config/constants.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index dc84712cd..e71097b6c 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -81,11 +81,11 @@ define('SHOW_DEBUG_BACKTRACE', TRUE); | Used to indicate the conditions under which the script is exit()ing. | While there is no universal standard for error codes, there are some | broad conventions. Three such conventions are mentioned below, for -| those who wish to make use of them. The CodeIgniter defaults were +| those who wish to make use of them. The CodeIgniter defaults were | chosen for the least overlap with these conventions, while still | leaving room for others to be defined in future versions and user | applications. -| +| | The three main conventions used for determining exit status codes | are as follows: | @@ -108,7 +108,6 @@ define('EXIT_USER_INPUT', 7); // invalid user input define('EXIT_DATABASE', 8); // database error define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code - /* End of file constants.php */ /* Location: ./application/config/constants.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 88f41dff43e8e787ab553d86715aca130abf9e51 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 23 Sep 2013 15:24:43 +0300 Subject: [ci skip] Update Zip library docblocks --- system/libraries/Zip.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 6608f050e..2ce457844 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -103,12 +103,12 @@ class CI_Zip { * * Lets you add a virtual directory into which you can place files. * - * @param mixed the directory name. Can be string or array + * @param mixed $directory the directory name. Can be string or array * @return void */ public function add_dir($directory) { - foreach ( (array) $directory as $dir) + foreach ((array) $directory as $dir) { if ( ! preg_match('|.+/$|', $dir)) { @@ -127,7 +127,7 @@ class CI_Zip { * * If this is a newly created file/dir, we will set the time to 'now' * - * @param string path to file + * @param string $dir path to file * @return array filemtime/filemdate */ protected function _get_mod_time($dir) @@ -146,9 +146,9 @@ class CI_Zip { /** * Add Directory * - * @param string the directory name - * @param int - * @param int + * @param string $dir the directory name + * @param int $file_mtime + * @param int $file_mdate * @return void */ protected function _add_dir($dir, $file_mtime, $file_mdate) @@ -199,8 +199,8 @@ class CI_Zip { * in the filename it will be placed within a directory. Make * sure you use add_dir() first to create the folder. * - * @param mixed - * @param string + * @param mixed $filepath A single filepath or an array of file => data pairs + * @param string $data Single file contents * @return void */ public function add_data($filepath, $data = NULL) @@ -225,10 +225,10 @@ class CI_Zip { /** * Add Data to Zip * - * @param string the file name/path - * @param string the data to be encoded - * @param int - * @param int + * @param string $filepath the file name/path + * @param string $data the data to be encoded + * @param int $file_mtime + * @param int $file_mdate * @return void */ protected function _add_data($filepath, $data, $file_mtime, $file_mdate) @@ -278,8 +278,8 @@ class CI_Zip { /** * Read the contents of a file and add it to the zip * - * @param string - * @param bool + * @param string $path + * @param bool $preserve_filepath * @return bool */ public function read_file($path, $preserve_filepath = FALSE) @@ -313,9 +313,9 @@ class CI_Zip { * sub-folders) and creates a zip based on it. Whatever directory structure * is in the original file path will be recreated in the zip file. * - * @param string path to source - * @param bool - * @param bool + * @param string $path path to source directory + * @param bool $preserve_filepath + * @param string $root_path * @return bool */ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) @@ -389,7 +389,7 @@ class CI_Zip { * * Lets you write a file * - * @param string the file name + * @param string $filepath the file name * @return bool */ public function archive($filepath) @@ -412,7 +412,7 @@ class CI_Zip { /** * Download * - * @param string the file name + * @param string $filename the file name * @return void */ public function download($filename = 'backup.zip') -- cgit v1.2.3-24-g4f1b From 6d917858b5ffd012bd85a0062d511d261cd6df2d Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Mon, 23 Sep 2013 23:47:26 -0400 Subject: fix #2637 cleaned up the regex to remove extra qualifiers used character sets where possible for clarity main expression optimized --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Output.php b/system/core/Output.php index b5955c008..7a5fb66f6 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -847,7 +847,7 @@ class CI_Output { } // Remove CSS comments - $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/(?!.*?("|\'))!i', '', $output); + $output = preg_replace('!/\*([^/][^*]*\*)*/(?!.+?["\'])!i', '', $output); // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) -- cgit v1.2.3-24-g4f1b From 06fa739406e5103298ca72fc67cc41f0f8c6b6f4 Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Wed, 25 Sep 2013 01:56:10 -0400 Subject: fix issue #2617 simply adds the $_FILES array to profiler output of POST data --- system/libraries/Profiler.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 9e9e7d08d..80130eb48 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -338,7 +338,7 @@ class CI_Profiler { ."\n" .'  '.$this->CI->lang->line('profiler_post_data')."  \n"; - if (count($_POST) === 0) + if (count($_POST) === 0 AND count($_FILES) === 0) { $output .= '
'.$this->CI->lang->line('profiler_no_post').'
'; } @@ -368,9 +368,29 @@ class CI_Profiler { $output .= "\n"; } + foreach ($_FILES as $key => $val) + { + if ( ! is_numeric($key)) + { + $key = "'".$key."'"; + } + + $output .= '$_FILES[' + .$key.']   '; + + if (is_array($val) OR is_object($val)) + { + $output .= '
'.htmlspecialchars(stripslashes(print_r($val, TRUE))).'
'; + } + + $output .= "\n"; + } + $output .= "\n"; } + + return $output.''; } -- cgit v1.2.3-24-g4f1b From cf60fa7ac654a15e00888eef469838ef4bf47204 Mon Sep 17 00:00:00 2001 From: Jesse van Assen Date: Fri, 27 Sep 2013 11:58:44 +0200 Subject: Script is killed with the proper exit code. --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Common.php b/system/core/Common.php index 7553f4ae6..d88b0867b 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -612,7 +612,7 @@ if ( ! function_exists('_exception_handler')) // default error handling. See http://www.php.net/manual/en/errorfunc.constants.php if ($is_error) { - exit(); + exit(EXIT_ERROR); } } } -- cgit v1.2.3-24-g4f1b From 871d8f67611d94e2662dd0ac6e06b96accc954e6 Mon Sep 17 00:00:00 2001 From: Jesse van Assen Date: Fri, 27 Sep 2013 12:04:37 +0200 Subject: Added changelog entry. --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2adbca19d..f5e2da738 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -501,6 +501,7 @@ Bug fixes for 3.0 - Fixed a bug (#2380) - :doc:`URI Routing ` method ``fetch_method()`` returned 'index' if the requested method name matches its controller name. - Fixed a bug (#2388) - :doc:`Email Library ` used to ignore attachment errors, resulting in broken emails being sent. - Fixed a bug (#2498) - :doc:`Form Validation Library ` rule **valid_base64** only checked characters instead of actual validity. +- Fixed a bug (#2515) - The script now halts when a fatal error occurs, instead of continuing. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From b53bd4e58f372b767ab33e0e7ffd89201710d043 Mon Sep 17 00:00:00 2001 From: garthkerr Date: Tue, 1 Oct 2013 19:46:11 -0400 Subject: Add return type for view loader. When _ci_return is TRUE. --- system/core/Loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 2eef9979c..e0962510d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -415,7 +415,7 @@ class CI_Loader { * to be extracted for use in the view * @param bool $return Whether to return the view output * or leave it to the Output class - * @return void + * @return void|string */ public function view($view, $vars = array(), $return = FALSE) { @@ -1293,4 +1293,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ \ No newline at end of file +/* Location: ./system/core/Loader.php */ -- cgit v1.2.3-24-g4f1b From a442bc2bced3bd9359548c376f99027d5334a1c7 Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Wed, 2 Oct 2013 23:16:51 -0400 Subject: re-fixes #2637 delimiter used for regex bounds found in neg. lookahead causes error using @ delimiter now for this expression --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Output.php b/system/core/Output.php index 7a5fb66f6..04209d920 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -847,7 +847,7 @@ class CI_Output { } // Remove CSS comments - $output = preg_replace('!/\*([^/][^*]*\*)*/(?!.+?["\'])!i', '', $output); + $output = preg_replace('@/\*([^/][^*]*\*)*/(?!.+?["\'])@i', '', $output); // Remove Javascript inline comments if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE) -- cgit v1.2.3-24-g4f1b From 46e77e0d28cf6c057484df022a012e85de2f79b6 Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Thu, 3 Oct 2013 16:56:04 -0400 Subject: partial fix #2667 this fixes the ability to replace a space with a / and skip the XSS filtering --- system/core/Security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Security.php b/system/core/Security.php index 70cf3e013..368e17dc3 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -603,7 +603,7 @@ class CI_Security { */ public function strip_image_tags($str) { - return preg_replace(array('##', '##'), '\\1', $str); + return preg_replace(array('##', '##'), '\\1', $str); } // ---------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 8e7cc7a18086ad32c8e13525b643aadde054bf40 Mon Sep 17 00:00:00 2001 From: Ahmad Anbar Date: Fri, 4 Oct 2013 02:45:28 +0300 Subject: parse $extra attributes in form_dropdown. --- system/helpers/form_helper.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 0cc5bd157..85f1f4e01 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -328,11 +328,8 @@ if ( ! function_exists('form_dropdown')) { $selected = array($_POST[$name]); } - - if ($extra != '') - { - $extra = ' '.$extra; - } + + $extra = _attributes_to_string($extra); $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; -- cgit v1.2.3-24-g4f1b From 3751517a5caf9299072248534577f66f9db9221d Mon Sep 17 00:00:00 2001 From: Dmitry Babenko Date: Fri, 4 Oct 2013 14:46:40 +0300 Subject: Exra bmp mimes Mimies source http://filext.com/file-extension/BMP --- application/config/mimes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index ad3602126..99b1c4b7d 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -97,7 +97,7 @@ return array( 'ra' => 'audio/x-realaudio', 'rv' => 'video/vnd.rn-realvideo', 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'), - 'bmp' => array('image/bmp', 'image/x-windows-bmp'), + 'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'), 'gif' => 'image/gif', 'jpeg' => array('image/jpeg', 'image/pjpeg'), 'jpg' => array('image/jpeg', 'image/pjpeg'), @@ -177,4 +177,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ \ No newline at end of file +/* Location: ./application/config/mimes.php */ -- cgit v1.2.3-24-g4f1b From 024105034909b189ad995ca01aadcefc510ce144 Mon Sep 17 00:00:00 2001 From: Jcchemin Date: Tue, 8 Oct 2013 18:18:54 +0200 Subject: Update user_agents.php Add detection for Opera 16 --- application/config/user_agents.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/config/user_agents.php b/application/config/user_agents.php index 5887a15be..9177f3e61 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -81,6 +81,7 @@ $platforms = array( // The order of this array should NOT be changed. Many browsers return // multiple browser types so we want to identify the sub-type first. $browsers = array( + 'OPR' => 'Opera', 'Flock' => 'Flock', 'Chrome' => 'Chrome', 'Opera' => 'Opera', @@ -222,4 +223,4 @@ $robots = array( ); /* End of file user_agents.php */ -/* Location: ./application/config/user_agents.php */ \ No newline at end of file +/* Location: ./application/config/user_agents.php */ -- cgit v1.2.3-24-g4f1b From 9f417d070916e82309a762639cc344445601156b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 14 Oct 2013 12:24:36 +0300 Subject: Fix #2682 --- application/config/mimes.php | 2 +- application/config/user_agents.php | 2 +- index.php | 14 +++++++------- system/core/Loader.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 99b1c4b7d..27d4b2514 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -177,4 +177,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ +/* Location: ./application/config/mimes.php */ \ No newline at end of file diff --git a/application/config/user_agents.php b/application/config/user_agents.php index 9177f3e61..899e96a94 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -223,4 +223,4 @@ $robots = array( ); /* End of file user_agents.php */ -/* Location: ./application/config/user_agents.php */ +/* Location: ./application/config/user_agents.php */ \ No newline at end of file diff --git a/index.php b/index.php index 3040ef080..72c97c410 100755 --- a/index.php +++ b/index.php @@ -220,28 +220,28 @@ switch (ENVIRONMENT) $application_folder = $_temp; } - define('APPPATH', $application_folder.'/'); + define('APPPATH', $application_folder.DIRECTORY_SEPARATOR); } else { - if ( ! is_dir(BASEPATH.$application_folder.'/')) + if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR)) { header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF; exit(3); // EXIT_* constants not yet defined; 3 is EXIT_CONFIG. } - define('APPPATH', BASEPATH.$application_folder.'/'); + define('APPPATH', BASEPATH.$application_folder.DIRECTORY_SEPARATOR); } // The path to the "views" folder if ( ! is_dir($view_folder)) { - if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.'/')) + if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR)) { $view_folder = APPPATH.$view_folder; } - elseif ( ! is_dir(APPPATH.'views/')) + elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR)) { header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF; @@ -255,11 +255,11 @@ switch (ENVIRONMENT) if (($_temp = realpath($view_folder)) !== FALSE) { - $view_folder = $_temp.'/'; + $view_folder = $_temp.DIRECTORY_SEPARATOR; } else { - $view_folder = rtrim($view_folder, '/').'/'; + $view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR; } define('VIEWPATH', $view_folder); diff --git a/system/core/Loader.php b/system/core/Loader.php index e0962510d..0c16632eb 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1293,4 +1293,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b367f7ba9302f00926f6b923ca1ca741b351ae96 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 14 Oct 2013 12:27:00 +0300 Subject: Fix #2674 --- system/libraries/Pagination.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 10fb29dbd..c6ffd03d4 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -354,7 +354,8 @@ class CI_Pagination { public function create_links() { // If our item count or per-page total is zero there is no need to continue. - if ($this->total_rows === 0 OR $this->per_page === 0) + // Note: DO NOT change the operator to === here! + if ($this->total_rows == 0 OR $this->per_page == 0) { return ''; } -- cgit v1.2.3-24-g4f1b From a81a5effc439306807730002c19d8b4dda3c6f1d Mon Sep 17 00:00:00 2001 From: Tomaz Lovrec Date: Wed, 16 Oct 2013 11:29:57 +0200 Subject: Added possibility clear out the cached variables from the Loader. --- system/core/Loader.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 0c16632eb..e5829ca80 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -470,6 +470,20 @@ class CI_Loader { // -------------------------------------------------------------------- + /** + * Clear Cached Variables + * + * Clears the cached variables. + * + * @return void + */ + public function clear_vars() + { + $this->_ci_cached_vars = array(); + } + + // -------------------------------------------------------------------- + /** * Get Variable * @@ -1293,4 +1307,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ \ No newline at end of file +/* Location: ./system/core/Loader.php */ -- cgit v1.2.3-24-g4f1b From 8bb20a1ff7217c9f5125db49916da8a9b6574c19 Mon Sep 17 00:00:00 2001 From: Tomaz Lovrec Date: Wed, 16 Oct 2013 12:34:36 +0200 Subject: Fixed empty line at EOF and added changelog entry --- system/core/Loader.php | 2 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index e5829ca80..70c1e4154 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1307,4 +1307,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a66fb265f..a76fcd784 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -57,6 +57,7 @@ Release Date: Not Released - Removed *cheatsheets* and *quick_reference* PDFs from the documentation. - Added availability checks where usage of dangerous functions like ``eval()`` and ``exec()`` is required. - Added support for changing the file extension of log files using ``$config['log_file_extension']``. + - Added possibility clear out the cached variables from the Loader. - Helpers -- cgit v1.2.3-24-g4f1b From b69cbcb6844870af6f95fd7648c8533408b12eb6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 16 Oct 2013 13:59:43 +0300 Subject: Changelog/doc edits following PR #2684 --- user_guide_src/source/changelog.rst | 2 +- user_guide_src/source/libraries/loader.rst | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a76fcd784..5774ff115 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -57,7 +57,6 @@ Release Date: Not Released - Removed *cheatsheets* and *quick_reference* PDFs from the documentation. - Added availability checks where usage of dangerous functions like ``eval()`` and ``exec()`` is required. - Added support for changing the file extension of log files using ``$config['log_file_extension']``. - - Added possibility clear out the cached variables from the Loader. - Helpers @@ -382,6 +381,7 @@ Release Date: Not Released - Added support for model aliasing on autoload. - Changed method ``is_loaded()`` to ask for the (case sensitive) library name instead of its instance name. - Removed ``$_base_classes`` property and unified all class data in ``$_ci_classes`` instead. + - Added method ``clear_vars()`` to allow clearing the cached variables for views. - :doc:`Input Library ` changes include: diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 19446a9c8..91db5afbd 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -234,6 +234,11 @@ $this->load->get_vars() This method retrieves all variables available to your views. +$this->load->clear_vars() +========================= + +Clears cached view variables. + $this->load->helper('file_name') ================================ -- cgit v1.2.3-24-g4f1b From abcb67c76ccb384ea213f9c4f42a392b15b3e15e Mon Sep 17 00:00:00 2001 From: David Cox Jr Date: Wed, 16 Oct 2013 14:43:52 -0400 Subject: req. changes: cleaned up conditionals added changelog note regarding profiler updated as per styleguide --- system/libraries/Profiler.php | 19 ++++--------------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 80130eb48..50ba1673f 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -307,10 +307,7 @@ class CI_Profiler { foreach ($_GET as $key => $val) { - if ( ! is_numeric($key)) - { - $key = "'".$key."'"; - } + is_int($key) OR $key = "'".$key."'"; $output .= '$_GET[' .$key.']   ' @@ -338,7 +335,7 @@ class CI_Profiler { ."\n" .'  '.$this->CI->lang->line('profiler_post_data')."  \n"; - if (count($_POST) === 0 AND count($_FILES) === 0) + if (count($_POST) === 0 && count($_FILES) === 0) { $output .= '
'.$this->CI->lang->line('profiler_no_post').'
'; } @@ -348,10 +345,7 @@ class CI_Profiler { foreach ($_POST as $key => $val) { - if ( ! is_numeric($key)) - { - $key = "'".$key."'"; - } + is_int($key) OR $key = "'".$key."'"; $output .= '$_POST[' .$key.']   '; @@ -370,10 +364,7 @@ class CI_Profiler { foreach ($_FILES as $key => $val) { - if ( ! is_numeric($key)) - { - $key = "'".$key."'"; - } + is_int($key) OR $key = "'".$key."'"; $output .= '$_FILES[' .$key.']   '; @@ -389,8 +380,6 @@ class CI_Profiler { $output .= "\n"; } - - return $output.''; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a66fb265f..052624076 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -351,6 +351,7 @@ Release Date: Not Released - Database object names are now being displayed. - The sum of all queries running times in seconds is now being displayed. - Added support for displaying the HTTP DNT ("Do Not Track") header. + - Added support for displaying $_FILES. - :doc:`Migration Library ` changes include: -- cgit v1.2.3-24-g4f1b From 3a3d5f6c2320a90436de241af41fe22df7344728 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 17 Oct 2013 22:22:16 +0200 Subject: Replace the last rand() with mt_rand() Better entropy, faster. Also fixed a few "it's" typos. --- system/core/Security.php | 4 ++-- system/database/DB_driver.php | 2 +- system/helpers/captcha_helper.php | 14 +++++++------- tests/codeigniter/core/Security_test.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index 368e17dc3..6f5f5cb90 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -884,7 +884,7 @@ class CI_Security { { if ($this->_csrf_hash === '') { - // If the cookie exists we will use it's value. + // If the cookie exists we will use its value. // We don't necessarily want to regenerate it with // each page load since a page could contain embedded // sub-pages causing this feature to fail @@ -894,7 +894,7 @@ class CI_Security { return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name]; } - $this->_csrf_hash = md5(uniqid(rand(), TRUE)); + $this->_csrf_hash = md5(uniqid(mt_rand(), TRUE)); $this->csrf_set_cookie(); } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 53decf014..618f3660c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1135,7 +1135,7 @@ abstract class CI_DB_driver { else { /* We have no other choice but to just get the first element's key. - * Due to array_shift() accepting it's argument by reference, if + * Due to array_shift() accepting its argument by reference, if * E_STRICT is on, this would trigger a warning. So we'll have to * assign it first. */ diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 29911dc17..ea46f97b3 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -126,9 +126,9 @@ if ( ! function_exists('create_captcha')) // Determine angle and position // ----------------------------------- $length = strlen($word); - $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0; - $x_axis = rand(6, (360/$length)-16); - $y_axis = ($angle >= 0) ? rand($img_height, $img_width) : rand(6, $img_height); + $angle = ($length >= 6) ? mt_rand(-($length-6), ($length-6)) : 0; + $x_axis = mt_rand(6, (360/$length)-16); + $y_axis = ($angle >= 0) ? mt_rand($img_height, $img_width) : mt_rand(6, $img_height); // Create image // PHP.net recommends imagecreatetruecolor(), but it isn't always available @@ -183,13 +183,13 @@ if ( ! function_exists('create_captcha')) if ($use_font === FALSE) { $font_size = 5; - $x = rand(0, $img_width / ($length / 3)); + $x = mt_rand(0, $img_width / ($length / 3)); $y = 0; } else { $font_size = 16; - $x = rand(0, $img_width / ($length / 1.5)); + $x = mt_rand(0, $img_width / ($length / 1.5)); $y = $font_size + 2; } @@ -197,13 +197,13 @@ if ( ! function_exists('create_captcha')) { if ($use_font === FALSE) { - $y = rand(0 , $img_height / 2); + $y = mt_rand(0 , $img_height / 2); imagestring($im, $font_size, $x, $y, $word[$i], $colors['text']); $x += ($font_size * 2); } else { - $y = rand($img_height / 2, $img_height - 3); + $y = mt_rand($img_height / 2, $img_height - 3); imagettftext($im, $font_size, $angle, $x, $y, $colors['text'], $font_path, $word[$i]); $x += $font_size; } diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 3f6e3b07a..433ad313f 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -5,7 +5,7 @@ class Security_test extends CI_TestCase { public function set_up() { // Set cookie for security test - $_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE)); + $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE)); // Set config for Security class $this->ci_set_config('csrf_protection', TRUE); -- cgit v1.2.3-24-g4f1b From 3fa729d7092c814fe14e15d8d51789ce7907f2a8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 18 Oct 2013 20:57:41 +0300 Subject: Fix issue #2681 (alternative to PR #2690) --- system/core/Security.php | 4 ++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index 6f5f5cb90..5c5c0efb6 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -553,9 +553,9 @@ class CI_Security { { $matches = $matches1 = 0; + $str = preg_replace('~(�*[0-9a-f]{2,5});?~iS', $str, -1, $matches); + $str = preg_replace('~(&#\d{2,4});?~S', $str, -1, $matches1); $str = html_entity_decode($str, ENT_COMPAT, $charset); - $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str, -1, $matches); - $str = preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str, -1, $matches1); } while ($matches OR $matches1); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8f5cffcb0..b5c00699a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -618,6 +618,7 @@ Bug fixes for 3.0 - Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. - Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. - Fixed a bug (#33) - Script execution was terminated when an invalid cookie key was encountered. +- Fixed a bug (#2681) - `CI_Security::entity_decode()` used the `PREG_REPLACE_EVAL` flag, which is deprecated since PHP 5.5. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From a277a50f82dacaa129876160dadbda98fc9e33ca Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 18 Oct 2013 20:58:44 +0300 Subject: [ci skip] Fix a changelog entry --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b5c00699a..8c992a575 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -618,7 +618,7 @@ Bug fixes for 3.0 - Fixed a bug (#2609) - :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. - Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. - Fixed a bug (#33) - Script execution was terminated when an invalid cookie key was encountered. -- Fixed a bug (#2681) - `CI_Security::entity_decode()` used the `PREG_REPLACE_EVAL` flag, which is deprecated since PHP 5.5. +- Fixed a bug (#2681) - ``CI_Security::entity_decode()`` used the `PREG_REPLACE_EVAL` flag, which is deprecated since PHP 5.5. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From e08411d72226ba5b2f97b519051f78d978747e18 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 18 Oct 2013 21:13:56 +0300 Subject: Eh ... preg_replace() needs a replacement --- system/core/Security.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index 5c5c0efb6..9423f825c 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -553,8 +553,8 @@ class CI_Security { { $matches = $matches1 = 0; - $str = preg_replace('~(�*[0-9a-f]{2,5});?~iS', $str, -1, $matches); - $str = preg_replace('~(&#\d{2,4});?~S', $str, -1, $matches1); + $str = preg_replace('~(�*[0-9a-f]{2,5});?~iS', '$1;', $str, -1, $matches); + $str = preg_replace('~(&#\d{2,4});?~S', '$1;', $str, -1, $matches1); $str = html_entity_decode($str, ENT_COMPAT, $charset); } while ($matches OR $matches1); -- cgit v1.2.3-24-g4f1b From 6c85442746c46009cdf3fe517465e174a91cc4c5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 21 Oct 2013 13:58:15 +0300 Subject: Fix #2691 --- system/database/DB_driver.php | 9 ++++++++- user_guide_src/source/changelog.rst | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 618f3660c..9aa6c5de5 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -624,7 +624,14 @@ abstract class CI_DB_driver { // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. - $this->_trans_depth > 0 && $this->trans_complete(); + if ($this->_trans_depth !== 0) + { + do + { + $this->trans_complete(); + } + while ($this->_trans_depth !== 0); + } // Display errors return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql)); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8c992a575..9f6feb744 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -619,6 +619,7 @@ Bug fixes for 3.0 - Fixed a bug in the 'postgre' :doc:`database ` driver where the connection ID wasn't passed to ``pg_escape_string()``. - Fixed a bug (#33) - Script execution was terminated when an invalid cookie key was encountered. - Fixed a bug (#2681) - ``CI_Security::entity_decode()`` used the `PREG_REPLACE_EVAL` flag, which is deprecated since PHP 5.5. +- Fixed a bug (#2691) - nested transactions could end in a deadlock when an error is encountered with *db_debug* set to TRUE. Version 2.1.4 ============= -- cgit v1.2.3-24-g4f1b From 7f5f8aaa01764f266b41791568863ec6bfda7e83 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 21 Oct 2013 14:37:40 +0300 Subject: Manually apply PR #2656 Fixes an 'Array to string conversion' notice in form_dropdown() --- system/helpers/form_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 85f1f4e01..400a91faa 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -316,7 +316,7 @@ if ( ! function_exists('form_dropdown')) { isset($name['options']) OR $name['options'] = array(); isset($name['selected']) OR $name['selected'] = array(); - isset($name['extra']) OR $name['extra'] = array(); + isset($name['extra']) OR $name['extra'] = ''; return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']); } @@ -328,7 +328,7 @@ if ( ! function_exists('form_dropdown')) { $selected = array($_POST[$name]); } - + $extra = _attributes_to_string($extra); $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; -- cgit v1.2.3-24-g4f1b From 72b4b3cbc71d2c266938b8878baba11c11c565ca Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 21 Oct 2013 14:44:57 +0300 Subject: Add 'filename' to the return elements for create_captcha() (PR #2602) --- system/helpers/captcha_helper.php | 8 ++++---- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/helpers/captcha_helper.rst | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index ea46f97b3..24cd53568 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -215,12 +215,12 @@ if ( ! function_exists('create_captcha')) // ----------------------------------- // Generate the image // ----------------------------------- - $img_name = $now.'.jpg'; - ImageJPEG($im, $img_path.$img_name); - $img = ' '; + $img_filename = $now.'.jpg'; + ImageJPEG($im, $img_path.$img_filename); + $img = ' '; ImageDestroy($im); - return array('word' => $word, 'time' => $now, 'image' => $img); + return array('word' => $word, 'time' => $now, 'image' => $img, 'filename' => $img_filename); } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8f5dfe540..053f57703 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -128,6 +128,7 @@ Release Date: Not Released - Added *word_length* and *pool* options to allow customization of the generated word. - Added *colors* configuration to allow customization for the *background*, *border*, *text* and *grid* colors. + - Added *filename* to the returned array elements. - :doc:`Directory Helper ` :php:func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array. - :doc:`Array Helper ` :php:func:`element()` and :php:func:`elements()` now return NULL instead of FALSE when the required elements don't exist. diff --git a/user_guide_src/source/helpers/captcha_helper.rst b/user_guide_src/source/helpers/captcha_helper.rst index 3c56addf3..f47173453 100644 --- a/user_guide_src/source/helpers/captcha_helper.rst +++ b/user_guide_src/source/helpers/captcha_helper.rst @@ -26,7 +26,7 @@ create_captcha() :param string $img_path: Path to create the image in :param string $img_url: URL to the CAPTCHA image folder :param string $font_path: Server path to font - :returns: array('word' => $word, 'time' => $now, 'image' => $img) + :returns: array Takes an array of information to generate the CAPTCHA as input and creates the image to your specifications, returning an array of @@ -35,9 +35,10 @@ associative data about the image. :: array( - 'image' => IMAGE TAG - 'time' => TIMESTAMP (in microtime) - 'word' => CAPTCHA WORD + 'word' => CAPTCHA WORD, + 'time' => TIMESTAMP (in microtime), + 'image' => IMAGE TAG, + 'filename' => IMAGE FILE NAME ) The **image** is the actual image tag:: -- cgit v1.2.3-24-g4f1b From 32c7212edb0488524a0eece98cb1e2321ee90c29 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 21 Oct 2013 15:35:05 +0300 Subject: Add CI_Upload:: option --- system/libraries/Upload.php | 10 +++++++++- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/file_uploading.rst | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 060973847..7989d113e 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -233,6 +233,13 @@ class CI_Upload { */ public $xss_clean = FALSE; + /** + * Apache mod_mime fix flag + * + * @var bool + */ + public $mod_mime_fix = TRUE; + /** * Temporary filename prefix * @@ -314,6 +321,7 @@ class CI_Upload { 'remove_spaces' => TRUE, 'detect_mime' => TRUE, 'xss_clean' => FALSE, + 'mod_mime_fix' => TRUE, 'temp_prefix' => 'temp_file_', 'client_name' => '' ); @@ -1148,7 +1156,7 @@ class CI_Upload { */ protected function _prep_filename($filename) { - if (strpos($filename, '.') === FALSE OR $this->allowed_types === '*') + if ($this->mod_mime_fix === FALSE OR $this->allowed_types === '*' OR strpos($filename, '.') === FALSE) { return $filename; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 053f57703..ecd0eb541 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -274,6 +274,7 @@ Release Date: Not Released - Added the **min_width** and **min_height** options for images. - Removed method ``clean_file_name()`` and its usage in favor of :doc:`Security Library `'s ``sanitize_filename()``. - Added **file_ext_tolower** config setting. + - Added **mod_mime_fix** option to disable suffixing multiple file extensions with an underscore. - :doc:`Cart library ` changes include: diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index a295d7427..ac56fabce 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -224,6 +224,11 @@ Preference Default Value Options Descripti **detect_mime** TRUE TRUE/FALSE (boolean) If set to TRUE, a server side detection of the file type will be performed to avoid code injection attacks. DO NOT disable this option unless you have no other option as that would cause a security risk. +**mod_mime_fix** TRUE TRUE/FALSE (boolean) If set to TRUE, multiple filename extensions will be suffixed with an + underscore in order to avoid triggering `Apache mod_mime + `_. + DO NOT turn off this option if your upload directory is public, as this + is a security risk. ============================ ================= ======================= ====================================================================== Setting preferences in a config file -- cgit v1.2.3-24-g4f1b From 6614367f62d2cbd9e8f979c9349cd5474b035866 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 22 Oct 2013 15:00:11 +0300 Subject: Fix CSS minifier --- system/core/Output.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 04209d920..719c43256 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -909,12 +909,12 @@ class CI_Output { $next = $array_output[$key + 1]; // Strip spaces preceded/followed by a non-ASCII character - // or not preceded/followed by an alphanumeric - // or not preceded/followed \ $ and _ + // that are not preceded/followed by an alphanumeric character, + // '\', '$', '_', '.' and '#' if ((preg_match('/^[\x20-\x7f]*$/D', $next) OR preg_match('/^[\x20-\x7f]*$/D', $prev)) && ( ! ctype_alnum($next) OR ! ctype_alnum($prev)) - && ! in_array($next, array('\\', '_', '$'), TRUE) - && ! in_array($prev, array('\\', '_', '$'), TRUE) + && ! in_array($next, array('\\', '_', '$', '.', '#'), TRUE) + && ! in_array($prev, array('\\', '_', '$', '.', '#'), TRUE) ) { unset($array_output[$key]); -- cgit v1.2.3-24-g4f1b From a587a939ce0b8e7d1dfe0830ac83d881e151d6e0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 23 Oct 2013 19:57:46 +0300 Subject: Fix issue #2695 --- system/helpers/form_helper.php | 32 +++++++++++++++++++++++++++----- system/libraries/Form_validation.php | 22 ++++++++++++++++++---- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 400a91faa..a3d299b0d 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -682,9 +682,20 @@ if ( ! function_exists('set_select')) { return ($default === TRUE) ? ' selected="selected"' : ''; } - elseif (is_array($input) && in_array($value, $input, TRUE)) + + $value = (string) $value; + if (is_array($input)) { - return ' selected="selected"'; + // Note: in_array('', array(0)) returns TRUE, do not use it + foreach ($input as &$v) + { + if ($value === $v) + { + return ' selected="selected"'; + } + } + + return ''; } return ($input === $value) ? ' selected="selected"' : ''; @@ -718,9 +729,20 @@ if ( ! function_exists('set_checkbox')) { return ($default === TRUE) ? ' checked="checked"' : ''; } - elseif (is_array($input) && in_array($value, $input, TRUE)) + + $value = (string) $value; + if (is_array($input)) { - return ' checked="checked"'; + // Note: in_array('', array(0)) returns TRUE, do not use it + foreach ($input as &$v) + { + if ($value === $v) + { + return ' checked="checked"'; + } + } + + return ''; } return ($input === $value) ? ' checked="checked"' : ''; @@ -755,7 +777,7 @@ if ( ! function_exists('set_radio')) return ($default === TRUE) ? ' checked="checked"' : ''; } - return ($input === $value) ? ' checked="checked"' : ''; + return ($input === (string) $value) ? ' checked="checked"' : ''; } } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 8b9bfa897..5ea2f81af 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -898,12 +898,19 @@ class CI_Form_validation { } $field = $this->_field_data[$field]['postdata']; + $value = (string) $value; if (is_array($field)) { - if ( ! in_array($value, $field)) + // Note: in_array('', array(0)) returns TRUE, do not use it + foreach ($field as &$v) { - return ''; + if ($value === $v) + { + return ' selected="selected"'; + } } + + return ''; } elseif (($field === '' OR $value === '') OR ($field !== $value)) { @@ -934,12 +941,19 @@ class CI_Form_validation { } $field = $this->_field_data[$field]['postdata']; + $value = (string) $value; if (is_array($field)) { - if ( ! in_array($value, $field)) + // Note: in_array('', array(0)) returns TRUE, do not use it + foreach ($field as &$v) { - return ''; + if ($value === $v) + { + return ' checked="checked"'; + } } + + return ''; } elseif (($field === '' OR $value === '') OR ($field !== $value)) { -- cgit v1.2.3-24-g4f1b From 4c07fce7191ed5d9c393479406cce454a9c4a7cc Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 25 Oct 2013 01:20:32 +0200 Subject: Implement $protocol parameter in Config base_url() and site_url() methods Let's keep the implementation logic in one place. Improves 2023c3d05b042cf1322286d69557c2b8bf3bd8d5. --- system/core/Config.php | 28 ++++++++++++++++++++++------ system/helpers/url_helper.php | 18 ++---------------- user_guide_src/source/changelog.rst | 1 + 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index 109ee6424..a0e830abe 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -228,13 +228,21 @@ class CI_Config { * @uses CI_Config::_uri_string() * * @param string|string[] $uri URI string or an array of segments + * @param string $protocol * @return string */ - public function site_url($uri = '') + public function site_url($uri = '', $protocol = NULL) { + $base_url = $this->slash_item('base_url'); + + if (isset($protocol)) + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } + if (empty($uri)) { - return $this->slash_item('base_url').$this->item('index_page'); + return $base_url.$this->item('index_page'); } $uri = $this->_uri_string($uri); @@ -255,14 +263,14 @@ class CI_Config { } } - return $this->slash_item('base_url').$this->slash_item('index_page').$uri; + return $base_url.$this->slash_item('index_page').$uri; } elseif (strpos($uri, '?') === FALSE) { $uri = '?'.$uri; } - return $this->slash_item('base_url').$this->item('index_page').$uri; + return $base_url.$this->item('index_page').$uri; } // ------------------------------------------------------------- @@ -275,11 +283,19 @@ class CI_Config { * @uses CI_Config::_uri_string() * * @param string|string[] $uri URI string or an array of segments + * @param string $protocol * @return string */ - public function base_url($uri = '') + public function base_url($uri = '', $protocol = NULL) { - return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/'); + $base_url = $this->slash_item('base_url'); + + if (isset($protocol)) + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } + + return $base_url.ltrim($this->_uri_string($uri), '/'); } // ------------------------------------------------------------- diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index fbb4a1b24..b0f436840 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -52,14 +52,7 @@ if ( ! function_exists('site_url')) */ function site_url($uri = '', $protocol = NULL) { - $uri = get_instance()->config->site_url($uri); - - if (isset($protocol)) - { - return $protocol.substr($uri, strpos($uri, '://')); - } - - return $uri; + return get_instance()->config->site_url($uri, $protocol); } } @@ -80,14 +73,7 @@ if ( ! function_exists('base_url')) */ function base_url($uri = '', $protocol = NULL) { - $uri = get_instance()->config->base_url($uri); - - if (isset($protocol)) - { - return $protocol.substr($uri, strpos($uri, '://')); - } - - return $uri; + return get_instance()->config->base_url($uri, $protocol); } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ecd0eb541..8f11bcc00 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -419,6 +419,7 @@ Release Date: Not Released - Changed ``site_url()`` method to accept an array as well. - Removed internal method ``_assign_to_config()`` and moved its implementation to *CodeIgniter.php* instead. - ``item()`` now returns NULL instead of FALSE when the required config item doesn't exist. + - Added an optional second parameter to both ``base_url()`` and ``site_url()`` that allows enforcing of a protocol different than the one in the *base_url* configuration setting. - :doc:`Security Library ` changes include: -- cgit v1.2.3-24-g4f1b From 8c0e56f5349cb52e993eb7132a87151e838e95b0 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 26 Oct 2013 01:15:49 +0200 Subject: Remove redundant changelog entry --- user_guide_src/source/changelog.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8f11bcc00..c191432b8 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -77,7 +77,6 @@ Release Date: Not Released - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`. - Changed :php:func:`redirect()` to choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). - - Added an optional second parameter to both :php:func:`base_url()` and :php:func:`site_url()` that allows enforcing of a protocol different than the one in the *base_url* configuration setting. - :doc:`HTML Helper ` changes include: -- cgit v1.2.3-24-g4f1b From 8adac96fdc90cfc8c667d64b95ae29845808947b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Oct 2013 14:13:09 +0200 Subject: Fix CI_DB_query_builder::_merge_cache() triggering E_WARNINGs Kudos to kakysha for noting the bug & providing initial fix in PR #2698 --- system/database/DB_query_builder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index a36501eb6..95c3af3a9 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2551,11 +2551,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $qb_variable = 'qb_'.$val; $qb_cache_var = 'qb_cache_'.$val; - if (count($this->$qb_cache_var) === 0) + if (count($this->$qb_cache_var) > 0) { - continue; + foreach ($this->$qb_cache_var as &$cache_var) + { + in_array($cache_var, $this->$qb_variable, TRUE) OR $this->$qb_variable[] = $cache_var; + } } - $this->$qb_variable = array_merge($this->$qb_variable, array_diff($this->$qb_cache_var, $this->$qb_variable)); } // If we are "protecting identifiers" we need to examine the "from" -- cgit v1.2.3-24-g4f1b From 6a424902ba0dbd59de2dd6e69bbf9e73d10c083d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Oct 2013 14:16:18 +0200 Subject: An alternative to CI_Output::_minify_script_style() using more efficient regexp patterns --- system/core/Output.php | 102 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 5 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 719c43256..cae1347bc 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -740,13 +740,13 @@ class CI_Output { preg_match_all('{}msU', $output, $style_clean); foreach ($style_clean[0] as $s) { - $output = str_replace($s, $this->_minify_script_style($s, TRUE), $output); + $output = str_replace($s, $this->_minify_js_css($s, 'css', TRUE), $output); } // Minify the javascript in