From 6b620fb7e61f1051f5bced189d1b57bd30a97126 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 20 Apr 2015 12:46:46 +0300 Subject: [ci skip] Remove whitespace --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index a81e45500..b850fd39a 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -749,7 +749,7 @@ if ( ! function_exists('html_escape')) { return $var; } - + if (is_array($var)) { return array_map('html_escape', $var, array_fill(0, count($var), $double_encode)); -- cgit v1.2.3-24-g4f1b From d3913f591353d17954ee900f2524f24c1833af85 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 20 Apr 2015 14:47:00 +0300 Subject: Fix #3787 --- system/libraries/Ftp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index af45bb55f..b53207577 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -490,7 +490,7 @@ class CI_FTP { // so we'll recursively call delete_dir() if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->conn_id, $list[$i])) { - $this->delete_dir($list[$i]); + $this->delete_dir($filepath.$list[$i]); } } } -- cgit v1.2.3-24-g4f1b From 24812132d7aa039bbdca1f150a850dc776ce7bd7 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Thu, 23 Apr 2015 15:11:03 -0400 Subject: Updates the fallback driver variable name to match the config option name. --- system/libraries/Cache/Cache.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 40ac70103..fd49f33ab 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -81,7 +81,7 @@ class CI_Cache extends CI_Driver_Library { * * @var string */ - protected $_backup_driver = 'dummy'; + protected $_backup = 'dummy'; /** * Cache key prefix @@ -119,23 +119,23 @@ class CI_Cache extends CI_Driver_Library { if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) { - $this->_backup_driver = $config['backup']; + $this->_backup = $config['backup']; } // If the specified adapter isn't available, check the backup. if ( ! $this->is_supported($this->_adapter)) { - if ( ! $this->is_supported($this->_backup_driver)) + if ( ! $this->is_supported($this->_backup)) { // Backup isn't supported either. Default to 'Dummy' driver. - log_message('error', 'Cache adapter "'.$this->_adapter.'" and backup "'.$this->_backup_driver.'" are both unavailable. Cache is now using "Dummy" adapter.'); + log_message('error', 'Cache adapter "'.$this->_adapter.'" and backup "'.$this->_backup.'" are both unavailable. Cache is now using "Dummy" adapter.'); $this->_adapter = 'dummy'; } 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; + log_message('debug', 'Cache adapter "'.$this->_adapter.'" is unavailable. Falling back to "'.$this->_backup.'" backup adapter.'); + $this->_adapter = $this->_backup; } } } -- cgit v1.2.3-24-g4f1b From 229a546efbbc0e6d70c2ea764d74b9c1c57516c2 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Thu, 23 Apr 2015 15:38:06 -0400 Subject: Cache Library Defaults Fixed - Comments! - Updates the cache library to validate *both* adapters. - No longer attempts to set an undefined "memcached" class variable. - $key variable renamed to $driver_type (more descriptive). --- system/libraries/Cache/Cache.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index fd49f33ab..5d32240ce 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -100,28 +100,19 @@ class CI_Cache extends CI_Driver_Library { */ public function __construct($config = array()) { - $default_config = array( - 'adapter', - 'memcached' - ); - - foreach ($default_config as $key) + // Loop through the available driver types and overwrite them as they're found. + foreach (array('adapter', 'backup') as $driver_type) { - if (isset($config[$key])) + if (isset($config[$driver_type]) && in_array($config[$driver_type], $this->valid_drivers)) { - $param = '_'.$key; - - $this->{$param} = $config[$key]; + $option = '_'.$driver_type; + $this->{$option} = $config[$driver_type]; } } + // Overwrite the default key prefix. isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; - if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) - { - $this->_backup = $config['backup']; - } - // If the specified adapter isn't available, check the backup. if ( ! $this->is_supported($this->_adapter)) { -- cgit v1.2.3-24-g4f1b From bf2ca381da2f63439f23df91369a68dccae6ea4b Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Thu, 23 Apr 2015 15:44:37 -0400 Subject: Renames $_adapter to $_driver. It's what we call it everywhere else. --- system/libraries/Cache/Cache.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 5d32240ce..39d05d930 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -74,7 +74,7 @@ class CI_Cache extends CI_Driver_Library { * * @var mixed */ - protected $_adapter = 'dummy'; + protected $_driver = 'dummy'; /** * Fallback driver @@ -114,19 +114,19 @@ class CI_Cache extends CI_Driver_Library { isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; // If the specified adapter isn't available, check the backup. - if ( ! $this->is_supported($this->_adapter)) + if ( ! $this->is_supported($this->_driver)) { if ( ! $this->is_supported($this->_backup)) { // Backup isn't supported either. Default to 'Dummy' driver. - log_message('error', 'Cache adapter "'.$this->_adapter.'" and backup "'.$this->_backup.'" are both unavailable. Cache is now using "Dummy" adapter.'); - $this->_adapter = 'dummy'; + log_message('error', 'Cache adapter "'.$this->_driver.'" and backup "'.$this->_backup.'" are both unavailable. Cache is now using "Dummy" adapter.'); + $this->_driver = 'dummy'; } else { // Backup is supported. Set it to primary. - log_message('debug', 'Cache adapter "'.$this->_adapter.'" is unavailable. Falling back to "'.$this->_backup.'" backup adapter.'); - $this->_adapter = $this->_backup; + log_message('debug', 'Cache adapter "'.$this->_driver.'" is unavailable. Falling back to "'.$this->_backup.'" backup adapter.'); + $this->_driver = $this->_backup; } } } @@ -144,7 +144,7 @@ class CI_Cache extends CI_Driver_Library { */ public function get($id) { - return $this->{$this->_adapter}->get($this->key_prefix.$id); + return $this->{$this->_driver}->get($this->key_prefix.$id); } // ------------------------------------------------------------------------ @@ -160,7 +160,7 @@ class CI_Cache extends CI_Driver_Library { */ public function save($id, $data, $ttl = 60, $raw = FALSE) { - return $this->{$this->_adapter}->save($this->key_prefix.$id, $data, $ttl, $raw); + return $this->{$this->_driver}->save($this->key_prefix.$id, $data, $ttl, $raw); } // ------------------------------------------------------------------------ @@ -173,7 +173,7 @@ class CI_Cache extends CI_Driver_Library { */ public function delete($id) { - return $this->{$this->_adapter}->delete($this->key_prefix.$id); + return $this->{$this->_driver}->delete($this->key_prefix.$id); } // ------------------------------------------------------------------------ @@ -187,7 +187,7 @@ class CI_Cache extends CI_Driver_Library { */ public function increment($id, $offset = 1) { - return $this->{$this->_adapter}->increment($id, $offset); + return $this->{$this->_driver}->increment($id, $offset); } // ------------------------------------------------------------------------ @@ -201,7 +201,7 @@ class CI_Cache extends CI_Driver_Library { */ public function decrement($id, $offset = 1) { - return $this->{$this->_adapter}->decrement($id, $offset); + return $this->{$this->_driver}->decrement($id, $offset); } // ------------------------------------------------------------------------ @@ -213,7 +213,7 @@ class CI_Cache extends CI_Driver_Library { */ public function clean() { - return $this->{$this->_adapter}->clean(); + return $this->{$this->_driver}->clean(); } // ------------------------------------------------------------------------ @@ -226,7 +226,7 @@ class CI_Cache extends CI_Driver_Library { */ public function cache_info($type = 'user') { - return $this->{$this->_adapter}->cache_info($type); + return $this->{$this->_driver}->cache_info($type); } // ------------------------------------------------------------------------ @@ -239,7 +239,7 @@ class CI_Cache extends CI_Driver_Library { */ public function get_metadata($id) { - return $this->{$this->_adapter}->get_metadata($this->key_prefix.$id); + return $this->{$this->_driver}->get_metadata($this->key_prefix.$id); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From fd1bc2213f158ae9368a3d85dc108f641dd566bf Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Thu, 23 Apr 2015 23:21:08 +0300 Subject: Output cache: Fixing a wrong timestamp. Credits to khoggatt (CodeIgniter forum). --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 02f66936c..e7d559a1d 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -674,7 +674,7 @@ class CI_Output { $cache_info = unserialize($match[1]); $expire = $cache_info['expire']; - $last_modified = filemtime($cache_path); + $last_modified = filemtime($filepath); // Has the file expired? if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path)) -- cgit v1.2.3-24-g4f1b From 0416a7f859e1ee6df557644b36ca10cfd356d224 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Fri, 24 Apr 2015 10:25:38 -0400 Subject: Reverts previous variable renaming and removes the foreach loop in favor of a simple if condition. --- system/libraries/Cache/Cache.php | 47 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 39d05d930..73dec72ab 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -74,14 +74,14 @@ class CI_Cache extends CI_Driver_Library { * * @var mixed */ - protected $_driver = 'dummy'; + protected $_adapter = 'dummy'; /** * Fallback driver * * @var string */ - protected $_backup = 'dummy'; + protected $_backup_driver = 'dummy'; /** * Cache key prefix @@ -100,33 +100,32 @@ class CI_Cache extends CI_Driver_Library { */ public function __construct($config = array()) { - // Loop through the available driver types and overwrite them as they're found. - foreach (array('adapter', 'backup') as $driver_type) + if (isset($config['adapter']) && in_array($config['adapter'], $this->valid_drivers)) { - if (isset($config[$driver_type]) && in_array($config[$driver_type], $this->valid_drivers)) - { - $option = '_'.$driver_type; - $this->{$option} = $config[$driver_type]; - } + $this->_adapter = $config['adapter']; + } + + if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) + { + $this->_backup_driver = $config['backup']; } - // Overwrite the default key prefix. isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; // If the specified adapter isn't available, check the backup. - if ( ! $this->is_supported($this->_driver)) + if ( ! $this->is_supported($this->_adapter)) { - if ( ! $this->is_supported($this->_backup)) + if ( ! $this->is_supported($this->_backup_driver)) { // Backup isn't supported either. Default to 'Dummy' driver. - log_message('error', 'Cache adapter "'.$this->_driver.'" and backup "'.$this->_backup.'" are both unavailable. Cache is now using "Dummy" adapter.'); - $this->_driver = 'dummy'; + log_message('error', 'Cache adapter "'.$this->_adapter.'" and backup "'.$this->_backup_driver.'" are both unavailable. Cache is now using "Dummy" adapter.'); + $this->_adapter = 'dummy'; } else { // Backup is supported. Set it to primary. - log_message('debug', 'Cache adapter "'.$this->_driver.'" is unavailable. Falling back to "'.$this->_backup.'" backup adapter.'); - $this->_driver = $this->_backup; + log_message('debug', 'Cache adapter "'.$this->_adapter.'" is unavailable. Falling back to "'.$this->_backup_driver.'" backup adapter.'); + $this->_adapter = $this->_backup_driver; } } } @@ -144,7 +143,7 @@ class CI_Cache extends CI_Driver_Library { */ public function get($id) { - return $this->{$this->_driver}->get($this->key_prefix.$id); + return $this->{$this->_adapter}->get($this->key_prefix.$id); } // ------------------------------------------------------------------------ @@ -160,7 +159,7 @@ class CI_Cache extends CI_Driver_Library { */ public function save($id, $data, $ttl = 60, $raw = FALSE) { - return $this->{$this->_driver}->save($this->key_prefix.$id, $data, $ttl, $raw); + return $this->{$this->_adapter}->save($this->key_prefix.$id, $data, $ttl, $raw); } // ------------------------------------------------------------------------ @@ -173,7 +172,7 @@ class CI_Cache extends CI_Driver_Library { */ public function delete($id) { - return $this->{$this->_driver}->delete($this->key_prefix.$id); + return $this->{$this->_adapter}->delete($this->key_prefix.$id); } // ------------------------------------------------------------------------ @@ -187,7 +186,7 @@ class CI_Cache extends CI_Driver_Library { */ public function increment($id, $offset = 1) { - return $this->{$this->_driver}->increment($id, $offset); + return $this->{$this->_adapter}->increment($id, $offset); } // ------------------------------------------------------------------------ @@ -201,7 +200,7 @@ class CI_Cache extends CI_Driver_Library { */ public function decrement($id, $offset = 1) { - return $this->{$this->_driver}->decrement($id, $offset); + return $this->{$this->_adapter}->decrement($id, $offset); } // ------------------------------------------------------------------------ @@ -213,7 +212,7 @@ class CI_Cache extends CI_Driver_Library { */ public function clean() { - return $this->{$this->_driver}->clean(); + return $this->{$this->_adapter}->clean(); } // ------------------------------------------------------------------------ @@ -226,7 +225,7 @@ class CI_Cache extends CI_Driver_Library { */ public function cache_info($type = 'user') { - return $this->{$this->_driver}->cache_info($type); + return $this->{$this->_adapter}->cache_info($type); } // ------------------------------------------------------------------------ @@ -239,7 +238,7 @@ class CI_Cache extends CI_Driver_Library { */ public function get_metadata($id) { - return $this->{$this->_driver}->get_metadata($this->key_prefix.$id); + return $this->{$this->_adapter}->get_metadata($this->key_prefix.$id); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From b7661228c22c180cdf289300c88825dafeda39d9 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Mon, 27 Apr 2015 11:54:08 -0400 Subject: Adds error-level log messages when invalid adapters are set. --- system/libraries/Cache/Cache.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 73dec72ab..ff68a4fd8 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -104,11 +104,19 @@ class CI_Cache extends CI_Driver_Library { { $this->_adapter = $config['adapter']; } + elseif (! in_array($config['adapter'], $this->valid_drivers)) + { + log_message('error', 'Cache adapter "'.$config['adapter'].'" is invalid.'); + } if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) { $this->_backup_driver = $config['backup']; } + elseif (! in_array($config['backup'], $this->valid_drivers)) + { + log_message('error', 'Cache backup adapter "'.$config['backup'].'" is invalid.'); + } isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; -- cgit v1.2.3-24-g4f1b From ef0173db881f326db14e00cb333b9059349fc9a3 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Tue, 28 Apr 2015 10:33:05 -0400 Subject: Removed extra adapter validation. Adapter validation already happens in the system Driver library. --- system/libraries/Cache/Cache.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index ff68a4fd8..215a7c528 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -100,24 +100,8 @@ class CI_Cache extends CI_Driver_Library { */ public function __construct($config = array()) { - if (isset($config['adapter']) && in_array($config['adapter'], $this->valid_drivers)) - { - $this->_adapter = $config['adapter']; - } - elseif (! in_array($config['adapter'], $this->valid_drivers)) - { - log_message('error', 'Cache adapter "'.$config['adapter'].'" is invalid.'); - } - - if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers)) - { - $this->_backup_driver = $config['backup']; - } - elseif (! in_array($config['backup'], $this->valid_drivers)) - { - log_message('error', 'Cache backup adapter "'.$config['backup'].'" is invalid.'); - } - + isset($config['adapter']) && $this->_adapter = $config['adapter']; + isset($config['backup']) && $this->_backup_driver = $config['backup']; isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix']; // If the specified adapter isn't available, check the backup. -- cgit v1.2.3-24-g4f1b From b137d232ef895cc47da4e39dfcb7c9078ba6be2b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Apr 2015 11:44:38 +0300 Subject: Fix #3816 --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bb872c7cc..7599602c0 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -461,7 +461,7 @@ class CI_Form_validation { { $this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']); } - elseif (isset($validation_array[$field]) && $validation_array[$field] !== '') + elseif (isset($validation_array[$field])) { $this->_field_data[$field]['postdata'] = $validation_array[$field]; } -- cgit v1.2.3-24-g4f1b From 0f8509025d2338dc069ddf42b6ade974a5da0ca3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Apr 2015 12:33:11 +0300 Subject: Add list_fields() support for SQLite3 --- system/database/DB_driver.php | 2 +- .../drivers/pdo/subdrivers/pdo_sqlite_driver.php | 30 ++++++++++++++++------ system/database/drivers/sqlite3/sqlite3_driver.php | 30 ++++++++++++++++------ 3 files changed, 45 insertions(+), 17 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 3d35c2d70..64ee880c8 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1218,7 +1218,7 @@ abstract class CI_DB_driver { /** * Fetch Field Names * - * @param string the table name + * @param string $table Table name * @return array */ public function list_fields($table) diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php index f07f49f84..d5ca741fd 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php @@ -121,17 +121,31 @@ class CI_DB_pdo_sqlite_driver extends CI_DB_pdo_driver { // -------------------------------------------------------------------- /** - * Show column query + * Fetch Field Names * - * Generates a platform-specific query string so that the column names can be fetched - * - * @param string $table - * @return string + * @param string $table Table name + * @return array */ - protected function _list_columns($table = '') + public function list_fields($table) { - // Not supported - return FALSE; + // Is there a cached result? + if (isset($this->data_cache['field_names'][$table])) + { + return $this->data_cache['field_names'][$table]; + } + + if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $this->data_cache['field_names'][$table] = array(); + foreach ($result as $row) + { + $this->data_cache['field_names'][$table][] = $row['name']; + } + + return $this->data_cache['field_names'][$table]; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index fdbe94939..a7c6420bb 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -247,17 +247,31 @@ class CI_DB_sqlite3_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Show column query + * Fetch Field Names * - * Generates a platform-specific query string so that the column names can be fetched - * - * @param string $table - * @return string + * @param string $table Table name + * @return array */ - protected function _list_columns($table = '') + public function list_fields($table) { - // Not supported - return FALSE; + // Is there a cached result? + if (isset($this->data_cache['field_names'][$table])) + { + return $this->data_cache['field_names'][$table]; + } + + if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $this->data_cache['field_names'][$table] = array(); + foreach ($result as $row) + { + $this->data_cache['field_names'][$table][] = $row['name']; + } + + return $this->data_cache['field_names'][$table]; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 73b9e851a96dcafc0c07a0d0480853e31ba48e59 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 30 Apr 2015 13:06:40 +0300 Subject: Fix #3823 --- system/libraries/Session/drivers/Session_memcached_driver.php | 2 +- system/libraries/Session/drivers/Session_redis_driver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Session/drivers/Session_memcached_driver.php b/system/libraries/Session/drivers/Session_memcached_driver.php index c7185ee44..97b860588 100644 --- a/system/libraries/Session/drivers/Session_memcached_driver.php +++ b/system/libraries/Session/drivers/Session_memcached_driver.php @@ -322,7 +322,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa $this->_lock_key = $lock_key; break; } - while ($attempt++ < 30); + while (++$attempt < 30); if ($attempt === 30) { diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php index 1ce101daf..b098cc441 100644 --- a/system/libraries/Session/drivers/Session_redis_driver.php +++ b/system/libraries/Session/drivers/Session_redis_driver.php @@ -336,7 +336,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle $this->_lock_key = $lock_key; break; } - while ($attempt++ < 30); + while (++$attempt < 30); if ($attempt === 30) { -- cgit v1.2.3-24-g4f1b From 170ae282338584ebe257d2fb21101ccf84a3f800 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 May 2015 10:43:28 +0300 Subject: Issue/PR #3836 --- system/libraries/Cache/drivers/Cache_redis.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index b940b76cb..773d20c43 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -165,7 +165,9 @@ class CI_Cache_redis extends CI_Driver */ public function increment($id, $offset = 1) { - return $this->_redis->incr($id, $offset); + return ($offset == 1) + ? $this->_redis->incr($id) + : $this->_redis->incrBy($id, $offset); } // ------------------------------------------------------------------------ @@ -179,7 +181,9 @@ class CI_Cache_redis extends CI_Driver */ public function decrement($id, $offset = 1) { - return $this->_redis->decr($id, $offset); + return ($offset == 1) + ? $this->_redis->decr($id) + : $this->_redis->decrBy($id, $offset); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 70f738a14b0f6f70d9292c0f488ea423a76f438e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 May 2015 12:16:33 +0300 Subject: Revert "Issue/PR #3836" This reverts commit 170ae282338584ebe257d2fb21101ccf84a3f800. --- system/libraries/Cache/drivers/Cache_redis.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 773d20c43..b940b76cb 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -165,9 +165,7 @@ class CI_Cache_redis extends CI_Driver */ public function increment($id, $offset = 1) { - return ($offset == 1) - ? $this->_redis->incr($id) - : $this->_redis->incrBy($id, $offset); + return $this->_redis->incr($id, $offset); } // ------------------------------------------------------------------------ @@ -181,9 +179,7 @@ class CI_Cache_redis extends CI_Driver */ public function decrement($id, $offset = 1) { - return ($offset == 1) - ? $this->_redis->decr($id) - : $this->_redis->decrBy($id, $offset); + return $this->_redis->decr($id, $offset); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From fbde2798688ab99cfe3fdd22746d60f0877b2c27 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 May 2015 11:03:06 +0300 Subject: Fix #3846 --- system/libraries/Image_lib.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index e056654bb..6374aacdd 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1055,8 +1055,11 @@ class CI_Image_lib { if ($this->rotation_angle === 'hor') { - for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1) + for ($i = 0; $i < $height; $i++) { + $left = 0; + $right = $width - 1; + while ($left < $right) { $cl = imagecolorat($src_img, $left, $i); @@ -1072,18 +1075,21 @@ class CI_Image_lib { } else { - for ($i = 0; $i < $width; $i++, $top = 0, $bot = $height-1) + for ($i = 0; $i < $width; $i++) { - while ($top < $bot) + $top = 0; + $bottom = $height - 1; + + while ($top < $botttom) { $ct = imagecolorat($src_img, $i, $top); - $cb = imagecolorat($src_img, $i, $bot); + $cb = imagecolorat($src_img, $i, $bottom); imagesetpixel($src_img, $i, $top, $cb); - imagesetpixel($src_img, $i, $bot, $ct); + imagesetpixel($src_img, $i, $bottom, $ct); $top++; - $bot--; + $bottom--; } } } -- cgit v1.2.3-24-g4f1b From 5d78fd839120419ba7c0642f120313543af99b99 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 May 2015 18:19:01 +0300 Subject: Fix an undefined variable error from fbde2798688ab99cfe3fdd22746d60f0877b2c27 --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 6374aacdd..ce6c42b02 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1080,7 +1080,7 @@ class CI_Image_lib { $top = 0; $bottom = $height - 1; - while ($top < $botttom) + while ($top < $bottom) { $ct = imagecolorat($src_img, $i, $top); $cb = imagecolorat($src_img, $i, $bottom); -- cgit v1.2.3-24-g4f1b From b4f3630ae5240d085cf4283b82546005002e59e4 Mon Sep 17 00:00:00 2001 From: ftwbzhao Date: Wed, 13 May 2015 17:47:41 +0800 Subject: [Cache]minor adjustments for save function --- system/libraries/Cache/drivers/Cache_redis.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index b940b76cb..66966ba16 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -125,9 +125,7 @@ class CI_Cache_redis extends CI_Driver $this->_redis->sRemove('_ci_redis_serialized', $id); } - return ($ttl) - ? $this->_redis->setex($id, $ttl, $data) - : $this->_redis->set($id, $data); + return $this->_redis->set($id, $data, $ttl); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 4c08ea9c69aeb4acc1fbe47e873a11e82a6d5b79 Mon Sep 17 00:00:00 2001 From: Leandro Mangini Antunes Date: Wed, 13 May 2015 11:15:01 -0300 Subject: Fixed bug - using field_data() on Oracle databases When you're using oracle databases and want to retrieve column information through the function field_data($table) you get the following notice: - Notice: Undefined property: stdClass::$COLUMN_DEFAULT in system/database/drivers/oci8/oci8_driver.php on line 576; This happens because the oci8 driver tries to access a property that does not exist on query used to get field information. Checking the code we see a small validation to set default value, but the variable $default is not used. So we fix this bug by simply changing: $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; to $retval[$i]->default = $default; Bug fixed. No more notices and the properly value is set. --- system/database/drivers/oci8/oci8_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 4010995a1..b5cf26536 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -573,7 +573,7 @@ class CI_DB_oci8_driver extends CI_DB { { $default = ''; } - $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + $retval[$i]->default = $default; } return $retval; -- cgit v1.2.3-24-g4f1b From b8978ee517fab43fea511869337ac40b577f00a3 Mon Sep 17 00:00:00 2001 From: ftwbzhao Date: Wed, 20 May 2015 16:10:35 +0800 Subject: optimize migrations class reference --- system/libraries/Migration.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index ae36a3b45..e17f41696 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -191,7 +191,7 @@ class CI_Migration { * choice * * @param string $target_version Target schema version - * @return mixed TRUE if already latest, FALSE if failed, string if upgraded + * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure */ public function version($target_version) { @@ -294,7 +294,7 @@ class CI_Migration { /** * Sets the schema to the latest migration * - * @return mixed TRUE if already latest, FALSE if failed, string if upgraded + * @return mixed current version string on success, FALSE on failure */ public function latest() { @@ -318,7 +318,7 @@ class CI_Migration { /** * Sets the schema to the migration version set in config * - * @return mixed TRUE if already current, FALSE if failed, string if upgraded + * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure */ public function current() { -- cgit v1.2.3-24-g4f1b From 3a1975956dfd99dd2cab05e530c8aecb0984b4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 May 2015 01:05:06 +0300 Subject: [ci skip] Trim some whitespace from Image_lib --- system/libraries/Image_lib.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index ce6c42b02..c69283a7c 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -845,7 +845,7 @@ class CI_Image_lib { */ public function image_process_imagemagick($action = 'resize') { - // Do we have a vaild library path? + // Do we have a vaild library path? if ($this->library_path === '') { $this->set_error('imglib_libpath_invalid'); @@ -1010,7 +1010,7 @@ class CI_Image_lib { // going to have to figure out how to determine the color // of the alpha channel in a future release. - $white = imagecolorallocate($src_img, 255, 255, 255); + $white = imagecolorallocate($src_img, 255, 255, 255); // Rotate it! $dst_img = imagerotate($src_img, $this->rotation_angle, $white); @@ -1333,7 +1333,7 @@ class CI_Image_lib { { $y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight / 2); } - + // Set horizontal alignment if ($this->wm_hor_alignment === 'R') { @@ -1343,13 +1343,13 @@ class CI_Image_lib { { $x_axis += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2); } - + if ($this->wm_use_drop_shadow) { // Offset from text $x_shad = $x_axis + $this->wm_shadow_distance; $y_shad = $y_axis + $this->wm_shadow_distance; - + /* Set RGB values for shadow * * First character is #, so we don't really need it. @@ -1358,7 +1358,7 @@ class CI_Image_lib { */ $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2])); - + // Add the shadow to the source image if ($this->wm_use_truetype) { @@ -1369,7 +1369,7 @@ class CI_Image_lib { imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); } } - + /* Set RGB values for text * * First character is #, so we don't really need it. @@ -1388,7 +1388,7 @@ class CI_Image_lib { { imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } - + // We can preserve transparency for PNG images if ($this->image_type === 3) { @@ -1437,7 +1437,7 @@ class CI_Image_lib { switch ($image_type) { - case 1 : + case 1: if ( ! function_exists('imagecreatefromgif')) { $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported')); @@ -1445,7 +1445,7 @@ class CI_Image_lib { } return imagecreatefromgif($path); - case 2 : + case 2: if ( ! function_exists('imagecreatefromjpeg')) { $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported')); @@ -1453,7 +1453,7 @@ class CI_Image_lib { } return imagecreatefromjpeg($path); - case 3 : + case 3: if ( ! function_exists('imagecreatefrompng')) { $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported')); -- cgit v1.2.3-24-g4f1b From b8cd5e657363795f127ae5e02e69972627b3fe9c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 May 2015 01:10:36 +0300 Subject: Fix a bug in the CSV export DB utility Reported via the forums: http://forum.codeigniter.com/thread-61810.html --- 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 57356ac53..78398ea83 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -249,7 +249,7 @@ abstract class CI_DB_utility { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + $out = substr($out, 0, -strlen($delim)).$newline; // Next blast through the result array and build out the rows while ($row = $query->unbuffered_row('array')) @@ -258,7 +258,7 @@ abstract class CI_DB_utility { { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } - $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + $out = substr($out, 0, -strlen($delim)).$newline; } return $out; -- cgit v1.2.3-24-g4f1b From 8d132bb1e999c2b2bdc2125d6d4ec36649556fc7 Mon Sep 17 00:00:00 2001 From: ftwbzhao Date: Thu, 21 May 2015 20:28:54 +0800 Subject: update function latest --- system/libraries/Migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index e17f41696..45a3cbbce 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -294,7 +294,7 @@ class CI_Migration { /** * Sets the schema to the latest migration * - * @return mixed current version string on success, FALSE on failure + * @return mixed Current version string on success, FALSE on failure */ public function latest() { -- cgit v1.2.3-24-g4f1b From b76394834a3e36e8c376913cd9666a8d7a4cea45 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 8 Jun 2015 14:44:47 +0300 Subject: Fix #3890 --- system/core/Input.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 12332cf51..b0bbb7b8d 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -799,19 +799,27 @@ class CI_Input { */ public function get_request_header($index, $xss_clean = FALSE) { - if (empty($this->headers)) + static $headers; + + if ( ! isset($headers)) { - $this->request_headers(); + empty($this->headers) OR $this->request_headers(); + foreach ($this->headers as $key => $value) + { + $headers[strtolower($key)] = $value; + } } - if ( ! isset($this->headers[$index])) + $index = strtolower($index); + + if ( ! isset($headers[$index])) { return NULL; } return ($xss_clean === TRUE) - ? $this->security->xss_clean($this->headers[$index]) - : $this->headers[$index]; + ? $this->security->xss_clean($headers[$index]) + : $headers[$index]; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b