summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-09-01 12:51:26 +0200
committerAndrey Andreev <narf@devilix.net>2015-09-01 12:51:26 +0200
commit554b452845e9ec26e1cd348fda607cf00d2a5026 (patch)
tree5f04c79bbca3037282796d6f9e0209195f511989
parent20573bd472bdeaa831074e563f239585554ffaf5 (diff)
Fix #4093
-rw-r--r--system/database/DB_query_builder.php2
-rw-r--r--tests/codeigniter/database/query_builder/where_test.php8
-rw-r--r--user_guide_src/source/changelog.rst1
3 files changed, 10 insertions, 1 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 7f3334763..cf1100d27 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2342,7 +2342,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
// Split multiple conditions
$conditions = preg_split(
- '/((^|\s+)AND\s+|(^|\s+)OR\s+)/i',
+ '/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i',
$this->{$qb_key}[$i]['condition'],
-1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php
index 20b7a567c..46a7fa2eb 100644
--- a/tests/codeigniter/database/query_builder/where_test.php
+++ b/tests/codeigniter/database/query_builder/where_test.php
@@ -123,4 +123,12 @@ class Where_test extends CI_TestCase {
$this->assertEquals('Musician', $jobs[1]['name']);
}
+ // ------------------------------------------------------------------------
+
+ public function test_issue4093()
+ {
+ $input = 'bar and baz or qux';
+ $sql = $this->db->where('foo', $input)->get_compiled_select('dummy');
+ $this->assertEquals("'".$input."'", substr($sql, -20));
+ }
} \ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 54dcea8be..69a7ed485 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -24,6 +24,7 @@ Bug fixes for 3.0.2
- Fixed a bug (#4073) - :doc:`Email Library <libraries/email>` method ``send()`` could return TRUE in case of an actual failure when an SMTP command fails.
- Fixed a bug (#4086) - :doc:`Query Builder <database/query_builder>` didn't apply *dbprefix* to LIKE conditions if the pattern included spaces.
- Fixed a bug (#4091) - :doc:`Cache Library <libraries/caching>` 'file' driver could be tricked into accepting empty cache item IDs.
+- Fixed a bug (#4093) - :doc:`Query Builder <database/query_builder>` modified string values containing 'AND', 'OR' while compiling WHERE conditions.
Version 3.0.1
=============