From 763b7703ee744b65878bbf721fce3e5ec4dfac82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Jun 2017 10:26:33 +0300 Subject: [ci skip] Merge pull request #5162 from hex-ci/patch-3 Fix a spelling typo in security docs --- user_guide_src/source/libraries/security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index fc5cba19d..868112684 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -107,7 +107,7 @@ Class Reference If the optional second parameter is set to true, it will return boolean TRUE if the image is safe to use and FALSE if malicious data was detected in it. - .. important:: This method is not suitable for filtering HTML attribute vales! + .. important:: This method is not suitable for filtering HTML attribute values! Use :php:func:`html_escape()` for that instead. .. php:method:: sanitize_filename($str[, $relative_path = FALSE]) -- cgit v1.2.3-24-g4f1b From 894a3f2c9fe111af35dee4f5e8e711259b893fb6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Jun 2017 16:31:17 +0300 Subject: Fix #5164 --- system/core/Loader.php | 41 +++++++++++++++++++------------------ user_guide_src/source/changelog.rst | 5 +++++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 5ed6adb48..7be5fd41b 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1037,6 +1037,26 @@ class CI_Loader { return $this->_ci_load_stock_library($class, $subdir, $params, $object_name); } + // Safety: Was the class already loaded by a previous call? + if (class_exists($class, FALSE)) + { + $property = $object_name; + if ( ! isset($property)) + { + $property = strtolower($class); + isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$object_name]; + } + + $CI =& get_instance(); + if (isset($CI->$property)) + { + log_message('debug', $class.' class already loaded. Second attempt ignored.'); + return; + } + + return $this->_ci_init_library($class, '', $params, $object_name); + } + // Let's search for the requested library file and load it. foreach ($this->_ci_library_paths as $path) { @@ -1047,27 +1067,8 @@ class CI_Loader { } $filepath = $path.'libraries/'.$subdir.$class.'.php'; - - // Safety: Was the class already loaded by a previous call? - if (class_exists($class, FALSE)) - { - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) - { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_library($class, '', $params, $object_name); - } - } - - log_message('debug', $class.' class already loaded. Second attempt ignored.'); - return; - } // Does the file exist? No? Bummer... - elseif ( ! file_exists($filepath)) + if ( ! file_exists($filepath)) { continue; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 3012b9eb2..fd7485f64 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -8,6 +8,11 @@ Version 3.1.6 Release Date: Not Released +Bug fixes for 3.1.6 +------------------- + +- Fixed a bug (#5164) - :doc:`Loader Library ` method ``library()`` ignored requests to load libraries previously assigned to super-object properties named differently than the library name. + Version 3.1.5 ============= -- cgit v1.2.3-24-g4f1b From db89c20721b3b66671db9ff4d3b6c9a6de352533 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Jun 2017 11:18:24 +0300 Subject: Correct fix for #5164 894a3f2c9fe111af35dee4f5e8e711259b893fb6 --- 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 7be5fd41b..cae01ed38 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1044,7 +1044,7 @@ class CI_Loader { if ( ! isset($property)) { $property = strtolower($class); - isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$object_name]; + isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property]; } $CI =& get_instance(); -- cgit v1.2.3-24-g4f1b From be0280d02a408a8b4aeb6aee10d9dd936f978ce2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Jun 2017 11:49:01 +0300 Subject: #5164 fix for stock libraries --- system/core/Loader.php | 21 +++++++++++---------- tests/codeigniter/core/Loader_test.php | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index cae01ed38..12922ca64 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1041,7 +1041,7 @@ class CI_Loader { if (class_exists($class, FALSE)) { $property = $object_name; - if ( ! isset($property)) + if (empty($property)) { $property = strtolower($class); isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property]; @@ -1113,16 +1113,17 @@ class CI_Loader { $prefix = config_item('subclass_prefix'); } - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) + $property = $object_name; + if (empty($property)) { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_library($library_name, $prefix, $params, $object_name); - } + $property = strtolower($library_name); + isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property]; + } + + $CI =& get_instance(); + if ( ! isset($CI->$property)) + { + return $this->_ci_init_library($library_name, $prefix, $params, $object_name); } log_message('debug', $library_name.' class already loaded. Second attempt ignored.'); diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 241c415b3..8c5bb3021 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -99,7 +99,7 @@ class Loader_test extends CI_TestCase { // Test reloading unset($this->ci_obj->$name); $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); - $this->assertObjectNotHasAttribute($name, $this->ci_obj); + $this->assertObjectHasAttribute($name, $this->ci_obj); // Create baseless library $name = 'ext_baseless_lib'; -- cgit v1.2.3-24-g4f1b From c58b005c5497419dd7ab79fc29ac7e5344c95039 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Jun 2017 11:50:27 +0300 Subject: [ci skip] Remove redundant elses from CI_Loader::_ci_load_stock_library() --- system/core/Loader.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 12922ca64..df93d591f 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1145,10 +1145,8 @@ class CI_Loader { { return $this->_ci_init_library($library_name, $prefix, $params, $object_name); } - else - { - log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name); - } + + log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name); } } @@ -1166,10 +1164,8 @@ class CI_Loader { $prefix = config_item('subclass_prefix'); break; } - else - { - log_message('debug', $path.' exists, but does not declare '.$subclass); - } + + log_message('debug', $path.' exists, but does not declare '.$subclass); } } -- cgit v1.2.3-24-g4f1b From 7af882026c476f2a64376512b33ff890d2792a8d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 3 Jul 2017 14:00:48 +0300 Subject: [ci skip] Drop application/cache/.htaccess; close #5169 --- .gitignore | 4 ++-- application/cache/.htaccess | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 application/cache/.htaccess diff --git a/.gitignore b/.gitignore index eb45390e9..96bce5941 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,11 @@ application/cache/* !application/cache/index.html -!application/cache/.htaccess application/logs/* !application/logs/index.html -!application/logs/.htaccess + +!application/*/.htaccess composer.lock diff --git a/application/cache/.htaccess b/application/cache/.htaccess deleted file mode 100644 index 6c63ed4c4..000000000 --- a/application/cache/.htaccess +++ /dev/null @@ -1,6 +0,0 @@ - - Require all denied - - - Deny from all - \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 59bae57503865f6dcea91fc20fd2729b2e79bb74 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 3 Jul 2017 14:13:08 +0300 Subject: [ci skip] Fix #5168 --- system/database/DB_query_builder.php | 14 ++++++-------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 9216651aa..7677f5b40 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1403,11 +1403,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // ORDER BY usage is often problematic here (most notably // on Microsoft SQL Server) and ultimately unnecessary // for selecting COUNT(*) ... - if ( ! empty($this->qb_orderby)) - { - $orderby = $this->qb_orderby; - $this->qb_orderby = NULL; - } + $qb_orderby = $this->qb_order_by; + $qb_cache_orderby = $this->qb_cache_orderby; + $this->qb_orderby = $this->qb_cache_orderby = NULL; $result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset) ? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results") @@ -1417,10 +1415,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $this->_reset_select(); } - // If we've previously reset the qb_orderby values, get them back - elseif ( ! isset($this->qb_orderby)) + else { - $this->qb_orderby = $orderby; + $this->qb_orderby = $qb_orderby; + $this->qb_cache_orderby = $qb_cache_orderby; } if ($result->num_rows() === 0) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index fd7485f64..77648a937 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -12,6 +12,7 @@ Bug fixes for 3.1.6 ------------------- - Fixed a bug (#5164) - :doc:`Loader Library ` method ``library()`` ignored requests to load libraries previously assigned to super-object properties named differently than the library name. +- Fixed a bug (#5168) - :doc:`Query Builder ` method ``count_all_results()`` produced erroneous queries on Microsoft SQL Server when ``ORDER BY`` clauses are cached. Version 3.1.5 ============= -- cgit v1.2.3-24-g4f1b From fdf4b59e7734e3417c745a651382dec8bf556ed0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 6 Jul 2017 11:49:13 +0300 Subject: [ci skip] Merge pull request #5170 from tianhe1986/develop_session_race_condition Decreasing the probability of race condition in session lock --- system/libraries/Session/drivers/Session_memcached_driver.php | 5 +++-- system/libraries/Session/drivers/Session_redis_driver.php | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/system/libraries/Session/drivers/Session_memcached_driver.php b/system/libraries/Session/drivers/Session_memcached_driver.php index 2556bf0f7..5e90539d7 100644 --- a/system/libraries/Session/drivers/Session_memcached_driver.php +++ b/system/libraries/Session/drivers/Session_memcached_driver.php @@ -310,7 +310,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa if ( ! $this->_memcached->replace($this->_lock_key, time(), 300)) { return ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND) - ? $this->_memcached->set($this->_lock_key, time(), 300) + ? $this->_memcached->add($this->_lock_key, time(), 300) : FALSE; } } @@ -326,7 +326,8 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa continue; } - if ( ! $this->_memcached->set($lock_key, time(), 300)) + $method = ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND) ? 'add' : 'set'; + if ( ! $this->_memcached->$method($lock_key, time(), 300)) { log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id); return FALSE; diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php index e220a2951..a9e655a8c 100644 --- a/system/libraries/Session/drivers/Session_redis_driver.php +++ b/system/libraries/Session/drivers/Session_redis_driver.php @@ -341,7 +341,11 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle continue; } - if ( ! $this->_redis->setex($lock_key, 300, time())) + $result = ($ttl === -2) + ? $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300)) + : $this->_redis->setex($lock_key, 300, time()); + + if ( ! $result) { log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id); return FALSE; -- cgit v1.2.3-24-g4f1b From 93d759dd84dc1eefb5f968d70177973a84c1df70 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 6 Jul 2017 11:54:16 +0300 Subject: [ci skip] Add changelog entry for PR #5170 --- user_guide_src/source/changelog.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 77648a937..b1dc618b2 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -7,6 +7,10 @@ Version 3.1.6 Release Date: Not Released +- General Changes + + - Updated the :doc:`Session Library ` 'redis', 'memcached' drivers to reduce the potential of a locking race conditions. + Bug fixes for 3.1.6 ------------------- -- cgit v1.2.3-24-g4f1b From 9bceb9c7c83082cd3d3aa2c96e5eb8c210890ade Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 6 Jul 2017 15:12:09 +0300 Subject: [ci skip] Merge pull request #5173 from Syafiqq/develop Add array identifier for library loader docblock --- 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 df93d591f..085c5b51d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -182,7 +182,7 @@ class CI_Loader { * Loads and instantiates libraries. * Designed to be called from application controllers. * - * @param string $library Library name + * @param mixed $library Library name * @param array $params Optional parameters to pass to the library class constructor * @param string $object_name An optional object name to assign to * @return object -- cgit v1.2.3-24-g4f1b From 9c068a1cfca6fbafb1013f0966207ac65bd120ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 10 Jul 2017 14:40:06 +0300 Subject: [ci skip] Merge pull request #5128 from lloricode/profiler-pre-tag Profiler add pre tag --- system/libraries/Profiler.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 9ea09a529..cb3eaed75 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -484,13 +484,19 @@ class CI_Profiler { foreach ($this->CI->config->config as $config => $val) { + $pre = ''; + $pre_close = ''; + if (is_array($val) OR is_object($val)) { $val = print_r($val, TRUE); + + $pre = '
' ;
+ 				$pre_close = '
'; } $output .= '' - .$config.'  '.htmlspecialchars($val, ENT_QUOTES, config_item('charset'))."\n"; + .$config.'  '.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."\n"; } return $output."\n"; @@ -516,13 +522,19 @@ class CI_Profiler { foreach ($this->CI->session->userdata() as $key => $val) { + $pre = ''; + $pre_close = ''; + if (is_array($val) OR is_object($val)) { $val = print_r($val, TRUE); + + $pre = '
' ;
+ 				$pre_close = '
'; } $output .= '' - .$key.'  '.htmlspecialchars($val, ENT_QUOTES, config_item('charset'))."\n"; + .$key.'  '.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."\n"; } return $output."\n"; -- cgit v1.2.3-24-g4f1b From e5b9f66a92c6352ca725520db4d9390247088a5a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 10 Jul 2017 14:42:14 +0300 Subject: [ci skip] Add changelog entry for #5128 --- 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 b1dc618b2..c6c339f07 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -17,6 +17,7 @@ Bug fixes for 3.1.6 - Fixed a bug (#5164) - :doc:`Loader Library ` method ``library()`` ignored requests to load libraries previously assigned to super-object properties named differently than the library name. - Fixed a bug (#5168) - :doc:`Query Builder ` method ``count_all_results()`` produced erroneous queries on Microsoft SQL Server when ``ORDER BY`` clauses are cached. +- Fixed a bug (#5128) - :doc:`Profiler ` didn't wrap ``$_SESSION`` and configuration arrays in ``
`` tags.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From 71a78c2c5ca485eac779622870a909091ec0a439 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 10 Jul 2017 14:51:08 +0300
Subject: [ci skip] Fix #5178 (regression caused by #5168)

