From a5e0ea8131e16752ab369d776f585b130b526f85 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 27 Feb 2013 18:17:35 +0100 Subject: Fix this use case: load->vars->('foobar', '') Previously, only the other syntax was working: load->vars->(array('foobar' => '')) --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Loader.php b/system/core/Loader.php index 6e5b58ba7..d4e63231c 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -459,7 +459,7 @@ class CI_Loader { */ public function vars($vars = array(), $val = '') { - if ($val !== '' && is_string($vars)) + if (is_string($vars)) { $vars = array($vars => $val); } -- cgit v1.2.3-24-g4f1b From b76e29242fd399c47ec633152092f9ce7ac917fc Mon Sep 17 00:00:00 2001 From: Michelle Jones Date: Wed, 27 Feb 2013 16:59:48 -0500 Subject: Remove trailing delimiters from csv_from_result When using the csv_from_result function, the returned string includes an extra delimiter at the end of every line, usually a comma unless another delimiter is specified. A simple addition of a couple of lines to remove the extra delimiter from the column names and the data rows is included. (Lines 241 and 251) --- system/database/DB_utility.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 9822fdaa3..9803307ed 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -238,7 +238,8 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = rtrim($out).$newline; + $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names + $out = $out.$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -247,6 +248,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } + $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines $out = rtrim($out).$newline; } -- cgit v1.2.3-24-g4f1b From 31875730b3cb67e865e99e748f885c5365339c9e Mon Sep 17 00:00:00 2001 From: Michelle Jones Date: Thu, 28 Feb 2013 09:44:47 -0500 Subject: added spaces after the parameter separators --- system/database/DB_utility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 9803307ed..b270cdd4d 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -238,7 +238,7 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names + $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names $out = $out.$newline; // Next blast through the result array and build out the rows @@ -248,7 +248,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out),0,-strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines + $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines $out = rtrim($out).$newline; } -- cgit v1.2.3-24-g4f1b From f5b4f6a156cddbed81ee4c4c6c3484507fa58ac5 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 28 Feb 2013 22:17:51 +0100 Subject: Text helper: convert_accented_characters() optimization Thanks to static variables, array_keys() and array_values() are now executed once only. --- system/helpers/text_helper.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 54db14f94..b2351db95 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -363,9 +363,9 @@ if ( ! function_exists('convert_accented_characters')) */ function convert_accented_characters($str) { - static $_foreign_characters; + static $array_from, $array_to; - if ( ! is_array($_foreign_characters)) + if ( ! is_array($array_from)) { if (file_exists(APPPATH.'config/foreign_chars.php')) { @@ -379,14 +379,17 @@ if ( ! function_exists('convert_accented_characters')) if (empty($foreign_characters) OR ! is_array($foreign_characters)) { - $_foreign_characters = array(); + $array_from = array(); + $array_to = array(); + return $str; } - $_foreign_characters = $foreign_characters; + $array_from = array_keys($foreign_characters); + $array_to = array_values($foreign_characters); } - return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str); + return preg_replace($array_from, $array_to, $str); } } -- cgit v1.2.3-24-g4f1b From d327c797027d4ccf3bb624d7f4edd10997e372ac Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 1 Mar 2013 16:28:58 +0200 Subject: Optimize changes from PR #2290 --- system/database/DB_utility.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index b270cdd4d..9f953d4ac 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -238,8 +238,7 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the column names - $out = $out.$newline; + $out = substr(rtrim($out), 0, -strlen($delim)).$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -248,8 +247,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)); // Remove the trailing delimiter character(s) at the end of the row lines - $out = rtrim($out).$newline; + $out = substr(rtrim($out), 0, -strlen($delim)).$newline; } return $out; -- cgit v1.2.3-24-g4f1b From 930d8ef0f04688e63cfcdaa6f0f7b073e7b644ff Mon Sep 17 00:00:00 2001 From: Daniel Robbins Date: Fri, 1 Mar 2013 21:36:48 -0500 Subject: Fix Session cookie driver storing untrimmed user agent string in the database causing set_userdata() calls to fail when $config['sess_match_useragent'] = TRUE Signed-off-by: Daniel Robbins --- system/libraries/Session/drivers/Session_cookie.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php index 057e5a1d1..0e8644102 100644 --- a/system/libraries/Session/drivers/Session_cookie.php +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -494,7 +494,7 @@ class CI_Session_cookie extends CI_Session_driver { $this->userdata = array( 'session_id' => $this->_make_sess_id(), 'ip_address' => $this->CI->input->ip_address(), - 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), + 'user_agent' => trim(substr($this->CI->input->user_agent(), 0, 120)), 'last_activity' => $this->now, ); -- cgit v1.2.3-24-g4f1b From 5780d8b2078126f8eb5738658fceadd38c66fe5b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Mar 2013 07:38:16 +0200 Subject: Fix #2298 --- system/database/DB_result.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/database/DB_result.php b/system/database/DB_result.php index a044fd5dc..41a851777 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -478,12 +478,9 @@ class CI_DB_result { return NULL; } - if (isset($result[$this->current_row + 1])) - { - ++$this->current_row; - } - - return $result[$this->current_row]; + return isset($result[$this->current_row + 1]) + ? $result[++$this->current_row] + : NULL; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b