summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-01-26 15:34:08 +0100
committerAndrey Andreev <narf@devilix.net>2016-01-26 15:34:08 +0100
commitcd32356021fbf83dc2cb27b9fe35472f08d10892 (patch)
treefe52eef1c11765fe3d9ddd9562e0f58c891f120b
parent1e77136c47032221ae0cdb7f6b43f56792dae224 (diff)
parent8ec82e2885d60847331e88f22ecffa71feafcb61 (diff)
Merge branch '3.0-stable' into develop
-rw-r--r--system/core/Output.php2
-rw-r--r--system/database/DB_query_builder.php59
-rw-r--r--system/libraries/Email.php18
-rw-r--r--user_guide_src/source/changelog.rst7
-rw-r--r--user_guide_src/source/libraries/output.rst4
5 files changed, 64 insertions, 26 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/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index e92c57091..be7582815 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)
{
@@ -1444,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]))
{
@@ -1845,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();
@@ -1855,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/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 7c09047f0..b8d073931 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -27,6 +27,13 @@ Version 3.0.5
Release Date: Not Released
+Bug fixes for 3.0.5
+-------------------
+
+- Fixed a bug (#4391) - :doc:`Email Library <libraries/email>` method ``reply_to()`` didn't apply Q-encoding.
+- Fixed a bug (#4384) - :doc:`Pagination Library <libraries/pagination>` ignored (possible) *cur_page* configuration value.
+- Fixed a bug (#4395) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` still fails if an ``ORDER BY`` condition is used.
+- Fixed a bug (#4399) - :doc:`Query Builder <database/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
=============
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>`.