---
 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 7677f5b40..81603bf31 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1403,7 +1403,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 		// ORDER BY usage is often problematic here (most notably
 		// on Microsoft SQL Server) and ultimately unnecessary
 		// for selecting COUNT(*) ...
-		$qb_orderby       = $this->qb_order_by;
+		$qb_orderby       = $this->qb_orderby;
 		$qb_cache_orderby = $this->qb_cache_orderby;
 		$this->qb_orderby = $this->qb_cache_orderby = NULL;
 
-- 
cgit v1.2.3-24-g4f1b


From 56e452ad93753754e16418f361930ef4d70f06e2 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 14 Jul 2017 13:05:48 +0300
Subject: [ci skip] Merge pull request #5183 from
 ytetsuro/add_oci8_driver_write_type

add is_write_type method for merge query
---
 system/database/DB_driver.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 3eb51f734..7efb37333 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1044,7 +1044,7 @@ abstract class CI_DB_driver {
 	 */
 	public function is_write_type($sql)
 	{
-		return (bool) preg_match('/^\s*"?(SET|INSERT|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|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX|MERGE)\s/i', $sql);
 	}
 
 	// --------------------------------------------------------------------
-- 
cgit v1.2.3-24-g4f1b


From 29740e442a1d78bd65b569c92575cdbf4fc2d614 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 14 Jul 2017 13:08:35 +0300
Subject: [ci skip] Add changelog entry for #5183

---
 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 c6c339f07..828c9d30d 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -18,6 +18,7 @@ Bug fixes for 3.1.6
 -  Fixed a bug (#5164) - :doc:`Loader Library ` method ``library()`` ignored requests to load libraries previously assigned to super-object properties named differently than the library name.
 -  Fixed a bug (#5168) - :doc:`Query Builder ` method ``count_all_results()`` produced erroneous queries on Microsoft SQL Server when ``ORDER BY`` clauses are cached.
 -  Fixed a bug (#5128) - :doc:`Profiler ` didn't wrap ``$_SESSION`` and configuration arrays in ``
`` tags.
+-  Fixed a bug (#5183) - :doc:`Database Library ` method ``is_write_type()`` didn't return TRUE for ``MERGE`` statements.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From 6cab78970f212a30ea923835510ffd1fb77a6ad0 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 17 Jul 2017 13:14:00 +0300
Subject: [ci skip] escapeshellarg on the image src path passed to NetPBM by
 Image_lib

---
 system/libraries/Image_lib.php      | 2 +-
 user_guide_src/source/changelog.rst | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 88c9e7ede..8786d9d02 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -972,7 +972,7 @@ class CI_Image_lib {
 			$cmd_inner = 'pnmscale -xysize '.$this->width.' '.$this->height;
 		}
 
-		$cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
+		$cmd = $this->library_path.$cmd_in.' '.escapeshellarg($this->full_src_path).' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
 
 		$retval = 1;
 		// exec() might be disabled
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 828c9d30d..d6984bb7b 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -19,6 +19,7 @@ Bug fixes for 3.1.6
 -  Fixed a bug (#5168) - :doc:`Query Builder ` method ``count_all_results()`` produced erroneous queries on Microsoft SQL Server when ``ORDER BY`` clauses are cached.
 -  Fixed a bug (#5128) - :doc:`Profiler ` didn't wrap ``$_SESSION`` and configuration arrays in ``
`` tags.
 -  Fixed a bug (#5183) - :doc:`Database Library ` method ``is_write_type()`` didn't return TRUE for ``MERGE`` statements.
+-  Fixed a bug where :doc:`Image Manipulation Library ` didn't escape image source paths passed to NetPBM as shell arguments.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From 954c4aac3211c5e04270c76b9f7ac11466638bef Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 21 Jul 2017 11:51:37 +0300
Subject: [ci skip] Merge pull request #5191 from jim-parry/patch/docs

Fix some mistakes in the user guide
---
 .gitignore                                       | 2 ++
 user_guide_src/source/database/query_builder.rst | 2 +-
 user_guide_src/source/general/urls.rst           | 6 +++---
 user_guide_src/source/libraries/input.rst        | 2 +-
 user_guide_src/source/libraries/loader.rst       | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 96bce5941..269044ea9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,5 @@ user_guide_src/cilexer/pycilexer.egg-info/*
 *.stTheme.cache
 *.sublime-workspace
 *.sublime-project
+/tests/tests/
+/tests/results/
diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
index 3135f76da..1b79c893a 100644
--- a/user_guide_src/source/database/query_builder.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -119,7 +119,7 @@ escaping of fields may break them.
 
 ::
 
-	$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);
+	$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4) AS amount_paid', FALSE);
 	$query = $this->db->get('mytable');
 
 **$this->db->select_max()**
diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst
index ca44e2f4c..e23554907 100644
--- a/user_guide_src/source/general/urls.rst
+++ b/user_guide_src/source/general/urls.rst
@@ -42,10 +42,10 @@ By default, the **index.php** file will be included in your URLs::
 If your Apache server has *mod_rewrite* enabled, you can easily remove this
 file by using a .htaccess file with some simple rules. Here is an example
 of such a file, using the "negative" method in which everything is redirected
-except the specified items:
-
-::
+except the specified items::
 	
+.. code-block:: console
+
 	RewriteEngine On
 	RewriteCond %{REQUEST_FILENAME} !-f
 	RewriteCond %{REQUEST_FILENAME} !-d
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index e7107fa06..300f47112 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -245,7 +245,7 @@ Class Reference
 		data::
 
 			$this->input->cookie('some_cookie');
-			$this->input->cookie('some_cookie, TRUE); // with XSS filter
+			$this->input->cookie('some_cookie', TRUE); // with XSS filter
 
 		To return an array of multiple cookie values, pass all the required keys
 		as an array.
diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst
index 228d5e478..22abb4586 100644
--- a/user_guide_src/source/libraries/loader.rst
+++ b/user_guide_src/source/libraries/loader.rst
@@ -125,7 +125,7 @@ Class Reference
 
 			$config = array (
 				'mailtype' => 'html',
-				'charset'  => 'utf-8,
+				'charset'  => 'utf-8',
 				'priority' => '1'
 			);
 
-- 
cgit v1.2.3-24-g4f1b


From 2f473195dcf6ed83fb31f90dce5b226f3e486ff0 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 21 Jul 2017 11:59:51 +0300
Subject: [ci skip] Merge pull request #5188 from
 ryanbriscall/update-sphinx-version-userguide-src
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

updates version of sphinx to 1.6.3 for easyinstall command in step 2 …
---
 user_guide_src/README.rst | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/user_guide_src/README.rst b/user_guide_src/README.rst
index d645adb73..b31db7cf8 100644
--- a/user_guide_src/README.rst
+++ b/user_guide_src/README.rst
@@ -13,17 +13,19 @@ output it to various formats.  Pages are written in human-readable
 Prerequisites
 =============
 
-Sphinx requires Python, which is already installed if you are running OS X.
+Sphinx requires Python 2.7.  If you are on OS X, then you already have Python.
 You can confirm in a Terminal window by executing the ``python`` command
 without any parameters.  It should load up and tell you which version you have
-installed.  If you're not on 2.7+, go ahead and install 2.7.2 from
-http://python.org/download/releases/2.7.2/
+installed.
+
+Note: If you're not on Python 2.7, then you must upgrade. E.g. Install 2.7.2
+from http://python.org/download/releases/2.7.2/
 
 Installation
 ============
 
 1. Install `easy_install `_
-2. ``easy_install "sphinx==1.2.3"``
+2. ``easy_install "sphinx==1.6.3"``
 3. ``easy_install "sphinxcontrib-phpdomain==0.1.3.post1"``
 4. Install the CI Lexer which allows PHP, HTML, CSS, and JavaScript syntax highlighting in code examples (see *cilexer/README*)
 5. ``cd user_guide_src``
-- 
cgit v1.2.3-24-g4f1b


From de3ac40bf40d21a994d170788792557e4e431f37 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Wed, 26 Jul 2017 17:46:51 +0300
Subject: [ci skip] Close #5206

---
 system/libraries/Upload.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index b37cc2f59..0ad8dd375 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1312,7 +1312,7 @@ class CI_Upload {
 			}
 		}
 
-		// Fall back to the deprecated mime_content_type(), if available (still better than $_FILES[$field]['type'])
+		// Fall back to mime_content_type(), if available (still better than $_FILES[$field]['type'])
 		if (function_exists('mime_content_type'))
 		{
 			$this->file_type = @mime_content_type($file['tmp_name']);
-- 
cgit v1.2.3-24-g4f1b


From 1d9e296934edb4fb026391312fa4311ba9f14b96 Mon Sep 17 00:00:00 2001
From: "Instructor, Computer Systems Technology" 
Date: Wed, 26 Jul 2017 21:42:14 -0700
Subject: Update readme.rst

---
 readme.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/readme.rst b/readme.rst
index f5d737028..b6520080e 100644
--- a/readme.rst
+++ b/readme.rst
@@ -57,7 +57,7 @@ Resources
 -  `Language File Translations `_
 -  `Community Forums `_
 -  `Community Wiki `_
--  `Community IRC `_
+-  `Community Slack Channel `_
 
 Report security issues to our `Security Panel `_
 or via our `page on HackerOne `_, thank you.
-- 
cgit v1.2.3-24-g4f1b


From 85869da7bf1080f26b13f1f1870e192a75a2f677 Mon Sep 17 00:00:00 2001
From: "Instructor, Computer Systems Technology" 
Date: Wed, 26 Jul 2017 21:43:24 -0700
Subject: Update composer.json

Replace IRC reference with Slack
---
 composer.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index c40d549c9..30630e224 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
 	"support": {
 		"forum": "http://forum.codeigniter.com/",
 		"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
-		"irc": "irc://irc.freenode.net/codeigniter",
+		"slack": "https://codeigniterchat.slack.com",
 		"source": "https://github.com/bcit-ci/CodeIgniter"
 	},
 	"require": {
-- 
cgit v1.2.3-24-g4f1b


From 613b898234debcaea5ec9160e5249358ac7e3dfc Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 25 Aug 2017 13:24:51 +0300
Subject: [ci skip] Fix #5236

---
 system/database/drivers/mssql/mssql_driver.php               | 2 +-
 system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php  | 2 +-
 system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php | 2 +-
 system/database/drivers/sqlsrv/sqlsrv_driver.php             | 2 +-
 user_guide_src/source/changelog.rst                          | 1 +
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index a2ccd1c80..cb89f3b3f 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -453,7 +453,7 @@ class CI_DB_mssql_driver extends CI_DB {
 			$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
 
 			// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
-			if (count($this->qb_select) === 0)
+			if (count($this->qb_select) === 0 OR strpos(implode(',', $this->qb_select), '*') !== FALSE)
 			{
 				$select = '*'; // Inevitable
 			}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
index 08243232e..e9226c350 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
@@ -284,7 +284,7 @@ class CI_DB_pdo_dblib_driver extends CI_DB_pdo_driver {
 			$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
 
 			// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
-			if (count($this->qb_select) === 0)
+			if (count($this->qb_select) === 0 OR strpos(implode(',', $this->qb_select), '*') !== FALSE)
 			{
 				$select = '*'; // Inevitable
 			}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
index 07c429eec..a9fb4d14a 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php
@@ -316,7 +316,7 @@ class CI_DB_pdo_sqlsrv_driver extends CI_DB_pdo_driver {
 			$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
 
 			// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
-			if (count($this->qb_select) === 0)
+			if (count($this->qb_select) === 0 OR strpos(implode(',', $this->qb_select), '*') !== FALSE)
 			{
 				$select = '*'; // Inevitable
 			}
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index a43e2539a..4edcc7fb8 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -478,7 +478,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
 			$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
 
 			// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
-			if (count($this->qb_select) === 0)
+			if (count($this->qb_select) === 0 OR strpos(implode(',', $this->qb_select), '*') !== FALSE)
 			{
 				$select = '*'; // Inevitable
 			}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index d6984bb7b..9d6620662 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -20,6 +20,7 @@ Bug fixes for 3.1.6
 -  Fixed a bug (#5128) - :doc:`Profiler ` didn't wrap ``$_SESSION`` and configuration arrays in ``
`` tags.
 -  Fixed a bug (#5183) - :doc:`Database Library ` method ``is_write_type()`` didn't return TRUE for ``MERGE`` statements.
 -  Fixed a bug where :doc:`Image Manipulation Library ` didn't escape image source paths passed to NetPBM as shell arguments.
+-  Fixed a bug (#5236) - :doc:`Query Builder ` methods ``limit()``, ``offset()`` break SQL Server 2005, 2008 queries with ``"".*`` in the ``SELECT`` clause.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From ce50148cbd3edb6c379b6431a5a55ae2107f9c48 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 31 Aug 2017 16:03:30 +0300
Subject: Merge pull request #5243 from rosseti/fix/pdo-dblib-sqlserver-version

Fix for DBLIB subdriver to get the right version number of SQL Server.
---
 .../database/drivers/pdo/subdrivers/pdo_dblib_driver.php | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
index e9226c350..b9b86f784 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
@@ -334,4 +334,20 @@ class CI_DB_pdo_dblib_driver extends CI_DB_pdo_driver {
 		return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Database version number
+	 *
+	 * @return      string
+	 */
+	public function version()
+	{
+		if (isset($this->data_cache['version']))
+		{
+			return $this->data_cache['version'];
+		}
+
+		return $this->data_cache['version'] = $this->conn_id->query("SELECT SERVERPROPERTY('ProductVersion') AS ver")->fetchColumn(0);
+	}
 }
-- 
cgit v1.2.3-24-g4f1b


From c4e7999ded26a1acbefdf7f9eebb69772860bb23 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 31 Aug 2017 16:05:37 +0300
Subject: [ci skip] Add changelog entry for #5243

---
 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 9d6620662..64c98e127 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -21,6 +21,7 @@ Bug fixes for 3.1.6
 -  Fixed a bug (#5183) - :doc:`Database Library ` method ``is_write_type()`` didn't return TRUE for ``MERGE`` statements.
 -  Fixed a bug where :doc:`Image Manipulation Library ` didn't escape image source paths passed to NetPBM as shell arguments.
 -  Fixed a bug (#5236) - :doc:`Query Builder ` methods ``limit()``, ``offset()`` break SQL Server 2005, 2008 queries with ``"".*`` in the ``SELECT`` clause.
+-  Fixed a bug (#5243) - :doc:`Database Library ` method ``version()`` didn't work with the 'pdo/dblib' driver.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From 5e88ea5b2d8c75c896094036ff7c4c3e0254258f Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 4 Sep 2017 15:13:37 +0300
Subject: Fix #5246

---
 system/database/DB_driver.php       | 1 +
 user_guide_src/source/changelog.rst | 1 +
 2 files changed, 2 insertions(+)

diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 7efb37333..0b13a2f82 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -916,6 +916,7 @@ abstract class CI_DB_driver {
 
 		if ($this->_trans_begin())
 		{
+			$this->_trans_status = TRUE;
 			$this->_trans_depth++;
 			return TRUE;
 		}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 64c98e127..372ceeb3b 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -22,6 +22,7 @@ Bug fixes for 3.1.6
 -  Fixed a bug where :doc:`Image Manipulation Library ` didn't escape image source paths passed to NetPBM as shell arguments.
 -  Fixed a bug (#5236) - :doc:`Query Builder ` methods ``limit()``, ``offset()`` break SQL Server 2005, 2008 queries with ``"".*`` in the ``SELECT`` clause.
 -  Fixed a bug (#5243) - :doc:`Database Library ` method ``version()`` didn't work with the 'pdo/dblib' driver.
+-  Fixed a bug (#5246) - :doc:`Database transactions ` status wasn't reset unless ``trans_complete()`` was called.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From 146b131dab454885bf7ae943a93ecab53333520a Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 4 Sep 2017 16:24:45 +0300
Subject: Fix Travis-CI failures

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 71ebec3da..a7e5cdaeb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,5 @@
 language: php
+dist: precise
 
 php:
   - 5.3
-- 
cgit v1.2.3-24-g4f1b


From 9385cfed8e61c4568d5ec93c8ee8900f314a5a5a Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Wed, 13 Sep 2017 13:17:28 +0300
Subject: Fix #5260

---
 system/database/drivers/mysqli/mysqli_result.php  | 58 ++++++++++++++++++++++-
 system/database/drivers/mysqli/mysqli_utility.php |  8 ++--
 user_guide_src/source/changelog.rst               |  2 +
 3 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 929c2b455..0b3d9c2b4 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -112,9 +112,9 @@ class CI_DB_mysqli_result extends CI_DB_result {
 		{
 			$retval[$i]			= new stdClass();
 			$retval[$i]->name		= $field_data[$i]->name;
-			$retval[$i]->type		= $field_data[$i]->type;
+			$retval[$i]->type		= static::_get_field_type($field_data[$i]->type);
 			$retval[$i]->max_length		= $field_data[$i]->max_length;
-			$retval[$i]->primary_key	= (int) ($field_data[$i]->flags & 2);
+			$retval[$i]->primary_key	= (int) ($field_data[$i]->flags & MYSQLI_PRI_KEY_FLAG);
 			$retval[$i]->default		= $field_data[$i]->def;
 		}
 
@@ -123,6 +123,60 @@ class CI_DB_mysqli_result extends CI_DB_result {
 
 	// --------------------------------------------------------------------
 
+	/**
+	 * Get field type
+	 *
+	 * Extracts field type info from the bitflags returned by
+	 * mysqli_result::fetch_fields()
+	 *
+	 * @used-by	CI_DB_mysqli_result::field_data()
+	 * @param	int	$flags
+	 * @return	string
+	 */
+	private static function _get_field_type($flags)
+	{
+		static $map;
+		isset($map) OR $map = array(
+			MYSQLI_TYPE_DECIMAL     => 'decimal',
+			MYSQLI_TYPE_BIT         => 'bit',
+			MYSQLI_TYPE_TINY        => 'tinyint',
+			MYSQLI_TYPE_SHORT       => 'smallint',
+			MYSQLI_TYPE_INT24       => 'mediumint',
+			MYSQLI_TYPE_LONG        => 'int',
+			MYSQLI_TYPE_LONGLONG    => 'bigint',
+			MYSQLI_TYPE_FLOAT       => 'float',
+			MYSQLI_TYPE_DOUBLE      => 'double',
+			MYSQLI_TYPE_TIMESTAMP   => 'timestamp',
+			MYSQLI_TYPE_DATE        => 'date',
+			MYSQLI_TYPE_TIME        => 'time',
+			MYSQLI_TYPE_DATETIME    => 'datetime',
+			MYSQLI_TYPE_YEAR        => 'year',
+			MYSQLI_TYPE_NEWDATE     => 'date',
+			MYSQLI_TYPE_INTERVAL    => 'interval',
+			MYSQLI_TYPE_ENUM        => 'enum',
+			MYSQLI_TYPE_SET         => 'set',
+			MYSQLI_TYPE_TINY_BLOB   => 'tinyblob',
+			MYSQLI_TYPE_MEDIUM_BLOB => 'mediumblob',
+			MYSQLI_TYPE_BLOB        => 'blob',
+			MYSQLI_TYPE_LONG_BLOB   => 'longblob',
+			MYSQLI_TYPE_STRING      => 'char',
+			MYSQLI_TYPE_VAR_STRING  => 'varchar',
+			MYSQLI_TYPE_GEOMETRY    => 'geometry'
+		);
+
+		foreach ($map as $flag => $name)
+		{
+			if ($flags & $flag)
+			{
+				return $name;
+			}
+		}
+
+		return $flags;
+	}
+
+	// --------------------------------------------------------------------
+
 	/**
 	 * Free the result
 	 *
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 4a3dad4d1..1699b611f 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -155,9 +155,11 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
 			while ($field = $query->result_id->fetch_field())
 			{
 				// Most versions of MySQL store timestamp as a string
-				$is_int[$i] = in_array(strtolower($field->type),
-							array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
-							TRUE);
+				$is_int[$i] = ($field->type & MYSQLI_TYPE_TINY)
+						OR ($field->type & MYSQLI_TYPE_SHORT)
+						OR ($field->type & MYSQLI_TYPE_INT24)
+						OR ($field->type & MYSQLI_TYPE_LONG)
+						OR ($field->type & MYSQLI_TYPE_LONGLONG);
 
 				// Create a string of field names
 				$field_str .= $this->db->escape_identifiers($field->name).', ';
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 372ceeb3b..055e2d08c 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -23,6 +23,8 @@ Bug fixes for 3.1.6
 -  Fixed a bug (#5236) - :doc:`Query Builder ` methods ``limit()``, ``offset()`` break SQL Server 2005, 2008 queries with ``"".*`` in the ``SELECT`` clause.
 -  Fixed a bug (#5243) - :doc:`Database Library ` method ``version()`` didn't work with the 'pdo/dblib' driver.
 -  Fixed a bug (#5246) - :doc:`Database transactions ` status wasn't reset unless ``trans_complete()`` was called.
+-  Fixed a bug (#5260) - :doc:`Database Utilities ` method ``backup()`` generated incorrect ``INSERT`` statements with the 'mysqli' driver.
+-  Fixed a bug where :doc:`Database Results ` method ``field_data()`` didn't parse field types with the 'mysqli' driver.
 
 Version 3.1.5
 =============
-- 
cgit v1.2.3-24-g4f1b


From e8eb86764955c9c904b50db7c12a3be73c627406 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 16 Sep 2017 17:27:29 +0300
Subject: [ci skip] Merge pull request #5265 from mehdibo/patch-1

Fixed dbprefix() documentation
---
 user_guide_src/source/database/queries.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst
index f626f1e83..710ababb0 100644
--- a/user_guide_src/source/database/queries.rst
+++ b/user_guide_src/source/database/queries.rst
@@ -66,7 +66,7 @@ the following::
 If for any reason you would like to change the prefix programatically
 without needing to create a new connection, you can use this method::
 
-	$this->db->set_dbprefix('newprefix');
+	$this->db->set_dbprefix('newprefix_');
 	$this->db->dbprefix('tablename'); // outputs newprefix_tablename
 
 
-- 
cgit v1.2.3-24-g4f1b


From 88c1a597360f5b63371c119b64e913c9238c75b8 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 25 Sep 2017 14:39:34 +0300
Subject: [ci skip] Fix potential object injection in apc cache driver;
 deprecate the apc driver

---
 system/libraries/Cache/drivers/Cache_apc.php | 48 +++++++++++++---------------
 user_guide_src/source/changelog.rst          |  5 +++
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index f2b61adb1..c873eb640 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -80,14 +80,7 @@ class CI_Cache_apc extends CI_Driver {
 		$success = FALSE;
 		$data = apc_fetch($id, $success);
 
-		if ($success === TRUE)
-		{
-			return is_array($data)
-				? unserialize($data[0])
-				: $data;
-		}
-
-		return FALSE;
+		return ($success === TRUE) ? $data : FALSE;
 	}
 
 	// ------------------------------------------------------------------------
@@ -98,18 +91,12 @@ class CI_Cache_apc extends CI_Driver {
 	 * @param	string	$id	Cache ID
 	 * @param	mixed	$data	Data to store
 	 * @param	int	$ttl	Length of time (in seconds) to cache the data
-	 * @param	bool	$raw	Whether to store the raw value
+	 * @param	bool	$raw	Whether to store the raw value (unused)
 	 * @return	bool	TRUE on success, FALSE on failure
 	 */
 	public function save($id, $data, $ttl = 60, $raw = FALSE)
 	{
-		$ttl = (int) $ttl;
-
-		return apc_store(
-			$id,
-			($raw === TRUE ? $data : array(serialize($data), time(), $ttl)),
-			$ttl
-		);
+		return apc_store($id, $data, (int) $ttl);
 	}
 
 	// ------------------------------------------------------------------------
@@ -188,21 +175,30 @@ class CI_Cache_apc extends CI_Driver {
 	 */
 	public function get_metadata($id)
 	{
-		$success = FALSE;
-		$stored = apc_fetch($id, $success);
-
-		if ($success === FALSE OR count($stored) !== 3)
+		$cache_info = apc_cache_info('user', FALSE);
+		if (empty($cache_info) OR empty($cache_info['cache_list']))
 		{
 			return FALSE;
 		}
 
-		list($data, $time, $ttl) = $stored;
+		foreach ($cache_info['cache_list'] as &$entry)
+		{
+			if ($entry['info'] !== $id)
+			{
+				continue;
+			}
+
+			$success  = FALSE;
+			$metadata = array(
+				'expire' => ($entry['ttl'] ? $entry['mtime'] + $entry['ttl'] : 0),
+				'mtime'  => $entry['ttl'],
+				'data'   => apc_fetch($id, $success)
+			);
+
+			return ($success === TRUE) ? $metadata : FALSE;
+		}
 
-		return array(
-			'expire'	=> $time + $ttl,
-			'mtime'		=> $time,
-			'data'		=> unserialize($data)
-		);
+		return FALSE;
 	}
 
 	// ------------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 055e2d08c..dcfe7b481 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -7,8 +7,13 @@ Version 3.1.6
 
 Release Date: Not Released
 
+-  **Security**
+
+   -  Fixed a potential object injection in :doc:`Cache Library ` 'apc' driver when ``save()`` is used with ``$raw = TRUE`` (thanks to Tomas Bortoli).
+
 -  General Changes
 
+   -  Deprecated :doc:`Cache Library Library ` driver 'apc'.
    -  Updated the :doc:`Session Library ` 'redis', 'memcached' drivers to reduce the potential of a locking race conditions.
 
 
-- 
cgit v1.2.3-24-g4f1b


From dcc029d23128c1e66edb0138adb773d74c808c90 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 25 Sep 2017 14:47:31 +0300
Subject: [ci skip] Add upgrade instructions about the APC deprecation

---
 user_guide_src/source/installation/upgrade_316.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/user_guide_src/source/installation/upgrade_316.rst b/user_guide_src/source/installation/upgrade_316.rst
index e382c20ab..1d86b5720 100644
--- a/user_guide_src/source/installation/upgrade_316.rst
+++ b/user_guide_src/source/installation/upgrade_316.rst
@@ -12,3 +12,17 @@ Replace all files and directories in your *system/* directory.
 
 .. note:: If you have any custom developed files in these directories,
 	please make copies of them first.
+
+Step 2: Remove usage of the APC Cache driver (deprecation)
+==========================================================
+
+The :doc:`Cache Library <../libraries/caching>` APC driver is now
+deprecated, as the APC extension is effectively dead, as explained in its
+`PHP Manual page `_.
+
+If your application happens to be using it, you can switch to another
+cache driver, as APC support will be removed in a future CodeIgniter
+version.
+
+.. note:: The driver is still available, but you're strongly encouraged
+	to remove its usage sooner rather than later.
-- 
cgit v1.2.3-24-g4f1b


From cf728703b5852591c160cbd9566a0e508dd5759a Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 25 Sep 2017 19:37:44 +0300
Subject: [ci skip] Prepare 3.1.6 release

---
 system/core/CodeIgniter.php                      | 2 +-
 user_guide_src/source/changelog.rst              | 2 +-
 user_guide_src/source/conf.py                    | 4 ++--
 user_guide_src/source/installation/downloads.rst | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index f5ffc5ddd..0d03293f6 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -55,7 +55,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
  * @var	string
  *
  */
-	const CI_VERSION = '3.1.6-dev';
+	const CI_VERSION = '3.1.6';
 
 /*
  * ------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index dcfe7b481..e5387cc5a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -5,7 +5,7 @@ Change Log
 Version 3.1.6
 =============
 
-Release Date: Not Released
+Release Date: Sep 25, 2017
 
 -  **Security**
 
diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py
index f783d67e7..7929f8ae7 100644
--- a/user_guide_src/source/conf.py
+++ b/user_guide_src/source/conf.py
@@ -48,9 +48,9 @@ copyright = u'2014 - 2017, British Columbia Institute of Technology'
 # built documents.
 #
 # The short X.Y version.
-version = '3.1.6-dev'
+version = '3.1.6'
 # The full version, including alpha/beta/rc tags.
-release = '3.1.6-dev'
+release = '3.1.6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst
index 23c500e12..76335bb67 100644
--- a/user_guide_src/source/installation/downloads.rst
+++ b/user_guide_src/source/installation/downloads.rst
@@ -2,7 +2,7 @@
 Downloading CodeIgniter
 #######################
 
--  `CodeIgniter v3.1.6-dev (Current version) `_
+-  `CodeIgniter v3.1.6 (Current version) `_
 -  `CodeIgniter v3.1.5 `_
 -  `CodeIgniter v3.1.4 `_
 -  `CodeIgniter v3.1.3 `_
-- 
cgit v1.2.3-24-g4f1b


From 4131d42c793c3db50b6184e5084332d5415c91cb Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Mon, 25 Sep 2017 19:47:49 +0300
Subject: [ci skip] Mark the start of 3.1.7-dev

---
 system/core/CodeIgniter.php                        |  2 +-
 user_guide_src/source/changelog.rst                |  6 ++++++
 user_guide_src/source/conf.py                      |  4 ++--
 user_guide_src/source/installation/downloads.rst   |  3 ++-
 user_guide_src/source/installation/upgrade_317.rst | 14 ++++++++++++++
 user_guide_src/source/installation/upgrading.rst   |  1 +
 6 files changed, 26 insertions(+), 4 deletions(-)
 create mode 100644 user_guide_src/source/installation/upgrade_317.rst

diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 0d03293f6..a4c7d5553 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -55,7 +55,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
  * @var	string
  *
  */
-	const CI_VERSION = '3.1.6';
+	const CI_VERSION = '3.1.7-dev';
 
 /*
  * ------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index e5387cc5a..b99a709ad 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -2,6 +2,12 @@
 Change Log
 ##########
 
+Version 3.1.7
+=============
+
+Release Date: Not Released
+
+
 Version 3.1.6
 =============
 
diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py
index 7929f8ae7..e2b1c2972 100644
--- a/user_guide_src/source/conf.py
+++ b/user_guide_src/source/conf.py
@@ -48,9 +48,9 @@ copyright = u'2014 - 2017, British Columbia Institute of Technology'
 # built documents.
 #
 # The short X.Y version.
-version = '3.1.6'
+version = '3.1.7-dev'
 # The full version, including alpha/beta/rc tags.
-release = '3.1.6'
+release = '3.1.7-dev'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst
index 76335bb67..bb7534d91 100644
--- a/user_guide_src/source/installation/downloads.rst
+++ b/user_guide_src/source/installation/downloads.rst
@@ -2,7 +2,8 @@
 Downloading CodeIgniter
 #######################
 
--  `CodeIgniter v3.1.6 (Current version) `_
+-  `CodeIgniter v3.1.7-dev (Current version) `_
+-  `CodeIgniter v3.1.6 `_
 -  `CodeIgniter v3.1.5 `_
 -  `CodeIgniter v3.1.4 `_
 -  `CodeIgniter v3.1.3 `_
diff --git a/user_guide_src/source/installation/upgrade_317.rst b/user_guide_src/source/installation/upgrade_317.rst
new file mode 100644
index 000000000..93c37b687
--- /dev/null
+++ b/user_guide_src/source/installation/upgrade_317.rst
@@ -0,0 +1,14 @@
+#############################
+Upgrading from 3.1.6 to 3.1.7
+#############################
+
+Before performing an update you should take your site offline by
+replacing the index.php file with a static one.
+
+Step 1: Update your CodeIgniter files
+=====================================
+
+Replace all files and directories in your *system/* directory.
+
+.. note:: If you have any custom developed files in these directories,
+	please make copies of them first.
diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst
index 991d5cf4c..1cc249869 100644
--- a/user_guide_src/source/installation/upgrading.rst
+++ b/user_guide_src/source/installation/upgrading.rst
@@ -8,6 +8,7 @@ upgrading from.
 .. toctree::
 	:titlesonly:
 
+	Upgrading from 3.1.6 to 3.1.7 
 	Upgrading from 3.1.5 to 3.1.6 
 	Upgrading from 3.1.4 to 3.1.5 
 	Upgrading from 3.1.3 to 3.1.4 
-- 
cgit v1.2.3-24-g4f1b