From 4921fed6c17a54efd4fac0bed4d058463bd9b601 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Sat, 7 Jan 2012 01:28:07 +0200
Subject: Improve the smiley, string & text helpers
---
system/helpers/smiley_helper.php | 97 ++++++++++++----------------
system/helpers/string_helper.php | 81 +++++++++---------------
system/helpers/text_helper.php | 133 +++++++++++++++++++--------------------
3 files changed, 134 insertions(+), 177 deletions(-)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 700f4486c..bc265e552 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -1,13 +1,13 @@
- $id)
{
- foreach ($alias as $name => $id)
- {
- $m[] = '"'.$name.'" : "'.$id.'"';
- }
+ $m[] = '"'.$name.'" : "'.$id.'"';
}
+ }
- $m = '{'.implode(',', $m).'}';
+ $m = '{'.implode(',', $m).'}';
- $r .= <</*';
- }
- else
- {
- return $r;
- }
+ return ($inline) ? '' : $r;
}
}
@@ -154,12 +145,9 @@ if ( ! function_exists('get_clickable_smileys'))
$smileys = $alias;
}
- if ( ! is_array($smileys))
+ if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))
{
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $smileys;
- }
+ return $smileys;
}
// Add a trailing slash to the file path if needed
@@ -178,7 +166,6 @@ if ( ! function_exists('get_clickable_smileys'))
}
$link[] = "";
-
$used[$smileys[$key][0]] = TRUE;
}
@@ -207,16 +194,13 @@ if ( ! function_exists('parse_smileys'))
return $str;
}
- if ( ! is_array($smileys))
+ if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))
{
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
+ return $str;
}
// Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+ $image_url = rtrim($image_url, '/').'/';
foreach ($smileys as $key => $val)
{
@@ -249,7 +233,7 @@ if ( ! function_exists('_get_smiley_array'))
{
include(APPPATH.'config/smileys.php');
}
-
+
if (isset($smileys) AND is_array($smileys))
{
return $smileys;
@@ -288,6 +272,5 @@ EOF;
}
}
-
/* End of file smiley_helper.php */
-/* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
+/* Location: ./system/helpers/smiley_helper.php */
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 04d51c2f9..654f721b0 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,13 +1,13 @@
-load->helper('security');
-
- return do_hash(uniqid(mt_rand(), TRUE), 'sha1');
- break;
+ case 'basic': return mt_rand();
+ case 'alnum':
+ case 'numeric':
+ case 'nozero':
+ case 'alpha':
+ switch ($type)
+ {
+ case 'alpha': $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ case 'alnum': $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ case 'numeric': $pool = '0123456789';
+ break;
+ case 'nozero': $pool = '123456789';
+ break;
+ }
+ return substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
+ case 'unique':
+ case 'md5': return md5(uniqid(mt_rand()));
+ case 'encrypt':
+ case 'sha1':
+ $CI =& get_instance();
+ $CI->load->helper('security');
+ return do_hash(uniqid(mt_rand(), TRUE), 'sha1');
}
}
}
@@ -262,7 +245,6 @@ if ( ! function_exists('random_string'))
function increment_string($str, $separator = '_', $first = 1)
{
preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
-
return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
}
@@ -311,6 +293,5 @@ if ( ! function_exists('repeater'))
}
}
-
/* End of file string_helper.php */
-/* Location: ./system/helpers/string_helper.php */
\ No newline at end of file
+/* Location: ./system/helpers/string_helper.php */
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 842a31d75..562270f96 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,13 +1,13 @@
-","\"", "'", "-"),
- $str);
+ return str_replace(array('&', '<', '>', '"', ''', '-'),
+ array('&', '<', '>', '"', "'", '-'),
+ $str);
}
return $str;
@@ -294,42 +294,38 @@ if ( ! function_exists('highlight_code'))
{
function highlight_code($str)
{
- // The highlight string function encodes and highlights
- // brackets so we need them to start raw
- $str = str_replace(array('<', '>'), array('<', '>'), $str);
-
- // Replace any existing PHP tags to temporary markers so they don't accidentally
- // break the string out of PHP, and thus, thwart the highlighting.
-
- $str = str_replace(array('', '?>', '<%', '%>', '\\', ''),
- array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
+ /* The highlight string function encodes and highlights
+ * brackets so we need them to start raw.
+ *
+ * Also replace any existing PHP tags to temporary markers
+ * so they don't accidentally break the string out of PHP,
+ * and thus, thwart the highlighting.
+ */
+ $str = str_replace(array('<', '>', '', '?>', '<%', '%>', '\\', ''),
+ array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ $str);
// The highlight_string function requires that the text be surrounded
// by PHP tags, which we will remove later
- $str = ''; //
-
- // All the magic happens here, baby!
- $str = highlight_string($str, TRUE);
-
- // Prior to PHP 5, the highligh function used icky tags
- // so we'll replace them with tags.
-
- if (abs(PHP_VERSION) < 5)
- {
- $str = str_replace(array(''), array(''), $str);
- $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- }
+ $str = highlight_string('', TRUE);
// Remove our artificially added PHP, and the syntax highlighting that came with it
- $str = preg_replace('/<\?php( | )/i', '', $str);
- $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str);
- $str = preg_replace('/<\/span>/i', '', $str);
+ $str = preg_replace(array(
+ '/<\?php( | )/i',
+ '/(.*?)\?><\/span>\n<\/span>\n<\/code>/is',
+ '/<\/span>/i'
+ ),
+ array(
+ '',
+ "$1\n\n",
+ ''
+ ),
+ $str);
// Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
- array('<?', '?>', '<%', '%>', '\\', '</script>'), $str);
-
- return $str;
+ return str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ array('<?', '?>', '<%', '%>', '\\', '</script>'),
+ $str);
}
}
@@ -414,12 +410,14 @@ if ( ! function_exists('word_wrap'))
{
function word_wrap($str, $charlim = '76')
{
- // Se the character limit
+ // Set the character limit
if ( ! is_numeric($charlim))
+ {
$charlim = 76;
+ }
// Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
+ $str = preg_replace('| +|', ' ', $str);
// Standardize newlines
if (strpos($str, "\r") !== FALSE)
@@ -430,22 +428,22 @@ if ( ! function_exists('word_wrap'))
// If the current word is surrounded by {unwrap} tags we'll
// strip the entire chunk and replace it with a marker.
$unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ if (preg_match_all('|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches))
{
- for ($i = 0; $i < count($matches['0']); $i++)
+ for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
{
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ $unwrap[] = $matches[1][$i];
+ $str = str_replace($matches[1][$i], '{{unwrapped'.$i.'}}', $str);
}
}
// Use PHP's native function to do the initial wordwrap.
// We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
+ // too long get left alone. In the next step we'll deal with them.
$str = wordwrap($str, $charlim, "\n", FALSE);
// Split the string into individual lines of text and cycle through them
- $output = "";
+ $output = '';
foreach (explode("\n", $str) as $line)
{
// Is the line within the allowed character count?
@@ -460,7 +458,7 @@ if ( ! function_exists('word_wrap'))
while ((strlen($line)) > $charlim)
{
// If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ if (preg_match('!\[url.+\]|://|wwww.!', $line))
{
break;
}
@@ -474,14 +472,12 @@ if ( ! function_exists('word_wrap'))
// word into smaller chunks so we'll add it back to our current line
if ($temp != '')
{
- $output .= $temp."\n".$line;
+ $output .= $temp."\n".$line."\n";
}
else
{
- $output .= $line;
+ $output .= $line."\n";
}
-
- $output .= "\n";
}
// Put our markers back
@@ -489,14 +485,12 @@ if ( ! function_exists('word_wrap'))
{
foreach ($unwrap as $key => $val)
{
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ $output = str_replace('{{unwrapped'.$key.'}}', $val, $output);
}
}
- // Remove the unwrap tags
- $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
-
- return $output;
+ // Remove the unwrap tags and return
+ return str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
}
}
@@ -527,7 +521,6 @@ if ( ! function_exists('ellipsize'))
}
$beg = substr($str, 0, floor($max_length * $position));
-
$position = ($position > 1) ? 1 : $position;
if ($position === 1)
@@ -544,4 +537,4 @@ if ( ! function_exists('ellipsize'))
}
/* End of file text_helper.php */
-/* Location: ./system/helpers/text_helper.php */
\ No newline at end of file
+/* Location: ./system/helpers/text_helper.php */
--
cgit v1.2.3-24-g4f1b
From fc443553248af8ac0c1cbb635fe9cbb70fdf7b82 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Sat, 7 Jan 2012 02:14:55 +0200
Subject: Remove quotes around an integer value
---
system/helpers/text_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 562270f96..3a847f29b 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -408,7 +408,7 @@ if ( ! function_exists('convert_accented_characters'))
*/
if ( ! function_exists('word_wrap'))
{
- function word_wrap($str, $charlim = '76')
+ function word_wrap($str, $charlim = 76)
{
// Set the character limit
if ( ! is_numeric($charlim))
--
cgit v1.2.3-24-g4f1b
From cb324bd9268fc6b0c93fd22545bd989771d68b04 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Sun, 8 Jan 2012 07:06:35 +0200
Subject: Some more misc. stuff
---
system/helpers/smiley_helper.php | 2 --
system/helpers/string_helper.php | 17 +++++++++--------
system/helpers/text_helper.php | 8 +++-----
3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index bc265e552..03f3ee287 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Smiley Helpers
*
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 654f721b0..fcdb0aa84 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter String Helpers
*
@@ -153,7 +151,7 @@ if ( ! function_exists('reduce_double_slashes'))
{
function reduce_double_slashes($str)
{
- return preg_replace("#(^|[^:])//+#", "\\1/", $str);
+ return preg_replace('#(^|[^:])//+#', '\\1/', $str);
}
}
@@ -181,7 +179,6 @@ if ( ! function_exists('reduce_multiples'))
function reduce_multiples($str, $character = ',', $trim = FALSE)
{
$str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
-
return ($trim === TRUE) ? trim($str, $character) : $str;
}
}
@@ -211,13 +208,17 @@ if ( ! function_exists('random_string'))
case 'alpha':
switch ($type)
{
- case 'alpha': $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ case 'alpha':
+ $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
- case 'alnum': $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ case 'alnum':
+ $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
- case 'numeric': $pool = '0123456789';
+ case 'numeric':
+ $pool = '0123456789';
break;
- case 'nozero': $pool = '123456789';
+ case 'nozero':
+ $pool = '123456789';
break;
}
return substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 3a847f29b..cef32847d 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Text Helpers
*
@@ -93,7 +91,7 @@ if ( ! function_exists('character_limiter'))
return $str;
}
- $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
+ $str = preg_replace('/\s+/', ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
if (strlen($str) <= $n)
{
@@ -108,7 +106,7 @@ if ( ! function_exists('character_limiter'))
if (strlen($out) >= $n)
{
$out = trim($out);
- return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
+ return (strlen($out) === strlen($str)) ? $out : $out.$end_char;
}
}
}
@@ -354,7 +352,7 @@ if ( ! function_exists('highlight_phrase'))
if ($phrase != '')
{
- return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
+ return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open.'\\1'.$tag_close, $str);
}
return $str;
--
cgit v1.2.3-24-g4f1b
From 0f2ec5bde259b67f66cc353692d71d8a47f71b01 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Mon, 16 Jan 2012 14:02:24 +0200
Subject: convert_accented_characters() to include foreign_chars.php only when
needed
---
application/config/foreign_chars.php | 6 +++---
system/helpers/text_helper.php | 25 +++++++++++++++----------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
index 1ae0cef5f..f2f981c27 100644
--- a/application/config/foreign_chars.php
+++ b/application/config/foreign_chars.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -87,4 +87,4 @@ $foreign_characters = array(
);
/* End of file foreign_chars.php */
-/* Location: ./application/config/foreign_chars.php */
\ No newline at end of file
+/* Location: ./application/config/foreign_chars.php */
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index cef32847d..8e308b722 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -372,18 +372,23 @@ if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
- }
- elseif (is_file(APPPATH.'config/foreign_chars.php'))
- {
- include(APPPATH.'config/foreign_chars.php');
- }
+ global $foreign_characters;
- if ( ! isset($foreign_characters))
+ if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
{
- return $str;
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
+ }
+ elseif (is_file(APPPATH.'config/foreign_chars.php'))
+ {
+ include(APPPATH.'config/foreign_chars.php');
+ }
+
+ if ( ! isset($foreign_characters) OR ! is_array($foreign_chars))
+ {
+ return $str;
+ }
}
return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str);
--
cgit v1.2.3-24-g4f1b
From 2a97c7db940e94a115dea863708f587e58d26be4 Mon Sep 17 00:00:00 2001
From: John Wright
Date: Mon, 16 Jan 2012 15:09:19 -0800
Subject: It appears the Security class has been added to the system/core
folder and is loaded automatically as well. Using
$this->load->library('security'); in controllers currently returns FALSE, yet
you might not notice because the Security class is already loaded. I
discovered this because of a custom Loader class I was using returned an
error when loading the Security class.
---
user_guide_src/source/general/core_classes.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst
index ac41407f7..4aa6693f7 100644
--- a/user_guide_src/source/general/core_classes.rst
+++ b/user_guide_src/source/general/core_classes.rst
@@ -31,6 +31,7 @@ time CodeIgniter runs:
- Log
- Output
- Router
+- Security
- URI
- Utf8
--
cgit v1.2.3-24-g4f1b
From 09375d71aa933ac6ba3665f7ccc6949840177ade Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 19 Jan 2012 14:57:46 +0200
Subject: Some more cleaning
---
system/helpers/smiley_helper.php | 39 ++++++++++++---------------------------
system/helpers/string_helper.php | 32 +++++++++++++++-----------------
system/helpers/text_helper.php | 8 ++++----
3 files changed, 31 insertions(+), 48 deletions(-)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 03f3ee287..d2b8936ae 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
@@ -40,7 +40,7 @@
/**
* Smiley Javascript
*
- * Returns the javascript required for the smiley insertion. Optionally takes
+ * Returns the javascript required for the smiley insertion. Optionally takes
* an array of aliases to loosely couple the smiley array to the view.
*
* @access public
@@ -105,14 +105,11 @@ if ( ! function_exists('smiley_js'))
}
EOF;
}
- else
+ elseif (is_array($alias))
{
- if (is_array($alias))
+ foreach ($alias as $name => $id)
{
- foreach ($alias as $name => $id)
- {
- $r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n";
- }
+ $r .= 'smiley_map["'.$name.'"] = "'.$id."\";\n";
}
}
@@ -137,13 +134,11 @@ if ( ! function_exists('get_clickable_smileys'))
function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
{
// For backward compatibility with js_insert_smiley
-
if (is_array($alias))
{
$smileys = $alias;
}
-
- if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))
+ elseif (FALSE === ($smileys = _get_smiley_array()))
{
return $smileys;
}
@@ -155,7 +150,7 @@ if ( ! function_exists('get_clickable_smileys'))
foreach ($smileys as $key => $val)
{
// Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
+ // mapping array contains multiple identical replacements. For example:
// :-) and :) might be replaced with the same image so both smileys
// will be in the array.
if (isset($used[$smileys[$key][0]]))
@@ -163,7 +158,7 @@ if ( ! function_exists('get_clickable_smileys'))
continue;
}
- $link[] = "";
+ $link[] = '';
$used[$smileys[$key][0]] = TRUE;
}
@@ -187,12 +182,7 @@ if ( ! function_exists('parse_smileys'))
{
function parse_smileys($str = '', $image_url = '', $smileys = NULL)
{
- if ($image_url == '')
- {
- return $str;
- }
-
- if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))
+ if ($image_url == '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())))
{
return $str;
}
@@ -202,7 +192,7 @@ if ( ! function_exists('parse_smileys'))
foreach ($smileys as $key => $val)
{
- $str = str_replace($key, "", $str);
+ $str = str_replace($key, '', $str);
}
return $str;
@@ -223,7 +213,7 @@ if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
+ if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
@@ -232,12 +222,7 @@ if ( ! function_exists('_get_smiley_array'))
include(APPPATH.'config/smileys.php');
}
- if (isset($smileys) AND is_array($smileys))
- {
- return $smileys;
- }
-
- return FALSE;
+ return (isset($smileys) && is_array($smileys)) ? $smileys : FALSE;
}
}
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index fcdb0aa84..d0948800b 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
@@ -75,16 +75,14 @@ if ( ! function_exists('strip_slashes'))
{
function strip_slashes($str)
{
- if (is_array($str))
+ if ( ! is_array($str))
{
- foreach ($str as $key => $val)
- {
- $str[$key] = strip_slashes($val);
- }
+ return stripslashes($str);
}
- else
+
+ foreach ($str as $key => $val)
{
- return stripslashes($str);
+ $str[$key] = strip_slashes($val);
}
return $str;
@@ -192,7 +190,7 @@ if ( ! function_exists('reduce_multiples'))
*
* @access public
* @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param integer number of characters
+ * @param int number of characters
* @return string
*/
if ( ! function_exists('random_string'))
@@ -238,10 +236,10 @@ if ( ! function_exists('random_string'))
/**
* Add's _1 to a string or increment the ending number to allow _2, _3, etc
*
- * @param string $str required
- * @param string $separator What should the duplicate number be appended with
- * @param string $first Which number should be used for the first dupe increment
- * @return string
+ * @param string $str required
+ * @param string $separator What should the duplicate number be appended with
+ * @param string $first Which number should be used for the first dupe increment
+ * @return string
*/
function increment_string($str, $separator = '_', $first = 1)
{
@@ -254,10 +252,10 @@ function increment_string($str, $separator = '_', $first = 1)
/**
* Alternator
*
- * Allows strings to be alternated. See docs...
+ * Allows strings to be alternated. See docs...
*
* @access public
- * @param string (as many parameters as needed)
+ * @param string (as many parameters as needed)
* @return string
*/
if ( ! function_exists('alternator'))
@@ -283,14 +281,14 @@ if ( ! function_exists('alternator'))
*
* @access public
* @param string
- * @param integer number of repeats
+ * @param int number of repeats
* @return string
*/
if ( ! function_exists('repeater'))
{
function repeater($data, $num = 1)
{
- return (($num > 0) ? str_repeat($data, $num) : '');
+ return ($num > 0) ? str_repeat($data, $num) : '';
}
}
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 8e308b722..2d6da73ac 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
@@ -73,7 +73,7 @@ if ( ! function_exists('word_limiter'))
/**
* Character Limiter
*
- * Limits the string based on the character count. Preserves complete words
+ * Limits the string based on the character count. Preserves complete words
* so the character count may not be exactly as specified.
*
* @access public
@@ -376,7 +376,7 @@ if ( ! function_exists('convert_accented_characters'))
if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
@@ -400,7 +400,7 @@ if ( ! function_exists('convert_accented_characters'))
/**
* Word Wrap
*
- * Wraps text at the specified character. Maintains the integrity of words.
+ * Wraps text at the specified character. Maintains the integrity of words.
* Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
* will URLs.
*
--
cgit v1.2.3-24-g4f1b
From c5a1f93ef25c99df4035ef7182a6200b91afabab Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Tue, 24 Jan 2012 15:29:02 +0200
Subject: Revert a space in the license agreement :)
---
system/helpers/smiley_helper.php | 2 +-
system/helpers/string_helper.php | 2 +-
system/helpers/text_helper.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index d2b8936ae..cb902114e 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index d0948800b..0d1018f53 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 2d6da73ac..37b5d3178 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -9,7 +9,7 @@
* Licensed under the Open Software License version 3.0
*
* This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst. It is
+ * bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
* http://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to obtain it
--
cgit v1.2.3-24-g4f1b
From 4da24f8f1137afbaa2ec51d9c9fb635df1481472 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Wed, 25 Jan 2012 21:54:23 +0200
Subject: Improve the MSSQL database driver
---
system/database/drivers/mssql/mssql_driver.php | 242 +++++++++---------------
system/database/drivers/mssql/mssql_forge.php | 134 ++++---------
system/database/drivers/mssql/mssql_result.php | 50 ++---
system/database/drivers/mssql/mssql_utility.php | 38 ++--
4 files changed, 164 insertions(+), 300 deletions(-)
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 2a1098932..9cabe87be 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -1,13 +1,13 @@
-port != '')
{
@@ -80,10 +77,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
if ($this->port != '')
{
@@ -101,12 +97,11 @@ class CI_DB_mssql_driver extends CI_DB {
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
- * @access public
* @return void
*/
- function reconnect()
+ public function reconnect()
{
- // not implemented in MSSQL
+ // Not supported in MSSQL
}
// --------------------------------------------------------------------
@@ -114,10 +109,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
- * @return resource
+ * @return bool
*/
- function db_select()
+ public function db_select()
{
// Note: The brackets are required in the event that the DB name
// contains reserved characters
@@ -129,14 +123,13 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Set client character set
*
- * @access public
* @param string
* @param string
- * @return resource
+ * @return bool
*/
- function db_set_charset($charset, $collation)
+ public function db_set_charset($charset, $collation)
{
- // @todo - add support if needed
+ // Not supported in MSSQL
return TRUE;
}
@@ -145,14 +138,12 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
- * @return resource
+ * @return mixed resource if rows are returned, bool otherwise
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
- return @mssql_query($sql, $this->conn_id);
+ return @mssql_query($this->_prep_query($sql), $this->conn_id);
}
// --------------------------------------------------------------------
@@ -162,11 +153,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* If needed, each database adapter can prep the query string
*
- * @access private called by execute()
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ protected function _prep_query($sql)
{
return $sql;
}
@@ -176,18 +166,12 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -195,10 +179,9 @@ class CI_DB_mssql_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = ($test_mode === TRUE);
- $this->simple_query('BEGIN TRAN');
- return TRUE;
+ return $this->simple_query('BEGIN TRAN');
}
// --------------------------------------------------------------------
@@ -206,24 +189,17 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
- $this->simple_query('COMMIT TRAN');
- return TRUE;
+ return $this->simple_query('COMMIT TRAN');
}
// --------------------------------------------------------------------
@@ -231,24 +207,17 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
- $this->simple_query('ROLLBACK TRAN');
- return TRUE;
+ return $this->simple_query('ROLLBACK TRAN');
}
// --------------------------------------------------------------------
@@ -256,12 +225,11 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -279,7 +247,7 @@ class CI_DB_mssql_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace(
+ return str_replace(
array($this->_like_escape_chr, '%', '_'),
array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
$str
@@ -294,10 +262,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @mssql_rows_affected($this->conn_id);
}
@@ -309,13 +276,14 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Returns the last id created in the Identity column.
*
- * @access public
- * @return integer
+ * @return int
*/
- function insert_id()
+ public function insert_id()
{
- $ver = self::_parse_major_version($this->version());
- $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
+ $sql = (self::_parse_major_version($this->version()) > 7)
+ ? 'SELECT SCOPE_IDENTITY() AS last_id'
+ : 'SELECT @@IDENTITY AS last_id';
+
$query = $this->query($sql);
$row = $query->row();
return $row->last_id;
@@ -329,11 +297,10 @@ class CI_DB_mssql_driver extends CI_DB {
* Grabs the major version number from the
* database server version string passed in.
*
- * @access private
- * @param string $version
- * @return int16 major version number
+ * @param string $version
+ * @return int major version number
*/
- function _parse_major_version($version)
+ private function _parse_major_version($version)
{
preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
return $ver_info[1]; // return the major version b/c that's all we're interested in.
@@ -344,12 +311,11 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Version number query string
*
- * @access public
- * @return string
+ * @return string
*/
- function _version()
+ protected function _version()
{
- return "SELECT @@VERSION AS ver";
+ return 'SELECT @@VERSION AS ver';
}
// --------------------------------------------------------------------
@@ -360,19 +326,17 @@ class CI_DB_mssql_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $query = $this->query($this->_count_string.$this->_protect_identifiers('numrows').' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
@@ -390,11 +354,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
@@ -415,11 +378,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access private
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
@@ -431,13 +393,12 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
- return "SELECT TOP 1 * FROM ".$table;
+ return 'SELECT TOP 1 * FROM '.$table;
}
// --------------------------------------------------------------------
@@ -445,10 +406,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* The error message string
*
- * @access private
* @return string
*/
- function _error_message()
+ protected function _error_message()
{
return mssql_get_last_message();
}
@@ -458,12 +418,11 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* The error message number
*
- * @access private
- * @return integer
+ * @return string
*/
- function _error_number()
+ protected function _error_number()
{
- // Are error numbers supported?
+ // Not supported in MSSQL
return '';
}
@@ -474,11 +433,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ protected function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -489,24 +447,20 @@ class CI_DB_mssql_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+ $item = str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item);
}
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
- }
- else
- {
- $str = $this->_escape_char.$item.$this->_escape_char;
+ $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item);
}
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char);
}
// --------------------------------------------------------------------
@@ -517,11 +471,10 @@ class CI_DB_mssql_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -538,15 +491,14 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
- return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -556,7 +508,6 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -564,24 +515,17 @@ class CI_DB_mssql_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key.' = '.$val;
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
-
- $sql .= $orderby.$limit;
-
- return $sql;
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
+ .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '')
+ .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '')
+ .( ! $limit ? '' : ' LIMIT '.$limit);
}
@@ -594,13 +538,12 @@ class CI_DB_mssql_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
- return "TRUNCATE ".$table;
+ return 'TRUNCATE '.$table;
}
// --------------------------------------------------------------------
@@ -610,31 +553,26 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
-
if (count($where) > 0 OR count($like) > 0)
{
- $conditions = "\nWHERE ";
- $conditions .= implode("\n", $this->ar_where);
+ $conditions .= "\nWHERE ".implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
- $conditions .= " AND ";
+ $conditions .= ' AND ';
}
$conditions .= implode("\n", $like);
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- return "DELETE FROM ".$table.$conditions.$limit;
+ return 'DELETE FROM '.$table.$conditions.( ! $limit ? '' : ' LIMIT '.$limit);
}
// --------------------------------------------------------------------
@@ -644,17 +582,14 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
- $i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql);
}
// --------------------------------------------------------------------
@@ -662,18 +597,15 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@mssql_close($conn_id);
}
}
-
-
/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index dd8aa3448..65513f437 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -1,13 +1,13 @@
-db->_escape_identifiers($table);
+ return 'DROP TABLE '.$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
@@ -80,15 +76,14 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
- * @return bool
+ * @return string
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -97,7 +92,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
$sql .= 'IF NOT EXISTS ';
}
- $sql .= $this->db->_escape_identifiers($table)." (";
+ $sql .= $this->db->_escape_identifiers($table).'(';
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
@@ -107,44 +102,19 @@ class CI_DB_mssql_forge extends CI_DB_forge {
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
- $sql .= "\n\t$attributes";
+ $sql .= "\n\t".$attributes;
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
-
- $sql .= ' '.$attributes['TYPE'];
-
- if (array_key_exists('CONSTRAINT', $attributes))
- {
- $sql .= '('.$attributes['CONSTRAINT'].')';
- }
-
- if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
- {
- $sql .= ' UNSIGNED';
- }
-
- if (array_key_exists('DEFAULT', $attributes))
- {
- $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
- }
-
- if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
- {
- $sql .= ' AUTO_INCREMENT';
- }
+ $sql .= "\n\t".$this->db->protect_identifiers($field)
+ .' '.$attributes['TYPE']
+ .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+ .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
@@ -156,8 +126,8 @@ class CI_DB_mssql_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
- $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')';
}
if (is_array($keys) && count($keys) > 0)
@@ -166,20 +136,18 @@ class CI_DB_mssql_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
- $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+ $sql .= ",\n\tFOREIGN KEY (".implode(', ', $key).')';
}
}
- $sql .= "\n)";
-
- return $sql;
+ return $sql."\n)";
}
// --------------------------------------------------------------------
@@ -190,7 +158,6 @@ class CI_DB_mssql_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
@@ -200,39 +167,20 @@ class CI_DB_mssql_forge extends CI_DB_forge {
* @param string the field after which we should add the new field
* @return object
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
- if ($alter_type == 'DROP')
+ if ($alter_type === 'DROP')
{
return $sql;
}
- $sql .= " $column_definition";
-
- if ($default_value != '')
- {
- $sql .= " DEFAULT \"$default_value\"";
- }
-
- if ($null === NULL)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if ($after_field != '')
- {
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
- }
-
- return $sql;
-
+ return $sql.' '.$column_definition
+ .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '')
+ .($null === NULL ? ' NULL' : ' NOT NULL')
+ .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : '');
}
// --------------------------------------------------------------------
@@ -242,19 +190,17 @@ class CI_DB_mssql_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file mssql_forge.php */
-/* Location: ./system/database/drivers/mssql/mssql_forge.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index bba2e6243..579cd3de7 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -1,13 +1,13 @@
-result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @mssql_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
while ($field = mssql_fetch_field($this->result_id))
@@ -90,20 +85,19 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
while ($field = mssql_fetch_field($this->result_id))
{
- $F = new stdClass();
- $F->name = $field->name;
- $F->type = $field->type;
+ $F = new stdClass();
+ $F->name = $field->name;
+ $F->type = $field->type;
$F->max_length = $field->max_length;
$F->primary_key = 0;
- $F->default = '';
+ $F->default = '';
$retval[] = $F;
}
@@ -116,9 +110,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -132,14 +126,13 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ public function _data_seek($n = 0)
{
return mssql_data_seek($this->result_id, $n);
}
@@ -151,10 +144,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return mssql_fetch_assoc($this->result_id);
}
@@ -166,16 +158,14 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return mssql_fetch_object($this->result_id);
}
}
-
/* End of file mssql_result.php */
-/* Location: ./system/database/drivers/mssql/mssql_result.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_result.php */
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index be6ed5bb0..11a1b3ad0 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -1,13 +1,13 @@
-db->protect_identifiers($table).' REORGANIZE';
}
// --------------------------------------------------------------------
@@ -70,13 +67,13 @@ class CI_DB_mssql_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
- return FALSE; // Is this supported in MS SQL?
+ // Not supported in MSSQL
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -84,11 +81,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
/**
* MSSQL Export
*
- * @access private
* @param array Preferences
- * @return mixed
+ * @return bool
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -97,4 +93,4 @@ class CI_DB_mssql_utility extends CI_DB_utility {
}
/* End of file mssql_utility.php */
-/* Location: ./system/database/drivers/mssql/mssql_utility.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_utility.php */
--
cgit v1.2.3-24-g4f1b
From 8c1b269b1a53f4ace1e7e549fa2c7781cc9f09e9 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Wed, 25 Jan 2012 22:05:49 +0200
Subject: Update the changelog
---
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 48011f208..a1b1ccbf2 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -47,6 +47,7 @@ Release Date: Not Released
get_compiled_insert(), get_compiled_update(), get_compiled_delete().
- Taking care of LIKE condition when used with MySQL UPDATE statement.
- Adding $escape parameter to the order_by function, this enables ordering by custom fields.
+ - Added random ordering support to the MSSQL driver.
- Libraries
--
cgit v1.2.3-24-g4f1b
From dd7242b9e78f5ca9e56ffe239c14918903d34cd8 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 00:43:38 +0200
Subject: Switch a few properties from public to protected
---
system/database/drivers/mssql/mssql_driver.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 9cabe87be..267c16171 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -43,19 +43,19 @@ class CI_DB_mssql_driver extends CI_DB {
public $dbdriver = 'mssql';
// The character used for escaping
- public $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- public $_like_escape_str = ' ESCAPE \'%s\' ';
- public $_like_escape_chr = '!';
+ protected $_like_escape_str = ' ESCAPE \'%s\' ';
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() methods.
*/
- public $_count_string = 'SELECT COUNT(*) AS ';
- public $_random_keyword = ' NEWID()';
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' NEWID()';
/**
* Non-persistent database connection
--
cgit v1.2.3-24-g4f1b
From 3318ab87718775289264c5f42edfd9f912632dd8 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 01:59:08 +0200
Subject: Make _escape_identifiers() public, so DB_forge can use it
---
system/database/drivers/mssql/mssql_driver.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 267c16171..22ed0478e 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -436,7 +436,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @param string
* @return string
*/
- protected function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
--
cgit v1.2.3-24-g4f1b
From 0e8968ab7c309d17cd61079f7554ced1411a8792 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 02:04:37 +0200
Subject: Improve the SQLSRV (MSSQL) database driver
---
system/database/DB_driver.php | 2 +-
system/database/drivers/sqlsrv/sqlsrv_driver.php | 285 +++++++++-------------
system/database/drivers/sqlsrv/sqlsrv_forge.php | 138 ++++-------
system/database/drivers/sqlsrv/sqlsrv_result.php | 62 ++---
system/database/drivers/sqlsrv/sqlsrv_utility.php | 39 ++-
5 files changed, 207 insertions(+), 319 deletions(-)
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 661b42ced..82e5d0486 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -257,7 +257,7 @@ class CI_DB_driver {
// Some DBs have functions that return the version, and don't run special
// SQL queries per se. In these instances, just return the result.
- $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo');
+ $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'sqlsrv');
if (in_array($this->dbdriver, $driver_version_exceptions))
{
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 6fd52ef70..cdd178261 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -1,13 +1,13 @@
-char_set)) ? 'UTF-8' : $this->char_set;
$connection = array(
- 'UID' => empty($this->username) ? '' : $this->username,
- 'PWD' => empty($this->password) ? '' : $this->password,
- 'Database' => $this->database,
- 'ConnectionPooling' => $pooling ? 1 : 0,
+ 'UID' => empty($this->username) ? '' : $this->username,
+ 'PWD' => empty($this->password) ? '' : $this->password,
+ 'Database' => $this->database,
+ 'ConnectionPooling' => $pooling ? 1 : 0,
'CharacterSet' => $character_set,
- 'ReturnDatesAsStrings' => 1
+ 'ReturnDatesAsStrings' => 1
);
-
- // If the username and password are both empty, assume this is a
+
+ // If the username and password are both empty, assume this is a
// 'Windows Authentication Mode' connection.
- if(empty($connection['UID']) && empty($connection['PWD'])) {
+ if (empty($connection['UID']) && empty($connection['PWD']))
+ {
unset($connection['UID'], $connection['PWD']);
}
@@ -93,10 +91,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
return $this->db_connect(TRUE);
}
@@ -109,12 +106,11 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
- * @access public
* @return void
*/
- function reconnect()
+ public function reconnect()
{
- // not implemented in MSSQL
+ // Not supported in MSSQL
}
// --------------------------------------------------------------------
@@ -122,10 +118,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
return $this->_execute('USE ' . $this->database);
}
@@ -135,14 +130,13 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Set client character set
*
- * @access public
* @param string
* @param string
- * @return resource
+ * @return bool
*/
- function db_set_charset($charset, $collation)
+ public function db_set_charset($charset, $collation)
{
- // @todo - add support if needed
+ // This is done upon connect
return TRUE;
}
@@ -151,17 +145,13 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
- return sqlsrv_query($this->conn_id, $sql, null, array(
- 'Scrollable' => SQLSRV_CURSOR_STATIC,
- 'SendStreamParamsAtExec' => true
- ));
+ return sqlsrv_query($this->conn_id, $this->_prep_query($sql), NULL,
+ array('Scrollable' => SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => TRUE));
}
// --------------------------------------------------------------------
@@ -171,11 +161,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* If needed, each database adapter can prep the query string
*
- * @access private called by execute()
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ protected function _prep_query($sql)
{
return $sql;
}
@@ -185,18 +174,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -204,7 +187,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = ($test_mode === TRUE);
return sqlsrv_begin_transaction($this->conn_id);
}
@@ -214,18 +197,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -238,18 +215,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -262,12 +233,11 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
// Escape single quotes
return str_replace("'", "''", $str);
@@ -278,10 +248,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @sqlrv_rows_affected($this->conn_id);
}
@@ -293,30 +262,13 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Returns the last id created in the Identity column.
*
- * @access public
- * @return integer
- */
- function insert_id()
- {
- return $this->query('select @@IDENTITY as insert_id')->row('insert_id');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse major version
- *
- * Grabs the major version number from the
- * database server version string passed in.
- *
- * @access private
- * @param string $version
- * @return int16 major version number
+ * @return int
*/
- function _parse_major_version($version)
+ public function insert_id()
{
- preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
- return $ver_info[1]; // return the major version b/c that's all we're interested in.
+ $query = $this->query('SELECT @@IDENTITY AS insert_id');
+ $query = $query->row();
+ return $query->insert_id;
}
// --------------------------------------------------------------------
@@ -324,13 +276,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Version number query string
*
- * @access public
- * @return string
+ * @return string
*/
- function _version()
+ protected function _version()
{
$info = sqlsrv_server_info($this->conn_id);
- return sprintf("select '%s' as ver", $info['SQLServerVersion']);
+ return $info['SQLServerVersion'];
}
// --------------------------------------------------------------------
@@ -341,23 +292,25 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
- return '0';
-
- $query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table);
-
- if ($query->num_rows() == 0)
- return '0';
-
- $row = $query->row();
+ {
+ return 0;
+ }
+
+ $query = $this->query('SELECT COUNT(*) AS numrows FROM '.$this->dbprefix.$table);
+ if ($query->num_rows() === 0)
+ {
+ return 0;
+ }
+
+ $query = $query->row();
$this->_reset_select();
- return $row->numrows;
+ return (int) $query->numrows;
}
// --------------------------------------------------------------------
@@ -367,11 +320,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
}
@@ -383,11 +335,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access private
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
}
@@ -399,13 +350,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
* @return object
*/
- function _field_data($table)
+ protected function _field_data($table)
{
- return "SELECT TOP 1 * FROM " . $this->_escape_table($table);
+ return 'SELECT TOP 1 * FROM '.$this->_escape_table($table);
}
// --------------------------------------------------------------------
@@ -413,13 +363,18 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* The error message string
*
- * @access private
* @return string
*/
- function _error_message()
+ protected function _error_message()
{
- $error = array_shift(sqlsrv_errors());
- return !empty($error['message']) ? $error['message'] : null;
+ $error = sqlsrv_errors();
+ if ( ! is_array($error))
+ {
+ return '';
+ }
+
+ $error = array_shift($error);
+ return isset($error['message']) ? $error['message'] : '';
}
// --------------------------------------------------------------------
@@ -427,13 +382,29 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* The error message number
*
- * @access private
- * @return integer
+ * @return string
*/
- function _error_number()
+ protected function _error_number()
{
- $error = array_shift(sqlsrv_errors());
- return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null;
+ $error = sqlsrv_errors();
+ if ( ! is_array($error))
+ {
+ return '';
+ }
+ elseif (isset($error['SQLSTATE'], $error['code']))
+ {
+ return $error['SQLSTATE'].'/'.$error['code'];
+ }
+ elseif (isset($error['SQLSTATE']))
+ {
+ return $error['SQLSTATE'];
+ }
+ elseif (isset($error['code']))
+ {
+ return $error['code'];
+ }
+
+ return '';
}
// --------------------------------------------------------------------
@@ -444,26 +415,23 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* This function adds backticks if the table name has a period
* in it. Some DBs will get cranky unless periods are escaped
*
- * @access private
* @param string the table name
* @return string
*/
- function _escape_table($table)
+ protected function _escape_table($table)
{
return $table;
- }
-
+ }
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
return $item;
}
@@ -476,11 +444,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -497,15 +464,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
- {
- return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ protected function _insert($table, $keys, $values)
+ {
+ return 'INSERT INTO '.$this->_escape_table($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -515,7 +481,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -523,16 +488,16 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where)
+ protected function _update($table, $values, $where)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key.' = '.$val;
}
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+
+ return 'UPDATE '.$this->_escape_table($table).' SET '.implode(', ', $valstr).' WHERE '.implode(' ', $where);
}
-
+
// --------------------------------------------------------------------
/**
@@ -542,13 +507,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
- return "TRUNCATE ".$table;
+ return 'TRUNCATE '.$table;
}
// --------------------------------------------------------------------
@@ -558,15 +522,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where)
+ protected function _delete($table, $where)
{
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ return 'DELETE FROM '.$this->_escape_table($table).' WHERE '.implode(' ', $where);
}
// --------------------------------------------------------------------
@@ -576,17 +539,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
- $i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql);
}
// --------------------------------------------------------------------
@@ -594,18 +554,15 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@sqlsrv_close($conn_id);
}
}
-
-
-/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
\ No newline at end of file
+/* End of file sqlsrv_driver.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index 2a7766927..1367ddc77 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -1,13 +1,13 @@
-db->_escape_identifiers($table);
+ return 'DROP TABLE '.$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
@@ -80,15 +76,14 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
- * @return bool
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
+ * @return string
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -97,54 +92,29 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
$sql .= 'IF NOT EXISTS ';
}
- $sql .= $this->db->_escape_identifiers($table)." (";
+ $sql .= $this->db->_escape_identifiers($table).' (';
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
- $sql .= "\n\t$attributes";
+ $sql .= "\n\t".$attributes;
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
-
- $sql .= ' '.$attributes['TYPE'];
-
- if (array_key_exists('CONSTRAINT', $attributes))
- {
- $sql .= '('.$attributes['CONSTRAINT'].')';
- }
-
- if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
- {
- $sql .= ' UNSIGNED';
- }
-
- if (array_key_exists('DEFAULT', $attributes))
- {
- $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
- }
-
- if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
- {
- $sql .= ' AUTO_INCREMENT';
- }
+ $sql .= "\n\t".$this->db->protect_identifiers($field)
+ .' '.$attributes['TYPE']
+ .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+ .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
@@ -156,8 +126,8 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
- $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')';
}
if (is_array($keys) && count($keys) > 0)
@@ -166,20 +136,18 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
- $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+ $sql .= ",\n\tFOREIGN KEY (".implode(', ', $key).')';
}
}
- $sql .= "\n)";
-
- return $sql;
+ return $sql."\n)";
}
// --------------------------------------------------------------------
@@ -190,7 +158,6 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
@@ -200,9 +167,9 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
* @param string the field after which we should add the new field
* @return object
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+ $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' '.$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -210,29 +177,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
return $sql;
}
- $sql .= " $column_definition";
-
- if ($default_value != '')
- {
- $sql .= " DEFAULT \"$default_value\"";
- }
-
- if ($null === NULL)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if ($after_field != '')
- {
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
- }
-
- return $sql;
-
+ return $sql.' '.$column_definition
+ .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '')
+ .($null === NULL ? ' NULL' : ' NOT NULL')
+ .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : '');
}
// --------------------------------------------------------------------
@@ -242,19 +190,17 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
-/* End of file mssql_forge.php */
-/* Location: ./system/database/drivers/mssql/mssql_forge.php */
\ No newline at end of file
+/* End of file sqlsrv_forge.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 1ee19c2d1..c5f9093db 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -1,13 +1,13 @@
-result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @sqlsrv_num_fields($this->result_id);
}
@@ -69,17 +65,16 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$field_names[] = $field['Name'];
}
-
+
return $field_names;
}
@@ -90,24 +85,23 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
- $F = new stdClass();
- $F->name = $field['Name'];
- $F->type = $field['Type'];
+ $F = new stdClass();
+ $F->name = $field['Name'];
+ $F->type = $field['Type'];
$F->max_length = $field['Size'];
$F->primary_key = 0;
- $F->default = '';
-
+ $F->default = '';
+
$retval[] = $F;
}
-
+
return $retval;
}
@@ -116,9 +110,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -136,10 +130,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
- * @return array
+ * @return void
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
// Not implemented
}
@@ -151,10 +144,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC);
}
@@ -166,16 +158,14 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return sqlsrv_fetch_object($this->result_id);
}
}
-
-/* End of file mssql_result.php */
-/* Location: ./system/database/drivers/mssql/mssql_result.php */
\ No newline at end of file
+/* End of file sqlsrv_result.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_result.php */
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
index e96df96f9..d2a421208 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_utility.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -1,13 +1,13 @@
-db->protect_identifiers($table).' REORGANIZE';
}
// --------------------------------------------------------------------
@@ -70,13 +66,13 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
- return FALSE; // Is this supported in MS SQL?
+ // Not supported in MSSQL
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -84,11 +80,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* MSSQL Export
*
- * @access private
* @param array Preferences
- * @return mixed
+ * @return bool
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -96,5 +91,5 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
}
-/* End of file mssql_utility.php */
-/* Location: ./system/database/drivers/mssql/mssql_utility.php */
\ No newline at end of file
+/* End of file sqlsrv_utility.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_utility.php */
--
cgit v1.2.3-24-g4f1b
From b7a47a7b934b2771561c1cefcfc74aeada90e352 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 02:13:33 +0200
Subject: A minor improvement to insert_id()
---
system/database/drivers/mssql/mssql_driver.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 22ed0478e..4d29920d6 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -280,13 +280,13 @@ class CI_DB_mssql_driver extends CI_DB {
*/
public function insert_id()
{
- $sql = (self::_parse_major_version($this->version()) > 7)
+ $query = (self::_parse_major_version($this->version()) > 7)
? 'SELECT SCOPE_IDENTITY() AS last_id'
: 'SELECT @@IDENTITY AS last_id';
- $query = $this->query($sql);
- $row = $query->row();
- return $row->last_id;
+ $query = $this->query($query);
+ $query = $query->row();
+ return $query->last_id;
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From d90387867fbc8e1d10058cf65805a7ae5c8cbaeb Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 12:38:49 +0200
Subject: Improve the SQLite database driver
---
system/database/drivers/sqlite/sqlite_driver.php | 238 ++++++++--------------
system/database/drivers/sqlite/sqlite_forge.php | 151 ++++----------
system/database/drivers/sqlite/sqlite_result.php | 76 +++----
system/database/drivers/sqlite/sqlite_utility.php | 37 ++--
4 files changed, 171 insertions(+), 331 deletions(-)
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 28c3caecd..96458e032 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -1,13 +1,13 @@
-database, FILE_WRITE_MODE, $error))
{
@@ -89,10 +84,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
{
@@ -117,12 +111,11 @@ class CI_DB_sqlite_driver extends CI_DB {
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
- * @access public
* @return void
*/
- function reconnect()
+ public function reconnect()
{
- // not implemented in SQLite
+ // Not supported in SQLite
}
// --------------------------------------------------------------------
@@ -130,11 +123,11 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
- * @return resource
+ * @return bool
*/
- function db_select()
+ public function db_select()
{
+ // Not needed, in SQLite every pseudo-connection is a database
return TRUE;
}
@@ -143,14 +136,13 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Set client character set
*
- * @access public
* @param string
* @param string
- * @return resource
+ * @return bool
*/
- function db_set_charset($charset, $collation)
+ public function db_set_charset($charset, $collation)
{
- // @todo - add support if needed
+ // Not supported
return TRUE;
}
@@ -159,10 +151,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Version number query string
*
- * @access public
* @return string
*/
- function _version()
+ public function _version()
{
return sqlite_libversion();
}
@@ -172,13 +163,18 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
$sql = $this->_prep_query($sql);
+
+ if ( ! preg_match('/^(SELECT|EXPLAIN).+$/i', ltrim($sql)))
+ {
+ return @sqlite_exec($this->conn_id, $sql);
+ }
+
return @sqlite_query($this->conn_id, $sql);
}
@@ -189,11 +185,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* If needed, each database adapter can prep the query string
*
- * @access private called by execute()
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ protected function _prep_query($sql)
{
return $sql;
}
@@ -203,18 +198,12 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -222,7 +211,7 @@ class CI_DB_sqlite_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = ($test_mode === TRUE);
$this->simple_query('BEGIN TRANSACTION');
return TRUE;
@@ -233,18 +222,12 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -258,18 +241,12 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -283,12 +260,11 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -305,9 +281,9 @@ class CI_DB_sqlite_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array('%', '_', $this->_like_escape_chr),
+ array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
+ $str);
}
return $str;
@@ -318,10 +294,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return sqlite_changes($this->conn_id);
}
@@ -331,10 +306,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
- function insert_id()
+ public function insert_id()
{
return @sqlite_last_insert_rowid($this->conn_id);
}
@@ -347,27 +321,25 @@ class CI_DB_sqlite_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $query = $this->query($this->_count_string.$this->_protect_identifiers('numrows').' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
- $row = $query->row();
+ $query = $query->row();
$this->_reset_select();
- return (int) $row->numrows;
+ return (int) $query->numrows;
}
// --------------------------------------------------------------------
@@ -377,18 +349,18 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
- $sql = "SELECT name from sqlite_master WHERE type='table'";
+ $sql = "SELECT name FROM sqlite_master WHERE type='table'";
- if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ if ($prefix_limit !== FALSE && $this->dbprefix != '')
{
- $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+ return $sql." AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
+
return $sql;
}
@@ -399,11 +371,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
- * @return string
+ * @return bool
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
// Not supported
return FALSE;
@@ -416,13 +387,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
- return "SELECT * FROM ".$table." LIMIT 1";
+ return 'SELECT * FROM '.$table.' LIMIT 1';
}
// --------------------------------------------------------------------
@@ -430,10 +400,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* The error message string
*
- * @access private
* @return string
*/
- function _error_message()
+ protected function _error_message()
{
return sqlite_error_string(sqlite_last_error($this->conn_id));
}
@@ -443,10 +412,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* The error message number
*
- * @access private
- * @return integer
+ * @return int
*/
- function _error_number()
+ protected function _error_number()
{
return sqlite_last_error($this->conn_id);
}
@@ -458,11 +426,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -473,24 +440,20 @@ class CI_DB_sqlite_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+ $item = str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item);
}
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
- }
- else
- {
- $str = $this->_escape_char.$item.$this->_escape_char;
+ $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item);
}
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char);
}
// --------------------------------------------------------------------
@@ -501,11 +464,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
* @param type
* @return type
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -522,15 +484,14 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
- return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -540,7 +501,6 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -548,24 +508,17 @@ class CI_DB_sqlite_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key.' = '.$val;
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
-
- $sql .= $orderby.$limit;
-
- return $sql;
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
+ .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '')
+ .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '')
+ .( ! $limit ? '' : ' LIMIT '.$limit);
}
@@ -578,11 +531,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -594,31 +546,27 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
- $conditions = "\nWHERE ";
- $conditions .= implode("\n", $this->ar_where);
+ $conditions = "\nWHERE ".implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
- $conditions .= " AND ";
+ $conditions .= ' AND ';
}
$conditions .= implode("\n", $like);
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- return "DELETE FROM ".$table.$conditions.$limit;
+ return 'DELETE FROM '.$table.$conditions.( ! $limit ? '' : ' LIMIT '.$limit);
}
// --------------------------------------------------------------------
@@ -628,24 +576,14 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
- if ($offset == 0)
- {
- $offset = '';
- }
- else
- {
- $offset .= ", ";
- }
-
- return $sql."LIMIT ".$offset.$limit;
+ return $sql.'LIMIT '.($offset == 0 ? '' : ', ').$limit;
}
// --------------------------------------------------------------------
@@ -653,11 +591,10 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@sqlite_close($conn_id);
}
@@ -665,6 +602,5 @@ class CI_DB_sqlite_driver extends CI_DB {
}
-
/* End of file sqlite_driver.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 2b723be0b..8bf1f2595 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -1,13 +1,13 @@
-db->database) OR ! @unlink($this->db->database))
{
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unable_to_drop');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
}
+
return TRUE;
}
// --------------------------------------------------------------------
@@ -76,15 +69,14 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -94,54 +86,29 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
$sql .= 'IF NOT EXISTS ';
}
- $sql .= $this->db->_escape_identifiers($table)."(";
+ $sql .= $this->db->_escape_identifiers($table).'(';
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
- $sql .= "\n\t$attributes";
+ $sql .= "\n\t".$attributes;
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
-
- $sql .= ' '.$attributes['TYPE'];
-
- if (array_key_exists('CONSTRAINT', $attributes))
- {
- $sql .= '('.$attributes['CONSTRAINT'].')';
- }
-
- if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
- {
- $sql .= ' UNSIGNED';
- }
-
- if (array_key_exists('DEFAULT', $attributes))
- {
- $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
- }
-
- if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
- {
- $sql .= ' AUTO_INCREMENT';
- }
+ $sql .= "\n\t".$this->db->protect_identifiers($field)
+ .' '.$attributes['TYPE']
+ .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+ .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
@@ -153,8 +120,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
- $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ $sql .= ",\n\tPRIMARY KEY (".implode(', ', $this->db->protect_identifiers($primary_keys)).')';
}
if (is_array($keys) && count($keys) > 0)
@@ -163,20 +129,18 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
- $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
+ $sql .= ",\n\tUNIQUE (".implode(', ', $key).')';
}
}
- $sql .= "\n)";
-
- return $sql;
+ return $sql."\n)";
}
// --------------------------------------------------------------------
@@ -184,18 +148,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Drop Table
*
- * Unsupported feature in SQLite
- *
- * @access private
- * @return bool
+ * @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return array();
+ return 'DROP TABLE '.$table.' IF EXISTS';
}
// --------------------------------------------------------------------
@@ -206,7 +163,6 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
@@ -214,44 +170,25 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
-
- // DROP has everything it needs now.
- if ($alter_type == 'DROP')
+ /* SQLite only supports adding new columns and it does
+ * NOT support the AFTER statement. Each new column will
+ * be added as the last one in the table.
+ */
+ if ($alter_type !== 'ADD COLUMN')
{
- // SQLite does not support dropping columns
- // http://www.sqlite.org/omitted.html
- // http://www.sqlite.org/faq.html#q11
+ // Not supported
return FALSE;
}
- $sql .= " $column_definition";
-
- if ($default_value != '')
- {
- $sql .= " DEFAULT \"$default_value\"";
- }
-
- if ($null === NULL)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if ($after_field != '')
- {
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
- }
-
- return $sql;
-
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name)
+ .' '.$column_definition
+ .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '')
+ // If NOT NULL is specified, the field must have a DEFAULT value other than NULL
+ .(($null !== NULL && $default_value !== 'NULL') ? ' NOT NULL' : ' NULL');
}
// --------------------------------------------------------------------
@@ -261,17 +198,15 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file sqlite_forge.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index 74c0dc549..91fe57ae1 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -1,13 +1,13 @@
-result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @sqlite_num_fields($this->result_id);
}
@@ -69,13 +65,12 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
$field_names[] = sqlite_field_name($this->result_id, $i);
}
@@ -90,22 +85,19 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
- $F = new stdClass();
- $F->name = sqlite_field_name($this->result_id, $i);
- $F->type = 'varchar';
- $F->max_length = 0;
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = sqlite_field_name($this->result_id, $i);
+ $retval[$i]->type = 'varchar';
+ $retval[$i]->max_length = 0;
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -116,11 +108,11 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
- // Not implemented in SQLite
+ // Not supported in SQLite
}
// --------------------------------------------------------------------
@@ -128,14 +120,13 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return sqlite_seek($this->result_id, $n);
}
@@ -147,10 +138,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return sqlite_fetch_array($this->result_id);
}
@@ -162,30 +152,20 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
if (function_exists('sqlite_fetch_object'))
{
return sqlite_fetch_object($this->result_id);
}
- else
- {
- $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
- if (is_array($arr))
- {
- $obj = (object) $arr;
- return $obj;
- } else {
- return NULL;
- }
- }
+
+ $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
+ return is_array($arr) ? (object) $arr : FALSE;
}
}
-
/* End of file sqlite_result.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_result.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_result.php */
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index f00687e38..358fe747f 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -1,13 +1,13 @@
-db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return array();
+ return ($this->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -61,14 +54,12 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* Optimize table query
*
- * Is optimization even supported in SQLite?
- *
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
+ // Not supported
return FALSE;
}
@@ -77,14 +68,13 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* Repair table query
*
- * Are table repairs even supported in SQLite?
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
+ // Not supported
return FALSE;
}
@@ -93,11 +83,10 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* SQLite Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -105,4 +94,4 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
}
/* End of file sqlite_utility.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
--
cgit v1.2.3-24-g4f1b
From fb86295d7d49e7ddfba266fe9f7305fb44708d4f Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 14:08:47 +0200
Subject: Replace array_key_exists() with isset() and ! empty()
---
system/database/drivers/mssql/mssql_forge.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index 65513f437..231284c7c 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -110,11 +110,11 @@ class CI_DB_mssql_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.' '.$attributes['TYPE']
- .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '')
- .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
- .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
- .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
- .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
+ .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+ .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
--
cgit v1.2.3-24-g4f1b
From 20ebf1459b6dc1449a545156b70e7cb2932fa9eb Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 14:14:02 +0200
Subject: Replace array_key_exists() with isset() and ! empty()
---
system/database/drivers/sqlite/sqlite_forge.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 8bf1f2595..5339f6e3e 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -104,11 +104,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.' '.$attributes['TYPE']
- .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '')
- .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
- .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
- .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
- .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
+ .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+ .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
--
cgit v1.2.3-24-g4f1b
From 684ee3a330c90744b249b48212d85dfe4d3b1caf Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 14:17:39 +0200
Subject: Replace array_key_exists() with isset()
---
system/database/drivers/sqlsrv/sqlsrv_forge.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index 1367ddc77..c0271f671 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -110,11 +110,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.' '.$attributes['TYPE']
- .(array_key_exists('CONSTRAINT', $attributes) ? '('.$attributes['CONSTRAINT'].')' : '')
- .((array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
- .(array_key_exists('DEFAULT', $attributes) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
- .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
- .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
+ .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+ .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
--
cgit v1.2.3-24-g4f1b
From b537c4d32d109cef2ddf541aa976c3e96736bf06 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 14:45:45 +0200
Subject: Fix _limit()
---
system/database/drivers/sqlite/sqlite_driver.php | 2 +-
system/database/drivers/sqlite/sqlite_forge.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 96458e032..119722d2f 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -583,7 +583,7 @@ class CI_DB_sqlite_driver extends CI_DB {
*/
protected function _limit($sql, $limit, $offset)
{
- return $sql.'LIMIT '.($offset == 0 ? '' : ', ').$limit;
+ return $sql.'LIMIT '.($offset == 0 ? '' : $offset.', ').$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 5339f6e3e..99766878b 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -104,11 +104,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.' '.$attributes['TYPE']
- .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
- .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
.(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
- .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
- .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
+ .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
--
cgit v1.2.3-24-g4f1b
From 993f932cb27f68ac4a3272502a823af0835b291c Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 26 Jan 2012 14:49:23 +0200
Subject: Another minor improvement and fix a possible false-positive
---
system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +-
system/database/drivers/sqlsrv/sqlsrv_forge.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index cdd178261..0c24ef38f 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -303,7 +303,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
}
$query = $this->query('SELECT COUNT(*) AS numrows FROM '.$this->dbprefix.$table);
- if ($query->num_rows() === 0)
+ if ($query->num_rows() == 0)
{
return 0;
}
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index c0271f671..3beb86b4e 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -110,11 +110,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.' '.$attributes['TYPE']
- .(isset($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
- .((isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
.(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
- .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
- .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
+ .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
--
cgit v1.2.3-24-g4f1b
From d33e24c2a649420d420ad9b11efb1bbf2421114c Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Sun, 12 Feb 2012 03:23:07 +0200
Subject: Add SQLite escape character
---
system/database/drivers/sqlite/sqlite_driver.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 119722d2f..25e012bf0 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -43,7 +43,7 @@ class CI_DB_sqlite_driver extends CI_DB {
public $dbdriver = 'sqlite';
// The character used to escape with - not needed for SQLite
- protected $_escape_char = '';
+ protected $_escape_char = '"';
// clause and character used for LIKE escape sequences
protected $_like_escape_str = ' ESCAPE \'%s\' ';
@@ -338,7 +338,7 @@ class CI_DB_sqlite_driver extends CI_DB {
}
$query = $query->row();
- $this->_reset_select();
+ $this->_data_seek(0);
return (int) $query->numrows;
}
--
cgit v1.2.3-24-g4f1b
From bd601d3d18531fa543ee57befac7cba6739c419b Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Sun, 12 Feb 2012 21:16:51 +0200
Subject: Added port handling support for UNIX systems and moved it to the
constructor
---
system/database/drivers/mssql/mssql_driver.php | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 611a4afba..c273323d8 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -57,6 +57,16 @@ class CI_DB_mssql_driver extends CI_DB {
protected $_count_string = 'SELECT COUNT(*) AS ';
protected $_random_keyword = ' NEWID()';
+ public function __construct($params)
+ {
+ parent::__construct($params);
+
+ if ( ! empty($this->port) && ctype_digit($this->port))
+ {
+ $this->hostname .= (DIRECTORY_SEPARATOR === '\\' ? ',' : ':').$this->port;
+ }
+ }
+
/**
* Non-persistent database connection
*
@@ -64,11 +74,6 @@ class CI_DB_mssql_driver extends CI_DB {
*/
public function db_connect()
{
- if ($this->port != '')
- {
- $this->hostname .= ','.$this->port;
- }
-
return @mssql_connect($this->hostname, $this->username, $this->password);
}
@@ -81,11 +86,6 @@ class CI_DB_mssql_driver extends CI_DB {
*/
public function db_pconnect()
{
- if ($this->port != '')
- {
- $this->hostname .= ','.$this->port;
- }
-
return @mssql_pconnect($this->hostname, $this->username, $this->password);
}
--
cgit v1.2.3-24-g4f1b
From ce383fa1a9702c1e04431a66c7a7e1fe5bc825cb Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Mon, 27 Feb 2012 23:28:48 +0200
Subject: Update the changelog
---
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 dc6b29516..8f7b3bc6c 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -108,6 +108,7 @@ Bug fixes for 3.0
- Fixed a possible bug in ``CI_Input::is_ajax_request()`` where some clients might not send the X-Requested-With HTTP header value exactly as 'XmlHttpRequest'.
- Fixed a bug (#1039) - MySQL's _backup() method failed due to a table name not being escaped.
- Fixed a bug (#1070) - CI_DB_driver::initialize() didn't set a character set if a database is not selected.
+- Fixed a bug (#611) - SQLSRV's _error_*() methods used to issue warnings when there's no actual error.
Version 2.1.0
=============
--
cgit v1.2.3-24-g4f1b
From a0c2785f91bc70fb4a0a02f1c9c28cb99c975457 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Fri, 2 Mar 2012 13:49:28 +0200
Subject: Change SQLite _execute() to use is_write_type()
---
system/database/drivers/sqlite/sqlite_driver.php | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 20b05af0d..8116cfb18 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -154,13 +154,9 @@ class CI_DB_sqlite_driver extends CI_DB {
protected function _execute($sql)
{
$sql = $this->_prep_query($sql);
-
- if ( ! preg_match('/^(SELECT|EXPLAIN).+$/i', ltrim($sql)))
- {
- return @sqlite_exec($this->conn_id, $sql);
- }
-
- return @sqlite_query($this->conn_id, $sql);
+ return $this->is_write_type($sql)
+ ? @sqlite_exec($this->conn_id, $sql)
+ : @sqlite_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 75124a53cf54f2a8c094756f9189be9159957f28 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Tue, 13 Mar 2012 12:47:58 +0200
Subject: Some comments altered
---
system/helpers/smiley_helper.php | 5 -----
system/helpers/string_helper.php | 20 +++++++-------------
system/helpers/text_helper.php | 29 ++++++++++-------------------
3 files changed, 17 insertions(+), 37 deletions(-)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 83fb863df..bc592f74f 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -43,7 +43,6 @@
* Returns the javascript required for the smiley insertion. Optionally takes
* an array of aliases to loosely couple the smiley array to the view.
*
- * @access public
* @param mixed alias name or array of alias->field_id pairs
* @param string field_id if alias name was passed in
* @return array
@@ -125,7 +124,6 @@ EOF;
* Returns an array of image tag links that can be clicked to be inserted
* into a form field.
*
- * @access public
* @param string the URL to the folder containing the smiley images
* @return array
*/
@@ -173,7 +171,6 @@ if ( ! function_exists('get_clickable_smileys'))
*
* Takes a string as input and swaps any contained smileys for the actual image
*
- * @access public
* @param string the text to be parsed
* @param string the URL to the folder containing the smiley images
* @return string
@@ -206,7 +203,6 @@ if ( ! function_exists('parse_smileys'))
*
* Fetches the config/smiley.php file
*
- * @access private
* @return mixed
*/
if ( ! function_exists('_get_smiley_array'))
@@ -235,7 +231,6 @@ if ( ! function_exists('_get_smiley_array'))
*
* DEPRECATED as of version 1.7.2, use smiley_js instead
*
- * @access public
* @param string form name
* @param string field name
* @return string
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 6573b9a5d..a53d1b88e 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -48,7 +48,6 @@
*
* this/that/theother
*
- * @access public
* @param string
* @return string
*/
@@ -67,7 +66,6 @@ if ( ! function_exists('trim_slashes'))
*
* Removes slashes contained in a string or in an array
*
- * @access public
* @param mixed string or array
* @return mixed string or array
*/
@@ -96,7 +94,6 @@ if ( ! function_exists('strip_slashes'))
*
* Removes single and double quotes from a string
*
- * @access public
* @param string
* @return string
*/
@@ -115,7 +112,6 @@ if ( ! function_exists('strip_quotes'))
*
* Converts single and double quotes to entities
*
- * @access public
* @param string
* @return string
*/
@@ -141,7 +137,6 @@ if ( ! function_exists('quotes_to_entities'))
*
* http://www.some-site.com/index.php
*
- * @access public
* @param string
* @return string
*/
@@ -166,7 +161,6 @@ if ( ! function_exists('reduce_double_slashes'))
*
* Fred, Bill, Joe, Jimmy
*
- * @access public
* @param string
* @param string the character you wish to reduce
* @param bool TRUE/FALSE - whether to trim the character from the beginning/end
@@ -188,7 +182,6 @@ if ( ! function_exists('reduce_multiples'))
*
* Useful for generating passwords or hashes.
*
- * @access public
* @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
* @param int number of characters
* @return string
@@ -219,7 +212,7 @@ if ( ! function_exists('random_string'))
$pool = '123456789';
break;
}
- return substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
+ return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len);
case 'unique':
case 'md5': return md5(uniqid(mt_rand()));
case 'encrypt':
@@ -241,10 +234,13 @@ if ( ! function_exists('random_string'))
* @param string $first Which number should be used for the first dupe increment
* @return string
*/
-function increment_string($str, $separator = '_', $first = 1)
+if ( ! function_exists('increment_string'))
{
- preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
- return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ function increment_string($str, $separator = '_', $first = 1)
+ {
+ preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
+ return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ }
}
// ------------------------------------------------------------------------
@@ -254,7 +250,6 @@ function increment_string($str, $separator = '_', $first = 1)
*
* Allows strings to be alternated. See docs...
*
- * @access public
* @param string (as many parameters as needed)
* @return string
*/
@@ -279,7 +274,6 @@ if ( ! function_exists('alternator'))
/**
* Repeater function
*
- * @access public
* @param string
* @param int number of repeats
* @return string
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index bddb112b2..9a56159d9 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -42,9 +42,8 @@
*
* Limits a string to X number of words.
*
- * @access public
* @param string
- * @param integer
+ * @param int
* @param string the end character. Usually an ellipsis
* @return string
*/
@@ -76,9 +75,8 @@ if ( ! function_exists('word_limiter'))
* Limits the string based on the character count. Preserves complete words
* so the character count may not be exactly as specified.
*
- * @access public
* @param string
- * @param integer
+ * @param int
* @param string the end character. Usually an ellipsis
* @return string
*/
@@ -119,7 +117,6 @@ if ( ! function_exists('character_limiter'))
*
* Converts High ascii text and MS Word special characters to character entities
*
- * @access public
* @param string
* @return string
*/
@@ -182,7 +179,6 @@ if ( ! function_exists('ascii_to_entities'))
*
* Converts character entities back to ASCII
*
- * @access public
* @param string
* @param bool
* @return string
@@ -238,7 +234,6 @@ if ( ! function_exists('entities_to_ascii'))
* matched words will be converted to #### or to the replacement
* word you've submitted.
*
- * @access public
* @param string the text string
* @param string the array of censoered words
* @param string the optional replacement value
@@ -284,7 +279,6 @@ if ( ! function_exists('word_censor'))
*
* Colorizes code strings
*
- * @access public
* @param string the text string
* @return string
*/
@@ -334,7 +328,6 @@ if ( ! function_exists('highlight_code'))
*
* Highlights a phrase within a text string
*
- * @access public
* @param string the text string
* @param string the phrase you'd like to highlight
* @param string the openging tag to precede the phrase with
@@ -364,7 +357,6 @@ if ( ! function_exists('highlight_phrase'))
/**
* Convert Accented Foreign Characters to ASCII
*
- * @access public
* @param string the text string
* @return string
*/
@@ -404,9 +396,8 @@ if ( ! function_exists('convert_accented_characters'))
* Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
* will URLs.
*
- * @access public
* @param string the text string
- * @param integer the number of characters to wrap at
+ * @param int the number of characters to wrap at
* @return string
*/
if ( ! function_exists('word_wrap'))
@@ -467,8 +458,8 @@ if ( ! function_exists('word_wrap'))
}
// Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
+ $temp .= substr($line, 0, $charlim - 1);
+ $line = substr($line, $charlim - 1);
}
// If $temp contains data it means we had to split up an over-length
@@ -504,11 +495,11 @@ if ( ! function_exists('word_wrap'))
*
* This function will strip tags from a string, split it at its max_length and ellipsize
*
- * @param string string to ellipsize
- * @param integer max length of string
- * @param mixed int (1|0) or float, .5, .2, etc for position to split
- * @param string ellipsis ; Default '...'
- * @return string ellipsized string
+ * @param string string to ellipsize
+ * @param int max length of string
+ * @param mixed int (1|0) or float, .5, .2, etc for position to split
+ * @param string ellipsis ; Default '...'
+ * @return string ellipsized string
*/
if ( ! function_exists('ellipsize'))
{
--
cgit v1.2.3-24-g4f1b
From e79a3b134bb5268106d550934808dd9e404ca515 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Tue, 20 Mar 2012 15:41:22 +0200
Subject: Remove EOF newlines
---
system/helpers/smiley_helper.php | 2 +-
system/helpers/string_helper.php | 2 +-
system/helpers/text_helper.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index bc592f74f..638100e9c 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -251,4 +251,4 @@ EOF;
}
/* End of file smiley_helper.php */
-/* Location: ./system/helpers/smiley_helper.php */
+/* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index a53d1b88e..e570d5d01 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -287,4 +287,4 @@ if ( ! function_exists('repeater'))
}
/* End of file string_helper.php */
-/* Location: ./system/helpers/string_helper.php */
+/* Location: ./system/helpers/string_helper.php */
\ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 9a56159d9..daf31c3d6 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -531,4 +531,4 @@ if ( ! function_exists('ellipsize'))
}
/* End of file text_helper.php */
-/* Location: ./system/helpers/text_helper.php */
+/* Location: ./system/helpers/text_helper.php */
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 7fd46308949522f1c7c8853381c2ce7cea093c9a Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Fri, 23 Mar 2012 15:59:38 +0200
Subject: Remove an accidently added newline at foreign_chars.php EOF
---
application/config/foreign_chars.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
index fc349ff0b..d3713fe98 100644
--- a/application/config/foreign_chars.php
+++ b/application/config/foreign_chars.php
@@ -87,4 +87,4 @@ $foreign_characters = array(
);
/* End of file foreign_chars.php */
-/* Location: ./application/config/foreign_chars.php */
+/* Location: ./application/config/foreign_chars.php */
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 9c9591c9b4a1d7ac412f7a85aeb5c92f50aa3490 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Fri, 6 Apr 2012 21:47:49 +0300
Subject: Fix erroneous merge
---
tests/mocks/autoloader.php | 79 ++++++++++++++
tests/mocks/ci_testcase.php | 196 +++++++++++++++++++++++++++++++++++
tests/mocks/core/common.php | 132 +++++++++++++++++++++++
tests/mocks/core/loader.php | 30 ++++++
tests/mocks/core/uri.php | 25 +++++
tests/mocks/libraries/parser.php | 3 +
tests/mocks/libraries/table.php | 15 +++
tests/mocks/libraries/typography.php | 3 +
tests/mocks/libraries/useragent.php | 3 +
9 files changed, 486 insertions(+)
create mode 100644 tests/mocks/autoloader.php
create mode 100644 tests/mocks/ci_testcase.php
create mode 100644 tests/mocks/core/common.php
create mode 100644 tests/mocks/core/loader.php
create mode 100644 tests/mocks/core/uri.php
create mode 100644 tests/mocks/libraries/parser.php
create mode 100644 tests/mocks/libraries/table.php
create mode 100644 tests/mocks/libraries/typography.php
create mode 100644 tests/mocks/libraries/useragent.php
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
new file mode 100644
index 000000000..dd5929206
--- /dev/null
+++ b/tests/mocks/autoloader.php
@@ -0,0 +1,79 @@
+ 'bm',
+ 'config' => 'cfg',
+ 'hooks' => 'ext',
+ 'utf8' => 'uni',
+ 'router' => 'rtr',
+ 'output' => 'out',
+ 'security' => 'sec',
+ 'input' => 'in',
+ 'lang' => 'lang',
+ 'loader' => 'load',
+ 'model' => 'model'
+ );
+
+ // --------------------------------------------------------------------
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->ci_config = array();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function setUp()
+ {
+ if (method_exists($this, 'set_up'))
+ {
+ $this->set_up();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function tearDown()
+ {
+ if (method_exists($this, 'tear_down'))
+ {
+ $this->tear_down();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public static function instance()
+ {
+ return self::$ci_test_instance;
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_set_config($key, $val = '')
+ {
+ if (is_array($key))
+ {
+ $this->ci_config = $key;
+ }
+ else
+ {
+ $this->ci_config[$key] = $val;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_get_config()
+ {
+ return $this->ci_config;
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_instance($obj = FALSE)
+ {
+ if ( ! is_object($obj))
+ {
+ return $this->ci_instance;
+ }
+
+ $this->ci_instance = $obj;
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_instance_var($name, $obj = FALSE)
+ {
+ if ( ! is_object($obj))
+ {
+ return $this->ci_instance->$name;
+ }
+
+ $this->ci_instance->$name =& $obj;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Grab a core class
+ *
+ * Loads the correct core class without extensions
+ * and returns a reference to the class name in the
+ * globals array with the correct key. This way the
+ * test can modify the variable it assigns to and
+ * still maintain the global.
+ */
+ function &ci_core_class($name)
+ {
+ $name = strtolower($name);
+
+ if (isset($this->global_map[$name]))
+ {
+ $class_name = ucfirst($name);
+ $global_name = $this->global_map[$name];
+ }
+ elseif (in_array($name, $this->global_map))
+ {
+ $class_name = ucfirst(array_search($name, $this->global_map));
+ $global_name = $name;
+ }
+ else
+ {
+ throw new Exception('Not a valid core class.');
+ }
+
+ if ( ! class_exists('CI_'.$class_name))
+ {
+ require_once BASEPATH.'core/'.$class_name.'.php';
+ }
+
+ $GLOBALS[strtoupper($global_name)] = 'CI_'.$class_name;
+ return $GLOBALS[strtoupper($global_name)];
+ }
+
+ // --------------------------------------------------------------------
+
+ // convenience function for global mocks
+ function ci_set_core_class($name, $obj)
+ {
+ $orig =& $this->ci_core_class($name);
+ $orig = $obj;
+ }
+
+ // --------------------------------------------------------------------
+ // Internals
+ // --------------------------------------------------------------------
+
+ /**
+ * Overwrite runBare
+ *
+ * PHPUnit instantiates the test classes before
+ * running them individually. So right before a test
+ * runs we set our instance. Normally this step would
+ * happen in setUp, but someone is bound to forget to
+ * call the parent method and debugging this is no fun.
+ */
+ public function runBare()
+ {
+ self::$ci_test_instance = $this;
+ parent::runBare();
+ }
+
+ // --------------------------------------------------------------------
+
+ function helper($name)
+ {
+ require_once(BASEPATH.'helpers/'.$name.'_helper.php');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * This overload is useful to create a stub, that need to have a specific method.
+ */
+ function __call($method, $args)
+ {
+ if ($this->{$method} instanceof Closure)
+ {
+ return call_user_func_array($this->{$method},$args);
+ }
+ else
+ {
+ return parent::__call($method, $args);
+ }
+ }
+}
+
+// EOF
\ No newline at end of file
diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php
new file mode 100644
index 000000000..fc94d7fff
--- /dev/null
+++ b/tests/mocks/core/common.php
@@ -0,0 +1,132 @@
+ci_instance();
+ return $instance;
+}
+
+// --------------------------------------------------------------------
+
+function &get_config() {
+ $test = CI_TestCase::instance();
+ $config = $test->ci_get_config();
+
+ return $config;
+}
+
+function config_item($item)
+{
+ $config =& get_config();
+
+ if ( ! isset($config[$item]))
+ {
+ return FALSE;
+ }
+
+ return $config[$item];
+}
+
+// --------------------------------------------------------------------
+
+function load_class($class, $directory = 'libraries', $prefix = 'CI_')
+{
+ if ($directory != 'core' OR $prefix != 'CI_')
+ {
+ throw new Exception('Not Implemented: Non-core load_class()');
+ }
+
+ $test = CI_TestCase::instance();
+
+ $obj =& $test->ci_core_class($class);
+
+ if (is_string($obj))
+ {
+ throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class.'');
+ }
+
+ return $obj;
+}
+
+// This is sort of meh. Should probably be mocked up with
+// controllable output, so that we can test some of our
+// security code. The function itself will be tested in the
+// bootstrap testsuite.
+// --------------------------------------------------------------------
+
+function remove_invisible_characters($str, $url_encoded = TRUE)
+{
+ $non_displayables = array();
+
+ // every control character except newline (dec 10)
+ // carriage return (dec 13), and horizontal tab (dec 09)
+
+ if ($url_encoded)
+ {
+ $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
+ $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
+ }
+
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
+
+ do
+ {
+ $str = preg_replace($non_displayables, '', $str, -1, $count);
+ }
+ while ($count);
+
+ return $str;
+}
+
+
+// Clean up error messages
+// --------------------------------------------------------------------
+
+function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
+{
+ throw new RuntimeException('CI Error: '.$message);
+}
+
+function show_404($page = '', $log_error = TRUE)
+{
+ throw new RuntimeException('CI Error: 404');
+}
+
+function _exception_handler($severity, $message, $filepath, $line)
+{
+ throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line);
+}
+
+
+// We assume a few things about our environment ...
+// --------------------------------------------------------------------
+
+function is_php($version = '5.0.0')
+{
+ return ! (version_compare(PHP_VERSION, $version) < 0);
+}
+
+function is_really_writable($file)
+{
+ return is_writable($file);
+}
+
+function is_loaded()
+{
+ throw new Exception('Bad Isolation: mock up environment');
+}
+
+function log_message($level = 'error', $message, $php_error = FALSE)
+{
+ return TRUE;
+}
+
+function set_status_header($code = 200, $text = '')
+{
+ return TRUE;
+}
+
+// EOF
\ No newline at end of file
diff --git a/tests/mocks/core/loader.php b/tests/mocks/core/loader.php
new file mode 100644
index 000000000..d4b29bb3d
--- /dev/null
+++ b/tests/mocks/core/loader.php
@@ -0,0 +1,30 @@
+models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot());
+ $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot());
+ $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot());
+ $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot());
+
+ $this->_ci_ob_level = ob_get_level();
+ $this->_ci_library_paths = array(vfsStream::url('application').'/', BASEPATH);
+ $this->_ci_helper_paths = array(vfsStream::url('application').'/', BASEPATH);
+ $this->_ci_model_paths = array(vfsStream::url('application').'/');
+ $this->_ci_view_paths = array(vfsStream::url('application').'/views/' => TRUE);
+ }
+}
\ No newline at end of file
diff --git a/tests/mocks/core/uri.php b/tests/mocks/core/uri.php
new file mode 100644
index 000000000..b6946091e
--- /dev/null
+++ b/tests/mocks/core/uri.php
@@ -0,0 +1,25 @@
+ci_core_class('cfg');
+
+ // set predictable config values
+ $test->ci_set_config(array(
+ 'index_page' => 'index.php',
+ 'base_url' => 'http://example.com/',
+ 'subclass_prefix' => 'MY_'
+ ));
+
+ $this->config = new $cls;
+
+ }
+
+ protected function _is_cli_request()
+ {
+ return FALSE;
+ }
+}
\ No newline at end of file
diff --git a/tests/mocks/libraries/parser.php b/tests/mocks/libraries/parser.php
new file mode 100644
index 000000000..81dcfb37e
--- /dev/null
+++ b/tests/mocks/libraries/parser.php
@@ -0,0 +1,3 @@
+
Date: Mon, 23 Apr 2012 13:14:27 +0200
Subject: Corrected the migration_missing_down_method language string
---
system/language/english/migration_lang.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php
index 4763ca243..f17530f00 100644
--- a/system/language/english/migration_lang.php
+++ b/system/language/english/migration_lang.php
@@ -5,7 +5,7 @@ $lang['migration_not_found'] = "This migration could not be found.";
$lang['migration_multiple_version'] = "This are multiple migrations with the same version number: %d.";
$lang['migration_class_doesnt_exist'] = "The migration class \"%s\" could not be found.";
$lang['migration_missing_up_method'] = "The migration class \"%s\" is missing an 'up' method.";
-$lang['migration_missing_down_method'] = "The migration class \"%s\" is missing an 'up' method.";
+$lang['migration_missing_down_method'] = "The migration class \"%s\" is missing an 'down' method.";
$lang['migration_invalid_filename'] = "Migration \"%s\" has an invalid filename.";
--
cgit v1.2.3-24-g4f1b
From 5335bc317f07f12c0f0bae5ac9189f75fcad0f1c Mon Sep 17 00:00:00 2001
From: Wes Baker
Date: Tue, 24 Apr 2012 15:17:14 -0400
Subject: Updating XSS cleaning to better handle base64 encoded attributes.
---
system/core/Security.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/system/core/Security.php b/system/core/Security.php
index ac39ce97b..65746637b 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -99,7 +99,8 @@ class CI_Security {
'javascript\s*:',
'expression\s*(\(|&\#40;)', // CSS and IE
'vbscript\s*:', // IE, surprise!
- 'Redirect\s+302'
+ 'Redirect\s+302',
+ "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?"
);
public function __construct()
@@ -362,7 +363,7 @@ class CI_Security {
* These words are compacted back to their correct state.
*/
$words = array(
- 'javascript', 'expression', 'vbscript', 'script',
+ 'javascript', 'expression', 'vbscript', 'script', 'base64',
'applet', 'alert', 'document', 'write', 'cookie', 'window'
);
@@ -602,10 +603,11 @@ class CI_Security {
$attribs = array();
// find occurrences of illegal attribute strings without quotes
- preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s]*)/is', $str, $matches, PREG_SET_ORDER);
+ preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER);
foreach ($matches as $attr)
{
+
$attribs[] = preg_quote($attr[0], '/');
}
@@ -620,7 +622,7 @@ class CI_Security {
// replace illegal attribute strings that are inside an html tag
if (count($attribs) > 0)
{
- $str = preg_replace('/<(\/?[^><]+?)([^A-Za-z\-])('.implode('|', $attribs).')([\s><])([><]*)/i', '<$1$2$4$5', $str, -1, $count);
+ $str = preg_replace("/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)(".implode('|', $attribs).")(.*?)([\s><])([><]*)/i", '<$1 $3$5$6$7', $str, -1, $count);
}
} while ($count);
@@ -661,7 +663,7 @@ class CI_Security {
protected function _js_link_removal($match)
{
return str_replace($match[1],
- preg_replace('#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|
-EOF;
- }
-}
-
/* End of file smiley_helper.php */
/* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index aed35c157..b42799a8e 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -37,22 +37,22 @@
// ------------------------------------------------------------------------
-/**
- * Trim Slashes
- *
- * Removes any leading/trailing slashes from a string:
- *
- * /this/that/theother/
- *
- * becomes:
- *
- * this/that/theother
- *
- * @param string
- * @return string
- */
if ( ! function_exists('trim_slashes'))
{
+ /**
+ * Trim Slashes
+ *
+ * Removes any leading/trailing slashes from a string:
+ *
+ * /this/that/theother/
+ *
+ * becomes:
+ *
+ * this/that/theother
+ *
+ * @param string
+ * @return string
+ */
function trim_slashes($str)
{
return trim($str, '/');
@@ -61,16 +61,16 @@ if ( ! function_exists('trim_slashes'))
// ------------------------------------------------------------------------
-/**
- * Strip Slashes
- *
- * Removes slashes contained in a string or in an array
- *
- * @param mixed string or array
- * @return mixed string or array
- */
if ( ! function_exists('strip_slashes'))
{
+ /**
+ * Strip Slashes
+ *
+ * Removes slashes contained in a string or in an array
+ *
+ * @param mixed string or array
+ * @return mixed string or array
+ */
function strip_slashes($str)
{
if (is_array($str))
@@ -91,16 +91,16 @@ if ( ! function_exists('strip_slashes'))
// ------------------------------------------------------------------------
-/**
- * Strip Quotes
- *
- * Removes single and double quotes from a string
- *
- * @param string
- * @return string
- */
if ( ! function_exists('strip_quotes'))
{
+ /**
+ * Strip Quotes
+ *
+ * Removes single and double quotes from a string
+ *
+ * @param string
+ * @return string
+ */
function strip_quotes($str)
{
return str_replace(array('"', "'"), '', $str);
@@ -109,16 +109,16 @@ if ( ! function_exists('strip_quotes'))
// ------------------------------------------------------------------------
-/**
- * Quotes to Entities
- *
- * Converts single and double quotes to entities
- *
- * @param string
- * @return string
- */
if ( ! function_exists('quotes_to_entities'))
{
+ /**
+ * Quotes to Entities
+ *
+ * Converts single and double quotes to entities
+ *
+ * @param string
+ * @return string
+ */
function quotes_to_entities($str)
{
return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str);
@@ -127,23 +127,23 @@ if ( ! function_exists('quotes_to_entities'))
// ------------------------------------------------------------------------
-/**
- * Reduce Double Slashes
- *
- * Converts double slashes in a string to a single slash,
- * except those found in http://
- *
- * http://www.some-site.com//index.php
- *
- * becomes:
- *
- * http://www.some-site.com/index.php
- *
- * @param string
- * @return string
- */
if ( ! function_exists('reduce_double_slashes'))
{
+ /**
+ * Reduce Double Slashes
+ *
+ * Converts double slashes in a string to a single slash,
+ * except those found in http://
+ *
+ * http://www.some-site.com//index.php
+ *
+ * becomes:
+ *
+ * http://www.some-site.com/index.php
+ *
+ * @param string
+ * @return string
+ */
function reduce_double_slashes($str)
{
return preg_replace('#(^|[^:])//+#', '\\1/', $str);
@@ -152,24 +152,24 @@ if ( ! function_exists('reduce_double_slashes'))
// ------------------------------------------------------------------------
-/**
- * Reduce Multiples
- *
- * Reduces multiple instances of a particular character. Example:
- *
- * Fred, Bill,, Joe, Jimmy
- *
- * becomes:
- *
- * Fred, Bill, Joe, Jimmy
- *
- * @param string
- * @param string the character you wish to reduce
- * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
- * @return string
- */
if ( ! function_exists('reduce_multiples'))
{
+ /**
+ * Reduce Multiples
+ *
+ * Reduces multiple instances of a particular character. Example:
+ *
+ * Fred, Bill,, Joe, Jimmy
+ *
+ * becomes:
+ *
+ * Fred, Bill, Joe, Jimmy
+ *
+ * @param string
+ * @param string the character you wish to reduce
+ * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
+ * @return string
+ */
function reduce_multiples($str, $character = ',', $trim = FALSE)
{
$str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
@@ -185,17 +185,17 @@ if ( ! function_exists('reduce_multiples'))
// ------------------------------------------------------------------------
-/**
- * Create a Random String
- *
- * Useful for generating passwords or hashes.
- *
- * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param int number of characters
- * @return string
- */
if ( ! function_exists('random_string'))
{
+ /**
+ * Create a Random String
+ *
+ * Useful for generating passwords or hashes.
+ *
+ * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
+ * @param int number of characters
+ * @return string
+ */
function random_string($type = 'alnum', $len = 8)
{
switch($type)
@@ -242,16 +242,16 @@ if ( ! function_exists('random_string'))
// ------------------------------------------------------------------------
-/**
- * Add's _1 to a string or increment the ending number to allow _2, _3, etc
- *
- * @param string required
- * @param string What should the duplicate number be appended with
- * @param string Which number should be used for the first dupe increment
- * @return string
- */
if ( ! function_exists('increment_string'))
{
+ /**
+ * Add's _1 to a string or increment the ending number to allow _2, _3, etc
+ *
+ * @param string required
+ * @param string What should the duplicate number be appended with
+ * @param string Which number should be used for the first dupe increment
+ * @return string
+ */
function increment_string($str, $separator = '_', $first = 1)
{
preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
@@ -262,17 +262,17 @@ if ( ! function_exists('increment_string'))
// ------------------------------------------------------------------------
-/**
- * Alternator
- *
- * Allows strings to be alternated. See docs...
- *
- * @param string (as many parameters as needed)
- * @return string
- */
if ( ! function_exists('alternator'))
{
- function alternator()
+ /**
+ * Alternator
+ *
+ * Allows strings to be alternated. See docs...
+ *
+ * @param string (as many parameters as needed)
+ * @return string
+ */
+ function alternator($args)
{
static $i;
@@ -288,15 +288,15 @@ if ( ! function_exists('alternator'))
// ------------------------------------------------------------------------
-/**
- * Repeater function
- *
- * @param string
- * @param int number of repeats
- * @return string
- */
if ( ! function_exists('repeater'))
{
+ /**
+ * Repeater function
+ *
+ * @param string
+ * @param int number of repeats
+ * @return string
+ */
function repeater($data, $num = 1)
{
return ($num > 0) ? str_repeat($data, $num) : '';
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index cc501c334..f53b06b93 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -37,18 +37,18 @@
// ------------------------------------------------------------------------
-/**
- * Word Limiter
- *
- * Limits a string to X number of words.
- *
- * @param string
- * @param int
- * @param string the end character. Usually an ellipsis
- * @return string
- */
if ( ! function_exists('word_limiter'))
{
+ /**
+ * Word Limiter
+ *
+ * Limits a string to X number of words.
+ *
+ * @param string
+ * @param int
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
function word_limiter($str, $limit = 100, $end_char = '…')
{
if (trim($str) == '')
@@ -69,19 +69,19 @@ if ( ! function_exists('word_limiter'))
// ------------------------------------------------------------------------
-/**
- * Character Limiter
- *
- * Limits the string based on the character count. Preserves complete words
- * so the character count may not be exactly as specified.
- *
- * @param string
- * @param int
- * @param string the end character. Usually an ellipsis
- * @return string
- */
if ( ! function_exists('character_limiter'))
{
+ /**
+ * Character Limiter
+ *
+ * Limits the string based on the character count. Preserves complete words
+ * so the character count may not be exactly as specified.
+ *
+ * @param string
+ * @param int
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
function character_limiter($str, $n = 500, $end_char = '…')
{
if (strlen($str) < $n)
@@ -112,16 +112,16 @@ if ( ! function_exists('character_limiter'))
// ------------------------------------------------------------------------
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @param string
- * @return string
- */
if ( ! function_exists('ascii_to_entities'))
{
+ /**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @param string
+ * @return string
+ */
function ascii_to_entities($str)
{
$count = 1;
@@ -172,17 +172,17 @@ if ( ! function_exists('ascii_to_entities'))
// ------------------------------------------------------------------------
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @param string
- * @param bool
- * @return string
- */
if ( ! function_exists('entities_to_ascii'))
{
+ /**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
function entities_to_ascii($str, $all = TRUE)
{
if (preg_match_all('/\(\d+)\;/', $str, $matches))
@@ -227,20 +227,20 @@ if ( ! function_exists('entities_to_ascii'))
// ------------------------------------------------------------------------
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
if ( ! function_exists('word_censor'))
{
+ /**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
function word_censor($str, $censored, $replacement = '')
{
if ( ! is_array($censored))
@@ -274,16 +274,16 @@ if ( ! function_exists('word_censor'))
// ------------------------------------------------------------------------
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @param string the text string
- * @return string
- */
if ( ! function_exists('highlight_code'))
{
+ /**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @param string the text string
+ * @return string
+ */
function highlight_code($str)
{
// The highlight string function encodes and highlights
@@ -317,19 +317,19 @@ if ( ! function_exists('highlight_code'))
// ------------------------------------------------------------------------
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
if ( ! function_exists('highlight_phrase'))
{
+ /**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '')
{
if ($str == '')
@@ -348,14 +348,14 @@ if ( ! function_exists('highlight_phrase'))
// ------------------------------------------------------------------------
-/**
- * Convert Accented Foreign Characters to ASCII
- *
- * @param string the text string
- * @return string
- */
if ( ! function_exists('convert_accented_characters'))
{
+ /**
+ * Convert Accented Foreign Characters to ASCII
+ *
+ * @param string the text string
+ * @return string
+ */
function convert_accented_characters($str)
{
if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
@@ -378,19 +378,19 @@ if ( ! function_exists('convert_accented_characters'))
// ------------------------------------------------------------------------
-/**
- * Word Wrap
- *
- * Wraps text at the specified character. Maintains the integrity of words.
- * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
- * will URLs.
- *
- * @param string the text string
- * @param int the number of characters to wrap at
- * @return string
- */
if ( ! function_exists('word_wrap'))
{
+ /**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @param string the text string
+ * @param int the number of characters to wrap at
+ * @return string
+ */
function word_wrap($str, $charlim = '76')
{
// Se the character limit
@@ -481,19 +481,19 @@ if ( ! function_exists('word_wrap'))
// ------------------------------------------------------------------------
-/**
- * Ellipsize String
- *
- * This function will strip tags from a string, split it at its max_length and ellipsize
- *
- * @param string string to ellipsize
- * @param int max length of string
- * @param mixed int (1|0) or float, .5, .2, etc for position to split
- * @param string ellipsis ; Default '...'
- * @return string ellipsized string
- */
if ( ! function_exists('ellipsize'))
{
+ /**
+ * Ellipsize String
+ *
+ * This function will strip tags from a string, split it at its max_length and ellipsize
+ *
+ * @param string string to ellipsize
+ * @param int max length of string
+ * @param mixed int (1|0) or float, .5, .2, etc for position to split
+ * @param string ellipsis ; Default '...'
+ * @return string ellipsized string
+ */
function ellipsize($str, $max_length, $position = 1, $ellipsis = '…')
{
// Strip tags
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 7a3db5d6b..af9d16a89 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -37,14 +37,14 @@
// ------------------------------------------------------------------------
-/**
- * Convert newlines to HTML line breaks except within PRE tags
- *
- * @param string
- * @return string
- */
if ( ! function_exists('nl2br_except_pre'))
{
+ /**
+ * Convert newlines to HTML line breaks except within PRE tags
+ *
+ * @param string
+ * @return string
+ */
function nl2br_except_pre($str)
{
$CI =& get_instance();
@@ -55,16 +55,16 @@ if ( ! function_exists('nl2br_except_pre'))
// ------------------------------------------------------------------------
-/**
- * Auto Typography Wrapper Function
- *
- * @param string
- * @param bool whether to allow javascript event handlers
- * @param bool whether to reduce multiple instances of double newlines to two
- * @return string
- */
if ( ! function_exists('auto_typography'))
{
+ /**
+ * Auto Typography Wrapper Function
+ *
+ * @param string
+ * @param bool whether to allow javascript event handlers
+ * @param bool whether to reduce multiple instances of double newlines to two
+ * @return string
+ */
function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
{
$CI =& get_instance();
@@ -73,20 +73,19 @@ if ( ! function_exists('auto_typography'))
}
}
-
// --------------------------------------------------------------------
-/**
- * HTML Entities Decode
- *
- * This function is a replacement for html_entity_decode()
- *
- * @param string
- * @param string
- * @return string
- */
if ( ! function_exists('entity_decode'))
{
+ /**
+ * HTML Entities Decode
+ *
+ * This function is a replacement for html_entity_decode()
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
function entity_decode($str, $charset = NULL)
{
global $SEC;
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 5576c2748..fa685645a 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -37,17 +37,17 @@
// ------------------------------------------------------------------------
-/**
- * Site URL
- *
- * Create a local URL based on your basepath. Segments can be passed via the
- * first parameter either as a string or an array.
- *
- * @param string
- * @return string
- */
if ( ! function_exists('site_url'))
{
+ /**
+ * Site URL
+ *
+ * Create a local URL based on your basepath. Segments can be passed via the
+ * first parameter either as a string or an array.
+ *
+ * @param string
+ * @return string
+ */
function site_url($uri = '')
{
$CI =& get_instance();
@@ -57,18 +57,18 @@ if ( ! function_exists('site_url'))
// ------------------------------------------------------------------------
-/**
- * Base URL
- *
- * Create a local URL based on your basepath.
- * Segments can be passed in as a string or an array, same as site_url
- * or a URL to a file can be passed in, e.g. to an image file.
- *
- * @param string
- * @return string
- */
if ( ! function_exists('base_url'))
{
+ /**
+ * Base URL
+ *
+ * Create a local URL based on your basepath.
+ * Segments can be passed in as a string or an array, same as site_url
+ * or a URL to a file can be passed in, e.g. to an image file.
+ *
+ * @param string
+ * @return string
+ */
function base_url($uri = '')
{
$CI =& get_instance();
@@ -78,16 +78,16 @@ if ( ! function_exists('base_url'))
// ------------------------------------------------------------------------
-/**
- * Current URL
- *
- * Returns the full URL (including segments) of the page where this
- * function is placed
- *
- * @return string
- */
if ( ! function_exists('current_url'))
{
+ /**
+ * Current URL
+ *
+ * Returns the full URL (including segments) of the page where this
+ * function is placed
+ *
+ * @return string
+ */
function current_url()
{
$CI =& get_instance();
@@ -96,15 +96,16 @@ if ( ! function_exists('current_url'))
}
// ------------------------------------------------------------------------
-/**
- * URL String
- *
- * Returns the URI segments.
- *
- * @return string
- */
+
if ( ! function_exists('uri_string'))
{
+ /**
+ * URL String
+ *
+ * Returns the URI segments.
+ *
+ * @return string
+ */
function uri_string()
{
$CI =& get_instance();
@@ -114,15 +115,15 @@ if ( ! function_exists('uri_string'))
// ------------------------------------------------------------------------
-/**
- * Index page
- *
- * Returns the "index_page" from your config file
- *
- * @return string
- */
if ( ! function_exists('index_page'))
{
+ /**
+ * Index page
+ *
+ * Returns the "index_page" from your config file
+ *
+ * @return string
+ */
function index_page()
{
$CI =& get_instance();
@@ -132,18 +133,18 @@ if ( ! function_exists('index_page'))
// ------------------------------------------------------------------------
-/**
- * Anchor Link
- *
- * Creates an anchor based on the local URL.
- *
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('anchor'))
{
+ /**
+ * Anchor Link
+ *
+ * Creates an anchor based on the local URL.
+ *
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
@@ -173,19 +174,19 @@ if ( ! function_exists('anchor'))
// ------------------------------------------------------------------------
-/**
- * Anchor Link - Pop-up version
- *
- * Creates an anchor based on the local URL. The link
- * opens a new window based on the attributes specified.
- *
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('anchor_popup'))
{
+ /**
+ * Anchor Link - Pop-up version
+ *
+ * Creates an anchor based on the local URL. The link
+ * opens a new window based on the attributes specified.
+ *
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
@@ -223,16 +224,16 @@ if ( ! function_exists('anchor_popup'))
// ------------------------------------------------------------------------
-/**
- * Mailto Link
- *
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('mailto'))
{
+ /**
+ * Mailto Link
+ *
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
@@ -248,18 +249,18 @@ if ( ! function_exists('mailto'))
// ------------------------------------------------------------------------
-/**
- * Encoded Mailto Link
- *
- * Create a spam-protected mailto link written in Javascript
- *
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('safe_mailto'))
{
+ /**
+ * Encoded Mailto Link
+ *
+ * Create a spam-protected mailto link written in Javascript
+ *
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function safe_mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
@@ -357,21 +358,21 @@ if ( ! function_exists('safe_mailto'))
// ------------------------------------------------------------------------
-/**
- * Auto-linker
- *
- * Automatically links URL and Email addresses.
- * Note: There's a bit of extra code here to deal with
- * URLs or emails that end in a period. We'll strip these
- * off and add them after the link.
- *
- * @param string the string
- * @param string the type: email, url, or both
- * @param bool whether to create pop-up links
- * @return string
- */
if ( ! function_exists('auto_link'))
{
+ /**
+ * Auto-linker
+ *
+ * Automatically links URL and Email addresses.
+ * Note: There's a bit of extra code here to deal with
+ * URLs or emails that end in a period. We'll strip these
+ * off and add them after the link.
+ *
+ * @param string the string
+ * @param string the type: email, url, or both
+ * @param bool whether to create pop-up links
+ * @return string
+ */
function auto_link($str, $type = 'both', $popup = FALSE)
{
if ($type !== 'email' && preg_match_all('#(^|\s|\(|\b)((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i', $str, $matches))
@@ -423,16 +424,16 @@ if ( ! function_exists('auto_link'))
// ------------------------------------------------------------------------
-/**
- * Prep URL
- *
- * Simply adds the http:// part if no scheme is included
- *
- * @param string the URL
- * @return string
- */
if ( ! function_exists('prep_url'))
{
+ /**
+ * Prep URL
+ *
+ * Simply adds the http:// part if no scheme is included
+ *
+ * @param string the URL
+ * @return string
+ */
function prep_url($str = '')
{
if ($str === 'http://' OR $str == '')
@@ -453,20 +454,20 @@ if ( ! function_exists('prep_url'))
// ------------------------------------------------------------------------
-/**
- * Create URL Title
- *
- * Takes a "title" string as input and creates a
- * human-friendly URL string with a "separator" string
- * as the word separator.
- *
- * @param string the string
- * @param string the separator
- * @param bool
- * @return string
- */
if ( ! function_exists('url_title'))
{
+ /**
+ * Create URL Title
+ *
+ * Takes a "title" string as input and creates a
+ * human-friendly URL string with a "separator" string
+ * as the word separator.
+ *
+ * @param string the string
+ * @param string the separator
+ * @param bool
+ * @return string
+ */
function url_title($str, $separator = '-', $lowercase = FALSE)
{
if ($separator === 'dash')
@@ -504,19 +505,20 @@ if ( ! function_exists('url_title'))
// ------------------------------------------------------------------------
-/**
- * Header Redirect
- *
- * Header redirect in two flavors
- * For very fine grained control over headers, you could use the Output
- * Library's set_header() function.
- *
- * @param string the URL
- * @param string the method: location or refresh
- * @return string
- */
if ( ! function_exists('redirect'))
{
+ /**
+ * Header Redirect
+ *
+ * Header redirect in two flavors
+ * For very fine grained control over headers, you could use the Output
+ * Library's set_header() function.
+ *
+ * @param string the URL
+ * @param string the method: location or refresh
+ * @param int
+ * @return string
+ */
function redirect($uri = '', $method = 'auto', $http_response_code = 302)
{
if ( ! preg_match('#^https?://#i', $uri))
@@ -545,17 +547,17 @@ if ( ! function_exists('redirect'))
// ------------------------------------------------------------------------
-/**
- * Parse out the attributes
- *
- * Some of the functions use this
- *
- * @param array
- * @param bool
- * @return string
- */
if ( ! function_exists('_parse_attributes'))
{
+ /**
+ * Parse out the attributes
+ *
+ * Some of the functions use this
+ *
+ * @param array
+ * @param bool
+ * @return string
+ */
function _parse_attributes($attributes, $javascript = FALSE)
{
if (is_string($attributes))
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 67fd34b97..958c633dd 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -37,15 +37,15 @@
// ------------------------------------------------------------------------
-/**
- * Convert Reserved XML characters to Entities
- *
- * @param string
- * @param bool
- * @return string
- */
if ( ! function_exists('xml_convert'))
{
+ /**
+ * Convert Reserved XML characters to Entities
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
function xml_convert($str, $protect_all = FALSE)
{
$temp = '__TEMP_AMPERSANDS__';
--
cgit v1.2.3-24-g4f1b
From 963c96c5507ceb8b5c3de50d0ab959d21dcc8cd1 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Wed, 2 May 2012 13:09:57 +0300
Subject: Fix a wrong variable name
---
system/helpers/text_helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index daf31c3d6..c1c0eb947 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -377,7 +377,7 @@ if ( ! function_exists('convert_accented_characters'))
include(APPPATH.'config/foreign_chars.php');
}
- if ( ! isset($foreign_characters) OR ! is_array($foreign_chars))
+ if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
{
return $str;
}
--
cgit v1.2.3-24-g4f1b
From 58dc75471c25f33b059967ffb515eedc08e86a0b Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Wed, 2 May 2012 13:24:19 +0300
Subject: Some line separation for better readability
---
system/database/drivers/sqlite/sqlite_forge.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index ce8eac91e..0a1c156be 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -105,10 +105,15 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.' '.$attributes['TYPE']
+
.( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+
.(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+
.(isset($attributes['DEFAULT']) ? ' DEFAULT \''.$attributes['DEFAULT'].'\'' : '')
+
.(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+
.(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
--
cgit v1.2.3-24-g4f1b
From 3110a0a3cc6b25985acc251799ca9cc97f92ce03 Mon Sep 17 00:00:00 2001
From: Phil Sturgeon
Date: Wed, 2 May 2012 11:37:31 +0100
Subject: Added a phpDocumenter config file
Allows API documentation to be built very easily. Wether or not
CodeIgniter will support property docblocks or not is currently in
question, but at least everything else will show up.
---
phpdoc.dist.xml | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 phpdoc.dist.xml
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
new file mode 100644
index 000000000..f1fcc6225
--- /dev/null
+++ b/phpdoc.dist.xml
@@ -0,0 +1,25 @@
+
+
+ CodeIgniter v3.0.0 API
+
+ ./api/
+
+
+ ./api/
+
+
+ .
+ ./application/*
+ ./tests/*
+ ./user_guide_src/*
+ ./views/*
+
+
+
+ warn
+
+ ./api/log/{DATE}.log
+ ./api/{DATE}.errors.log
+
+
+
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 81aa94bbb533737c19a705d5b8864bd47fbab85c Mon Sep 17 00:00:00 2001
From: Phil Sturgeon
Date: Wed, 2 May 2012 11:40:46 +0100
Subject: Reverted rui_string change.
This had knock-on effects as can be seen in #1306. Issue #122 has been
reopend until it is fixed properly.
---
system/core/Router.php | 5 +----
system/core/URI.php | 4 ++--
user_guide_src/source/changelog.rst | 2 ++
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/system/core/Router.php b/system/core/Router.php
index fe9909b06..9314052fe 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -242,12 +242,9 @@ class CI_Router {
$segments[1] = 'index';
}
- // This is being routed to a file in a sub directory
- $this->directory and array_unshift($segments, trim($this->directory, '/'));
-
// Update our "routed" segment array to contain the segments.
// Note: If there is no custom routing, this array will be
- // identical to $this->uri->segments
+ // identical to $this->uri->segments
$this->uri->rsegments = $segments;
}
diff --git a/system/core/URI.php b/system/core/URI.php
index 705575a0c..cf82c5838 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -645,10 +645,10 @@ class CI_URI {
*/
public function ruri_string()
{
- return implode('/', $this->rsegment_array());
+ return '/'.implode('/', $this->rsegment_array());
}
}
/* End of file URI.php */
-/* Location: ./system/core/URI.php */
\ No newline at end of file
+/* Location: ./system/core/URI.php */
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index bdb418f86..95e32f793 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -204,6 +204,7 @@ Bug fixes for 3.0
- Fixed a bug (#23, #1238) - delete_all() in the `Database Caching Library ` used to delete .htaccess and index.html files, which is a potential security risk.
- Fixed a bug in :doc:`Trackback Library ` method validate_url() where it didn't actually do anything, due to input not being passed by reference.
- Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found.
+<<<<<<< HEAD
- Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories
- Fixed a bug (#1242) - read_dir() in the :doc:`Zip Library ` wasn't compatible with Windows.
- Fixed a bug (#306) - ODBC driver didn't have an _insert_batch() method, which resulted in fatal error being triggered when insert_batch() is used with it.
@@ -214,6 +215,7 @@ Bug fixes for 3.0
- Fixed a bug in SQLSRV's delete() method where like() and limit() conditions were ignored.
- Fixed a bug (#1265) - Database connections were always closed, regardless of the 'pconnect' option value.
- Fixed a bug (#128) - :doc:`Language Library ` did not correctly keep track of loaded language files.
+- Fixed a bug (#1242) Added Windows path compatibility to function read_dir of ZIP library
Version 2.1.1
=============
--
cgit v1.2.3-24-g4f1b
From ee04a913dfd78d394a0e09f01655df0870369512 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Wed, 2 May 2012 13:41:23 +0300
Subject: Changelog fix
---
user_guide_src/source/changelog.rst | 1 -
1 file changed, 1 deletion(-)
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 95e32f793..bbbe6f718 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -204,7 +204,6 @@ Bug fixes for 3.0
- Fixed a bug (#23, #1238) - delete_all() in the `Database Caching Library ` used to delete .htaccess and index.html files, which is a potential security risk.
- Fixed a bug in :doc:`Trackback Library ` method validate_url() where it didn't actually do anything, due to input not being passed by reference.
- Fixed a bug (#11, #183, #863) - CI_Form_validation::_execute() silently continued to the next rule, if a rule method/function is not found.
-<<<<<<< HEAD
- Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories
- Fixed a bug (#1242) - read_dir() in the :doc:`Zip Library ` wasn't compatible with Windows.
- Fixed a bug (#306) - ODBC driver didn't have an _insert_batch() method, which resulted in fatal error being triggered when insert_batch() is used with it.
--
cgit v1.2.3-24-g4f1b
From c821a587dce2da70bab3f5955f2b40c6a3c194f5 Mon Sep 17 00:00:00 2001
From: Timothy Warren
Date: Wed, 2 May 2012 10:37:01 -0400
Subject: Fix phpdoc config file
---
phpdoc.dist.xml | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
index f1fcc6225..6dc58c259 100644
--- a/phpdoc.dist.xml
+++ b/phpdoc.dist.xml
@@ -8,11 +8,7 @@
./api/
- .
- ./application/*
- ./tests/*
- ./user_guide_src/*
- ./views/*
+ ./system
--
cgit v1.2.3-24-g4f1b
From 2d51c08027382cc10692188ccb68789daf2f2083 Mon Sep 17 00:00:00 2001
From: George Petsagourakis
Date: Wed, 2 May 2012 20:29:04 +0300
Subject: Fixing some typos.
---
system/libraries/Form_validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index a52cad5ff..5547c6a69 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1005,7 +1005,7 @@ class CI_Form_validation {
return (MB_ENABLED === TRUE)
? ($val <= mb_strlen($str))
- : ($val <= strlen(str));
+ : ($val <= strlen($str));
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 306b378525a13d9c5d1a7f0d6d50c2f263f22a04 Mon Sep 17 00:00:00 2001
From: George Petsagourakis
Date: Wed, 2 May 2012 20:31:08 +0300
Subject: Fixing some typos in the xmlrpc class. Also, fputs is an alias for
fwrite.
---
system/libraries/Xmlrpc.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 7009deacc..0d2533855 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -436,7 +436,7 @@ class XML_RPC_Client extends CI_Xmlrpc
*/
public function sendPayload($msg)
{
- $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
+ $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstring, $this->timeout);
if ( ! is_resource($fp))
{
@@ -458,7 +458,7 @@ class XML_RPC_Client extends CI_Xmlrpc
.'Content-Length: '.strlen($msg->payload).$r.$r
.$msg->payload;
- if ( ! fputs($fp, $op, strlen($op)))
+ if ( ! fwrite($fp, $op, strlen($op)))
{
error_log($this->xmlrpcstr['http_error']);
return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
@@ -1076,7 +1076,7 @@ class XML_RPC_Message extends CI_Xmlrpc
// we have an I4/INT
// we must check that only 0123456789- are characters here
$this->xh[$the_parser]['value'] = preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac'])
- ? (int) $this->xh[$the_parset]['ac']
+ ? (int) $this->xh[$the_parser]['ac']
: 'ERROR_NON_NUMERIC_FOUND';
}
$this->xh[$the_parser]['ac'] = '';
--
cgit v1.2.3-24-g4f1b
From 190c6bb125447f83793d9437f1bea28feada910a Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Thu, 3 May 2012 12:13:39 +0700
Subject: Cleaning up
---
tests/codeigniter/database/query_builder/insert_test.php | 5 ++---
tests/codeigniter/database/query_builder/select_test.php | 16 ++++++++--------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
index 53ce23c19..8ba60e242 100644
--- a/tests/codeigniter/database/query_builder/insert_test.php
+++ b/tests/codeigniter/database/query_builder/insert_test.php
@@ -30,11 +30,10 @@ class Insert_test extends CI_TestCase {
// Do normal insert
$this->assertTrue($this->db->insert('job', $job_data));
- $jobs = $this->db->get('job')->result_array();
- $job1 = $jobs[0];
+ $job1 = $this->db->get('job')->row();
// Check the result
- $this->assertEquals('Grocery Sales', $job1['name']);
+ $this->assertEquals('Grocery Sales', $job1->name);
}
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
index dbf432a7c..0d299ed16 100644
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -41,10 +41,10 @@ class Select_test extends CI_TestCase {
{
$job_min = $this->db->select_min('id')
->get('job')
- ->result_array();
+ ->row();
// Minimum id was 1
- $this->assertEquals('1', $job_min[0]['id']);
+ $this->assertEquals('1', $job_min->id);
}
// ------------------------------------------------------------------------
@@ -56,10 +56,10 @@ class Select_test extends CI_TestCase {
{
$job_max = $this->db->select_max('id')
->get('job')
- ->result_array();
+ ->row();
// Maximum id was 4
- $this->assertEquals('4', $job_max[0]['id']);
+ $this->assertEquals('4', $job_max->id);
}
// ------------------------------------------------------------------------
@@ -71,10 +71,10 @@ class Select_test extends CI_TestCase {
{
$job_avg = $this->db->select_avg('id')
->get('job')
- ->result_array();
+ ->row();
// Average should be 2.5
- $this->assertEquals('2.5', $job_avg[0]['id']);
+ $this->assertEquals('2.5', $job_avg->id);
}
// ------------------------------------------------------------------------
@@ -86,10 +86,10 @@ class Select_test extends CI_TestCase {
{
$job_sum = $this->db->select_sum('id')
->get('job')
- ->result_array();
+ ->row();
// Sum of ids should be 10
- $this->assertEquals('10', $job_sum[0]['id']);
+ $this->assertEquals('10', $job_sum->id);
}
}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 6e131cbd0a5243f29a5ad9f56c80715e534e4267 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Thu, 3 May 2012 12:14:19 +0700
Subject: FROM clause API code-coverage
---
.../database/query_builder/from_test.php | 51 ++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/from_test.php
diff --git a/tests/codeigniter/database/query_builder/from_test.php b/tests/codeigniter/database/query_builder/from_test.php
new file mode 100644
index 000000000..95ae4dfdb
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/from_test.php
@@ -0,0 +1,51 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_from_simple()
+ {
+ $jobs = $this->db->from('job')
+ ->get()
+ ->result_array();
+
+ // Check items
+ $this->assertEquals(4, count($jobs));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_from_with_where()
+ {
+ $job1 = $this->db->from('job')
+ ->where('id', 1)
+ ->get()
+ ->row();
+
+ // Check the result
+ $this->assertEquals('1', $job1->id);
+ $this->assertEquals('Developer', $job1->name);
+ $this->assertEquals('Awesome job, but sometimes makes you bored', $job1->description);
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 17f799e1017d1688a2890a1ba78e4f53d80af77e Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Thu, 3 May 2012 15:15:40 +0700
Subject: Add user entity into schema skeleton
---
tests/mocks/database/schema/skeleton.php | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index a3d5bac65..fbd533bfb 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -50,6 +50,24 @@ class Mock_Database_Schema_Skeleton {
*/
public static function create_tables()
{
+ // User Table
+ static::$forge->add_field(array(
+ 'id' => array(
+ 'type' => 'INTEGER',
+ 'constraint' => 3,
+ ),
+ 'name' => array(
+ 'type' => 'VARCHAR',
+ 'constraint' => 40,
+ ),
+ 'email' => array(
+ 'type' => 'VARCHAR',
+ 'constraint' => 100,
+ ),
+ ));
+ static::$forge->add_key('id', TRUE);
+ static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE));
+
// Job Table
static::$forge->add_field(array(
'id' => array(
@@ -77,6 +95,12 @@ class Mock_Database_Schema_Skeleton {
{
// Job Data
$data = array(
+ 'user' => array(
+ array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com'),
+ array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'),
+ array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'),
+ array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'),
+ )
'job' => array(
array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
--
cgit v1.2.3-24-g4f1b
From f074dff71f136860102a6042dccd3ff6db02d9f4 Mon Sep 17 00:00:00 2001
From: ThallisPHP
Date: Thu, 3 May 2012 16:01:46 -0300
Subject: Update system/libraries/Cart.php - To enable integrity when using
associative arrays
---
system/libraries/Cart.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index eee123584..9f258beb3 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -244,7 +244,7 @@ class CI_Cart {
// This becomes the unique "row ID"
if (isset($items['options']) && count($items['options']) > 0)
{
- $rowid = md5($items['id'].implode('', $items['options']));
+ $rowid = md5($items['id'].serialize($items['options']));
}
else
{
--
cgit v1.2.3-24-g4f1b
From d6b41bb2659f959da01aee0ddb38bb4bce6cd4b6 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 15:05:22 +0700
Subject: JOIN clause API code-coverage
---
.../database/query_builder/join_test.php | 38 ++++++++++++++++++++++
tests/mocks/database/schema/skeleton.php | 2 +-
2 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 tests/codeigniter/database/query_builder/join_test.php
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
new file mode 100644
index 000000000..e05329d67
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -0,0 +1,38 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_join_simple()
+ {
+ $job_user = $this->db->select('job.id as job_id, job.name as job_name, user.id as user_id, user.name as user_name')
+ ->from('job')
+ ->join('user', 'user.id = job.id')
+ ->get()
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals('1', $job_user[0]['job_id']);
+ $this->assertEquals('1', $job_user[0]['user_id']);
+ $this->assertEquals('Derek Jones', $job_user[0]['user_name']);
+ $this->assertEquals('Developer', $job_user[0]['job_name']);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index fbd533bfb..9ebd6e85f 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -100,7 +100,7 @@ class Mock_Database_Schema_Skeleton {
array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'),
array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'),
array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'),
- )
+ ),
'job' => array(
array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
--
cgit v1.2.3-24-g4f1b
From 12f5475e2b279d1c2361ad5fc85bc2ba0d0f9033 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 15:46:39 +0700
Subject: WHERE clause API code-coverage
---
.../database/query_builder/where_test.php | 144 +++++++++++++++++++++
1 file changed, 144 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/where_test.php
diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php
new file mode 100644
index 000000000..607eaa076
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/where_test.php
@@ -0,0 +1,144 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_simple_key_value()
+ {
+ $job1 = $this->db->where('id', 1)
+ ->get('job')
+ ->row();
+
+ // Check the result
+ $this->assertEquals('1', $job1->id);
+ $this->assertEquals('Developer', $job1->name);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_custom_key_value()
+ {
+ $jobs = $this->db->where('id !=', 1)
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(3, count($jobs));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_associative_array()
+ {
+ $where = array('id >' => 2, 'name !=' => 'Accountant');
+ $jobs = $this->db->where($where)
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(1, count($jobs));
+
+ // Should be Musician
+ $job = current($jobs);
+
+ $this->assertEquals('Musician', $job['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_custom_string()
+ {
+ $where = "id > 2 AND name != 'Accountant'";
+ $jobs = $this->db->where($where)
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(1, count($jobs));
+
+ // Should be Musician
+ $job = current($jobs);
+
+ $this->assertEquals('Musician', $job['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_or()
+ {
+ $jobs = $this->db->where('name !=', 'Accountant')
+ ->or_where('id >', 3)
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(3, count($jobs));
+ $this->assertEquals('Developer', $jobs[0]['name']);
+ $this->assertEquals('Politician', $jobs[1]['name']);
+ $this->assertEquals('Musician', $jobs[2]['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_in()
+ {
+ $jobs = $this->db->where_in('name', array('Politician', 'Accountant'))
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(2, count($jobs));
+ $this->assertEquals('Politician', $jobs[0]['name']);
+ $this->assertEquals('Accountant', $jobs[1]['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_where_not_in()
+ {
+ $jobs = $this->db->where_not_in('name', array('Politician', 'Accountant'))
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(2, count($jobs));
+ $this->assertEquals('Developer', $jobs[0]['name']);
+ $this->assertEquals('Musician', $jobs[1]['name']);
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From f78018ec6b081518e4be24934448862a31bda9f8 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 15:53:55 +0700
Subject: LIKE clause API code-coverage
---
.../database/query_builder/like_test.php | 90 ++++++++++++++++++++++
1 file changed, 90 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/like_test.php
diff --git a/tests/codeigniter/database/query_builder/like_test.php b/tests/codeigniter/database/query_builder/like_test.php
new file mode 100644
index 000000000..df98c713f
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/like_test.php
@@ -0,0 +1,90 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_like()
+ {
+ $job1 = $this->db->like('name', 'veloper')
+ ->get('job')
+ ->row();
+
+ // Check the result
+ $this->assertEquals('1', $job1->id);
+ $this->assertEquals('Developer', $job1->name);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_or_like()
+ {
+ $jobs = $this->db->like('name', 'ian')
+ ->or_like('name', 'veloper')
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(3, count($jobs));
+ $this->assertEquals('Developer', $jobs[0]['name']);
+ $this->assertEquals('Politician', $jobs[1]['name']);
+ $this->assertEquals('Musician', $jobs[2]['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_not_like()
+ {
+ $jobs = $this->db->not_like('name', 'veloper')
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(3, count($jobs));
+ $this->assertEquals('Politician', $jobs[0]['name']);
+ $this->assertEquals('Accountant', $jobs[1]['name']);
+ $this->assertEquals('Musician', $jobs[2]['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_or_not_like()
+ {
+ $jobs = $this->db->like('name', 'an')
+ ->or_not_like('name', 'veloper')
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(3, count($jobs));
+ $this->assertEquals('Politician', $jobs[0]['name']);
+ $this->assertEquals('Accountant', $jobs[1]['name']);
+ $this->assertEquals('Musician', $jobs[2]['name']);
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 4c316b6bdfa970e98127ea280fcc77ff1288190f Mon Sep 17 00:00:00 2001
From: Michiel Vugteveen
Date: Fri, 4 May 2012 11:32:48 +0200
Subject: unset userdata
---
system/libraries/Session.php | 45 +++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 3fa446d84..3195f0a91 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -36,146 +36,146 @@
*/
class CI_Session {
- /**
+ /**
* Whether to encrypt the session cookie
*
* @var bool
*/
public $sess_encrypt_cookie = FALSE;
-
+
/**
* Whether to use to the database for session storage
*
* @var bool
*/
public $sess_use_database = FALSE;
-
+
/**
* Name of the database table in which to store sessions
*
* @var string
*/
public $sess_table_name = '';
-
+
/**
* Length of time (in seconds) for sessions to expire
*
* @var int
*/
public $sess_expiration = 7200;
-
+
/**
* Whether to kill session on close of browser window
*
* @var bool
*/
public $sess_expire_on_close = FALSE;
-
+
/**
* Whether to match session on ip address
*
* @var bool
*/
public $sess_match_ip = FALSE;
-
+
/**
* Whether to match session on user-agent
*
* @var bool
*/
public $sess_match_useragent = TRUE;
-
+
/**
* Name of session cookie
*
* @var string
*/
public $sess_cookie_name = 'ci_session';
-
+
/**
* Session cookie prefix
*
* @var string
*/
public $cookie_prefix = '';
-
+
/**
* Session cookie path
*
* @var string
*/
public $cookie_path = '';
-
+
/**
* Session cookie domain
*
* @var string
*/
public $cookie_domain = '';
-
+
/**
* Whether to set the cookie only on HTTPS connections
*
* @var bool
*/
public $cookie_secure = FALSE;
-
+
/**
* Whether cookie should be allowed only to be sent by the server
*
* @var bool
*/
public $cookie_httponly = FALSE;
-
+
/**
* Interval at which to update session
*
* @var int
*/
public $sess_time_to_update = 300;
-
+
/**
* Key with which to encrypt the session cookie
*
* @var string
*/
public $encryption_key = '';
-
+
/**
* String to indicate flash data cookies
*
* @var string
*/
public $flashdata_key = 'flash';
-
+
/**
* Function to use to get the current time
*
* @var string
*/
public $time_reference = 'time';
-
+
/**
* Probablity level of garbage collection of old sessions
*
* @var int
*/
public $gc_probability = 5;
-
+
/**
* Session data
*
* @var array
*/
public $userdata = array();
-
+
/**
* Reference to CodeIgniter instance
*
* @var object
*/
public $CI;
-
+
/**
* Current time
*
@@ -570,6 +570,9 @@ class CI_Session {
$this->cookie_domain,
0
);
+
+ // Kill session data
+ $this->userdata = array();
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 0e18f625e10a8d8ba57c58c8597875c342cfa3e6 Mon Sep 17 00:00:00 2001
From: Michiel Vugteveen
Date: Fri, 4 May 2012 11:41:32 +0200
Subject: changelog entry
---
user_guide_src/source/changelog.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index bbbe6f718..a70531901 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -55,7 +55,7 @@ Release Date: Not Released
- Database
- - Renamed the Active Record class to Query Builder to remove confusion with
+ - Renamed the Active Record class to Query Builder to remove confusion with
the Active Record design pattern
- Added new :doc:`Query Builder ` methods that return
- Added the ability to insert objects with insert_batch() in :doc:`Query Builder `.
@@ -215,6 +215,7 @@ Bug fixes for 3.0
- Fixed a bug (#1265) - Database connections were always closed, regardless of the 'pconnect' option value.
- Fixed a bug (#128) - :doc:`Language Library ` did not correctly keep track of loaded language files.
- Fixed a bug (#1242) Added Windows path compatibility to function read_dir of ZIP library
+- Fixed a bug (#1314) sess_destroy() did not destroy userdata.
Version 2.1.1
=============
--
cgit v1.2.3-24-g4f1b
From 4e607b00b2c56b7fdcc5f1d1a290be2363c74a46 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 19:22:48 +0700
Subject: GROUP BY clause API code-coverage
---
.travis.yml | 3 +-
.../database/query_builder/group_test.php | 37 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 tests/codeigniter/database/query_builder/group_test.php
diff --git a/.travis.yml b/.travis.yml
index 97ea0422d..971f62f38 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,4 +25,5 @@ script: phpunit --configuration tests/travis/$DB.phpunit.xml
branches:
only:
- develop
- - master
\ No newline at end of file
+ - master
+ - db-tests
\ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php
new file mode 100644
index 000000000..ddb2d0d6a
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/group_test.php
@@ -0,0 +1,37 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_group_by()
+ {
+ $jobs = $this->db->select('name')
+ ->from('job')
+ ->group_by('name HAVING SUM(id) > 2')
+ ->get()
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(2, count($jobs));
+ $this->assertEquals('Accountant', $jobs[0]['name']);
+ $this->assertEquals('Musician', $jobs[1]['name']);
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From f7377abee2ef1e165a362edc9a1c650373a002ca Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 19:42:24 +0700
Subject: Trace error
---
.../database/query_builder/group_test.php | 8 ++++----
tests/mocks/database/ci_test.sqlite | Bin 17408 -> 19456 bytes
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php
index ddb2d0d6a..dd248ae9a 100644
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ b/tests/codeigniter/database/query_builder/group_test.php
@@ -22,16 +22,16 @@ class Group_test extends CI_TestCase {
*/
public function test_group_by()
{
- $jobs = $this->db->select('name')
+ $jobs = $this->db->select('job.name as job_name, job.id as job_id')
->from('job')
- ->group_by('name HAVING SUM(id) > 2')
+ ->group_by('job_name HAVING SUM(job_id) > 2')
->get()
->result_array();
// Check the result
$this->assertEquals(2, count($jobs));
- $this->assertEquals('Accountant', $jobs[0]['name']);
- $this->assertEquals('Musician', $jobs[1]['name']);
+ $this->assertEquals('Accountant', $jobs[0]['job_name']);
+ $this->assertEquals('Musician', $jobs[1]['job_name']);
}
}
\ No newline at end of file
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index 86d868af2..e4128b23f 100755
Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ
--
cgit v1.2.3-24-g4f1b
From 1afd479059c3d6f7c46aa0c36aa56cfba7f94226 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 20:34:30 +0700
Subject: HAVING clause API code-coverage
---
.../database/query_builder/group_test.php | 24 +++++++++++++++++----
tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes
tests/mocks/database/schema/skeleton.php | 12 +++++++----
3 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php
index dd248ae9a..7d8abc33f 100644
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ b/tests/codeigniter/database/query_builder/group_test.php
@@ -22,16 +22,32 @@ class Group_test extends CI_TestCase {
*/
public function test_group_by()
{
- $jobs = $this->db->select('job.name as job_name, job.id as job_id')
+ $jobs = $this->db->select('name')
->from('job')
- ->group_by('job_name HAVING SUM(job_id) > 2')
+ ->group_by('name')
+ ->get()
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(4, count($jobs));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_having_by()
+ {
+ $jobs = $this->db->select('name')
+ ->from('job')
+ ->group_by('name')
+ ->having('SUM(id) > 2')
->get()
->result_array();
// Check the result
$this->assertEquals(2, count($jobs));
- $this->assertEquals('Accountant', $jobs[0]['job_name']);
- $this->assertEquals('Musician', $jobs[1]['job_name']);
}
}
\ No newline at end of file
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index e4128b23f..d48e3317f 100755
Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index 9ebd6e85f..671336cc4 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -64,6 +64,10 @@ class Mock_Database_Schema_Skeleton {
'type' => 'VARCHAR',
'constraint' => 100,
),
+ 'country' => array(
+ 'type' => 'VARCHAR',
+ 'constraint' => 40,
+ ),
));
static::$forge->add_key('id', TRUE);
static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE));
@@ -96,10 +100,10 @@ class Mock_Database_Schema_Skeleton {
// Job Data
$data = array(
'user' => array(
- array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com'),
- array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'),
- array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'),
- array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'),
+ array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'),
+ array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'),
+ array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'),
+ array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK'),
),
'job' => array(
array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
--
cgit v1.2.3-24-g4f1b
From 44d8d881b401238661d81fc9db10482604b4cf43 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 20:43:45 +0700
Subject: DISTINCT clause API code-coverage
---
.../database/query_builder/distinct_test.php | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/distinct_test.php
diff --git a/tests/codeigniter/database/query_builder/distinct_test.php b/tests/codeigniter/database/query_builder/distinct_test.php
new file mode 100644
index 000000000..925eadb19
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/distinct_test.php
@@ -0,0 +1,34 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_distinct()
+ {
+ $users = $this->db->select('country')
+ ->distinct()
+ ->get('user')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(3, count($users));
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 8ca31f34c855c783689198f0d352e6efec352b4d Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Fri, 4 May 2012 23:57:46 +0700
Subject: PDO SQLite bug fixed, for result_object
---
system/database/drivers/pdo/pdo_result.php | 19 +++++++------------
tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index 19aee1dfc..0b8937cc5 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -84,19 +84,14 @@ class CI_DB_pdo_result extends CI_DB_result {
// Define the output
$output = array('assoc', 'object');
+ // Initial value
+ $this->result_assoc = array() and $this->result_object = array();
+
// Fetch the result
- foreach ($output as $type)
+ while ($row = $this->_fetch_assoc())
{
- // Define the method and handler
- $res_method = '_fetch_'.$type;
- $res_handler = 'result_'.$type;
-
- $this->$res_handler = array();
-
- while ($row = $this->$res_method())
- {
- $this->{$res_handler}[] = $row;
- }
+ $this->result_assoc[] = $row;
+ $this->result_object[] = (object) $row;
}
// Save this as buffer and marked the fetch flag
@@ -249,7 +244,7 @@ class CI_DB_pdo_result extends CI_DB_result {
*/
protected function _fetch_object()
{
- return $this->result_id->fetchObject();
+ return $this->result_id->fetch(PDO::FETCH_OBJ);
}
}
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index d48e3317f..23a3de2a4 100755
Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ
--
cgit v1.2.3-24-g4f1b
From d2d329a99f60bebc36eebc1c7b3c1a94b9789b49 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 00:33:04 +0700
Subject: ORDER BY clause API code-coverage
---
.../database/query_builder/order_test.php | 55 ++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/order_test.php
diff --git a/tests/codeigniter/database/query_builder/order_test.php b/tests/codeigniter/database/query_builder/order_test.php
new file mode 100644
index 000000000..01aa1c2b4
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/order_test.php
@@ -0,0 +1,55 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_order_ascending()
+ {
+ $jobs = $this->db->order_by('name', 'asc')
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(4, count($jobs));
+ $this->assertEquals('Accountant', $jobs[0]['name']);
+ $this->assertEquals('Developer', $jobs[1]['name']);
+ $this->assertEquals('Musician', $jobs[2]['name']);
+ $this->assertEquals('Politician', $jobs[3]['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_order_descending()
+ {
+ $jobs = $this->db->order_by('name', 'desc')
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(4, count($jobs));
+ $this->assertEquals('Politician', $jobs[0]['name']);
+ $this->assertEquals('Musician', $jobs[1]['name']);
+ $this->assertEquals('Developer', $jobs[2]['name']);
+ $this->assertEquals('Accountant', $jobs[3]['name']);
+ }
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From be6fb4271ce723376930507dbe534f91344f26c7 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 00:35:41 +0700
Subject: LIMIT clause API code-coverage
---
.../database/query_builder/limit_test.php | 49 ++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/limit_test.php
diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php
new file mode 100644
index 000000000..704f3b651
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/limit_test.php
@@ -0,0 +1,49 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_limit()
+ {
+ $jobs = $this->db->limit(2)
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(2, count($jobs));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_limit_and_offset()
+ {
+ $jobs = $this->db->limit(2, 2)
+ ->get('job')
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals(2, count($jobs));
+ $this->assertEquals('Accountant', $jobs[0]['name']);
+ $this->assertEquals('Musician', $jobs[1]['name']);
+ }
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From c386b2a363c289afcfa07eea081050e35c1e86d8 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 00:42:02 +0700
Subject: count code-coverage
---
.../database/query_builder/count_test.php | 44 ++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/count_test.php
diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php
new file mode 100644
index 000000000..5e691692d
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/count_test.php
@@ -0,0 +1,44 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_count_all()
+ {
+ $job_count = $this->db->count_all('job');
+
+ // Check the result
+ $this->assertEquals(4, $job_count);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_count_all_results()
+ {
+ $job_count = $this->db->like('name', 'ian')
+ ->count_all_results('job');
+
+ // Check the result
+ $this->assertEquals(2, $job_count);
+ }
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 9ec507badf60952750e76b5d83da54874dd19119 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 00:55:39 +0700
Subject: UPDATE and SET clause code-coverage
---
.../database/query_builder/update_test.php | 71 ++++++++++++++++++++++
1 file changed, 71 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/update_test.php
diff --git a/tests/codeigniter/database/query_builder/update_test.php b/tests/codeigniter/database/query_builder/update_test.php
new file mode 100644
index 000000000..f5bbffd4f
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/update_test.php
@@ -0,0 +1,71 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_update()
+ {
+ // Check initial record
+ $job1 = $this->db->where('id', 1)
+ ->get('job')
+ ->row();
+
+ $this->assertEquals('Developer', $job1->name);
+
+ // Do the update
+ $job_data = array('name' => 'Programmer');
+
+ $this->db->where('id', 1)
+ ->update('job', $job_data);
+
+ // Check updated record
+ $job1 = $this->db->where('id', 1)
+ ->get('job')
+ ->row();
+
+ $this->assertEquals('Programmer', $job1->name);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_update_with_set()
+ {
+ // Check initial record
+ $job1 = $this->db->where('id', 4)
+ ->get('job')
+ ->row();
+
+ $this->assertEquals('Musician', $job1->name);
+
+ // Do the update
+ $this->db->set('name', 'Vocalist');
+ $this->db->update('job', NULL, 'id = 4');
+
+ // Check updated record
+ $job1 = $this->db->where('id', 4)
+ ->get('job')
+ ->row();
+
+ $this->assertEquals('Vocalist', $job1->name);
+ }
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 6657cc1672f3f466655b1e476028b9d46a16bd1c Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 01:06:41 +0700
Subject: DELETE code-coverage
---
.../database/query_builder/delete_test.php | 72 ++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/delete_test.php
diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php
new file mode 100644
index 000000000..84ea7616f
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/delete_test.php
@@ -0,0 +1,72 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_delete()
+ {
+ // Check initial record
+ $job1 = $this->db->where('id', 1)
+ ->get('job')
+ ->row();
+
+ $this->assertEquals('Developer', $job1->name);
+
+ // Do the delete
+ $this->db->delete('job', array('id' => 1));
+
+ // Check the record
+ $job1 = $this->db->where('id', 1)
+ ->get('job');
+
+ $this->assertEmpty($job1->result_array());
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_delete_several_tables()
+ {
+ // Check initial record
+ $user4 = $this->db->where('id', 4)
+ ->get('user')
+ ->row();
+
+ $job4 = $this->db->where('id', 4)
+ ->get('job')
+ ->row();
+
+ $this->assertEquals('Musician', $job4->name);
+ $this->assertEquals('Chris Martin', $user4->name);
+
+ // Do the delete
+ $this->db->delete(array('job', 'user'), array('id' => 4));
+
+ // Check the record
+ $job4 = $this->db->where('id', 4)->get('job');
+ $user4 = $this->db->where('id', 4)->get('user');
+
+ $this->assertEmpty($job4->result_array());
+ $this->assertEmpty($user4->result_array());
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 85859b212e480e2e1a59aae50c759367d6794ecd Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 01:26:51 +0700
Subject: empty table API code-coverage
---
.../database/query_builder/empty_test.php | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/empty_test.php
diff --git a/tests/codeigniter/database/query_builder/empty_test.php b/tests/codeigniter/database/query_builder/empty_test.php
new file mode 100644
index 000000000..d1f56285f
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/empty_test.php
@@ -0,0 +1,39 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_empty_table()
+ {
+ // Check initial record
+ $jobs = $this->db->get('job')->result_array();
+
+ $this->assertEquals(4, count($jobs));
+
+ // Do the empty
+ $this->db->empty_table('job');
+
+ // Check the record
+ $jobs = $this->db->get('job');
+
+ $this->assertEmpty($jobs->result_array());
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 39f35fde6d023433e98904105f55f305483b6b5e Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 01:29:13 +0700
Subject: TRUNCATE code-coverage
---
.../database/query_builder/truncate_test.php | 61 ++++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 tests/codeigniter/database/query_builder/truncate_test.php
diff --git a/tests/codeigniter/database/query_builder/truncate_test.php b/tests/codeigniter/database/query_builder/truncate_test.php
new file mode 100644
index 000000000..2a9c8a91e
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/truncate_test.php
@@ -0,0 +1,61 @@
+db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_truncate()
+ {
+ // Check initial record
+ $jobs = $this->db->get('job')->result_array();
+
+ $this->assertEquals(4, count($jobs));
+
+ // Do the empty
+ $this->db->truncate('job');
+
+ // Check the record
+ $jobs = $this->db->get('job');
+
+ $this->assertEmpty($jobs->result_array());
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_truncate_with_from()
+ {
+ // Check initial record
+ $users = $this->db->get('user')->result_array();
+
+ $this->assertEquals(4, count($users));
+
+ // Do the empty
+ $this->db->from('user')
+ ->truncate();
+
+ // Check the record
+ $users = $this->db->get('user');
+
+ $this->assertEmpty($users->result_array());
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 51a7c0b98df29205d39bb404c2bcd12bfb4ed4cb Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 01:43:08 +0700
Subject: Clean up
---
tests/README.md | 6 ------
tests/codeigniter/Setup_test.php | 10 +++++-----
tests/travis/mysql.phpunit.xml | 6 +-----
tests/travis/pdo/mysql.phpunit.xml | 4 ----
tests/travis/pdo/pgsql.phpunit.xml | 6 +-----
tests/travis/pdo/sqlite.phpunit.xml | 6 +-----
tests/travis/pgsql.phpunit.xml | 6 +-----
tests/travis/sqlite.phpunit.xml | 6 +-----
8 files changed, 10 insertions(+), 40 deletions(-)
diff --git a/tests/README.md b/tests/README.md
index 6d83c34d8..b46f344cb 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -2,12 +2,6 @@
Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=feature/unit-tests)](http://travis-ci.org/EllisLab/CodeIgniter)
-*Do not merge to default until these issues have been addressed*
-
-- Clean up naming conventions
-- Figure out config stuff
-- Figure out database testing
-
### Introduction:
This is the preliminary CodeIgniter testing documentation. It
diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php
index 550245f2f..b48e32bfb 100644
--- a/tests/codeigniter/Setup_test.php
+++ b/tests/codeigniter/Setup_test.php
@@ -2,12 +2,12 @@
class Setup_test extends PHPUnit_Framework_TestCase {
- function test_nonsense()
+ function test_bootstrap_constants()
{
- $this->markTestIncomplete('not implemented');
- // ensure that our bootstrapped test environment
- // is a good representation of an isolated CI install
- //die('here');
+ $this->assertTrue(defined('PROJECT_BASE'));
+ $this->assertTrue(defined('BASEPATH'));
+ $this->assertTrue(defined('APPPATH'));
+ $this->assertTrue(defined('VIEWPATH'));
}
}
\ No newline at end of file
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
index e9556f758..c5fcf1335 100644
--- a/tests/travis/mysql.phpunit.xml
+++ b/tests/travis/mysql.phpunit.xml
@@ -14,11 +14,7 @@
- ../codeigniter/Setup_test.php
- ../codeigniter/core
- ../codeigniter/helpers
- ../codeigniter/libraries
- ../codeigniter/database
+ ../codeigniter
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
index 69eece24f..f6fcc1c39 100644
--- a/tests/travis/pdo/mysql.phpunit.xml
+++ b/tests/travis/pdo/mysql.phpunit.xml
@@ -14,10 +14,6 @@
- ../../codeigniter/Setup_test.php
- ../../codeigniter/core
- ../../codeigniter/helpers
- ../../codeigniter/libraries../../codeigniter/database
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
index e68c3e028..6a23227db 100644
--- a/tests/travis/pdo/pgsql.phpunit.xml
+++ b/tests/travis/pdo/pgsql.phpunit.xml
@@ -14,11 +14,7 @@
- ../../codeigniter/Setup_test.php
- ../../codeigniter/core
- ../../codeigniter/helpers
- ../../codeigniter/libraries
- ../../codeigniter/database
+ ../../codeigniter
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
index 1871f6221..b85b7308a 100644
--- a/tests/travis/pdo/sqlite.phpunit.xml
+++ b/tests/travis/pdo/sqlite.phpunit.xml
@@ -14,11 +14,7 @@
- ../../codeigniter/Setup_test.php
- ../../codeigniter/core
- ../../codeigniter/helpers
- ../../codeigniter/libraries
- ../../codeigniter/database
+ ../../codeigniter
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
index ad8aeded2..78b6046cf 100644
--- a/tests/travis/pgsql.phpunit.xml
+++ b/tests/travis/pgsql.phpunit.xml
@@ -14,11 +14,7 @@
- ../codeigniter/Setup_test.php
- ../codeigniter/core
- ../codeigniter/helpers
- ../codeigniter/libraries
- ../codeigniter/database
+ ../codeigniter
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
index 628370e93..46e3d5073 100644
--- a/tests/travis/sqlite.phpunit.xml
+++ b/tests/travis/sqlite.phpunit.xml
@@ -14,11 +14,7 @@
- ../codeigniter/Setup_test.php
- ../codeigniter/core
- ../codeigniter/helpers
- ../codeigniter/libraries
- ../codeigniter/database
+ ../codeigniter
--
cgit v1.2.3-24-g4f1b
From 82196b945e291c65fdb66b35e3205f786ce8e921 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Sat, 5 May 2012 01:52:47 +0700
Subject: Remove temporary branch from travis whitelist
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 971f62f38..97ea0422d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,5 +25,4 @@ script: phpunit --configuration tests/travis/$DB.phpunit.xml
branches:
only:
- develop
- - master
- - db-tests
\ No newline at end of file
+ - master
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From d4fb95ff19666f178b9f84850d122ff07fe193b9 Mon Sep 17 00:00:00 2001
From: Cusco
Date: Sat, 5 May 2012 03:22:24 +0800
Subject: Update system/database/drivers/interbase/interbase_utility.php
---
system/database/drivers/interbase/interbase_utility.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index 1b92af9b6..164211836 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -42,7 +42,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
* @param string $filename
* @return mixed
*/
- protected function backup($filename)
+ protected function _backup($filename)
{
if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
{
--
cgit v1.2.3-24-g4f1b
From bb2c83bddbf51c42815be3de60eab24fd87ae392 Mon Sep 17 00:00:00 2001
From: Wes Baker
Date: Fri, 4 May 2012 18:44:24 -0400
Subject: Added a return false if an image doesn't pass XSS cleaning to prevent
file_get_contents from returning a NULL and passing through unscathed.
---
system/libraries/Upload.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 8ad67050d..4a4a66f73 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -850,6 +850,10 @@ class CI_Upload {
{
return TRUE; // its an image, no "triggers" detected in the first 256 bytes, we're good
}
+ else
+ {
+ return FALSE;
+ }
}
if (($data = @file_get_contents($file)) === FALSE)
@@ -1099,4 +1103,4 @@ class CI_Upload {
}
/* End of file Upload.php */
-/* Location: ./system/libraries/Upload.php */
\ No newline at end of file
+/* Location: ./system/libraries/Upload.php */
--
cgit v1.2.3-24-g4f1b
From 43ef706d3684af7efa02c21db02ca150c9b424a9 Mon Sep 17 00:00:00 2001
From: dixy
Date: Sat, 5 May 2012 18:26:54 +0200
Subject: Remove -webkit prefix for box-shadow
---
application/errors/error_404.php | 2 +-
application/errors/error_db.php | 2 +-
application/errors/error_general.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/application/errors/error_404.php b/application/errors/error_404.php
index 746032956..c19bedfcd 100644
--- a/application/errors/error_404.php
+++ b/application/errors/error_404.php
@@ -72,7 +72,7 @@ code {
#container {
margin: 10px;
border: 1px solid #D0D0D0;
- -webkit-box-shadow: 0 0 8px #D0D0D0;
+ box-shadow: 0 0 8px #D0D0D0;
}
p {
diff --git a/application/errors/error_db.php b/application/errors/error_db.php
index eb3a75260..3b244e094 100644
--- a/application/errors/error_db.php
+++ b/application/errors/error_db.php
@@ -72,7 +72,7 @@ code {
#container {
margin: 10px;
border: 1px solid #D0D0D0;
- -webkit-box-shadow: 0 0 8px #D0D0D0;
+ box-shadow: 0 0 8px #D0D0D0;
}
p {
diff --git a/application/errors/error_general.php b/application/errors/error_general.php
index 59896e1ea..c88afe168 100644
--- a/application/errors/error_general.php
+++ b/application/errors/error_general.php
@@ -72,7 +72,7 @@ code {
#container {
margin: 10px;
border: 1px solid #D0D0D0;
- -webkit-box-shadow: 0 0 8px #D0D0D0;
+ box-shadow: 0 0 8px #D0D0D0;
}
p {
--
cgit v1.2.3-24-g4f1b
From e463c4d71c2fdcc224e70f7576582220ae64e3d7 Mon Sep 17 00:00:00 2001
From: Wes Baker
Date: Fri, 4 May 2012 18:44:24 -0400
Subject: Added a return false if an image doesn't pass XSS cleaning to prevent
file_get_contents from returning a NULL and passing through unscathed.
---
system/libraries/Upload.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index b0490de30..0e5d73b19 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -868,6 +868,10 @@ class CI_Upload {
{
return TRUE; // its an image, no "triggers" detected in the first 256 bytes, we're good
}
+ else
+ {
+ return FALSE;
+ }
}
if (($data = @file_get_contents($file)) === FALSE)
--
cgit v1.2.3-24-g4f1b
From cdcceecba73dd9f54665f531d15c12f5c9679738 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Wed, 9 May 2012 11:23:30 +0300
Subject: Fix issue #1342
---
system/libraries/Form_validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 5547c6a69..73f607be8 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -448,7 +448,7 @@ class CI_Form_validation {
{
$this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']);
}
- elseif ( ! empty($validation_array[$field]))
+ elseif (isset($validation_array[$field]))
{
$this->_field_data[$field]['postdata'] = $validation_array[$field];
}
--
cgit v1.2.3-24-g4f1b
From d41f423528b21d97ff0eb268e10947b257f5a90e Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Fri, 11 May 2012 11:00:42 +0700
Subject: Generate better conditions statement on boolean field type. Actually
boolean field type need TRUE or FALSE value. Common DBMS (e.g., MySQL) can
substite this value with 1 or 0, but it can't be implemented on PostgreSQL.
So, its better to use TRUE or FALSE value for boolean field type.
---
system/database/DB_query_builder.php | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index d0af66de1..969a25acb 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -432,7 +432,21 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$k .= ' IS NULL';
}
- if ( ! is_null($v))
+ if ( is_bool($v))
+ {
+ if ($escape === TRUE)
+ {
+ $k = $this->protect_identifiers($k, FALSE, $escape);
+
+ $v = ' '.($v ? 'TRUE' : 'FALSE');
+ }
+
+ if ( ! $this->_has_operator($k))
+ {
+ $k .= ' =';
+ }
+ }
+ else if ( ! is_null($v))
{
if ($escape === TRUE)
{
--
cgit v1.2.3-24-g4f1b
From b01d96f65a78528323b3917eec31c4ed8b58eb7b Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Fri, 11 May 2012 11:18:38 +0700
Subject: simpler script, add boolean handling on DB_driver/escape
---
system/database/DB_query_builder.php | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 969a25acb..8fa67ea06 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -432,26 +432,16 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$k .= ' IS NULL';
}
- if ( is_bool($v))
+ if ( ! is_null($v))
{
if ($escape === TRUE)
{
$k = $this->protect_identifiers($k, FALSE, $escape);
-
- $v = ' '.($v ? 'TRUE' : 'FALSE');
+ $v = ' '.$this->escape($v);
}
-
- if ( ! $this->_has_operator($k))
+ else if (is_bool($v))
{
- $k .= ' =';
- }
- }
- else if ( ! is_null($v))
- {
- if ($escape === TRUE)
- {
- $k = $this->protect_identifiers($k, FALSE, $escape);
- $v = ' '.$this->escape($v);
+ $v = ' '.($v ? 'TRUE' : 'FALSE');
}
if ( ! $this->_has_operator($k))
--
cgit v1.2.3-24-g4f1b
From 938c7ef59991ed12b8634b292e2f8fc9fa385264 Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Fri, 11 May 2012 11:21:43 +0700
Subject: Escaping boolean data type, some DBMS (e.g., postgre) need it
---
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 ef77b594e..09513e267 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -696,7 +696,7 @@ abstract class CI_DB_driver {
}
elseif (is_bool($str))
{
- return ($str === FALSE) ? 0 : 1;
+ return ($str === FALSE) ? "FALSE" : "TRUE";
}
elseif (is_null($str))
{
--
cgit v1.2.3-24-g4f1b
From ca7d822f224033196e0e327944a01f319c90f37f Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Fri, 11 May 2012 10:59:09 +0300
Subject: User_agent library improvements
---
application/config/user_agents.php | 147 +++++++++++++++++++-----------------
system/libraries/User_agent.php | 24 +++---
user_guide_src/source/changelog.rst | 2 +-
3 files changed, 89 insertions(+), 84 deletions(-)
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 60f256e01..72d74dbc7 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -36,7 +36,7 @@
|
*/
-$platforms = array (
+$platforms = array(
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
@@ -51,6 +51,11 @@ $platforms = array (
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows' => 'Unknown Windows OS',
+ 'android' => 'Android',
+ 'blackberry' => 'BlackBerry',
+ 'iphone' => 'iOS',
+ 'ipad' => 'iOS',
+ 'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
@@ -117,84 +122,84 @@ $mobiles = array(
// 'motorola' => 'Motorola'
// Phones and Manufacturers
- 'motorola' => "Motorola",
- 'nokia' => "Nokia",
- 'palm' => "Palm",
- 'iphone' => "Apple iPhone",
- 'ipad' => "iPad",
- 'ipod' => "Apple iPod Touch",
- 'sony' => "Sony Ericsson",
- 'ericsson' => "Sony Ericsson",
- 'blackberry' => "BlackBerry",
- 'cocoon' => "O2 Cocoon",
- 'blazer' => "Treo",
- 'lg' => "LG",
- 'amoi' => "Amoi",
- 'xda' => "XDA",
- 'mda' => "MDA",
- 'vario' => "Vario",
- 'htc' => "HTC",
- 'samsung' => "Samsung",
- 'sharp' => "Sharp",
- 'sie-' => "Siemens",
- 'alcatel' => "Alcatel",
- 'benq' => "BenQ",
- 'ipaq' => "HP iPaq",
- 'mot-' => "Motorola",
- 'playstation portable' => "PlayStation Portable",
- 'hiptop' => "Danger Hiptop",
- 'nec-' => "NEC",
- 'panasonic' => "Panasonic",
- 'philips' => "Philips",
- 'sagem' => "Sagem",
- 'sanyo' => "Sanyo",
- 'spv' => "SPV",
- 'zte' => "ZTE",
- 'sendo' => "Sendo",
- 'dsi' => "Nintendo DSi",
- 'ds' => "Nintendo DS",
- 'wii' => "Nintendo Wii",
- '3ds' => "Nintendo 3DS",
- 'open web' => "Open Web",
- 'openweb' => "OpenWeb",
+ 'motorola' => 'Motorola',
+ 'nokia' => 'Nokia',
+ 'palm' => 'Palm',
+ 'iphone' => 'Apple iPhone',
+ 'ipad' => 'iPad',
+ 'ipod' => 'Apple iPod Touch',
+ 'sony' => 'Sony Ericsson',
+ 'ericsson' => 'Sony Ericsson',
+ 'blackberry' => 'BlackBerry',
+ 'cocoon' => 'O2 Cocoon',
+ 'blazer' => 'Treo',
+ 'lg' => 'LG',
+ 'amoi' => 'Amoi',
+ 'xda' => 'XDA',
+ 'mda' => 'MDA',
+ 'vario' => 'Vario',
+ 'htc' => 'HTC',
+ 'samsung' => 'Samsung',
+ 'sharp' => 'Sharp',
+ 'sie-' => 'Siemens',
+ 'alcatel' => 'Alcatel',
+ 'benq' => 'BenQ',
+ 'ipaq' => 'HP iPaq',
+ 'mot-' => 'Motorola',
+ 'playstation portable' => 'PlayStation Portable',
+ 'hiptop' => 'Danger Hiptop',
+ 'nec-' => 'NEC',
+ 'panasonic' => 'Panasonic',
+ 'philips' => 'Philips',
+ 'sagem' => 'Sagem',
+ 'sanyo' => 'Sanyo',
+ 'spv' => 'SPV',
+ 'zte' => 'ZTE',
+ 'sendo' => 'Sendo',
+ 'dsi' => 'Nintendo DSi',
+ 'ds' => 'Nintendo DS',
+ 'wii' => 'Nintendo Wii',
+ '3ds' => 'Nintendo 3DS',
+ 'open web' => 'Open Web',
+ 'openweb' => 'OpenWeb',
// Operating Systems
- 'android' => "Android",
- 'symbian' => "Symbian",
- 'SymbianOS' => "SymbianOS",
- 'elaine' => "Palm",
- 'palm' => "Palm",
- 'series60' => "Symbian S60",
- 'windows ce' => "Windows CE",
+ 'android' => 'Android',
+ 'symbian' => 'Symbian',
+ 'SymbianOS' => 'SymbianOS',
+ 'elaine' => 'Palm',
+ 'palm' => 'Palm',
+ 'series60' => 'Symbian S60',
+ 'windows ce' => 'Windows CE',
// Browsers
- 'obigo' => "Obigo",
- 'netfront' => "Netfront Browser",
- 'openwave' => "Openwave Browser",
- 'mobilexplorer' => "Mobile Explorer",
- 'operamini' => "Opera Mini",
- 'opera mini' => "Opera Mini",
- 'opera mobi' => "Opera Mobile",
+ 'obigo' => 'Obigo',
+ 'netfront' => 'Netfront Browser',
+ 'openwave' => 'Openwave Browser',
+ 'mobilexplorer' => 'Mobile Explorer',
+ 'operamini' => 'Opera Mini',
+ 'opera mini' => 'Opera Mini',
+ 'opera mobi' => 'Opera Mobile',
// Other
- 'digital paths' => "Digital Paths",
- 'avantgo' => "AvantGo",
- 'xiino' => "Xiino",
- 'novarra' => "Novarra Transcoder",
- 'vodafone' => "Vodafone",
- 'docomo' => "NTT DoCoMo",
- 'o2' => "O2",
+ 'digital paths' => 'Digital Paths',
+ 'avantgo' => 'AvantGo',
+ 'xiino' => 'Xiino',
+ 'novarra' => 'Novarra Transcoder',
+ 'vodafone' => 'Vodafone',
+ 'docomo' => 'NTT DoCoMo',
+ 'o2' => 'O2',
// Fallback
- 'mobile' => "Generic Mobile",
- 'wireless' => "Generic Mobile",
- 'j2me' => "Generic Mobile",
- 'midp' => "Generic Mobile",
- 'cldc' => "Generic Mobile",
- 'up.link' => "Generic Mobile",
- 'up.browser' => "Generic Mobile",
- 'smartphone' => "Generic Mobile",
- 'cellphone' => "Generic Mobile"
+ 'mobile' => 'Generic Mobile',
+ 'wireless' => 'Generic Mobile',
+ 'j2me' => 'Generic Mobile',
+ 'midp' => 'Generic Mobile',
+ 'cldc' => 'Generic Mobile',
+ 'up.link' => 'Generic Mobile',
+ 'up.browser' => 'Generic Mobile',
+ 'smartphone' => 'Generic Mobile',
+ 'cellphone' => 'Generic Mobile'
);
// There are hundreds of bots but these are the most common.
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 0ac605fa4..ff596f04b 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -51,14 +51,14 @@ class CI_User_agent {
* @var bool
*/
public $is_browser = FALSE;
-
+
/**
* Flag for if the user-agent is a robot
*
* @var bool
*/
public $is_robot = FALSE;
-
+
/**
* Flag for if the user-agent is a mobile browser
*
@@ -72,7 +72,7 @@ class CI_User_agent {
* @var array
*/
public $languages = array();
-
+
/**
* Character sets accepted by the current user agent
*
@@ -86,21 +86,21 @@ class CI_User_agent {
* @var array
*/
public $platforms = array();
-
+
/**
* List of browsers to compare against current user agent
*
* @var array
*/
public $browsers = array();
-
+
/**
* List of mobile browsers to compare against current user agent
*
* @var array
*/
public $mobiles = array();
-
+
/**
* List of robots to compare against current user agent
*
@@ -114,28 +114,28 @@ class CI_User_agent {
* @var string
*/
public $platform = '';
-
+
/**
* Current user-agent browser
*
* @var string
*/
public $browser = '';
-
+
/**
* Current user-agent version
*
* @var string
*/
public $version = '';
-
+
/**
* Current user-agent mobile name
*
* @var string
*/
public $mobile = '';
-
+
/**
* Current user-agent robot name
*
@@ -330,7 +330,7 @@ class CI_User_agent {
{
foreach ($this->mobiles as $key => $val)
{
- if (FALSE !== (strpos(strtolower($this->agent), $key)))
+ if (FALSE !== (stripos($this->agent, $key)))
{
$this->is_mobile = TRUE;
$this->mobile = $val;
@@ -604,7 +604,7 @@ class CI_User_agent {
/**
* Test for a particular character set
*
- * @param string $charset
+ * @param string $charset
* @return bool
*/
public function accept_charset($charset = 'utf-8')
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index a70531901..4756eb3f5 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -22,7 +22,7 @@ Release Date: Not Released
- PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4.
- Added an optional backtrace to php-error template.
- Added Android to the list of user agents.
- - Added Windows 7 to the list of user platforms.
+ - Added Windows 7, Android, Blackberry and iOS to the list of user platforms.
- Ability to log certain error types, not all under a threshold.
- Added support for pem, p10, p12, p7a, p7c, p7m, p7r, p7s, crt, crl, der, kdb, rsa, cer, sst, csr Certs to mimes.php.
- Added support for pgp and gpg to mimes.php.
--
cgit v1.2.3-24-g4f1b
From 585cf67a98d8a31f584c13a319310ca7561d572c Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Fri, 11 May 2012 11:55:15 +0300
Subject: Remove a duplicate mobile user agent entry
---
application/config/user_agents.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 72d74dbc7..76114616b 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -168,7 +168,6 @@ $mobiles = array(
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
- 'palm' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
--
cgit v1.2.3-24-g4f1b
From 46d53fb8799eb2f84798f0e7a5f57b065c2482e2 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Fri, 11 May 2012 13:42:24 +0300
Subject: Fix issue #1349
---
system/libraries/Upload.php | 2 +-
user_guide_src/source/changelog.rst | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 4a4a66f73..24d4bd4d0 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -725,7 +725,7 @@ class CI_Upload {
public function get_extension($filename)
{
$x = explode('.', $filename);
- return '.'.end($x);
+ return (count($x) !== 1) ? '.'.end($x) : '';
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 4756eb3f5..d457a3fbc 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -214,8 +214,9 @@ Bug fixes for 3.0
- Fixed a bug in SQLSRV's delete() method where like() and limit() conditions were ignored.
- Fixed a bug (#1265) - Database connections were always closed, regardless of the 'pconnect' option value.
- Fixed a bug (#128) - :doc:`Language Library ` did not correctly keep track of loaded language files.
-- Fixed a bug (#1242) Added Windows path compatibility to function read_dir of ZIP library
-- Fixed a bug (#1314) sess_destroy() did not destroy userdata.
+- Fixed a bug (#1242) - Added Windows path compatibility to function read_dir of ZIP library
+- Fixed a bug (#1314) - sess_destroy() did not destroy userdata.
+- Fixed a bug (#1349) - get_extension() in the `File Uploading Library ` returned the original filename when it didn't have an actual extension.
Version 2.1.1
=============
--
cgit v1.2.3-24-g4f1b
From fff6c2a3caa1ce14e58fcb3ee0d937d17985eea1 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Sun, 13 May 2012 22:15:23 +0300
Subject: Improve the solution for issue #1342
---
system/libraries/Form_validation.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 73f607be8..c396580be 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -448,7 +448,7 @@ class CI_Form_validation {
{
$this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']);
}
- elseif (isset($validation_array[$field]))
+ elseif (isset($validation_array[$field]) && $validation_array[$field] !== '')
{
$this->_field_data[$field]['postdata'] = $validation_array[$field];
}
--
cgit v1.2.3-24-g4f1b
From 66c982e8fa8fb0261394b63b25a3817503263d17 Mon Sep 17 00:00:00 2001
From: Thanasis Polychronakis
Date: Mon, 14 May 2012 21:31:04 +0300
Subject: Load base config first, then environment's config
---
system/core/Common.php | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/system/core/Common.php b/system/core/Common.php
index 78aa6e874..01b0d8673 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -231,21 +231,21 @@ if ( ! function_exists('get_config'))
return $_config[0];
}
- // Is the config file in the environment folder?
- if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
- {
- $file_path = APPPATH.'config/config.php';
+ $file_path = APPPATH.'config/config.php';
+ $found = false;
+ if (file_exists($file_path)) {
+ $found = true;
+ require($file_path);
}
- // Fetch the config file
- if ( ! file_exists($file_path))
+ // Is the config file in the environment folder?
+ if (defined(ENVIRONMENT) && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
{
- set_status_header(503);
+ require($file_path);
+ } else if (!$found) {
exit('The configuration file does not exist.');
}
- require($file_path);
-
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
--
cgit v1.2.3-24-g4f1b
From 09069ddcecde9a0c66e41087e816567d420eb750 Mon Sep 17 00:00:00 2001
From: Timothy Warren
Date: Mon, 14 May 2012 15:21:33 -0400
Subject: Move errors to views folder
---
application/errors/error_404.php | 89 ------------------------------
application/errors/error_db.php | 89 ------------------------------
application/errors/error_general.php | 89 ------------------------------
application/errors/error_php.php | 55 ------------------
application/errors/index.html | 10 ----
application/views/errors/error_404.php | 89 ++++++++++++++++++++++++++++++
application/views/errors/error_db.php | 89 ++++++++++++++++++++++++++++++
application/views/errors/error_general.php | 89 ++++++++++++++++++++++++++++++
application/views/errors/error_php.php | 55 ++++++++++++++++++
application/views/errors/index.html | 10 ++++
system/core/Exceptions.php | 4 +-
11 files changed, 334 insertions(+), 334 deletions(-)
delete mode 100644 application/errors/error_404.php
delete mode 100644 application/errors/error_db.php
delete mode 100644 application/errors/error_general.php
delete mode 100644 application/errors/error_php.php
delete mode 100644 application/errors/index.html
create mode 100644 application/views/errors/error_404.php
create mode 100644 application/views/errors/error_db.php
create mode 100644 application/views/errors/error_general.php
create mode 100644 application/views/errors/error_php.php
create mode 100644 application/views/errors/index.html
diff --git a/application/errors/error_404.php b/application/errors/error_404.php
deleted file mode 100644
index c19bedfcd..000000000
--- a/application/errors/error_404.php
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-404 Page Not Found
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/errors/error_db.php b/application/errors/error_db.php
deleted file mode 100644
index 3b244e094..000000000
--- a/application/errors/error_db.php
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-Database Error
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/errors/error_general.php b/application/errors/error_general.php
deleted file mode 100644
index c88afe168..000000000
--- a/application/errors/error_general.php
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-Error
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/errors/error_php.php b/application/errors/error_php.php
deleted file mode 100644
index 3855720de..000000000
--- a/application/errors/error_php.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
A PHP Error was encountered
-
-
Severity:
-
Message:
-
Filename:
-
Line Number:
-
-
-
-
Backtrace:
-
-
-
-
- File:
- Line:
- Function:
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/errors/index.html b/application/errors/index.html
deleted file mode 100644
index c942a79ce..000000000
--- a/application/errors/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- 403 Forbidden
-
-
-
-
Directory access is forbidden.
-
-
-
\ No newline at end of file
diff --git a/application/views/errors/error_404.php b/application/views/errors/error_404.php
new file mode 100644
index 000000000..c19bedfcd
--- /dev/null
+++ b/application/views/errors/error_404.php
@@ -0,0 +1,89 @@
+
+
+
+
+404 Page Not Found
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/error_db.php b/application/views/errors/error_db.php
new file mode 100644
index 000000000..3b244e094
--- /dev/null
+++ b/application/views/errors/error_db.php
@@ -0,0 +1,89 @@
+
+
+
+
+Database Error
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/error_general.php b/application/views/errors/error_general.php
new file mode 100644
index 000000000..c88afe168
--- /dev/null
+++ b/application/views/errors/error_general.php
@@ -0,0 +1,89 @@
+
+
+
+
+Error
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/error_php.php b/application/views/errors/error_php.php
new file mode 100644
index 000000000..3855720de
--- /dev/null
+++ b/application/views/errors/error_php.php
@@ -0,0 +1,55 @@
+
+
+
+
+
A PHP Error was encountered
+
+
Severity:
+
Message:
+
Filename:
+
Line Number:
+
+
+
+
Backtrace:
+
+
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/index.html b/application/views/errors/index.html
new file mode 100644
index 000000000..c942a79ce
--- /dev/null
+++ b/application/views/errors/index.html
@@ -0,0 +1,10 @@
+
+
+ 403 Forbidden
+
+
+
+
Directory access is forbidden.
+
+
+
\ No newline at end of file
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index 2e9f0c766..f9618044e 100755
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -141,7 +141,7 @@ class CI_Exceptions {
ob_end_flush();
}
ob_start();
- include(APPPATH.'errors/'.$template.'.php');
+ include(APPPATH.'views/errors/'.$template.'.php');
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
@@ -175,7 +175,7 @@ class CI_Exceptions {
ob_end_flush();
}
ob_start();
- include(APPPATH.'errors/'.'error_php.php');
+ include(APPPATH.'views/errors/error_php.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
--
cgit v1.2.3-24-g4f1b
From f25b9295557f9d5fda1e0b2342964f17e26a390e Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Tue, 15 May 2012 08:10:31 +0700
Subject: Escaping boolean data type on postgre
---
system/database/drivers/postgre/postgre_driver.php | 101 +++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 84bf768ee..915763ad7 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -310,6 +310,35 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
+ /**
+ * "Smart" Escape String
+ *
+ * Escapes data based on type
+ * Sets boolean and null types
+ *
+ * @param string
+ * @return mixed
+ */
+ public function escape($str)
+ {
+ if (is_string($str) OR method_exists($str, '__toString'))
+ {
+ return "'".$this->escape_str($str)."'";
+ }
+ elseif (is_bool($str))
+ {
+ return $str ? "TRUE" : "FALSE";
+ }
+ elseif (is_null($str))
+ {
+ return 'NULL';
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Affected Rows
*
@@ -557,6 +586,78 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
+ /**
+ * Where
+ *
+ * Called by where() or or_where()
+ *
+ * @param mixed
+ * @param mixed
+ * @param string
+ * @return object
+ *
+ */
+ protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
+ {
+ $type = $this->_group_get_type($type);
+
+ if ( ! is_array($key))
+ {
+ $key = array($key => $value);
+ }
+
+ // If the escape value was not set will will base it on the global setting
+ if ( ! is_bool($escape))
+ {
+ $escape = $this->_protect_identifiers;
+ }
+
+ foreach ($key as $k => $v)
+ {
+ $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
+
+ if (is_null($v) && ! $this->_has_operator($k))
+ {
+ // value appears not to have been set, assign the test to IS NULL
+ $k .= ' IS NULL';
+ }
+
+ if ( ! is_null($v))
+ {
+ if ($escape === TRUE)
+ {
+ $k = $this->protect_identifiers($k, FALSE, $escape);
+ $v = ' '.$this->escape($v);
+ }
+ else if (is_bool($v))
+ {
+ $v = ' '.($v ? 'TRUE' : 'FALSE');
+ }
+
+ if ( ! $this->_has_operator($k))
+ {
+ $k .= ' = ';
+ }
+ }
+ else
+ {
+ $k = $this->protect_identifiers($k, FALSE, $escape);
+ }
+
+ $this->qb_where[] = $prefix.$k.$v;
+ if ($this->qb_caching === TRUE)
+ {
+ $this->qb_cache_where[] = $prefix.$k.$v;
+ $this->qb_cache_exists[] = 'where';
+ }
+
+ }
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
/**
* Close DB Connection
*
--
cgit v1.2.3-24-g4f1b
From 68fe7935a391b20dcf0cbdde9c1b49c697a6443b Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Tue, 15 May 2012 08:19:29 +0700
Subject: Rollback changes, move it to postgre_driver
---
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 09513e267..ef77b594e 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -696,7 +696,7 @@ abstract class CI_DB_driver {
}
elseif (is_bool($str))
{
- return ($str === FALSE) ? "FALSE" : "TRUE";
+ return ($str === FALSE) ? 0 : 1;
}
elseif (is_null($str))
{
--
cgit v1.2.3-24-g4f1b
From f79bdda8d823495b1f6524bd0cafb985860b7331 Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Tue, 15 May 2012 08:20:24 +0700
Subject: Rollback changes, move it to postgre_driver
---
system/database/DB_query_builder.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 8fa67ea06..d0af66de1 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -439,10 +439,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$k = $this->protect_identifiers($k, FALSE, $escape);
$v = ' '.$this->escape($v);
}
- else if (is_bool($v))
- {
- $v = ' '.($v ? 'TRUE' : 'FALSE');
- }
if ( ! $this->_has_operator($k))
{
--
cgit v1.2.3-24-g4f1b
From d2574db779d97f2a1ff8351b5a7c31c028601e17 Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Tue, 15 May 2012 16:28:16 +0700
Subject: Escaping boolean data type for postgre
---
system/database/drivers/postgre/postgre_driver.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 915763ad7..4b2fb7a9e 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -327,7 +327,7 @@ class CI_DB_postgre_driver extends CI_DB {
}
elseif (is_bool($str))
{
- return $str ? "TRUE" : "FALSE";
+ return ($str) ? 'TRUE' : 'FALSE';
}
elseif (is_null($str))
{
@@ -629,7 +629,7 @@ class CI_DB_postgre_driver extends CI_DB {
$k = $this->protect_identifiers($k, FALSE, $escape);
$v = ' '.$this->escape($v);
}
- else if (is_bool($v))
+ elseif (is_bool($v))
{
$v = ' '.($v ? 'TRUE' : 'FALSE');
}
--
cgit v1.2.3-24-g4f1b
From 5963db71348a06c14b38e7ce998df4249d4fd45a Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Tue, 15 May 2012 16:31:18 +0700
Subject: escaping boolean data type for postgre change log
---
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 a70531901..77c7e2ca4 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -100,6 +100,7 @@ Release Date: Not Released
- Added PDO support for create_database(), drop_database and drop_table() in :doc:`Database Forge `.
- Added MSSQL, SQLSRV support for optimize_table() in :doc:`Database Utility `.
- Improved CUBRID support for list_databases() in :doc:`Database Utility ` (until now only the currently used database was returned).
+ - Added escaping boolean data type for PosgreSQL
- Libraries
--
cgit v1.2.3-24-g4f1b
From dabeaa11ca2076935e5091e0f9e90ff9c4593962 Mon Sep 17 00:00:00 2001
From: Soesapto Joeni Hantoro
Date: Tue, 15 May 2012 16:37:46 +0700
Subject: Escaping boolean data type for postgre
---
system/database/drivers/postgre/postgre_driver.php | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 4b2fb7a9e..670eb549d 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -321,20 +321,12 @@ class CI_DB_postgre_driver extends CI_DB {
*/
public function escape($str)
{
- if (is_string($str) OR method_exists($str, '__toString'))
- {
- return "'".$this->escape_str($str)."'";
- }
- elseif (is_bool($str))
+ if (is_bool($str))
{
return ($str) ? 'TRUE' : 'FALSE';
}
- elseif (is_null($str))
- {
- return 'NULL';
- }
- return $str;
+ return parent::escape($str);
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 242925bc084e4d606d5f34bdb49bdf9f5235ec32 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Tue, 15 May 2012 13:03:51 +0300
Subject: Minor changes on the pull #1355 additions
---
system/database/drivers/postgre/postgre_driver.php | 8 ++++----
user_guide_src/source/changelog.rst | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 670eb549d..17bd37b38 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -328,7 +328,7 @@ class CI_DB_postgre_driver extends CI_DB {
return parent::escape($str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -623,7 +623,7 @@ class CI_DB_postgre_driver extends CI_DB {
}
elseif (is_bool($v))
{
- $v = ' '.($v ? 'TRUE' : 'FALSE');
+ $v = ($v ? ' TRUE' : ' FALSE');
}
if ( ! $this->_has_operator($k))
@@ -647,7 +647,7 @@ class CI_DB_postgre_driver extends CI_DB {
return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -664,4 +664,4 @@ class CI_DB_postgre_driver extends CI_DB {
}
/* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */
\ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 2f2ebce98..d33a6a635 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -77,6 +77,7 @@ Release Date: Not Released
- pg_version() is now used to get the database version number, when possible.
- Added db_set_charset() support.
- Added _optimize_table() support for the :doc:`Database Utility Class ` (rebuilds table indexes).
+ - Added boolean data type support in escape().
- Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction.
- Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features.
- Removed protect_identifiers() and renamed internal method _protect_identifiers() to it instead - it was just an alias.
@@ -100,7 +101,6 @@ Release Date: Not Released
- Added PDO support for create_database(), drop_database and drop_table() in :doc:`Database Forge `.
- Added MSSQL, SQLSRV support for optimize_table() in :doc:`Database Utility `.
- Improved CUBRID support for list_databases() in :doc:`Database Utility ` (until now only the currently used database was returned).
- - Added escaping boolean data type for PosgreSQL
- Libraries
--
cgit v1.2.3-24-g4f1b
From 570e77cd78e0c704b032c3e7702372ca63d5ddaa Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Tue, 15 May 2012 18:47:24 +0700
Subject: Benchmark code-coverage
---
tests/codeigniter/core/Benchmark_test.php | 42 +++++++++++++++++++++++++++++++
tests/mocks/core/benchmark.php | 3 +++
2 files changed, 45 insertions(+)
create mode 100644 tests/codeigniter/core/Benchmark_test.php
create mode 100644 tests/mocks/core/benchmark.php
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
new file mode 100644
index 000000000..2790b582e
--- /dev/null
+++ b/tests/codeigniter/core/Benchmark_test.php
@@ -0,0 +1,42 @@
+benchmark = new Mock_Core_Benchmark();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_mark()
+ {
+ $this->assertEmpty($this->benchmark->marker);
+
+ $this->benchmark->mark('code_start');
+
+ $this->assertEquals(1, count($this->benchmark->marker));
+ $this->assertArrayHasKey('code_start', $this->benchmark->marker);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_elapsed_time()
+ {
+ $this->assertEquals('{elapsed_time}', $this->benchmark->elapsed_time());
+ $this->assertEmpty($this->benchmark->elapsed_time('undefined_point'));
+
+ $this->benchmark->mark('code_start');
+ sleep(1);
+ $this->benchmark->mark('code_end');
+
+ $this->assertEquals('1.00', $this->benchmark->elapsed_time('code_start', 'code_end', 3));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_memory_usage()
+ {
+ $this->assertEquals('{memory_usage}', $this->benchmark->memory_usage());
+ }
+}
\ No newline at end of file
diff --git a/tests/mocks/core/benchmark.php b/tests/mocks/core/benchmark.php
new file mode 100644
index 000000000..d92be21db
--- /dev/null
+++ b/tests/mocks/core/benchmark.php
@@ -0,0 +1,3 @@
+
Date: Tue, 15 May 2012 18:48:45 +0700
Subject: Clean up autoloader annotation
---
tests/mocks/autoloader.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index f1bdb5d6f..92c9bea59 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -6,7 +6,6 @@
//
// Prototype :
//
-// include_once('Mock_Core_Loader') // Will load ./mocks/core/loader.php
// $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php
// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php
// and so on...
--
cgit v1.2.3-24-g4f1b
From 8af88f3f729b7bcfd2a106f858b5445deafe5ed0 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Tue, 15 May 2012 21:52:53 +0700
Subject: Security Code coverage
---
tests/Bootstrap.php | 3 ++
tests/codeigniter/core/Security_test.php | 79 ++++++++++++++++++++++++++++++++
tests/mocks/core/security.php | 27 +++++++++++
tests/mocks/libraries/table.php | 2 +-
4 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 tests/codeigniter/core/Security_test.php
create mode 100644 tests/mocks/core/security.php
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
index 9f89d1be8..2bec364ef 100644
--- a/tests/Bootstrap.php
+++ b/tests/Bootstrap.php
@@ -12,6 +12,9 @@ define('BASEPATH', PROJECT_BASE.'system/');
define('APPPATH', PROJECT_BASE.'application/');
define('VIEWPATH', PROJECT_BASE.'');
+// Set cookie for security test
+$_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE));
+
// Prep our test environment
require_once 'vfsStream/vfsStream.php';
include_once $dir.'/mocks/core/common.php';
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
new file mode 100644
index 000000000..c3b526965
--- /dev/null
+++ b/tests/codeigniter/core/Security_test.php
@@ -0,0 +1,79 @@
+ci_set_config('csrf_protection', TRUE);
+ $this->ci_set_config('csrf_token_name', 'ci_csrf_token');
+ // @see : ./Bootstrap.php Line 16
+ $this->ci_set_config('csrf_cookie_name', 'ci_csrf_cookie');
+ $this->ci_set_config('csrf_expire', 7200);
+ $this->ci_set_config('csrf_regenerate', TRUE);
+ $this->ci_set_config('csrf_exclude_uris', array());
+
+ $this->ci_set_config('cookie_prefix', "");
+ $this->ci_set_config('cookie_domain', "");
+ $this->ci_set_config('cookie_path', "/");
+ $this->ci_set_config('cookie_secure', FALSE);
+ $this->ci_set_config('cookie_httponly', FALSE);
+
+ $this->security = new Mock_Core_Security();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_csrf_verify()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+
+ $this->assertInstanceOf('CI_Security', $this->security->csrf_verify());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_csrf_verify_invalid()
+ {
+ // Without issuing $_POST[csrf_token_name], this request will triggering CSRF error
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+
+ $this->setExpectedException('RuntimeException', 'CI Error: The action you have requested is not allowed');
+
+ $this->security->csrf_verify();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_csrf_verify_valid()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ $_POST[$this->security->csrf_token_name] = $this->security->csrf_hash;
+
+ $this->assertInstanceOf('CI_Security', $this->security->csrf_verify());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_csrf_hash()
+ {
+ $this->assertEquals($this->security->csrf_hash, $this->security->get_csrf_hash());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_csrf_token_name()
+ {
+ $this->assertEquals('ci_csrf_token', $this->security->get_csrf_token_name());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_xss_clean()
+ {
+ $harm_string = "Hello, i try to your site";
+
+ $harmless_string = $this->security->xss_clean($harm_string);
+
+ $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_string);
+ }
+}
\ No newline at end of file
diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php
new file mode 100644
index 000000000..de8e44710
--- /dev/null
+++ b/tests/mocks/core/security.php
@@ -0,0 +1,27 @@
+{'_'.$property}) ? $this->{'_'.$property} : NULL;
+ }
+
+ // Overide inaccesible protected method
+ public function __call($method, $params)
+ {
+ if (is_callable(array($this, '_'.$method)))
+ {
+ return call_user_func_array(array($this, '_'.$method), $params);
+ }
+
+ throw new BadMethodCallException('Method '.$method.' was not found');
+ }
+
+}
\ No newline at end of file
diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php
index 1a6ff8d35..97fbb30bd 100644
--- a/tests/mocks/libraries/table.php
+++ b/tests/mocks/libraries/table.php
@@ -2,7 +2,7 @@
class Mock_Libraries_Table extends CI_Table {
- // Overide inaccesible private or protected method
+ // Overide inaccesible protected method
public function __call($method, $params)
{
if (is_callable(array($this, '_'.$method)))
--
cgit v1.2.3-24-g4f1b
From d40a545e9e7e4dc222d58fe46fe23f3691f043ee Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Tue, 15 May 2012 22:00:14 +0700
Subject: Comment block for explanation
---
tests/mocks/core/security.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php
index de8e44710..c5269fbc5 100644
--- a/tests/mocks/core/security.php
+++ b/tests/mocks/core/security.php
@@ -4,6 +4,9 @@ class Mock_Core_Security extends CI_Security {
public function csrf_set_cookie()
{
+ // We cannot set cookie in CLI mode, so for csrf test, who rely on $_COOKIE,
+ // we superseded set_cookie with directly set the cookie variable,
+ // @see : ./Bootstrap.php, line 16
return $this;
}
--
cgit v1.2.3-24-g4f1b
From 7756af5df0a53930019e9fd7b828504f0c2c5427 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Tue, 15 May 2012 23:57:05 +0700
Subject: Input class code-coverage
---
tests/Bootstrap.php | 3 -
tests/codeigniter/core/Input_test.php | 144 +++++++++++++++++++++++++++++++
tests/codeigniter/core/Security_test.php | 14 +--
tests/mocks/core/input.php | 31 +++++++
tests/mocks/core/security.php | 2 +-
tests/mocks/core/utf8.php | 27 ++++++
6 files changed, 207 insertions(+), 14 deletions(-)
create mode 100644 tests/codeigniter/core/Input_test.php
create mode 100644 tests/mocks/core/input.php
create mode 100644 tests/mocks/core/utf8.php
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
index 2bec364ef..9f89d1be8 100644
--- a/tests/Bootstrap.php
+++ b/tests/Bootstrap.php
@@ -12,9 +12,6 @@ define('BASEPATH', PROJECT_BASE.'system/');
define('APPPATH', PROJECT_BASE.'application/');
define('VIEWPATH', PROJECT_BASE.'');
-// Set cookie for security test
-$_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE));
-
// Prep our test environment
require_once 'vfsStream/vfsStream.php';
include_once $dir.'/mocks/core/common.php';
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
new file mode 100644
index 000000000..fd0576e38
--- /dev/null
+++ b/tests/codeigniter/core/Input_test.php
@@ -0,0 +1,144 @@
+ci_set_config('allow_get_array', TRUE);
+ $this->ci_set_config('global_xss_filtering', FALSE);
+ $this->ci_set_config('csrf_protection', FALSE);
+
+ $security = new Mock_Core_Security();
+ $utf8 = new Mock_Core_Utf8();
+
+ $this->input = new Mock_Core_Input($security, $utf8);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_not_exists()
+ {
+ $this->assertEmpty($this->input->get());
+ $this->assertEmpty($this->input->get('foo'));
+
+ $this->assertTrue( ! $this->input->get());
+ $this->assertTrue( ! $this->input->get('foo'));
+
+ $this->assertTrue($this->input->get() == FALSE);
+ $this->assertTrue($this->input->get('foo') == FALSE);
+
+ $this->assertTrue($this->input->get() === FALSE);
+ $this->assertTrue($this->input->get('foo') === FALSE);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_exist()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_GET['foo'] = 'bar';
+
+ $this->assertArrayHasKey('foo', $this->input->get());
+ $this->assertEquals('bar', $this->input->get('foo'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_exist_with_xss_clean()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_GET['harm'] = "Hello, i try to your site";
+
+ $this->assertArrayHasKey('harm', $this->input->get());
+ $this->assertEquals("Hello, i try to your site", $this->input->get('harm'));
+ $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $this->input->get('harm', TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_post_not_exists()
+ {
+ $this->assertEmpty($this->input->post());
+ $this->assertEmpty($this->input->post('foo'));
+
+ $this->assertTrue( ! $this->input->post());
+ $this->assertTrue( ! $this->input->post('foo'));
+
+ $this->assertTrue($this->input->post() == FALSE);
+ $this->assertTrue($this->input->post('foo') == FALSE);
+
+ $this->assertTrue($this->input->post() === FALSE);
+ $this->assertTrue($this->input->post('foo') === FALSE);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_post_exist()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ $_POST['foo'] = 'bar';
+
+ $this->assertArrayHasKey('foo', $this->input->post());
+ $this->assertEquals('bar', $this->input->post('foo'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_post_exist_with_xss_clean()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ $_POST['harm'] = "Hello, i try to your site";
+
+ $this->assertArrayHasKey('harm', $this->input->post());
+ $this->assertEquals("Hello, i try to your site", $this->input->post('harm'));
+ $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $this->input->post('harm', TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_post()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ $_POST['foo'] = 'bar';
+
+ $this->assertEquals('bar', $this->input->get_post('foo'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_cookie()
+ {
+ $_COOKIE['foo'] = 'bar';
+
+ $this->assertEquals('bar', $this->input->cookie('foo'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_server()
+ {
+ $this->assertEquals('GET', $this->input->server('REQUEST_METHOD'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_fetch_from_array()
+ {
+ $data = array(
+ 'foo' => 'bar',
+ 'harm' => 'Hello, i try to your site',
+ );
+
+ $foo = $this->input->fetch_from_array($data, 'foo');
+ $harm = $this->input->fetch_from_array($data, 'harm');
+ $harmless = $this->input->fetch_from_array($data, 'harm', TRUE);
+
+ $this->assertEquals('bar', $foo);
+ $this->assertEquals("Hello, i try to your site", $harm);
+ $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless);
+ }
+}
\ No newline at end of file
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index c3b526965..1796ba74d 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -4,19 +4,13 @@ class Security_test extends CI_TestCase {
public function set_up()
{
+ // Set cookie for security test
+ $_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE));
+
+ // Set config for Security class
$this->ci_set_config('csrf_protection', TRUE);
$this->ci_set_config('csrf_token_name', 'ci_csrf_token');
- // @see : ./Bootstrap.php Line 16
$this->ci_set_config('csrf_cookie_name', 'ci_csrf_cookie');
- $this->ci_set_config('csrf_expire', 7200);
- $this->ci_set_config('csrf_regenerate', TRUE);
- $this->ci_set_config('csrf_exclude_uris', array());
-
- $this->ci_set_config('cookie_prefix', "");
- $this->ci_set_config('cookie_domain', "");
- $this->ci_set_config('cookie_path', "/");
- $this->ci_set_config('cookie_secure', FALSE);
- $this->ci_set_config('cookie_httponly', FALSE);
$this->security = new Mock_Core_Security();
}
diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php
new file mode 100644
index 000000000..8a337d2ef
--- /dev/null
+++ b/tests/mocks/core/input.php
@@ -0,0 +1,31 @@
+_allow_get_array = (config_item('allow_get_array') === TRUE);
+ $this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
+ $this->_enable_csrf = (config_item('csrf_protection') === TRUE);
+
+ // Assign Security and Utf8 classes
+ $this->security = $security;
+ $this->uni = $utf8;
+
+ // Sanitize global arrays
+ $this->_sanitize_globals();
+ }
+
+ public function fetch_from_array($array, $index = '', $xss_clean = FALSE)
+ {
+ return parent::_fetch_from_array($array, $index, $xss_clean);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php
index c5269fbc5..d7ea0e6bd 100644
--- a/tests/mocks/core/security.php
+++ b/tests/mocks/core/security.php
@@ -6,7 +6,7 @@ class Mock_Core_Security extends CI_Security {
{
// We cannot set cookie in CLI mode, so for csrf test, who rely on $_COOKIE,
// we superseded set_cookie with directly set the cookie variable,
- // @see : ./Bootstrap.php, line 16
+ // @see : ./tests/codeigniter/core/Security_test.php, line 8
return $this;
}
diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php
new file mode 100644
index 000000000..b77d717e7
--- /dev/null
+++ b/tests/mocks/core/utf8.php
@@ -0,0 +1,27 @@
+
Date: Wed, 16 May 2012 00:08:05 +0700
Subject: Remove unused hardcoded reference from *phpunit.xml files
---
tests/travis/mysql.phpunit.xml | 2 --
tests/travis/pdo/mysql.phpunit.xml | 4 +---
tests/travis/pdo/pgsql.phpunit.xml | 2 --
tests/travis/pdo/sqlite.phpunit.xml | 2 --
tests/travis/pgsql.phpunit.xml | 2 --
tests/travis/sqlite.phpunit.xml | 2 --
6 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
index c5fcf1335..1792ae38d 100644
--- a/tests/travis/mysql.phpunit.xml
+++ b/tests/travis/mysql.phpunit.xml
@@ -21,8 +21,6 @@
PEAR_INSTALL_DIRPHP_LIBDIR
- PROJECT_BASE.'tests'
- '../../system/core/CodeIgniter.php'
\ No newline at end of file
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
index f6fcc1c39..602030d4e 100644
--- a/tests/travis/pdo/mysql.phpunit.xml
+++ b/tests/travis/pdo/mysql.phpunit.xml
@@ -14,15 +14,13 @@
- ../../codeigniter/database
+ ../../codeigniterPEAR_INSTALL_DIRPHP_LIBDIR
- PROJECT_BASE.'tests'
- '../../../system/core/CodeIgniter.php'
\ No newline at end of file
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
index 6a23227db..77e1493c6 100644
--- a/tests/travis/pdo/pgsql.phpunit.xml
+++ b/tests/travis/pdo/pgsql.phpunit.xml
@@ -21,8 +21,6 @@
PEAR_INSTALL_DIRPHP_LIBDIR
- PROJECT_BASE.'tests'
- '../../../system/core/CodeIgniter.php'
\ No newline at end of file
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
index b85b7308a..cdccef017 100644
--- a/tests/travis/pdo/sqlite.phpunit.xml
+++ b/tests/travis/pdo/sqlite.phpunit.xml
@@ -21,8 +21,6 @@
PEAR_INSTALL_DIRPHP_LIBDIR
- PROJECT_BASE.'tests'
- '../../../system/core/CodeIgniter.php'
\ No newline at end of file
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
index 78b6046cf..dfc1bff1c 100644
--- a/tests/travis/pgsql.phpunit.xml
+++ b/tests/travis/pgsql.phpunit.xml
@@ -21,8 +21,6 @@
PEAR_INSTALL_DIRPHP_LIBDIR
- PROJECT_BASE.'tests'
- '../../system/core/CodeIgniter.php'
\ No newline at end of file
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
index 46e3d5073..3223da5e7 100644
--- a/tests/travis/sqlite.phpunit.xml
+++ b/tests/travis/sqlite.phpunit.xml
@@ -21,8 +21,6 @@
PEAR_INSTALL_DIRPHP_LIBDIR
- PROJECT_BASE.'tests'
- '../../system/core/CodeIgniter.php'
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 04d4091dfa551475998c351e09858e5ebdcf4482 Mon Sep 17 00:00:00 2001
From: Alan Jenkins
Date: Mon, 30 Apr 2012 16:04:43 +0100
Subject: fix backtrace filtering
The backtrace was filtered to remove CI system files,
but the filter was buggy. It would also filter out
application files which happened to contain the string "system"...
or ALL files, if the application directory is under /system/
(Perhaps the latter comes as a surprise, but it's explicitly
mentioned in index.php and ).
Instead, we should test whether the file is underneath BASEPATH
(using realpath() to make sure we have the same sort of slashes).
---
application/errors/error_php.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/application/errors/error_php.php b/application/errors/error_php.php
index 3855720de..b76dc8a9e 100644
--- a/application/errors/error_php.php
+++ b/application/errors/error_php.php
@@ -40,12 +40,15 @@
Backtrace:
-
+
+
File:
Line:
Function:
+
--
cgit v1.2.3-24-g4f1b
From 2ed226bd5ed19754c2fb28d4b98ac5423741f039 Mon Sep 17 00:00:00 2001
From: Timothy Warren
Date: Wed, 16 May 2012 08:37:32 -0400
Subject: Add note in the upgrade guide to move errors folder
---
user_guide_src/source/installation/upgrade_300.rst | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index e434e8d45..63c4227dc 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -40,4 +40,9 @@ need to rename the `$active_record` variable to `$query_builder`.
$active_group = 'default';
// $active_record = TRUE;
- $query_builder = TRUE;
\ No newline at end of file
+ $query_builder = TRUE;
+
+Step 5: Move your errors folder
+===============================
+
+In version 3.0.0, the errors folder has been moved from "application/errors" to "application/views/errors".
\ No newline at end of file
--
cgit v1.2.3-24-g4f1b
From 09a1b5e7fb3c930aa9a50e246236227a499b5d28 Mon Sep 17 00:00:00 2001
From: Taufan Aditya
Date: Wed, 16 May 2012 22:18:00 +0700
Subject: Reduce decimal points, since there is a micro differencess on runtime
and update travis status
---
tests/README.md | 2 +-
tests/codeigniter/core/Benchmark_test.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/README.md b/tests/README.md
index b46f344cb..c8fc608e8 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,6 +1,6 @@
# CodeIgniter Unit Tests #
-Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=feature/unit-tests)](http://travis-ci.org/EllisLab/CodeIgniter)
+Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=develop)](http://travis-ci.org/EllisLab/CodeIgniter)
### Introduction:
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
index 2790b582e..109b38821 100644
--- a/tests/codeigniter/core/Benchmark_test.php
+++ b/tests/codeigniter/core/Benchmark_test.php
@@ -29,8 +29,8 @@ class Benchmark_test extends CI_TestCase {
$this->benchmark->mark('code_start');
sleep(1);
$this->benchmark->mark('code_end');
-
- $this->assertEquals('1.00', $this->benchmark->elapsed_time('code_start', 'code_end', 3));
+
+ $this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1));
}
// --------------------------------------------------------------------
--
cgit v1.2.3-24-g4f1b
From 94e74bf0f8ae82a28c70fe1a3cb76a01f6c50fd8 Mon Sep 17 00:00:00 2001
From: Alan Jenkins
Date: Wed, 16 May 2012 17:20:56 +0100
Subject: If we want E_STRICT, don't suppress it!
15be8fc "Changed the 'development' environment default error
reporting to included E_STRICT"
Not present in any tagged release, so
no need for -stable or a changlelog entry.
---
system/core/Common.php | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/system/core/Common.php b/system/core/Common.php
index 78aa6e874..ec94c528b 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -487,16 +487,6 @@ if ( ! function_exists('_exception_handler'))
*/
function _exception_handler($severity, $message, $filepath, $line)
{
- // We don't bother with "strict" notices since they tend to fill up
- // the log file with excess information that isn't normally very helpful.
- // For example, if you are running PHP 5 and you use version 4 style
- // class functions (without prefixes like "public", "private", etc.)
- // you'll get notices telling you that these have been deprecated.
- if ($severity == E_STRICT)
- {
- return;
- }
-
$_error =& load_class('Exceptions', 'core');
// Should we display the error? We'll get the current error_reporting
--
cgit v1.2.3-24-g4f1b
From e2c374fc474f91cc1c04aaae68e15cef6984f494 Mon Sep 17 00:00:00 2001
From: Alexander Hofstede
Date: Thu, 17 May 2012 00:28:08 +0200
Subject: Check cookie against md5 regex.
Otherwise, cookie can contain arbitrary injected code that gets sent
back directly to the browser.
---
system/core/Security.php | 2 +-
user_guide/changelog.html | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/system/core/Security.php b/system/core/Security.php
index a3e227437..6f5ac1ed8 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -848,7 +848,7 @@ class CI_Security {
// each page load since a page could contain embedded
// sub-pages causing this feature to fail
if (isset($_COOKIE[$this->_csrf_cookie_name]) &&
- $_COOKIE[$this->_csrf_cookie_name] != '')
+ preg_match('#^[0-9a-f]{32}$#iS', $_COOKIE[$this->_csrf_cookie_name]) === 1)
{
return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name];
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 613c4e65d..38275955b 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -85,6 +85,7 @@ Change Log
Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
+
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
-
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
+
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
-
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
+
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
--
cgit v1.2.3-24-g4f1b
From 8f04c69fe65ddc2604425eaee811b50a909d905f Mon Sep 17 00:00:00 2001
From: Alexander Hofstede
Date: Thu, 17 May 2012 10:52:44 +0200
Subject: Use tabs for indenting
---
user_guide/changelog.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 38275955b..55fbceeaf 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -85,7 +85,7 @@ Change Log
Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
Fixed a bug (#538) - Windows paths were ignored when using the Image Manipulation Class to create a new file.
Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
-
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
+
Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
--
cgit v1.2.3-24-g4f1b
From 92ebfb65ac044f5c2e6d88fba137253854cf1b94 Mon Sep 17 00:00:00 2001
From: Andrey Andreev
Date: Thu, 17 May 2012 12:49:24 +0300
Subject: Cleanup the core classes
---
system/core/Benchmark.php | 6 ++--
system/core/CodeIgniter.php | 2 +-
system/core/Common.php | 6 ++--
system/core/Config.php | 27 +++++++++---------
system/core/Controller.php | 7 +++--
system/core/Exceptions.php | 12 ++++----
system/core/Hooks.php | 6 ++--
system/core/Input.php | 31 ++++++++++-----------
system/core/Loader.php | 35 +++++++++++------------
system/core/Model.php | 3 ++
system/core/Output.php | 18 ++++++------
system/core/Router.php | 25 ++++++++---------
system/core/Security.php | 18 ++++++------
system/core/URI.php | 67 ++++++++++++++++++++++-----------------------
system/core/Utf8.php | 4 ++-
15 files changed, 135 insertions(+), 132 deletions(-)
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
index c17e95a19..bb630f40b 100755
--- a/system/core/Benchmark.php
+++ b/system/core/Benchmark.php
@@ -25,13 +25,11 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Benchmark Class
*
* This class enables you to mark points and calculate the time difference
- * between them. Memory consumption can also be displayed.
+ * between them. Memory consumption can also be displayed.
*
* @package CodeIgniter
* @subpackage Libraries
@@ -119,4 +117,4 @@ class CI_Benchmark {
}
/* End of file Benchmark.php */
-/* Location: ./system/core/Benchmark.php */
+/* Location: ./system/core/Benchmark.php */
\ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 349f9f2d0..00db6e13a 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -31,7 +31,7 @@
* Loads the base classes and executes the request.
*
* @package CodeIgniter
- * @subpackage codeigniter
+ * @subpackage CodeIgniter
* @category Front-controller
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/
diff --git a/system/core/Common.php b/system/core/Common.php
index 78aa6e874..8b897776f 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -31,7 +31,7 @@
* Loads the base classes and executes the request.
*
* @package CodeIgniter
- * @subpackage codeigniter
+ * @subpackage CodeIgniter
* @category Common Functions
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/
@@ -57,7 +57,7 @@ if ( ! function_exists('is_php'))
if ( ! isset($_is_php[$version]))
{
- $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
+ $_is_php[$version] = (version_compare(PHP_VERSION, $version) >= 0);
}
return $_is_php[$version];
@@ -506,7 +506,7 @@ if ( ! function_exists('_exception_handler'))
$_error->show_php_error($severity, $message, $filepath, $line);
}
- // Should we log the error? No? We're done...
+ // Should we log the error? No? We're done...
if (config_item('log_threshold') == 0)
{
return;
diff --git a/system/core/Config.php b/system/core/Config.php
index 9cebe6c86..c07ffa591 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Config Class
*
@@ -46,14 +44,14 @@ class CI_Config {
* @var array
*/
public $config = array();
-
+
/**
* List of all loaded config files
*
* @var array
*/
public $is_loaded = array();
-
+
/**
* List of paths to search when trying to load a config file.
* This must be public as it's used by the Loader class.
@@ -77,9 +75,9 @@ class CI_Config {
{
if (isset($_SERVER['HTTP_HOST']))
{
- $base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
- $base_url .= '://'. $_SERVER['HTTP_HOST']
- . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
+ $base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http';
+ $base_url .= '://'.$_SERVER['HTTP_HOST']
+ .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
else
{
@@ -96,9 +94,9 @@ class CI_Config {
* Load Config File
*
* @param string the config file name
- * @param boolean if configuration values should be loaded into their own section
- * @param boolean true if errors should just return false, false if an error message should be displayed
- * @return boolean if the file was loaded correctly
+ * @param bool if configuration values should be loaded into their own section
+ * @param bool true if errors should just return false, false if an error message should be displayed
+ * @return bool if the file was loaded correctly
*/
public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
@@ -254,8 +252,8 @@ class CI_Config {
* Base URL
* Returns base_url [. uri_string]
*
- * @param string $uri
- * @return string
+ * @param string $uri
+ * @return string
*/
public function base_url($uri = '')
{
@@ -267,8 +265,8 @@ class CI_Config {
/**
* Build URI string for use in Config::site_url() and Config::base_url()
*
- * @param mixed $uri
- * @return string
+ * @param mixed $uri
+ * @return string
*/
protected function _uri_string($uri)
{
@@ -345,6 +343,7 @@ class CI_Config {
}
}
}
+
}
/* End of file Config.php */
diff --git a/system/core/Controller.php b/system/core/Controller.php
index 1f69146d0..491414807 100644
--- a/system/core/Controller.php
+++ b/system/core/Controller.php
@@ -48,6 +48,8 @@ class CI_Controller {
/**
* Set up controller properties and methods
+ *
+ * @return void
*/
public function __construct()
{
@@ -67,14 +69,15 @@ class CI_Controller {
}
/**
- * Return the CI object
+ * Return the CI object
*
- * @return object
+ * @return object
*/
public static function &get_instance()
{
return self::$instance;
}
+
}
/* End of file Controller.php */
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index 2e9f0c766..965a717ad 100755
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -65,6 +65,8 @@ class CI_Exceptions {
/**
* Initialize execption class
+ *
+ * @return void
*/
public function __construct()
{
@@ -87,7 +89,7 @@ class CI_Exceptions {
*/
public function log_exception($severity, $message, $filepath, $line)
{
- $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
+ $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
}
@@ -127,14 +129,14 @@ class CI_Exceptions {
* @param string the heading
* @param string the message
* @param string the template name
- * @param int the status code
+ * @param int the status code
* @return string
*/
public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
set_status_header($status_code);
- $message = '
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" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.
+
+
Note: If you have any custom developed files in these folders please make copies of them first.
+
+
Step 2: Replace config/mimes.php
+
+
This config file has been updated to contain more user mime-types, please copy it to application/config/mimes.php.
@@ -89,7 +89,7 @@ minimizing the amount of code needed for a given task.
diff --git a/user_guide/installation/downloads.html b/user_guide/installation/downloads.html
index 14c65edd0..12252ad47 100644
--- a/user_guide/installation/downloads.html
+++ b/user_guide/installation/downloads.html
@@ -28,7 +28,7 @@
Public Git access is available at GitHub.
- Please note that while every effort is made to keep this code base functional, we cannot guarantee the functionality of code taken
- from the tip.
+
Public Git access is available at GitHub.
+ Please note that while every effort is made to keep this code base functional, we cannot guarantee the functionality of code taken
+ from the tip.
+
+
Beginning with version 2.0.3, stable tags are also available via GitHub, simply select the version from the Tags dropdown.
-
Beginning with version 2.0.3, stable tags are also available via GitHub, simply select the version from the Tags dropdown.