From 5d69a6e8e096faa99fb838dabd7fe548213b0f26 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Oct 2013 15:34:47 +0200 Subject: Fix #2703 --- system/database/DB_forge.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index d52029ecd..f156d24eb 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -740,6 +740,18 @@ abstract class CI_DB_forge { '_literal' => FALSE ); + if ($create_table === FALSE) + { + if (isset($attributes['AFTER'])) + { + $field['after'] = $attributes['after']; + } + elseif (isset($attributes['FIRST'])) + { + $field['first'] = (bool) $attributes['FIRST']; + } + } + $this->_attr_default($attributes, $field); if (isset($attributes['NULL'])) @@ -748,11 +760,15 @@ abstract class CI_DB_forge { { $field['null'] = empty($this->_null) ? '' : ' '.$this->_null; } - elseif ($create_table === TRUE) + else { $field['null'] = ' NOT NULL'; } } + elseif ($create_table === TRUE) + { + $field['null'] = ' NOT NULL'; + } $this->_attr_auto_increment($attributes, $field); $this->_attr_unique($attributes, $field); -- cgit v1.2.3-24-g4f1b From 96185a3a0edcc27fa0af6df761d6353a2208ea9d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Oct 2013 16:04:02 +0200 Subject: Really fix #2703 --- system/database/DB_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index f156d24eb..92806d305 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -744,7 +744,7 @@ abstract class CI_DB_forge { { if (isset($attributes['AFTER'])) { - $field['after'] = $attributes['after']; + $field['after'] = $attributes['AFTER']; } elseif (isset($attributes['FIRST'])) { -- cgit v1.2.3-24-g4f1b From 80d663aa81eec7bc0894efe1012faec7f6d452b0 Mon Sep 17 00:00:00 2001 From: Kakysha Date: Mon, 28 Oct 2013 01:39:17 +0400 Subject: Added option to connect through unix socket in redis cache driver --- system/libraries/Cache/drivers/Cache_redis.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 40823fcb4..8daed8bc3 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -44,6 +44,7 @@ class CI_Cache_redis extends CI_Driver * @var array */ protected static $_default_config = array( + 'socket_type' => 'tcp', 'host' => '127.0.0.1', 'password' => NULL, 'port' => 6379, @@ -200,7 +201,13 @@ class CI_Cache_redis extends CI_Driver try { - $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + if ($config['socket_type'] === 'unix') + { + $v = $this->_redis->connect($config['socket']); + } else // tcp socket + { + $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + } } catch (RedisException $e) { -- cgit v1.2.3-24-g4f1b From 2d14673d1a513a372a5921775aa3987f8444477e Mon Sep 17 00:00:00 2001 From: Kakysha Date: Mon, 28 Oct 2013 20:20:24 +0400 Subject: Correct Redis connection troubleshooting --- system/libraries/Cache/drivers/Cache_redis.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 8daed8bc3..b0315a3ab 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -164,8 +164,7 @@ class CI_Cache_redis extends CI_Driver { if (extension_loaded('redis')) { - $this->_setup_redis(); - return TRUE; + return $this->_setup_redis(); } else { @@ -206,18 +205,26 @@ class CI_Cache_redis extends CI_Driver $v = $this->_redis->connect($config['socket']); } else // tcp socket { - $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + $v = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + } + if (!$v) + { + log_message('debug','Redis connection refused. Check the config.'); + return FALSE; } } catch (RedisException $e) { - show_error('Redis connection refused. ' . $e->getMessage()); + log_message('debug','Redis connection refused. ' . $e->getMessage()); + return FALSE; } if (isset($config['password'])) { $this->_redis->auth($config['password']); } + + return TRUE; } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From ffe2130b00bffb2f43debf82c34586642c831b0b Mon Sep 17 00:00:00 2001 From: Kakysha Date: Mon, 28 Oct 2013 21:30:05 +0400 Subject: some code rewrite --- system/libraries/Cache/drivers/Cache_redis.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index b0315a3ab..0bbd5b05c 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -202,12 +202,12 @@ class CI_Cache_redis extends CI_Driver { if ($config['socket_type'] === 'unix') { - $v = $this->_redis->connect($config['socket']); + $success = $this->_redis->connect($config['socket']); } else // tcp socket { - $v = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); } - if (!$v) + if ( ! $success) { log_message('debug','Redis connection refused. Check the config.'); return FALSE; -- cgit v1.2.3-24-g4f1b From 8f3f1f9a6dd7c4feb77ffc040b37799fc101e470 Mon Sep 17 00:00:00 2001 From: Kakysha Date: Mon, 28 Oct 2013 23:14:08 +0400 Subject: Code cleanup --- system/libraries/Cache/drivers/Cache_redis.php | 6 ++++-- 1 file changed, 4 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 0bbd5b05c..194745fe0 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -203,10 +203,12 @@ class CI_Cache_redis extends CI_Driver if ($config['socket_type'] === 'unix') { $success = $this->_redis->connect($config['socket']); - } else // tcp socket + } + else // tcp socket { $success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']); } + if ( ! $success) { log_message('debug','Redis connection refused. Check the config.'); @@ -215,7 +217,7 @@ class CI_Cache_redis extends CI_Driver } catch (RedisException $e) { - log_message('debug','Redis connection refused. ' . $e->getMessage()); + log_message('debug','Cache: Redis connection refused ('.$e->getMessage().')'); return FALSE; } -- cgit v1.2.3-24-g4f1b From 333b69b029c4d694f1f77aaefeb9c4deeeca47b9 Mon Sep 17 00:00:00 2001 From: Kakysha Date: Tue, 29 Oct 2013 03:49:56 +0400 Subject: Spaces, log message --- system/libraries/Cache/drivers/Cache_redis.php | 4 ++-- 1 file changed, 2 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 194745fe0..f13e4479f 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -211,13 +211,13 @@ class CI_Cache_redis extends CI_Driver if ( ! $success) { - log_message('debug','Redis connection refused. Check the config.'); + log_message('debug', 'Cache: Redis connection refused. Check the config.'); return FALSE; } } catch (RedisException $e) { - log_message('debug','Cache: Redis connection refused ('.$e->getMessage().')'); + log_message('debug', 'Cache: Redis connection refused ('.$e->getMessage().')'); return FALSE; } -- cgit v1.2.3-24-g4f1b From 5e3d48c21dea8a97dcea1b820ebc14700a336312 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 29 Oct 2013 14:36:18 +0200 Subject: Fix a bug when multiple calls to QB's _compile_wh() or _compile_group_by() are required --- system/database/DB_query_builder.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index ebc9855bc..a73460394 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2291,7 +2291,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { for ($i = 0, $c = count($this->$qb_key); $i < $c; $i++) { - if ($this->{$qb_key}[$i]['escape'] === FALSE) + // Is this condition already compiled? + if (is_string($this->{$qb_key}[$i])) + { + continue; + } + elseif ($this->{$qb_key}[$i]['escape'] === FALSE) { $this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition']; continue; @@ -2361,6 +2366,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { for ($i = 0, $c = count($this->qb_groupby); $i < $c; $i++) { + // Is it already compiled? + if (is_string($this->qb_groupby)) + { + continue; + } + $this->qb_groupby[$i] = ($this->qb_groupby[$i]['escape'] === FALSE OR $this->_is_literal($this->qb_groupby[$i]['field'])) ? $this->qb_groupby[$i]['field'] : $this->protect_identifiers($this->qb_groupby[$i]['field']); -- cgit v1.2.3-24-g4f1b