From 05268d6d08afb3b66e7edd5877c597ef7ea2113a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jan 2016 15:59:42 +0200 Subject: Merge pull request #4378 from jtneal/patch-1 [ci skip] Fix a defined() typo in config/constants.php --- application/config/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/constants.php b/application/config/constants.php index e8d2c00ea..18d3b4b76 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -42,7 +42,7 @@ defined('DIR_WRITE_MODE') OR define('DIR_WRITE_MODE', 0755); defined('FOPEN_READ') OR define('FOPEN_READ', 'rb'); defined('FOPEN_READ_WRITE') OR define('FOPEN_READ_WRITE', 'r+b'); defined('FOPEN_WRITE_CREATE_DESTRUCTIVE') OR define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care -defined('FOPEN_READ_WRITE_CREATE_DESCTRUCTIVE') OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care +defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE') OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care defined('FOPEN_WRITE_CREATE') OR define('FOPEN_WRITE_CREATE', 'ab'); defined('FOPEN_READ_WRITE_CREATE') OR define('FOPEN_READ_WRITE_CREATE', 'a+b'); defined('FOPEN_WRITE_CREATE_STRICT') OR define('FOPEN_WRITE_CREATE_STRICT', 'xb'); -- cgit v1.2.3-24-g4f1b From 22df06b544cb74b4a71c0e1b0d9fa0bc13c95469 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jan 2016 12:10:08 +0200 Subject: [ci skip] Fix a documentation error on output cache times --- system/core/Output.php | 2 +- user_guide_src/source/libraries/output.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index ad87f8545..ec9c21b91 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -377,7 +377,7 @@ class CI_Output { /** * Set Cache * - * @param int $time Cache expiration time in seconds + * @param int $time Cache expiration time in minutes * @return CI_Output */ public function cache($time) diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 84529f766..92060f66a 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -199,11 +199,11 @@ Class Reference .. php:method:: cache($time) - :param int $time: Cache expiration time in seconds + :param int $time: Cache expiration time in minutes :returns: CI_Output instance (method chaining) :rtype: CI_Output - Caches the current page for the specified amount of seconds. + Caches the current page for the specified amount of minutes. For more information, please see the :doc:`caching documentation <../general/caching>`. -- cgit v1.2.3-24-g4f1b From c70216d560d85adf907d9941868a0d8d3df868ca Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jan 2016 17:25:13 +0200 Subject: Fix #4391 --- system/libraries/Email.php | 18 +++++++++++------- user_guide_src/source/changelog.rst | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 007f9b431..ed6f737a1 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -574,14 +574,18 @@ class CI_Email { $this->validate_email($this->_str_to_array($replyto)); } - if ($name === '') - { - $name = $replyto; - } - - if (strpos($name, '"') !== 0) + if ($name !== '') { - $name = '"'.$name.'"'; + // only use Q encoding if there are characters that would require it + if ( ! preg_match('/[\200-\377]/', $name)) + { + // add slashes for non-printing characters, slashes, and double quotes, and surround it in double quotes + $name = '"'.addcslashes($name, "\0..\37\177'\"\\").'"'; + } + else + { + $name = $this->_prep_q_encoding($name); + } } $this->set_header('Reply-To', $name.' <'.$replyto.'>'); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1ba85fa35..bd3d567d9 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -7,6 +7,10 @@ Version 3.0.5 Release Date: Not Released +Bug fixes for 3.0.5 +------------------- + +- Fixed a bug (#4391) - :doc:`Email Library ` method ``reply_to()`` didn't apply Q-encoding. Version 3.0.4 ============= -- cgit v1.2.3-24-g4f1b From 4e87bd3622b3b9edcb90d7d4792f4374daf46446 Mon Sep 17 00:00:00 2001 From: jekkos Date: Mon, 18 Jan 2016 21:14:06 +0100 Subject: Respect $config['cur_page'] variable for pagination After upgrading to CI3 I noticed that developers are able to determine the current page counter for pagination based on * Explicit query string parameters * URI segment configuration In earlier versions a developer could still set the current page counter in the pagination lib directly which is useful if you want to use pagination with HTTP POST instead of GET. This could be done by passing $config['cur_page'] = '10'; to the pagination function for link generation. Currently this code has changed and will always try to check whether the uri segment is a valid number or not, even if the cur_page variable was passed in the associative array, and fallback to zero if it fails to validate that result. This can be easily resolved by checking whether the counter was already set with a valid number from the $config array before trying to resolve it from the uri segment. This fix give a developer more flexibility and stop CI from overwriting the externally set value with an incorrect one. Signed-off-by: jekkos --- system/libraries/Pagination.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index cef98ebf4..9ac9661ad 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -497,7 +497,7 @@ class CI_Pagination { { $this->cur_page = $this->CI->input->get($this->query_string_segment); } - else + elseif (empty($this->cur_page)) { // Default to the last segment number if one hasn't been defined. if ($this->uri_segment === 0) @@ -512,6 +512,10 @@ class CI_Pagination { { $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page); } + } + else + { + $this->cur_page = (string) $this->cur_page; } // If something isn't quite right, back to the default base page. -- cgit v1.2.3-24-g4f1b From ca26561a987bf0ec6e2736ea4c2eab29c663b94b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jan 2016 19:36:39 +0200 Subject: [ci skip] Remove a trailing space from latest PR merge --- system/libraries/Pagination.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 9ac9661ad..44f848fe0 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -512,7 +512,7 @@ class CI_Pagination { { $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page); } - } + } else { $this->cur_page = (string) $this->cur_page; -- cgit v1.2.3-24-g4f1b From b5d410530f7641ba0feb1ec0e25b4243be1fe053 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jan 2016 19:41:29 +0200 Subject: [ci skip] Add changelog entry for PR #4384 --- 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 bd3d567d9..d0d0a10eb 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -11,6 +11,7 @@ Bug fixes for 3.0.5 ------------------- - Fixed a bug (#4391) - :doc:`Email Library ` method ``reply_to()`` didn't apply Q-encoding. +- Fixed a bug (#4384) - :doc:`Pagination Library ` ignored (possible) *cur_page* configuration value. Version 3.0.4 ============= -- cgit v1.2.3-24-g4f1b From 075bdb4e90d9b567cdb4db3e46410854c0437856 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 25 Jan 2016 13:31:23 +0200 Subject: Fix #4395 --- system/database/DB_query_builder.php | 16 +++++++++++++++- user_guide_src/source/changelog.rst | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index e92c57091..c180a17e9 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1379,7 +1379,16 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->from($table); } - $result = ($this->qb_distinct === TRUE OR ! empty($this->qb_orderby)) + // 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; + } + + $result = ($this->qb_distinct === TRUE) ? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results") : $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows'))); @@ -1387,6 +1396,11 @@ 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)) + { + $this->qb_orderby = $orderby; + } if ($result->num_rows() === 0) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d0d0a10eb..466726a7e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -12,6 +12,7 @@ Bug fixes for 3.0.5 - Fixed a bug (#4391) - :doc:`Email Library ` method ``reply_to()`` didn't apply Q-encoding. - Fixed a bug (#4384) - :doc:`Pagination Library ` ignored (possible) *cur_page* configuration value. +- Fixed a bug (#4395) - :doc:`Query Builder ` method ``count_all_results()`` still fails if an ``ORDER BY`` condition is used. Version 3.0.4 ============= -- cgit v1.2.3-24-g4f1b From 8ec82e2885d60847331e88f22ecffa71feafcb61 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 26 Jan 2016 16:33:31 +0200 Subject: Fix #4399 --- system/database/DB_query_builder.php | 43 +++++++++++++++++++++++------------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index c180a17e9..be7582815 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1458,20 +1458,26 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool $escape Whether to escape values and identifiers * @return int Number of rows inserted or FALSE on failure */ - public function insert_batch($table = '', $set = NULL, $escape = NULL) + public function insert_batch($table, $set = NULL, $escape = NULL) { - if ($set !== NULL) + if ($set === NULL) { - $this->set_insert_batch($set, '', $escape); + if (empty($this->qb_set)) + { + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } } - - if (count($this->qb_set) === 0) + else { - // No valid data array. Folds in cases where keys and values did not match up - return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + if (empty($set)) + { + return ($this->db_debug) ? $this->display_error('insert_batch() called with no data') : FALSE; + } + + $this->set_insert_batch($set, '', $escape); } - if ($table === '') + if (strlen($table) === 0) { if ( ! isset($this->qb_from[0])) { @@ -1859,7 +1865,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string the where key * @return int number of rows affected or FALSE on failure */ - public function update_batch($table = '', $set = NULL, $index = NULL) + public function update_batch($table, $set = NULL, $index = NULL) { // Combine any cached components with the current statements $this->_merge_cache(); @@ -1869,17 +1875,24 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_index') : FALSE; } - if ($set !== NULL) + if ($set === NULL) { - $this->set_update_batch($set, $index); + if (empty($this->qb_set)) + { + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } } - - if (count($this->qb_set) === 0) + else { - return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + if (empty($set)) + { + return ($this->db_debug) ? $this->display_error('update_batch() called with no data') : FALSE; + } + + $this->set_update_batch($set, $index); } - if ($table === '') + if (strlen($table) === 0) { if ( ! isset($this->qb_from[0])) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 466726a7e..1623341ea 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -13,6 +13,7 @@ Bug fixes for 3.0.5 - Fixed a bug (#4391) - :doc:`Email Library ` method ``reply_to()`` didn't apply Q-encoding. - Fixed a bug (#4384) - :doc:`Pagination Library ` ignored (possible) *cur_page* configuration value. - Fixed a bug (#4395) - :doc:`Query Builder ` method ``count_all_results()`` still fails if an ``ORDER BY`` condition is used. +- Fixed a bug (#4399) - :doc:`Query Builder ` methods ``insert_batch()``, ``update_batch()`` produced confusing error messages when called with no data and *db_debug* is enabled. Version 3.0.4 ============= -- cgit v1.2.3-24-g4f1b