From c4e266b87f39d521ff1002fefa9df809c6b9bd61 Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Tue, 30 Aug 2011 15:40:27 -0400 Subject: Added Session driver with native PHP sessions and original-flavor CI cookie sessions --- system/core/Loader.php | 11 +- system/libraries/Driver.php | 42 +- system/libraries/Session.php | 776 --------------------- system/libraries/Session/Session.php | 601 ++++++++++++++++ .../libraries/Session/drivers/Session_cookie.php | 583 ++++++++++++++++ .../libraries/Session/drivers/Session_native.php | 190 +++++ 6 files changed, 1414 insertions(+), 789 deletions(-) delete mode 100644 system/libraries/Session.php create mode 100755 system/libraries/Session/Session.php create mode 100755 system/libraries/Session/drivers/Session_cookie.php create mode 100755 system/libraries/Session/drivers/Session_native.php diff --git a/system/core/Loader.php b/system/core/Loader.php index de0fc06d2..51e6b82ca 100755 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1174,6 +1174,15 @@ class CI_Loader { } } + // Autoload drivers + if (isset($autoload['drivers'])) + { + foreach ($autoload['drivers'] as $item) + { + $this->driver($item); + } + } + // Autoload models if (isset($autoload['model'])) { @@ -1240,4 +1249,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ \ No newline at end of file +/* Location: ./system/core/Loader.php */ diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 9881c1eec..e958fc67f 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -30,11 +30,32 @@ class CI_Driver_Library { protected $valid_drivers = array(); - protected static $lib_name; - - // The first time a child is used it won't exist, so we instantiate it - // subsequents calls will go straight to the proper child. - function __get($child) + protected $lib_name; + + /** + * Get magic method + * + * The first time a child is used it won't exist, so we instantiate it + * subsequents calls will go straight to the proper child. + * + * @param string Child class name + * @return object Child class + */ + public function __get($child) + { + // Try to load the driver + return load_driver($child); + } + + /** + * Load driver + * + * Separate load_driver call to support explicit driver load by library or user + * + * @param string Child class name + * @return object Child class + */ + public function load_driver($child) { if ( ! isset($this->lib_name)) { @@ -64,7 +85,7 @@ class CI_Driver_Library { if (file_exists($filepath)) { include_once $filepath; - break; + break 2; } } } @@ -84,12 +105,9 @@ class CI_Driver_Library { } // The requested driver isn't valid! - log_message('error', "Invalid driver requested: ".$child_class); - show_error("Invalid driver requested: ".$child_class); + log_message('error', 'Invalid driver requested: '.$child_class); + show_error('Invalid driver requested: '.$child_class); } - - // -------------------------------------------------------------------- - } // END CI_Driver_Library CLASS @@ -226,4 +244,4 @@ class CI_Driver { // END CI_Driver CLASS /* End of file Driver.php */ -/* Location: ./system/libraries/Driver.php */ \ No newline at end of file +/* Location: ./system/libraries/Driver.php */ diff --git a/system/libraries/Session.php b/system/libraries/Session.php deleted file mode 100644 index 2c8a80163..000000000 --- a/system/libraries/Session.php +++ /dev/null @@ -1,776 +0,0 @@ -CI =& get_instance(); - - // Set all the session preferences, which can either be set - // manually via the $params array above or via the config file - foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) - { - $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); - } - - if ($this->encryption_key == '') - { - show_error('In order to use the Session class you are required to set an encryption key in your config file.'); - } - - // Load the string helper so we can use the strip_slashes() function - $this->CI->load->helper('string'); - - // Do we need encryption? If so, load the encryption class - if ($this->sess_encrypt_cookie == TRUE) - { - $this->CI->load->library('encrypt'); - } - - // Are we using a database? If so, load it - if ($this->sess_use_database === TRUE AND $this->sess_table_name != '') - { - $this->CI->load->database(); - } - - // Set the "now" time. Can either be GMT or server time, based on the - // config prefs. We use this to set the "last activity" time - $this->now = $this->_get_time(); - - // Set the session length. If the session expiration is - // set to zero we'll set the expiration two years from now. - if ($this->sess_expiration == 0) - { - $this->sess_expiration = (60*60*24*365*2); - } - - // Set the cookie name - $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name; - - // Run the Session routine. If a session doesn't exist we'll - // create a new one. If it does, we'll update it. - if ( ! $this->sess_read()) - { - $this->sess_create(); - } - else - { - $this->sess_update(); - } - - // Delete 'old' flashdata (from last request) - $this->_flashdata_sweep(); - - // Mark all new flashdata as old (data will be deleted before next request) - $this->_flashdata_mark(); - - // Delete expired sessions if necessary - $this->_sess_gc(); - - log_message('debug', "Session routines successfully run"); - } - - // -------------------------------------------------------------------- - - /** - * Fetch the current session data if it exists - * - * @access public - * @return bool - */ - function sess_read() - { - // Fetch the cookie - $session = $this->CI->input->cookie($this->sess_cookie_name); - - // No cookie? Goodbye cruel world!... - if ($session === FALSE) - { - log_message('debug', 'A session cookie was not found.'); - return FALSE; - } - - // Decrypt the cookie data - if ($this->sess_encrypt_cookie == TRUE) - { - $session = $this->CI->encrypt->decode($session); - } - else - { - // encryption was not used, so we need to check the md5 hash - $hash = substr($session, strlen($session)-32); // get last 32 chars - $session = substr($session, 0, strlen($session)-32); - - // Does the md5 hash match? This is to prevent manipulation of session data in userspace - if ($hash !== md5($session.$this->encryption_key)) - { - log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.'); - $this->sess_destroy(); - return FALSE; - } - } - - // Unserialize the session array - $session = $this->_unserialize($session); - - // Is the session data we unserialized an array with the correct format? - if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity'])) - { - $this->sess_destroy(); - return FALSE; - } - - // Is the session current? - if (($session['last_activity'] + $this->sess_expiration) < $this->now) - { - $this->sess_destroy(); - return FALSE; - } - - // Does the IP Match? - if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address()) - { - $this->sess_destroy(); - return FALSE; - } - - // Does the User Agent Match? - if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 120))) - { - $this->sess_destroy(); - return FALSE; - } - - // Is there a corresponding session in the DB? - if ($this->sess_use_database === TRUE) - { - $this->CI->db->where('session_id', $session['session_id']); - - if ($this->sess_match_ip == TRUE) - { - $this->CI->db->where('ip_address', $session['ip_address']); - } - - if ($this->sess_match_useragent == TRUE) - { - $this->CI->db->where('user_agent', $session['user_agent']); - } - - $query = $this->CI->db->get($this->sess_table_name); - - // No result? Kill it! - if ($query->num_rows() == 0) - { - $this->sess_destroy(); - return FALSE; - } - - // Is there custom data? If so, add it to the main session array - $row = $query->row(); - if (isset($row->user_data) AND $row->user_data != '') - { - $custom_data = $this->_unserialize($row->user_data); - - if (is_array($custom_data)) - { - foreach ($custom_data as $key => $val) - { - $session[$key] = $val; - } - } - } - } - - // Session is valid! - $this->userdata = $session; - unset($session); - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Write the session data - * - * @access public - * @return void - */ - function sess_write() - { - // Are we saving custom data to the DB? If not, all we do is update the cookie - if ($this->sess_use_database === FALSE) - { - $this->_set_cookie(); - return; - } - - // set the custom userdata, the session data we will set in a second - $custom_userdata = $this->userdata; - $cookie_userdata = array(); - - // Before continuing, we need to determine if there is any custom data to deal with. - // Let's determine this by removing the default indexes to see if there's anything left in the array - // and set the session data while we're at it - foreach (array('session_id','ip_address','user_agent','last_activity') as $val) - { - unset($custom_userdata[$val]); - $cookie_userdata[$val] = $this->userdata[$val]; - } - - // Did we find any custom data? If not, we turn the empty array into a string - // since there's no reason to serialize and store an empty array in the DB - if (count($custom_userdata) === 0) - { - $custom_userdata = ''; - } - else - { - // Serialize the custom data array so we can store it - $custom_userdata = $this->_serialize($custom_userdata); - } - - // Run the update query - $this->CI->db->where('session_id', $this->userdata['session_id']); - $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata)); - - // Write the cookie. Notice that we manually pass the cookie data array to the - // _set_cookie() function. Normally that function will store $this->userdata, but - // in this case that array contains custom data, which we do not want in the cookie. - $this->_set_cookie($cookie_userdata); - } - - // -------------------------------------------------------------------- - - /** - * Create a new session - * - * @access public - * @return void - */ - function sess_create() - { - $sessid = ''; - while (strlen($sessid) < 32) - { - $sessid .= mt_rand(0, mt_getrandmax()); - } - - // To make the session ID even more secure we'll combine it with the user's IP - $sessid .= $this->CI->input->ip_address(); - - $this->userdata = array( - 'session_id' => md5(uniqid($sessid, TRUE)), - 'ip_address' => $this->CI->input->ip_address(), - 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), - 'last_activity' => $this->now - ); - - - // Save the data to the DB if needed - if ($this->sess_use_database === TRUE) - { - $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata)); - } - - // Write the cookie - $this->_set_cookie(); - } - - // -------------------------------------------------------------------- - - /** - * Update an existing session - * - * @access public - * @return void - */ - function sess_update() - { - // We only update the session every five minutes by default - if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now) - { - return; - } - - // Save the old session id so we know which record to - // update in the database if we need it - $old_sessid = $this->userdata['session_id']; - $new_sessid = ''; - while (strlen($new_sessid) < 32) - { - $new_sessid .= mt_rand(0, mt_getrandmax()); - } - - // To make the session ID even more secure we'll combine it with the user's IP - $new_sessid .= $this->CI->input->ip_address(); - - // Turn it into a hash - $new_sessid = md5(uniqid($new_sessid, TRUE)); - - // Update the session data in the session data array - $this->userdata['session_id'] = $new_sessid; - $this->userdata['last_activity'] = $this->now; - - // _set_cookie() will handle this for us if we aren't using database sessions - // by pushing all userdata to the cookie. - $cookie_data = NULL; - - // Update the session ID and last_activity field in the DB if needed - if ($this->sess_use_database === TRUE) - { - // set cookie explicitly to only have our session data - $cookie_data = array(); - foreach (array('session_id','ip_address','user_agent','last_activity') as $val) - { - $cookie_data[$val] = $this->userdata[$val]; - } - - $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid))); - } - - // Write the cookie - $this->_set_cookie($cookie_data); - } - - // -------------------------------------------------------------------- - - /** - * Destroy the current session - * - * @access public - * @return void - */ - function sess_destroy() - { - // Kill the session DB row - if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id'])) - { - $this->CI->db->where('session_id', $this->userdata['session_id']); - $this->CI->db->delete($this->sess_table_name); - } - - // Kill the cookie - setcookie( - $this->sess_cookie_name, - addslashes(serialize(array())), - ($this->now - 31500000), - $this->cookie_path, - $this->cookie_domain, - 0 - ); - } - - // -------------------------------------------------------------------- - - /** - * Fetch a specific item from the session array - * - * @access public - * @param string - * @return string - */ - function userdata($item) - { - return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; - } - - // -------------------------------------------------------------------- - - /** - * Fetch all session data - * - * @access public - * @return array - */ - function all_userdata() - { - return $this->userdata; - } - - // -------------------------------------------------------------------- - - /** - * Add or change data in the "userdata" array - * - * @access public - * @param mixed - * @param string - * @return void - */ - function set_userdata($newdata = array(), $newval = '') - { - if (is_string($newdata)) - { - $newdata = array($newdata => $newval); - } - - if (count($newdata) > 0) - { - foreach ($newdata as $key => $val) - { - $this->userdata[$key] = $val; - } - } - - $this->sess_write(); - } - - // -------------------------------------------------------------------- - - /** - * Delete a session variable from the "userdata" array - * - * @access array - * @return void - */ - function unset_userdata($newdata = array()) - { - if (is_string($newdata)) - { - $newdata = array($newdata => ''); - } - - if (count($newdata) > 0) - { - foreach ($newdata as $key => $val) - { - unset($this->userdata[$key]); - } - } - - $this->sess_write(); - } - - // ------------------------------------------------------------------------ - - /** - * Add or change flashdata, only available - * until the next request - * - * @access public - * @param mixed - * @param string - * @return void - */ - function set_flashdata($newdata = array(), $newval = '') - { - if (is_string($newdata)) - { - $newdata = array($newdata => $newval); - } - - if (count($newdata) > 0) - { - foreach ($newdata as $key => $val) - { - $flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set_userdata($flashdata_key, $val); - } - } - } - - // ------------------------------------------------------------------------ - - /** - * Keeps existing flashdata available to next request. - * - * @access public - * @param string - * @return void - */ - function keep_flashdata($key) - { - // 'old' flashdata gets removed. Here we mark all - // flashdata as 'new' to preserve it from _flashdata_sweep() - // Note the function will return FALSE if the $key - // provided cannot be found - $old_flashdata_key = $this->flashdata_key.':old:'.$key; - $value = $this->userdata($old_flashdata_key); - - $new_flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set_userdata($new_flashdata_key, $value); - } - - // ------------------------------------------------------------------------ - - /** - * Fetch a specific flashdata item from the session array - * - * @access public - * @param string - * @return string - */ - function flashdata($key) - { - $flashdata_key = $this->flashdata_key.':old:'.$key; - return $this->userdata($flashdata_key); - } - - // ------------------------------------------------------------------------ - - /** - * Identifies flashdata as 'old' for removal - * when _flashdata_sweep() runs. - * - * @access private - * @return void - */ - function _flashdata_mark() - { - $userdata = $this->all_userdata(); - foreach ($userdata as $name => $value) - { - $parts = explode(':new:', $name); - if (is_array($parts) && count($parts) === 2) - { - $new_name = $this->flashdata_key.':old:'.$parts[1]; - $this->set_userdata($new_name, $value); - $this->unset_userdata($name); - } - } - } - - // ------------------------------------------------------------------------ - - /** - * Removes all flashdata marked as 'old' - * - * @access private - * @return void - */ - - function _flashdata_sweep() - { - $userdata = $this->all_userdata(); - foreach ($userdata as $key => $value) - { - if (strpos($key, ':old:')) - { - $this->unset_userdata($key); - } - } - - } - - // -------------------------------------------------------------------- - - /** - * Get the "now" time - * - * @access private - * @return string - */ - function _get_time() - { - if (strtolower($this->time_reference) == 'gmt') - { - $now = time(); - $time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); - } - else - { - $time = time(); - } - - return $time; - } - - // -------------------------------------------------------------------- - - /** - * Write the session cookie - * - * @access public - * @return void - */ - function _set_cookie($cookie_data = NULL) - { - if (is_null($cookie_data)) - { - $cookie_data = $this->userdata; - } - - // Serialize the userdata for the cookie - $cookie_data = $this->_serialize($cookie_data); - - if ($this->sess_encrypt_cookie == TRUE) - { - $cookie_data = $this->CI->encrypt->encode($cookie_data); - } - else - { - // if encryption is not used, we provide an md5 hash to prevent userside tampering - $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key); - } - - $expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time(); - - // Set the cookie - setcookie( - $this->sess_cookie_name, - $cookie_data, - $expire, - $this->cookie_path, - $this->cookie_domain, - $this->cookie_secure - ); - } - - // -------------------------------------------------------------------- - - /** - * Serialize an array - * - * This function first converts any slashes found in the array to a temporary - * marker, so when it gets unserialized the slashes will be preserved - * - * @access private - * @param array - * @return string - */ - function _serialize($data) - { - if (is_array($data)) - { - foreach ($data as $key => $val) - { - if (is_string($val)) - { - $data[$key] = str_replace('\\', '{{slash}}', $val); - } - } - } - else - { - if (is_string($data)) - { - $data = str_replace('\\', '{{slash}}', $data); - } - } - - return serialize($data); - } - - // -------------------------------------------------------------------- - - /** - * Unserialize - * - * This function unserializes a data string, then converts any - * temporary slash markers back to actual slashes - * - * @access private - * @param array - * @return string - */ - function _unserialize($data) - { - $data = @unserialize(strip_slashes($data)); - - if (is_array($data)) - { - foreach ($data as $key => $val) - { - if (is_string($val)) - { - $data[$key] = str_replace('{{slash}}', '\\', $val); - } - } - - return $data; - } - - return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data; - } - - // -------------------------------------------------------------------- - - /** - * Garbage collection - * - * This deletes expired session rows from database - * if the probability percentage is met - * - * @access public - * @return void - */ - function _sess_gc() - { - if ($this->sess_use_database != TRUE) - { - return; - } - - srand(time()); - if ((rand() % 100) < $this->gc_probability) - { - $expire = $this->now - $this->sess_expiration; - - $this->CI->db->where("last_activity < {$expire}"); - $this->CI->db->delete($this->sess_table_name); - - log_message('debug', 'Session garbage collection performed.'); - } - } - - -} -// END Session Class - -/* End of file Session.php */ -/* Location: ./system/libraries/Session.php */ \ No newline at end of file diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php new file mode 100755 index 000000000..7aaf706a1 --- /dev/null +++ b/system/libraries/Session/Session.php @@ -0,0 +1,601 @@ +session or $this->session). + * In keeping with the CI_Driver methodology, multiple drivers may be loaded, although this might be a bit confusing. + * The Session library class keeps track of the most recently loaded driver as "current" to call for driver methods. + * Ideally, one driver is loaded and all calls go directly through the main library interface. However, any methods + * called through the specific driver will switch the "current" driver to itself before invoking the library method + * (which will then call back into the driver for low-level operations). So, alternation between two drivers can be + * achieved by specifying which driver to use for each call (e.g.: $this->session->native->set_userdata('foo', 'bar'); + * $this->session->cookie->userdata('foo'); $this->session->native->unset_userdata('foo');). Notice in the previous + * example that the _native_ userdata value 'foo' would be set to 'bar', which would NOT be returned by the call for + * the _cookie_ userdata 'foo', nor would the _cookie_ value be unset by the call to unset the _native_ 'foo' value. + * + * @package CodeIgniter + * @subpackage Libraries + * @category Sessions + * @author Darren Hill (DChill) + * @link http://codeigniter.com/user_guide/libraries/sessions.html + */ +final class Session extends CI_Driver_Library { + public $params = array(); + private $current = null; + private $userdata = array(); + + const FLASHDATA_KEY = 'flash'; + const FLASHDATA_NEW = ':new:'; + const FLASHDATA_OLD = ':old:'; + const FLASHDATA_EXP = ':exp:'; + const EXPIRATION_KEY = '__expirations'; + const TEMP_EXP_DEF = 300; + + /** + * Session constructor + * + * The constructor loads the configured driver ('sess_driver' in config.php or as a parameter), running + * routines in its constructor, and manages flashdata aging. + * + * @param array Configuration parameters + */ + public function __construct(array $params = array()) + { + log_message('debug', 'Session Class Initialized'); + + // Get valid drivers list + $CI =& get_instance(); + $this->valid_drivers = array('Session_Native', 'Session_Cookie'); + $key = 'sess_valid_drivers'; + $drivers = (isset($params[$key])) ? $params[$key] : $CI->config->item($key); + if ($drivers) + { + if (!is_array($drivers)) $drivers = array($drivers); + + // Add driver names to valid list + foreach ($drivers as $driver) + { + if (!in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers))) + { + $this->valid_drivers[] = $driver; + } + } + } + + // Get driver to load + $key = 'sess_driver'; + $driver = (isset($params[$key])) ? $params[$key] : $CI->config->item($key); + if (!$driver) $driver = 'Native'; + if (!in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers))) + { + $this->valid_drivers[] = 'Session_'.$driver; + } + + // Save a copy of parameters in case drivers need access + $this->params = $params; + + // Load driver and get array reference + $this->load_driver($driver); + $this->userdata =& $this->current->get_userdata(); + + // Delete 'old' flashdata (from last request) + $this->_flashdata_sweep(); + + // Mark all new flashdata as old (data will be deleted before next request) + $this->_flashdata_mark(); + + // Delete expired tempdata + $this->_tempdata_sweep(); + + log_message('debug', 'Session routines successfully run'); + } + + /** + * Loads session storage driver + * + * @param string Driver classname + * @return object Loaded driver object + */ + public function load_driver($driver) + { + // Save reference to most recently loaded driver as library default + $this->current = parent::load_driver($driver); + return $this->current; + } + + /** + * Select default session storage driver + * + * @param string Driver classname + * @return void + */ + public function select_driver($driver) + { + // Validate driver name + $lowername = strtolower($driver); + if (in_array($lowername, array_map('strtolower', $this->valid_drivers))) + { + // See if regular or lowercase variant is loaded + if (class_exists($driver)) + { + $this->current = $this->$driver; + } + else if (class_exists($lowername)) + { + $this->current = $this->$lowername; + } + else + { + $this->load_driver($driver); + } + } + } + + /** + * Destroy the current session + * + * @return void + */ + public function sess_destroy() + { + // Just call destroy on driver + $this->current->sess_destroy(); + } + + /** + * Regenerate the current session + * + * @param boolean Destroy session data flag (default: false) + * @return void + */ + public function sess_regenerate($destroy = false) + { + // Just call regenerate on driver + $this->current->sess_regenerate($destroy); + } + + /** + * Fetch a specific item from the session array + * + * @param string Item key + * @return string Item value + */ + public function userdata($item) + { + // Return value or FALSE if not found + return (!isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; + } + + /** + * Fetch all session data + * + * @return array User data array + */ + public function all_userdata() + { + // Return entire array + return (!isset($this->userdata)) ? FALSE : $this->userdata; + } + + /** + * Add or change data in the "userdata" array + * + * @param mixed Item name or array of items + * @param string Item value or empty string + * @return void + */ + public function set_userdata($newdata = array(), $newval = '') + { + // Wrap params as array if singular + if (is_string($newdata)) + { + $newdata = array($newdata => $newval); + } + + // Set each name/value pair + if (count($newdata) > 0) + { + foreach ($newdata as $key => $val) + { + $this->userdata[$key] = $val; + } + } + + // Tell driver data changed + $this->current->sess_save(); + } + + /** + * Delete a session variable from the "userdata" array + * + * @param mixed Item name or array of item names + * @return void + */ + public function unset_userdata($newdata = array()) + { + // Wrap single name as array + if (is_string($newdata)) + { + $newdata = array($newdata => ''); + } + + // Unset each item name + if (count($newdata) > 0) + { + foreach ($newdata as $key => $val) + { + unset($this->userdata[$key]); + } + } + + // Tell driver data changed + $this->current->sess_save(); + } + + /** + * Determine if an item exists + * + * @param string Item name + * @return boolean + */ + public function has_userdata($item) + { + // Check for item name + return isset($this->userdata[$item]); + } + + /** + * Add or change flashdata, only available until the next request + * + * @param mixed Item name or array of items + * @param string Item value or empty string + * @return void + */ + public function set_flashdata($newdata = array(), $newval = '') + { + // Wrap item as array if singular + if (is_string($newdata)) + { + $newdata = array($newdata => $newval); + } + + // Prepend each key name and set value + if (count($newdata) > 0) + { + foreach ($newdata as $key => $val) + { + $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key; + $this->set_userdata($flashdata_key, $val); + } + } + } + + /** + * Keeps existing flashdata available to next request. + * + * @param string Item key + * @return void + */ + public function keep_flashdata($key) + { + // 'old' flashdata gets removed. Here we mark all + // flashdata as 'new' to preserve it from _flashdata_sweep() + $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; + $value = $this->userdata($old_flashdata_key); + + $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key; + $this->set_userdata($new_flashdata_key, $value); + } + + /** + * Fetch a specific flashdata item from the session array + * + * @param string Item key + * @return string + */ + public function flashdata($key) + { + // Prepend key and retrieve value + $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; + return $this->userdata($flashdata_key); + } + + /** + * Add or change tempdata, only available + * until expiration + * + * @param mixed Item name or array of items + * @param string Item value or empty string + * @param int Item lifetime in seconds or 0 for default + * @return void + */ + public function set_tempdata($newdata = array(), $newval = '', $expire = 0) + { + // Set expiration time + $expire = time() + ($expire ? $expire : self::TEMP_EXP_DEF); + + // Wrap item as array if singular + if (is_string($newdata)) + { + $newdata = array($newdata => $newval); + } + + // Get or create expiration list + $expirations = $this->userdata(self::EXPIRATION_KEY); + if (!$expirations) + { + $expirations = array(); + } + + // Prepend each key name and set value + if (count($newdata) > 0) + { + foreach ($newdata as $key => $val) + { + $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key; + $expirations[$tempdata_key] = $expire; + $this->set_userdata($tempdata_key, $val); + } + } + + // Update expiration list + $this->set_userdata(self::EXPIRATION_KEY, $expirations); + } + + /** + * Delete a temporary session variable from the "userdata" array + * + * @param mixed Item name or array of item names + * @return void + */ + public function unset_tempdata($newdata = array()) + { + // Get expirations list + $expirations = $this->userdata(self::EXPIRATION_KEY); + if (!$expirations || !count($expirations)) + { + // Nothing to do + return; + } + + // Wrap single name as array + if (is_string($newdata)) + { + $newdata = array($newdata => ''); + } + + // Prepend each item name and unset + if (count($newdata) > 0) + { + foreach ($newdata as $key => $val) + { + $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key; + unset($expirations[$tempdata_key]); + $this->unset_userdata($tempdata_key); + } + } + + // Update expiration list + $this->set_userdata(self::EXPIRATION_KEY, $expirations); + } + + /** + * Fetch a specific tempdata item from the session array + * + * @param string Item key + * @return string + */ + public function tempdata($key) + { + // Prepend key and return value + $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key; + return $this->userdata($tempdata_key); + } + + /** + * Identifies flashdata as 'old' for removal + * when _flashdata_sweep() runs. + * + * @access private + * @return void + */ + private function _flashdata_mark() + { + $userdata = $this->all_userdata(); + foreach ($userdata as $name => $value) + { + $parts = explode(self::FLASHDATA_NEW, $name); + if (is_array($parts) && count($parts) === 2) + { + $new_name = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$parts[1]; + $this->set_userdata($new_name, $value); + $this->unset_userdata($name); + } + } + } + + /** + * Removes all flashdata marked as 'old' + * + * @access private + * @return void + */ + private function _flashdata_sweep() + { + $userdata = $this->all_userdata(); + foreach ($userdata as $key => $value) + { + if (strpos($key, self::FLASHDATA_OLD)) + { + $this->unset_userdata($key); + } + } + } + + /** + * Removes all expired tempdata + * + * @access private + * @return void + */ + private function _tempdata_sweep() + { + // Get expirations list + $expirations = $this->userdata(self::EXPIRATION_KEY); + if (!$expirations || !count($expirations)) + { + // Nothing to do + return; + } + + // Unset expired elements + $now = time(); + $userdata = $this->all_userdata(); + foreach ($userdata as $key => $value) + { + if (strpos($key, self::FLASHDATA_EXP) && $expirations[$key] < $now) + { + unset($expirations[$key]); + $this->unset_userdata($key); + } + } + + // Update expiration list + $this->set_userdata(self::EXPIRATION_KEY, $expirations); + } +} +// END Session Class + + +/** + * SessionDriver Class + * + * Extend this class to make a new Session driver. + * A Session driver basically manages an array of name/value pairs with some sort of storage mechanism. + * To make a new driver, derive from (extend) SessionDriver. Overload the initialize method and read or create + * session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler + * to remove deleted data (sess_destroy), and an access handler to expose the data (get_userdata). + * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the application + * directory, the system directory, or any path you add with $CI->load->add_package_path(). + * Your driver must be named Session_, where is capitalized, and your filename must be Session_.EXT, + * preferably also capitalized. (e.g.: Session_Foo in libraries/Session/drivers/Session_Foo.php) + * Then specify the driver by setting 'sess_driver' in your config file or as a parameter when loading the Session + * object. (e.g.: $config['sess_driver'] = 'foo'; OR $CI->load->driver('session', array('sess_driver' => 'foo')); ) + * Already provided are the Native driver, which manages the native PHP $_SESSION array, and + * the Cookie driver, which manages the data in a browser cookie, with optional extra storage in a database table. + * + * @package CodeIgniter + * @subpackage Libraries + * @category Sessions + * @author Darren Hill (DChill) + */ +abstract class SessionDriver extends CI_Driver { + /** + * Decorate + * + * Decorates the child with the parent driver lib's methods and properties + * + * @param object Parent library object + * @return void + */ + public function decorate($parent) + { + // Call base class decorate first + parent::decorate($parent); + + // Call initialize method now that driver has access to $this->parent + $this->initialize(); + } + + /** + * __call magic method + * + * Handles access to the parent driver library's methods + * + * @param string Library method name + * @param array Method arguments (default: none) + * @return mixed + */ + public function __call($method, $args = array()) + { + // Make sure the parent library uses this driver + $this->parent->select_driver(get_class($this)); + return parent::__call($method, $args); + } + + /** + * Initialize driver + * + * @return void + */ + protected function initialize() + { + // Overload this method to implement initialization + } + + /** + * Save the session data + * + * Data in the array has changed - perform any storage synchronization necessary + * The child class MUST implement this abstract method! + * + * @return void + */ + abstract public function sess_save(); + + /** + * Destroy the current session + * + * Clean up storage for this session - it has been terminated + * The child class MUST implement this abstract method! + * + * @return void + */ + abstract public function sess_destroy(); + + /** + * Regenerate the current session + * + * Regenerate the session id + * The child class MUST implement this abstract method! + * + * @param boolean Destroy session data flag (default: false) + * @return void + */ + abstract public function sess_regenerate($destroy = false); + + /** + * Get a reference to user data array + * + * Give array access to the main Session object + * The child class MUST implement this abstract method! + * + * @return array Reference to userdata + */ + abstract public function &get_userdata(); +} +// END SessionDriver Class + + +/* End of file Session.php */ +/* Location: ./system/libraries/Session/Session.php */ +?> diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php new file mode 100755 index 000000000..0982b1e01 --- /dev/null +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -0,0 +1,583 @@ +CI =& get_instance(); + + // Set all the session preferences, which can either be set + // manually via the $params array above or via the config file + foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', + 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', + 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) + { + $this->$key = (isset($this->parent->params[$key])) ? $this->parent->params[$key] : $this->CI->config->item($key); + } + + if ($this->encryption_key == '') + { + show_error('In order to use the Cookie Session driver you are required to set an encryption key '. + 'in your config file.'); + } + + // Load the string helper so we can use the strip_slashes() function + $this->CI->load->helper('string'); + + // Do we need encryption? If so, load the encryption class + if ($this->sess_encrypt_cookie == TRUE) + { + $this->CI->load->library('encrypt'); + } + + // Are we using a database? If so, load it + if ($this->sess_use_database === TRUE && $this->sess_table_name != '') + { + $this->CI->load->database(); + } + + // Set the "now" time. Can either be GMT or server time, based on the config prefs. + // We use this to set the "last activity" time + $this->now = $this->_get_time(); + + // Set the session length. If the session expiration is + // set to zero we'll set the expiration two years from now. + if ($this->sess_expiration == 0) + { + $this->sess_expiration = (60*60*24*365*2); + } + + // Set the cookie name + $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name; + + // Run the Session routine. If a session doesn't exist we'll + // create a new one. If it does, we'll update it. + if ( ! $this->_sess_read()) + { + $this->_sess_create(); + } + else + { + $this->_sess_update(); + } + + // Delete expired sessions if necessary + $this->_sess_gc(); + } + + /** + * Write the session data + * + * @return void + */ + public function sess_save() + { + // Are we saving custom data to the DB? If not, all we do is update the cookie + if ($this->sess_use_database === FALSE) + { + $this->_set_cookie(); + return; + } + + // set the custom userdata, the session data we will set in a second + $custom_userdata = $this->all_userdata(); + $cookie_userdata = array(); + + // Before continuing, we need to determine if there is any custom data to deal with. + // Let's determine this by removing the default indexes to see if there's anything left in the array + // and set the session data while we're at it + foreach (array('session_id','ip_address','user_agent','last_activity') as $val) + { + unset($custom_userdata[$val]); + $cookie_userdata[$val] = $this->userdata($val); + } + + // Did we find any custom data? If not, we turn the empty array into a string + // since there's no reason to serialize and store an empty array in the DB + if (count($custom_userdata) === 0) + { + $custom_userdata = ''; + } + else + { + // Serialize the custom data array so we can store it + $custom_userdata = $this->_serialize($custom_userdata); + } + + // Run the update query + $this->CI->db->where('session_id', $this->userdata('session_id')); + $this->CI->db->update($this->sess_table_name, + array('last_activity' => $this->userdata('last_activity'), 'user_data' => $custom_userdata)); + + // Write the cookie. Notice that we manually pass the cookie data array to the + // _set_cookie() function. Normally that function will store $this->userdata, but + // in this case that array contains custom data, which we do not want in the cookie. + $this->_set_cookie($cookie_userdata); + } + + /** + * Destroy the current session + * + * @return void + */ + public function sess_destroy() + { + // Kill the session DB row + if ($this->sess_use_database === TRUE && $this->has_userdata('session_id')) + { + $this->CI->db->where('session_id', $this->userdata['session_id']); + $this->CI->db->delete($this->sess_table_name); + } + + // Kill the cookie + setcookie($this->sess_cookie_name, addslashes(serialize(array())), ($this->now - 31500000), + $this->cookie_path, $this->cookie_domain, 0); + } + + /** + * Regenerate the current session + * + * Regenerate the session id + * + * @param boolean Destroy session data flag (default: false) + * @return void + */ + public function sess_regenerate($destroy = false) + { + // Check destroy flag + if ($destroy) + { + // Destroy old session and create new one + $this->sess_destroy(); + $this->_sess_create(); + } + else + { + // Just force an update to recreate the id + $this->_sess_update(true); + } + } + + /** + * Get a reference to user data array + * + * @return array - Reference to userdata + */ + public function &get_userdata() + { + // Return reference to array + return $this->userdata; + } + + /** + * Fetch the current session data if it exists + * + * @access private + * @return bool + */ + private function _sess_read() + { + // Fetch the cookie + $session = $this->CI->input->cookie($this->sess_cookie_name); + + // No cookie? Goodbye cruel world!... + if ($session === FALSE) + { + log_message('debug', 'A session cookie was not found.'); + return FALSE; + } + + // Decrypt the cookie data + if ($this->sess_encrypt_cookie == TRUE) + { + $session = $this->CI->encrypt->decode($session); + } + else + { + // encryption was not used, so we need to check the md5 hash + $hash = substr($session, strlen($session)-32); // get last 32 chars + $session = substr($session, 0, strlen($session)-32); + + // Does the md5 hash match? This is to prevent manipulation of session data in userspace + if ($hash !== md5($session.$this->encryption_key)) + { + log_message('error', 'The session cookie data did not match what was expected. '. + 'This could be a possible hacking attempt.'); + $this->sess_destroy(); + return FALSE; + } + } + + // Unserialize the session array + $session = $this->_unserialize($session); + + // Is the session data we unserialized an array with the correct format? + if ( ! is_array($session) || ! isset($session['session_id']) || ! isset($session['ip_address']) || + ! isset($session['user_agent']) || ! isset($session['last_activity'])) + { + $this->sess_destroy(); + return FALSE; + } + + // Is the session current? + if (($session['last_activity'] + $this->sess_expiration) < $this->now()) + { + $this->sess_destroy(); + return FALSE; + } + + // Does the IP Match? + if ($this->sess_match_ip == TRUE && $session['ip_address'] != $this->CI->input->ip_address()) + { + $this->sess_destroy(); + return FALSE; + } + + // Does the User Agent Match? + if ($this->sess_match_useragent == TRUE && + trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50))) + { + $this->sess_destroy(); + return FALSE; + } + + // Is there a corresponding session in the DB? + if ($this->sess_use_database === TRUE) + { + $this->CI->db->where('session_id', $session['session_id']); + + if ($this->sess_match_ip == TRUE) + { + $this->CI->db->where('ip_address', $session['ip_address']); + } + + if ($this->sess_match_useragent == TRUE) + { + $this->CI->db->where('user_agent', $session['user_agent']); + } + + $query = $this->CI->db->get($this->sess_table_name); + + // No result? Kill it! + if ($query->num_rows() == 0) + { + $this->sess_destroy(); + return FALSE; + } + + // Is there custom data? If so, add it to the main session array + $row = $query->row(); + if (isset($row->user_data) && $row->user_data != '') + { + $custom_data = $this->_unserialize($row->user_data); + + if (is_array($custom_data)) + { + foreach ($custom_data as $key => $val) + { + $session[$key] = $val; + } + } + } + } + + // Session is valid! + $this->userdata = $session; + unset($session); + + return TRUE; + } + + /** + * Create a new session + * + * @access private + * @return void + */ + private function _sess_create() + { + $sessid = ''; + while (strlen($sessid) < 32) + { + $sessid .= mt_rand(0, mt_getrandmax()); + } + + // To make the session ID even more secure we'll combine it with the user's IP + $sessid .= $this->CI->input->ip_address(); + + $this->set_userdata('session_id', md5(uniqid($sessid, TRUE))); + $this->set_userdata('ip_address', $this->CI->input->ip_address()); + $this->set_userdata('user_agent', substr($this->CI->input->user_agent(), 0, 50)); + $this->set_userdata('last_activity',$this->now()); + + + // Save the data to the DB if needed + if ($this->sess_use_database === TRUE) + { + $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->all_userdata())); + } + + // Write the cookie + $this->_set_cookie(); + } + + /** + * Update an existing session + * + * @access private + * @param boolean Force update flag (default: false) + * @return void + */ + private function _sess_update($force = false) + { + // We only update the session every five minutes by default (unless forced) + if (!$force && ($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now()) + { + return; + } + + // Save the old session id so we know which record to + // update in the database if we need it + $old_sessid = $this->userdata['session_id']; + $new_sessid = ''; + while (strlen($new_sessid) < 32) + { + $new_sessid .= mt_rand(0, mt_getrandmax()); + } + + // To make the session ID even more secure we'll combine it with the user's IP + $new_sessid .= $this->CI->input->ip_address(); + + // Turn it into a hash + $new_sessid = md5(uniqid($new_sessid, TRUE)); + + // Update the session data in the session data array + $this->set_userdata('session_id', $new_sessid); + $this->set_userdata('last_activity', $this->now()); + + // _set_cookie() will handle this for us if we aren't using database sessions + // by pushing all userdata to the cookie. + $cookie_data = NULL; + + // Update the session ID and last_activity field in the DB if needed + if ($this->sess_use_database === TRUE) + { + // set cookie explicitly to only have our session data + $cookie_data = array(); + foreach (array('session_id','ip_address','user_agent','last_activity') as $val) + { + $cookie_data[$val] = $this->userdata[$val]; + } + + $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, + array('last_activity' => $this->now(), 'session_id' => $new_sessid), + array('session_id' => $old_sessid))); + } + + // Write the cookie + $this->_set_cookie($cookie_data); + } + + /** + * Get the "now" time + * + * @access private + * @return int + */ + private function _get_time() + { + if (strtolower($this->time_reference) == 'gmt') + { + $now = time(); + $time = mktime(gmdate('H', $now), gmdate('i', $now), gmdate('s', $now), gmdate('m', $now), + gmdate('d', $now), gmdate('Y', $now)); + } + else + { + $time = time(); + } + + return $time; + } + + /** + * Write the session cookie + * + * @access private + * @param array Cookie name/value pairs + * @return void + */ + private function _set_cookie(array $cookie_data = NULL) + { + if (is_null($cookie_data)) + { + $cookie_data = $this->all_userdata(); + } + + // Serialize the userdata for the cookie + $cookie_data = $this->_serialize($cookie_data); + + if ($this->sess_encrypt_cookie == TRUE) + { + $cookie_data = $this->CI->encrypt->encode($cookie_data); + } + else + { + // if encryption is not used, we provide an md5 hash to prevent userside tampering + $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key); + } + + $expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time(); + + // Set the cookie + setcookie($this->sess_cookie_name, $cookie_data, $expire, $this->cookie_path, $this->cookie_domain, 0); + } + + /** + * Serialize an array + * + * This function first converts any slashes found in the array to a temporary + * marker, so when it gets unserialized the slashes will be preserved + * + * @access private + * @param mixed Data to serialize + * @return string + */ + private function _serialize($data) + { + if (is_array($data)) + { + foreach ($data as $key => $val) + { + if (is_string($val)) + { + $data[$key] = str_replace('\\', '{{slash}}', $val); + } + } + } + else + { + if (is_string($data)) + { + $data = str_replace('\\', '{{slash}}', $data); + } + } + + return serialize($data); + } + + /** + * Unserialize + * + * This function unserializes a data string, then converts any + * temporary slash markers back to actual slashes + * + * @access private + * @param string Data to unserialize + * @return mixed + */ + private function _unserialize($data) + { + $data = @unserialize(strip_slashes($data)); + + if (is_array($data)) + { + foreach ($data as $key => $val) + { + if (is_string($val)) + { + $data[$key] = str_replace('{{slash}}', '\\', $val); + } + } + + return $data; + } + + return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data; + } + + /** + * Garbage collection + * + * This deletes expired session rows from database + * if the probability percentage is met + * + * @access private + * @return void + */ + private function _sess_gc() + { + if ($this->sess_use_database != TRUE) + { + return; + } + + srand(time()); + if ((rand() % 100) < self::gc_probability) + { + $expire = $this->now() - $this->sess_expiration; + + $this->CI->db->where('last_activity < '.$expire); + $this->CI->db->delete($this->sess_table_name); + + log_message('debug', 'Session garbage collection performed.'); + } + } +} +// END Session_Cookie Class + +/* End of file Session_cookie.php */ +/* Location: ./system/libraries/Session/Session.php */ +?> diff --git a/system/libraries/Session/drivers/Session_native.php b/system/libraries/Session/drivers/Session_native.php new file mode 100755 index 000000000..df588175f --- /dev/null +++ b/system/libraries/Session/drivers/Session_native.php @@ -0,0 +1,190 @@ +parent->params[$key]) ? $this->parent->params[$key] : $CI->config->item($key); + } + + // Set session name, if specified + if ($config['sess_cookie_name']) + { + $name = $config['sess_cookie_name']; + if ($config['cookie_prefix']) + { + // Prepend cookie prefix + $name = $config['cookie_prefix'].$name; + } + session_name($name); + } + + // Set expiration, path, and domain + $expire = 7200; + $path = '/'; + $domain = ''; + if ($config['sess_expiration'] !== FALSE) + { + // Default to 2 years if expiration is "0" + $expire = ($config['sess_expiration'] == 0) ? (60*60*24*365*2) : $config['sess_expiration']; + } + if ($config['cookie_path']) + { + // Use specified path + $path = $config['cookie_path']; + } + if ($config['cookie_domain']) + { + // Use specified domain + $domain = $config['cookie_domain']; + } + session_set_cookie_params($config['sess_expire_on_close'] ? 0 : $expire, $path, $domain); + + // Start session + session_start(); + + // Check session expiration, ip, and agent + $now = time(); + $destroy = FALSE; + if (isset($_SESSION['last_activity']) && ($_SESSION['last_activity'] + $expire) < $now) + { + // Expired - destroy + $destroy = TRUE; + } + else if ($config['sess_match_ip'] == TRUE && isset($_SESSION['ip_address']) && + $_SESSION['ip_address'] != $CI->input->ip_address()) + { + // IP doesn't match - destroy + $destroy = TRUE; + } + else if ($config['sess_match_useragent'] == TRUE && isset($_SESSION['user_agent']) && + $_SESSION['user_agent'] != trim(substr($CI->input->user_agent(), 0, 50))) + { + // Agent doesn't match - destroy + $destroy = TRUE; + } + + // Destroy expired or invalid session + if ($destroy) + { + // Clear old session and start new + $this->sess_destroy(); + session_start(); + } + + // Set activity time + $_SESSION['last_activity'] = $now; + + // Set matching values as required + if ($config['sess_match_ip'] == TRUE && !isset($_SESSION['ip_address'])) + { + // Store user IP address + $_SESSION['ip_address'] = $CI->input->ip_address(); + } + if ($config['sess_match_useragent'] == TRUE && !isset($_SESSION['user_agent'])) + { + // Store user agent string + $_SESSION['user_agent'] = trim(substr($CI->input->user_agent(), 0, 50)); + } + } + + /** + * Save the session data + * + * @access public + * @return void + */ + public function sess_save() + { + // Nothing to do - changes to $_SESSION are automatically saved + } + + /** + * Destroy the current session + * + * @access public + * @return void + */ + public function sess_destroy() + { + // Cleanup session + $_SESSION = array(); + $name = session_name(); + if (isset($_COOKIE[$name])) + { + // Clear session cookie + $params = session_get_cookie_params(); + setcookie($name, '', time() - 42000, $params['path'], $params['domain']); + unset($_COOKIE[$name]); + } + session_destroy(); + } + + /** + * Regenerate the current session + * + * Regenerate the session id + * + * @access public + * @param boolean Destroy session data flag (default: false) + * @return void + */ + public function sess_regenerate($destroy = false) + { + // Just regenerate id, passing destroy flag + session_regenerate_id($destroy); + } + + /** + * Get a reference to user data array + * + * @access public + * @return array Reference to userdata + */ + public function &get_userdata() + { + // Just return reference to $_SESSION + return $_SESSION; + } +} +// END Session_Native Class + + +/* End of file Session_native.php */ +/* Location: ./system/libraries/Session/Session.php */ +?> -- cgit v1.2.3-24-g4f1b From 3bd8d1ad9273f12c47d1ce1f59d4140718a02e4f Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 31 Aug 2011 08:28:16 -0400 Subject: Removed ucfirst on Driver library name --- system/libraries/Driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index e958fc67f..c3bcc252e 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -66,8 +66,8 @@ class CI_Driver_Library { $child_class = $this->lib_name.'_'.$child; // Remove the CI_ prefix and lowercase - $lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name))); - $driver_name = strtolower(str_replace('CI_', '', $child_class)); + $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name)); + $driver_name = strtolower(preg_replace('/^CI_/', '', $child_class)); if (in_array($driver_name, array_map('strtolower', $this->valid_drivers))) { -- cgit v1.2.3-24-g4f1b From ca3be1d515a68293b64704a9a8346802702dedaa Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 31 Aug 2011 08:31:18 -0400 Subject: Whitespace cleanup --- system/core/Loader.php | 8 ++++---- system/libraries/Driver.php | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 51e6b82ca..edf5853f0 100755 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1177,10 +1177,10 @@ class CI_Loader { // Autoload drivers if (isset($autoload['drivers'])) { - foreach ($autoload['drivers'] as $item) - { - $this->driver($item); - } + foreach ($autoload['drivers'] as $item) + { + $this->driver($item); + } } // Autoload models diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index c3bcc252e..80c0e2812 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -32,29 +32,29 @@ class CI_Driver_Library { protected $valid_drivers = array(); protected $lib_name; - /** - * Get magic method - * + /** + * Get magic method + * * The first time a child is used it won't exist, so we instantiate it * subsequents calls will go straight to the proper child. - * - * @param string Child class name - * @return object Child class - */ + * + * @param string Child class name + * @return object Child class + */ public function __get($child) { - // Try to load the driver + // Try to load the driver return load_driver($child); - } + } - /** - * Load driver - * + /** + * Load driver + * * Separate load_driver call to support explicit driver load by library or user - * - * @param string Child class name - * @return object Child class - */ + * + * @param string Child class name + * @return object Child class + */ public function load_driver($child) { if ( ! isset($this->lib_name)) -- cgit v1.2.3-24-g4f1b From 5073a375951f09b654f6b991df7ca04e1f88d93c Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 31 Aug 2011 13:54:19 -0400 Subject: Better style guide compliance --- system/libraries/Session/Session.php | 136 ++++++++++----------- .../libraries/Session/drivers/Session_cookie.php | 8 +- .../libraries/Session/drivers/Session_native.php | 8 +- 3 files changed, 76 insertions(+), 76 deletions(-) diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index 7aaf706a1..dacc249c5 100755 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -15,15 +15,15 @@ /** - * Session Class + * CI_Session Class * * The user interface defined by EllisLabs, now with puggable drivers to manage different storage mechanisms. - * By default, the Native PHP session driver will load, but the 'sess_driver' config/param item (see above) can be - * used to specify the 'Cookie' driver, or any other you might create. + * By default, the native PHP session driver will load, but the 'sess_driver' config/param item (see above) can be + * used to specify the 'cookie' driver, or any other you might create. * Once loaded, this driver setup is a drop-in replacement for the former CI_Session library, taking its place as the * 'session' member of the global controller framework (e.g.: $CI->session or $this->session). * In keeping with the CI_Driver methodology, multiple drivers may be loaded, although this might be a bit confusing. - * The Session library class keeps track of the most recently loaded driver as "current" to call for driver methods. + * The CI_Session library class keeps track of the most recently loaded driver as "current" to call for driver methods. * Ideally, one driver is loaded and all calls go directly through the main library interface. However, any methods * called through the specific driver will switch the "current" driver to itself before invoking the library method * (which will then call back into the driver for low-level operations). So, alternation between two drivers can be @@ -35,10 +35,10 @@ * @package CodeIgniter * @subpackage Libraries * @category Sessions - * @author Darren Hill (DChill) + * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/libraries/sessions.html */ -final class Session extends CI_Driver_Library { +final class CI_Session extends CI_Driver_Library { public $params = array(); private $current = null; private $userdata = array(); @@ -51,20 +51,20 @@ final class Session extends CI_Driver_Library { const TEMP_EXP_DEF = 300; /** - * Session constructor + * CI_Session constructor * * The constructor loads the configured driver ('sess_driver' in config.php or as a parameter), running * routines in its constructor, and manages flashdata aging. * - * @param array Configuration parameters + * @param array Configuration parameters */ public function __construct(array $params = array()) { - log_message('debug', 'Session Class Initialized'); + log_message('debug', 'CI_Session Class Initialized'); // Get valid drivers list $CI =& get_instance(); - $this->valid_drivers = array('Session_Native', 'Session_Cookie'); + $this->valid_drivers = array('CI_Session_native', 'CI_Session_cookie'); $key = 'sess_valid_drivers'; $drivers = (isset($params[$key])) ? $params[$key] : $CI->config->item($key); if ($drivers) @@ -84,7 +84,7 @@ final class Session extends CI_Driver_Library { // Get driver to load $key = 'sess_driver'; $driver = (isset($params[$key])) ? $params[$key] : $CI->config->item($key); - if (!$driver) $driver = 'Native'; + if (!$driver) $driver = 'native'; if (!in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers))) { $this->valid_drivers[] = 'Session_'.$driver; @@ -106,14 +106,14 @@ final class Session extends CI_Driver_Library { // Delete expired tempdata $this->_tempdata_sweep(); - log_message('debug', 'Session routines successfully run'); + log_message('debug', 'CI_Session routines successfully run'); } /** * Loads session storage driver * - * @param string Driver classname - * @return object Loaded driver object + * @param string Driver classname + * @return object Loaded driver object */ public function load_driver($driver) { @@ -125,8 +125,8 @@ final class Session extends CI_Driver_Library { /** * Select default session storage driver * - * @param string Driver classname - * @return void + * @param string Driver classname + * @return void */ public function select_driver($driver) { @@ -153,7 +153,7 @@ final class Session extends CI_Driver_Library { /** * Destroy the current session * - * @return void + * @return void */ public function sess_destroy() { @@ -164,8 +164,8 @@ final class Session extends CI_Driver_Library { /** * Regenerate the current session * - * @param boolean Destroy session data flag (default: false) - * @return void + * @param boolean Destroy session data flag (default: false) + * @return void */ public function sess_regenerate($destroy = false) { @@ -176,8 +176,8 @@ final class Session extends CI_Driver_Library { /** * Fetch a specific item from the session array * - * @param string Item key - * @return string Item value + * @param string Item key + * @return string Item value */ public function userdata($item) { @@ -199,9 +199,9 @@ final class Session extends CI_Driver_Library { /** * Add or change data in the "userdata" array * - * @param mixed Item name or array of items - * @param string Item value or empty string - * @return void + * @param mixed Item name or array of items + * @param string Item value or empty string + * @return void */ public function set_userdata($newdata = array(), $newval = '') { @@ -227,8 +227,8 @@ final class Session extends CI_Driver_Library { /** * Delete a session variable from the "userdata" array * - * @param mixed Item name or array of item names - * @return void + * @param mixed Item name or array of item names + * @return void */ public function unset_userdata($newdata = array()) { @@ -254,8 +254,8 @@ final class Session extends CI_Driver_Library { /** * Determine if an item exists * - * @param string Item name - * @return boolean + * @param string Item name + * @return boolean */ public function has_userdata($item) { @@ -266,9 +266,9 @@ final class Session extends CI_Driver_Library { /** * Add or change flashdata, only available until the next request * - * @param mixed Item name or array of items - * @param string Item value or empty string - * @return void + * @param mixed Item name or array of items + * @param string Item value or empty string + * @return void */ public function set_flashdata($newdata = array(), $newval = '') { @@ -292,12 +292,12 @@ final class Session extends CI_Driver_Library { /** * Keeps existing flashdata available to next request. * - * @param string Item key - * @return void + * @param string Item key + * @return void */ public function keep_flashdata($key) { - // 'old' flashdata gets removed. Here we mark all + // 'old' flashdata gets removed. Here we mark all // flashdata as 'new' to preserve it from _flashdata_sweep() $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; $value = $this->userdata($old_flashdata_key); @@ -309,8 +309,8 @@ final class Session extends CI_Driver_Library { /** * Fetch a specific flashdata item from the session array * - * @param string Item key - * @return string + * @param string Item key + * @return string */ public function flashdata($key) { @@ -323,10 +323,10 @@ final class Session extends CI_Driver_Library { * Add or change tempdata, only available * until expiration * - * @param mixed Item name or array of items - * @param string Item value or empty string - * @param int Item lifetime in seconds or 0 for default - * @return void + * @param mixed Item name or array of items + * @param string Item value or empty string + * @param int Item lifetime in seconds or 0 for default + * @return void */ public function set_tempdata($newdata = array(), $newval = '', $expire = 0) { @@ -364,8 +364,8 @@ final class Session extends CI_Driver_Library { /** * Delete a temporary session variable from the "userdata" array * - * @param mixed Item name or array of item names - * @return void + * @param mixed Item name or array of item names + * @return void */ public function unset_tempdata($newdata = array()) { @@ -401,8 +401,8 @@ final class Session extends CI_Driver_Library { /** * Fetch a specific tempdata item from the session array * - * @param string Item key - * @return string + * @param string Item key + * @return string */ public function tempdata($key) { @@ -483,32 +483,32 @@ final class Session extends CI_Driver_Library { $this->set_userdata(self::EXPIRATION_KEY, $expirations); } } -// END Session Class +// END CI_Session Class /** - * SessionDriver Class + * CI_Session_driver Class * - * Extend this class to make a new Session driver. - * A Session driver basically manages an array of name/value pairs with some sort of storage mechanism. - * To make a new driver, derive from (extend) SessionDriver. Overload the initialize method and read or create + * Extend this class to make a new CI_Session driver. + * A CI_Session driver basically manages an array of name/value pairs with some sort of storage mechanism. + * To make a new driver, derive from (extend) CI_Session_driver. Overload the initialize method and read or create * session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler * to remove deleted data (sess_destroy), and an access handler to expose the data (get_userdata). - * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the application - * directory, the system directory, or any path you add with $CI->load->add_package_path(). - * Your driver must be named Session_, where is capitalized, and your filename must be Session_.EXT, - * preferably also capitalized. (e.g.: Session_Foo in libraries/Session/drivers/Session_Foo.php) - * Then specify the driver by setting 'sess_driver' in your config file or as a parameter when loading the Session + * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the + * application directory, the system directory, or any path you add with $CI->load->add_package_path(). + * Your driver must be named CI_Session_, and your filename must be Session_.php, + * preferably also capitalized. (e.g.: CI_Session_foo in libraries/Session/drivers/Session_foo.php) + * Then specify the driver by setting 'sess_driver' in your config file or as a parameter when loading the CI_Session * object. (e.g.: $config['sess_driver'] = 'foo'; OR $CI->load->driver('session', array('sess_driver' => 'foo')); ) * Already provided are the Native driver, which manages the native PHP $_SESSION array, and * the Cookie driver, which manages the data in a browser cookie, with optional extra storage in a database table. * - * @package CodeIgniter - * @subpackage Libraries + * @package CodeIgniter + * @subpackage Libraries * @category Sessions - * @author Darren Hill (DChill) + * @author ExpressionEngine Dev Team */ -abstract class SessionDriver extends CI_Driver { +abstract class CI_Session_driver extends CI_Driver { /** * Decorate * @@ -531,8 +531,8 @@ abstract class SessionDriver extends CI_Driver { * * Handles access to the parent driver library's methods * - * @param string Library method name - * @param array Method arguments (default: none) + * @param string Library method name + * @param array Method arguments (default: none) * @return mixed */ public function __call($method, $args = array()) @@ -545,7 +545,7 @@ abstract class SessionDriver extends CI_Driver { /** * Initialize driver * - * @return void + * @return void */ protected function initialize() { @@ -558,7 +558,7 @@ abstract class SessionDriver extends CI_Driver { * Data in the array has changed - perform any storage synchronization necessary * The child class MUST implement this abstract method! * - * @return void + * @return void */ abstract public function sess_save(); @@ -568,7 +568,7 @@ abstract class SessionDriver extends CI_Driver { * Clean up storage for this session - it has been terminated * The child class MUST implement this abstract method! * - * @return void + * @return void */ abstract public function sess_destroy(); @@ -578,22 +578,22 @@ abstract class SessionDriver extends CI_Driver { * Regenerate the session id * The child class MUST implement this abstract method! * - * @param boolean Destroy session data flag (default: false) - * @return void + * @param boolean Destroy session data flag (default: false) + * @return void */ abstract public function sess_regenerate($destroy = false); /** * Get a reference to user data array * - * Give array access to the main Session object + * Give array access to the main CI_Session object * The child class MUST implement this abstract method! * - * @return array Reference to userdata + * @return array Reference to userdata */ abstract public function &get_userdata(); } -// END SessionDriver Class +// END CI_Session_driver Class /* End of file Session.php */ diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php index 0982b1e01..d26ab0432 100755 --- a/system/libraries/Session/drivers/Session_cookie.php +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -24,9 +24,9 @@ * @package CodeIgniter * @subpackage Libraries * @category Sessions - * @author ExpressionEngine Dev Team and Darren Hill (DChill42) + * @author ExpressionEngine Dev Team */ -class Session_Cookie extends SessionDriver { +class CI_Session_cookie extends CI_Session_driver { private $sess_encrypt_cookie = FALSE; private $sess_use_database = FALSE; private $sess_table_name = ''; @@ -576,8 +576,8 @@ class Session_Cookie extends SessionDriver { } } } -// END Session_Cookie Class +// END CI_Session_cookie Class /* End of file Session_cookie.php */ -/* Location: ./system/libraries/Session/Session.php */ +/* Location: ./system/libraries/Session/drivers/Session_cookie.php */ ?> diff --git a/system/libraries/Session/drivers/Session_native.php b/system/libraries/Session/drivers/Session_native.php index df588175f..37da3445a 100755 --- a/system/libraries/Session/drivers/Session_native.php +++ b/system/libraries/Session/drivers/Session_native.php @@ -22,9 +22,9 @@ * @package CodeIgniter * @subpackage Libraries * @category Sessions - * @author Darren Hill (DChill) + * @author ExpressionEngine Dev Team */ -class Session_Native extends SessionDriver { +class CI_Session_native extends CI_Session_driver { /** * Initialize session driver object * @@ -182,9 +182,9 @@ class Session_Native extends SessionDriver { return $_SESSION; } } -// END Session_Native Class +// END CI_Session_native Class /* End of file Session_native.php */ -/* Location: ./system/libraries/Session/Session.php */ +/* Location: ./system/libraries/Session/drivers/Session_native.php */ ?> -- cgit v1.2.3-24-g4f1b From 4d1cd4c56697bc53b5a9899089ab4c978c66e1da Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 31 Aug 2011 13:59:09 -0400 Subject: Restored errantly removed ucfirst --- system/libraries/Driver.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 80c0e2812..e958fc67f 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -32,29 +32,29 @@ class CI_Driver_Library { protected $valid_drivers = array(); protected $lib_name; - /** - * Get magic method - * + /** + * Get magic method + * * The first time a child is used it won't exist, so we instantiate it * subsequents calls will go straight to the proper child. - * - * @param string Child class name - * @return object Child class - */ + * + * @param string Child class name + * @return object Child class + */ public function __get($child) { - // Try to load the driver + // Try to load the driver return load_driver($child); - } + } - /** - * Load driver - * + /** + * Load driver + * * Separate load_driver call to support explicit driver load by library or user - * - * @param string Child class name - * @return object Child class - */ + * + * @param string Child class name + * @return object Child class + */ public function load_driver($child) { if ( ! isset($this->lib_name)) @@ -66,8 +66,8 @@ class CI_Driver_Library { $child_class = $this->lib_name.'_'.$child; // Remove the CI_ prefix and lowercase - $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name)); - $driver_name = strtolower(preg_replace('/^CI_/', '', $child_class)); + $lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name))); + $driver_name = strtolower(str_replace('CI_', '', $child_class)); if (in_array($driver_name, array_map('strtolower', $this->valid_drivers))) { -- cgit v1.2.3-24-g4f1b From 6fbf6bd1dfa2ef373fc8072c52f63446cdd00327 Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 31 Aug 2011 14:15:35 -0400 Subject: Missed whitespace on Driver --- system/libraries/Driver.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index e958fc67f..77476e139 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -32,29 +32,29 @@ class CI_Driver_Library { protected $valid_drivers = array(); protected $lib_name; - /** - * Get magic method - * + /** + * Get magic method + * * The first time a child is used it won't exist, so we instantiate it * subsequents calls will go straight to the proper child. - * - * @param string Child class name - * @return object Child class - */ + * + * @param string Child class name + * @return object Child class + */ public function __get($child) { - // Try to load the driver + // Try to load the driver return load_driver($child); - } + } - /** - * Load driver - * + /** + * Load driver + * * Separate load_driver call to support explicit driver load by library or user - * - * @param string Child class name - * @return object Child class - */ + * + * @param string Child class name + * @return object Child class + */ public function load_driver($child) { if ( ! isset($this->lib_name)) -- cgit v1.2.3-24-g4f1b From a2ae6571e55d5a3d23645e96929eea996e9f0499 Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Thu, 1 Sep 2011 07:36:26 -0400 Subject: Made private members protected for inheritance --- system/libraries/Session/Session.php | 18 +++--- .../libraries/Session/drivers/Session_cookie.php | 66 +++++++++++----------- .../libraries/Session/drivers/Session_native.php | 28 ++++----- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index dacc249c5..7c340ccca 100755 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -38,10 +38,10 @@ * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/libraries/sessions.html */ -final class CI_Session extends CI_Driver_Library { +class CI_Session extends CI_Driver_Library { public $params = array(); - private $current = null; - private $userdata = array(); + protected $current = null; + protected $userdata = array(); const FLASHDATA_KEY = 'flash'; const FLASHDATA_NEW = ':new:'; @@ -415,10 +415,10 @@ final class CI_Session extends CI_Driver_Library { * Identifies flashdata as 'old' for removal * when _flashdata_sweep() runs. * - * @access private + * @access protected * @return void */ - private function _flashdata_mark() + protected function _flashdata_mark() { $userdata = $this->all_userdata(); foreach ($userdata as $name => $value) @@ -436,10 +436,10 @@ final class CI_Session extends CI_Driver_Library { /** * Removes all flashdata marked as 'old' * - * @access private + * @access protected * @return void */ - private function _flashdata_sweep() + protected function _flashdata_sweep() { $userdata = $this->all_userdata(); foreach ($userdata as $key => $value) @@ -454,10 +454,10 @@ final class CI_Session extends CI_Driver_Library { /** * Removes all expired tempdata * - * @access private + * @access protected * @return void */ - private function _tempdata_sweep() + protected function _tempdata_sweep() { // Get expirations list $expirations = $this->userdata(self::EXPIRATION_KEY); diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php index d26ab0432..334218ec2 100755 --- a/system/libraries/Session/drivers/Session_cookie.php +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -27,23 +27,23 @@ * @author ExpressionEngine Dev Team */ class CI_Session_cookie extends CI_Session_driver { - private $sess_encrypt_cookie = FALSE; - private $sess_use_database = FALSE; - private $sess_table_name = ''; - private $sess_expiration = 7200; - private $sess_expire_on_close = FALSE; - private $sess_match_ip = FALSE; - private $sess_match_useragent = TRUE; - private $sess_cookie_name = 'ci_session'; - private $cookie_prefix = ''; - private $cookie_path = ''; - private $cookie_domain = ''; - private $sess_time_to_update = 300; - private $encryption_key = ''; - private $time_reference = 'time'; - private $userdata = array(); - private $CI = null; - private $now = 0; + protected $sess_encrypt_cookie = FALSE; + protected $sess_use_database = FALSE; + protected $sess_table_name = ''; + protected $sess_expiration = 7200; + protected $sess_expire_on_close = FALSE; + protected $sess_match_ip = FALSE; + protected $sess_match_useragent = TRUE; + protected $sess_cookie_name = 'ci_session'; + protected $cookie_prefix = ''; + protected $cookie_path = ''; + protected $cookie_domain = ''; + protected $sess_time_to_update = 300; + protected $encryption_key = ''; + protected $time_reference = 'time'; + protected $userdata = array(); + protected $CI = null; + protected $now = 0; const gc_probability = 5; @@ -224,10 +224,10 @@ class CI_Session_cookie extends CI_Session_driver { /** * Fetch the current session data if it exists * - * @access private + * @access protected * @return bool */ - private function _sess_read() + protected function _sess_read() { // Fetch the cookie $session = $this->CI->input->cookie($this->sess_cookie_name); @@ -343,10 +343,10 @@ class CI_Session_cookie extends CI_Session_driver { /** * Create a new session * - * @access private + * @access protected * @return void */ - private function _sess_create() + protected function _sess_create() { $sessid = ''; while (strlen($sessid) < 32) @@ -376,11 +376,11 @@ class CI_Session_cookie extends CI_Session_driver { /** * Update an existing session * - * @access private + * @access protected * @param boolean Force update flag (default: false) * @return void */ - private function _sess_update($force = false) + protected function _sess_update($force = false) { // We only update the session every five minutes by default (unless forced) if (!$force && ($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now()) @@ -433,10 +433,10 @@ class CI_Session_cookie extends CI_Session_driver { /** * Get the "now" time * - * @access private + * @access protected * @return int */ - private function _get_time() + protected function _get_time() { if (strtolower($this->time_reference) == 'gmt') { @@ -455,11 +455,11 @@ class CI_Session_cookie extends CI_Session_driver { /** * Write the session cookie * - * @access private + * @access protected * @param array Cookie name/value pairs * @return void */ - private function _set_cookie(array $cookie_data = NULL) + protected function _set_cookie(array $cookie_data = NULL) { if (is_null($cookie_data)) { @@ -491,11 +491,11 @@ class CI_Session_cookie extends CI_Session_driver { * This function first converts any slashes found in the array to a temporary * marker, so when it gets unserialized the slashes will be preserved * - * @access private + * @access protected * @param mixed Data to serialize * @return string */ - private function _serialize($data) + protected function _serialize($data) { if (is_array($data)) { @@ -524,11 +524,11 @@ class CI_Session_cookie extends CI_Session_driver { * This function unserializes a data string, then converts any * temporary slash markers back to actual slashes * - * @access private + * @access protected * @param string Data to unserialize * @return mixed */ - private function _unserialize($data) + protected function _unserialize($data) { $data = @unserialize(strip_slashes($data)); @@ -554,10 +554,10 @@ class CI_Session_cookie extends CI_Session_driver { * This deletes expired session rows from database * if the probability percentage is met * - * @access private + * @access protected * @return void */ - private function _sess_gc() + protected function _sess_gc() { if ($this->sess_use_database != TRUE) { diff --git a/system/libraries/Session/drivers/Session_native.php b/system/libraries/Session/drivers/Session_native.php index 37da3445a..c7130b688 100755 --- a/system/libraries/Session/drivers/Session_native.php +++ b/system/libraries/Session/drivers/Session_native.php @@ -5,11 +5,11 @@ * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com - * @since Version 2.0 + * @since Version 2.0 * @filesource */ @@ -22,13 +22,13 @@ * @package CodeIgniter * @subpackage Libraries * @category Sessions - * @author ExpressionEngine Dev Team + * @author ExpressionEngine Dev Team */ class CI_Session_native extends CI_Session_driver { /** * Initialize session driver object * - * @access protected + * @access protected * @return void */ protected function initialize() @@ -126,8 +126,8 @@ class CI_Session_native extends CI_Session_driver { /** * Save the session data * - * @access public - * @return void + * @access public + * @return void */ public function sess_save() { @@ -137,8 +137,8 @@ class CI_Session_native extends CI_Session_driver { /** * Destroy the current session * - * @access public - * @return void + * @access public + * @return void */ public function sess_destroy() { @@ -160,9 +160,9 @@ class CI_Session_native extends CI_Session_driver { * * Regenerate the session id * - * @access public - * @param boolean Destroy session data flag (default: false) - * @return void + * @access public + * @param boolean Destroy session data flag (default: false) + * @return void */ public function sess_regenerate($destroy = false) { @@ -173,8 +173,8 @@ class CI_Session_native extends CI_Session_driver { /** * Get a reference to user data array * - * @access public - * @return array Reference to userdata + * @access public + * @return array Reference to userdata */ public function &get_userdata() { -- cgit v1.2.3-24-g4f1b 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[] = "\"".$smileys[$key][3]."\""; - $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 = ''; // 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 2139ecdbe882dee32f60de5aec74ec2b8a509b7a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 11 Jan 2012 23:58:50 +0200 Subject: Added date_range() to the Date helper --- system/helpers/date_helper.php | 166 +++++++++++++++++++++++++- user_guide_src/source/changelog.rst | 3 +- user_guide_src/source/helpers/date_helper.rst | 24 ++++ 3 files changed, 191 insertions(+), 2 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 9e58d8630..4a0791a43 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -695,5 +695,169 @@ if ( ! function_exists('timezones')) } } +// ------------------------------------------------------------------------ + +/** + * Date range + * + * Returns a list of dates within a specified period. + * + * @access public + * @param int unix_start UNIX timestamp of period start date + * @param int unix_end|days UNIX timestamp of period end date + * or interval in days. + * @param mixed is_unix Specifies wether the second @param + * is a UNIX timestamp or day interval + * - TRUE or 'unix' for a timestamp + * - FALSE or 'days' for an interval + * @param string date_format Output date format, same as in date() + * @return array + */ +if ( ! function_exists('date_range')) +{ + function date_range($unix_start = '', $mixed = '', $is_unix = TRUE, $format = 'Y-m-d') + { + if ($unix_start == '' OR $mixed == '' OR $format == '') + { + return FALSE; + } + + $is_unix = ! ( ! $is_unix OR $is_unix === 'days'); + + // Validate input and try strtotime() on invalid timestamps/intervals, just in case + if ( ( ! preg_match('/^[0-9]+$/', $unix_start) && ($unix_start = @strtotime($unix_time)) === FALSE) + OR ( ! preg_match('/^[0-9]+$/', $mixed) && ($is_unix === FALSE OR ($mixed = @strtotime($mixed)) === FALSE)) + OR ($is_unix === TRUE && $mixed < $unix_start)) + { + return FALSE; + } + + if ($is_unix && ($unix_start == $mixed OR date($format, $unix_start) === date($format, $mixed))) + { + return array($start_date); + } + + $range = array(); + + if (is_php('5.2')) + { + /* NOTE: Even though the DateTime object has many useful features, it appears that + * it doesn't always handle properly timezones, when timestamps are passed + * directly to its constructor. Neither of the following gave proper results: + * + * new DateTime('') + * new DateTime('', '') + * + * --- available in PHP 5.3: + * + * DateTime::createFromFormat('', '') + * DateTime::createFromFormat('', '', 'setTimestamp($unix_start); + if ($is_unix) + { + $arg = new DateTime(); + $arg->setTimestamp($mixed); + } + else + { + $arg = (int) $mixed; + } + $period = new DatePeriod($from, new DateInterval('P1D'), $arg); + $range = array(); + foreach ($period as $date) + { + $range[] = $date->format($format); + } + + /* If a period end date was passed to the DatePeriod constructor, it might not + * be in our results. Not sure if this is a bug or it's just possible because + * the end date might actually be less than 24 hours away from the previously + * generated DateTime object, but either way - we have to append it manually. + */ + if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format)) + { + $range[] = $arg->format($format); + } + + return $range; + } + + $from->setDate(date('Y', $unix_start), date('n', $unix_start), date('j', $unix_start)); + $from->setTime(date('G', $unix_start), date('i', $unix_start), date('s', $unix_start)); + if ($is_unix) + { + $arg = new DateTime(); + $arg->setDate(date('Y', $mixed), date('n', $mixed), date('j', $mixed)); + $arg->setTime(date('G', $mixed), date('i', $mixed), date('s', $mixed)); + } + else + { + $arg = (int) $mixed; + } + $range[] = $from->format($format); + + if (is_int($arg)) // Day intervals + { + do + { + $from->modify('+1 day'); + $range[] = $from->format($format); + } + while (--$arg > 0); + } + else // end date UNIX timestamp + { + for ($from->modify('+1 day'), $end_check = $arg->format('Ymd'); $from->format('Ymd') < $end_check; $from->modify('+1 day')) + { + $range[] = $from->format($format); + } + + // Our loop only appended dates prior to our end date + $range[] = $arg->format($format); + } + + return $range; + } + + /* ---------------------------------------------------------------------------------- + * PHP Version is < 5.2. We have no other option, but to calculate manually ... + * + * NOTE: If we do something like this: + * + * $unix_timestamp + 86400 + * + * ... due to DST, there's a possibility of calculation errors and/or incorrect + * hours generated (if the specified format displays such data) due to DST. + */ + + $from = $to = array(); + sscanf(date('Y-n-j G:i:s', $unix_start), '%d-%d-%d %d:%d:%d', $from['y'], $from['mo'], $from['d'], $from['h'], $from['mi'], $from['s']); + + // If we don't have the end timestamp, let mktime() calculate it + $unix_end = ($is_unix) ? (int) $mixed : mktime($from['h'], $from['mi'], $from['s'], $from['mo'], $from['d'] + $mixed, $from['y']); + + $end_check = date('Ymd', $unix_end); + while (date('Ymd', $unix_start = mktime($from['h'], $from['mi'], $from['s'], $from['mo'], $from['d'], $from['y'])) !== $end_check) + { + $range[] = date($format, $unix_start); + $from['d']++; + } + + // Our loop only appended dates prior to our end date + $range[] = date($format, $unix_end); + + return $range; + } +} + /* End of file date_helper.php */ -/* Location: ./system/helpers/date_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/date_helper.php */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 48011f208..613ef7881 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -38,7 +38,8 @@ Release Date: Not Released - url_title() will now trim extra dashes from beginning and end. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. - - Changed humanize to include a second param for the separator. + - Changed humanize() to include a second param for the separator. + - Added date_range() to the :doc:`Date Helper `. - Database diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index ad06dd628..f965e6166 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -296,6 +296,30 @@ Example If the second parameter is empty, the current year will be used. +date_range() +============ + +Returns a list of dates within a specified period. + +.. php:method:: date_range($unix_start = '', $mixed = '', $is_unix = TRUE, $format = 'Y-m-d') + + :param integer $unix_start: UNIX timestamp of the range start date + :param integer $mixed: UNIX timestamp of the range end date or interval in days + :param boolean $is_unix: set to FALSE if $mixed is not a timestamp + :param string $format: output date format, same as in date() + :returns: array + +Example + +:: + + $range = date_range('2012-01-01', '2012-01-15'); + echo "First 15 days of 2012:"; + foreach ($range as $date) + { + echo $date."\n"; + } + timezones() =========== -- cgit v1.2.3-24-g4f1b From 4f553dfe20a3dcb2d384fe30210d85cf4f645de2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 15 Jan 2012 15:03:02 +0200 Subject: Remove a space :) --- system/helpers/date_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 4a0791a43..7bec8079d 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -745,7 +745,7 @@ if ( ! function_exists('date_range')) * it doesn't always handle properly timezones, when timestamps are passed * directly to its constructor. Neither of the following gave proper results: * - * new DateTime('') + * new DateTime('') * new DateTime('', '') * * --- available in PHP 5.3: -- 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[] = "\"".$smileys[$key][3]."\""; + $link[] = ''.$smileys[$key][3].''; $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, "\"".$smileys[$key][3]."\"", $str); + $str = str_replace($key, ''.$smileys[$key][3].'', $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 1e8be299b1c0f6385fb0536a6983147bd8ac029e Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Sat, 21 Jan 2012 12:25:08 +0100 Subject: Added redis cache driver. --- application/controllers/test_redis.php | 43 +++++ system/libraries/Cache/Cache.php | 2 +- system/libraries/Cache/drivers/Cache_redis.php | 217 +++++++++++++++++++++++++ 3 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 application/controllers/test_redis.php create mode 100644 system/libraries/Cache/drivers/Cache_redis.php diff --git a/application/controllers/test_redis.php b/application/controllers/test_redis.php new file mode 100644 index 000000000..b84c652d7 --- /dev/null +++ b/application/controllers/test_redis.php @@ -0,0 +1,43 @@ +load->library('unit_test'); + + $this->load->driver('cache', array('adapter' => 'redis')); + } + + function index() + { + $this->unit->run($this->cache->redis->is_supported(), 'is_true'); + + $this->unit->run($this->cache->redis->save('foo', 'bar'), 'is_true'); + + $this->unit->run($this->cache->redis->get('foo'), 'bar'); + + $this->unit->run($this->cache->redis->delete('foo'), 'is_true'); + + $this->unit->run($this->cache->redis->save('foo', 'bar', 1800), 'is_true'); + + $this->unit->run( + $this->cache->redis->get_metadata('foo'), + array( + 'data' => 'bar', + 'expire' => time() + 1800 + ) + ); + + $this->unit->run($this->cache->redis->clean(), 'is_true'); + + $this->unit->run($this->cache->redis->get('foo'), 'is_false'); + + $this->unit->run($this->cache->redis->cache_info(), 'is_array'); + + echo $this->unit->report(); + } + +} \ No newline at end of file diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 2e78a6660..25555506c 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -39,7 +39,7 @@ class CI_Cache extends CI_Driver_Library { protected $valid_drivers = array( - 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy' + 'cache_apc', 'cache_file', 'cache_memcached', 'cache_redis', 'cache_dummy' ); protected $_cache_path = NULL; // Path of cache files (if file-based cache) diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php new file mode 100644 index 000000000..9eb7a8d4e --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -0,0 +1,217 @@ + + * @link + */ +class CI_Cache_redis extends CI_Driver +{ + + /** + * Default config + * + * @access private + * @static + * @var array + */ + private static $_default_config = array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'timeout' => 0 + ); + + /** + * Redis connection + * + * @access private + * @var Redis + */ + private $_redis; + + /** + * Class destructor + * + * Closes the connection to Redis if present. + * + * @access public + * @return void + */ + public function __destruct() + { + if ($this->_redis) + { + $this->_redis->close(); + } + } + + /** + * Get cache + * + * @access public + * @param string $key Cache key identifier + * @return mixed + */ + public function get($key) + { + return $this->_redis->get($key); + } + + /** + * Save cache + * + * @access public + * @param string $key Cache key identifier + * @param mixed $value Data to save + * @param integer $ttl Time to live + * @return boolean + */ + public function save($key, $value, $ttl = NULL) + { + return ($ttl) + ? $this->_redis->setex($key, $ttl, $value) + : $this->_redis->set($key, $value); + } + + /** + * Delete from cache + * + * @access public + * @param string $key Cache key + * @return boolean + */ + public function delete($key) + { + return ($this->_redis->delete($key) === 1); + } + + /** + * Clean cache + * + * @access public + * @return boolean + * @see Redis::flushDB() + */ + public function clean() + { + return $this->_redis->flushDB(); + } + + /** + * Get cache driver info + * + * @access public + * @param string $type Not supported in Redis. Only included in order to offer a + * consistent cache API. + * @return array + * @see Redis::info() + */ + public function cache_info($type = NULL) + { + return $this->_redis->info(); + } + + /** + * Get cache metadata + * + * @access public + * @param string $key Cache key + * @return array + */ + public function get_metadata($key) + { + $value = $this->get($key); + + if ($value) + { + return array( + 'expire' => time() + $this->_redis->ttl($key), + 'data' => $value + ); + } + } + + /** + * Check if Redis driver is supported + * + * @access public + * @return boolean + */ + public function is_supported() + { + if (extension_loaded('redis')) + { + $this->_setup_redis(); + + return TRUE; + } + else + { + log_message( + 'error', + 'The Redis extension must be loaded to use Redis cache.' + ); + + return FALSE; + } + + } + + /** + * Setup Redis config and connection + * + * Loads Redis config file if present. Will halt execution if a Redis connection + * can't be established. + * + * @access private + * @return void + * @see Redis::connect() + */ + private function _setup_redis() + { + $config = array(); + $CI =& get_instance(); + + if ($CI->config->load('redis', TRUE, TRUE)) + { + $config += $CI->config->item('redis'); + } + + $config = array_merge(self::$_default_config, $config); + + $this->_redis = new Redis(); + + try + { + $this->_redis->connect($config['host'], $config['port'], $config['timeout']); + } + catch (RedisException $e) + { + show_error('Redis connection refused. ' . $e->getMessage()); + } + } + +} +// End Class + +/* End of file Cache_redis.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_redis.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3573af8b98ceeb2308a1eaf02ee3b327dfca82b0 Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Sat, 21 Jan 2012 20:33:12 +0100 Subject: Fixed syntax according to feedback. --- system/libraries/Cache/drivers/Cache_redis.php | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 9eb7a8d4e..f3acc6e46 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -30,11 +30,10 @@ class CI_Cache_redis extends CI_Driver /** * Default config * - * @access private * @static * @var array */ - private static $_default_config = array( + protected static $_default_config = array( 'host' => '127.0.0.1', 'port' => 6379, 'timeout' => 0 @@ -43,17 +42,15 @@ class CI_Cache_redis extends CI_Driver /** * Redis connection * - * @access private * @var Redis */ - private $_redis; + protected $_redis; /** * Class destructor * * Closes the connection to Redis if present. * - * @access public * @return void */ public function __destruct() @@ -67,7 +64,6 @@ class CI_Cache_redis extends CI_Driver /** * Get cache * - * @access public * @param string $key Cache key identifier * @return mixed */ @@ -79,7 +75,6 @@ class CI_Cache_redis extends CI_Driver /** * Save cache * - * @access public * @param string $key Cache key identifier * @param mixed $value Data to save * @param integer $ttl Time to live @@ -95,7 +90,6 @@ class CI_Cache_redis extends CI_Driver /** * Delete from cache * - * @access public * @param string $key Cache key * @return boolean */ @@ -107,7 +101,6 @@ class CI_Cache_redis extends CI_Driver /** * Clean cache * - * @access public * @return boolean * @see Redis::flushDB() */ @@ -119,7 +112,6 @@ class CI_Cache_redis extends CI_Driver /** * Get cache driver info * - * @access public * @param string $type Not supported in Redis. Only included in order to offer a * consistent cache API. * @return array @@ -133,7 +125,6 @@ class CI_Cache_redis extends CI_Driver /** * Get cache metadata * - * @access public * @param string $key Cache key * @return array */ @@ -153,7 +144,6 @@ class CI_Cache_redis extends CI_Driver /** * Check if Redis driver is supported * - * @access public * @return boolean */ public function is_supported() @@ -166,10 +156,7 @@ class CI_Cache_redis extends CI_Driver } else { - log_message( - 'error', - 'The Redis extension must be loaded to use Redis cache.' - ); + log_message('error', 'The Redis extension must be loaded to use Redis cache.'); return FALSE; } @@ -182,7 +169,6 @@ class CI_Cache_redis extends CI_Driver * Loads Redis config file if present. Will halt execution if a Redis connection * can't be established. * - * @access private * @return void * @see Redis::connect() */ -- cgit v1.2.3-24-g4f1b From 363b7dab5d73d3a57fb495daf0212df71afa2c1d Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Mon, 23 Jan 2012 23:18:29 +0100 Subject: Removed test_redis controller. --- application/controllers/test_redis.php | 43 ---------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 application/controllers/test_redis.php diff --git a/application/controllers/test_redis.php b/application/controllers/test_redis.php deleted file mode 100644 index b84c652d7..000000000 --- a/application/controllers/test_redis.php +++ /dev/null @@ -1,43 +0,0 @@ -load->library('unit_test'); - - $this->load->driver('cache', array('adapter' => 'redis')); - } - - function index() - { - $this->unit->run($this->cache->redis->is_supported(), 'is_true'); - - $this->unit->run($this->cache->redis->save('foo', 'bar'), 'is_true'); - - $this->unit->run($this->cache->redis->get('foo'), 'bar'); - - $this->unit->run($this->cache->redis->delete('foo'), 'is_true'); - - $this->unit->run($this->cache->redis->save('foo', 'bar', 1800), 'is_true'); - - $this->unit->run( - $this->cache->redis->get_metadata('foo'), - array( - 'data' => 'bar', - 'expire' => time() + 1800 - ) - ); - - $this->unit->run($this->cache->redis->clean(), 'is_true'); - - $this->unit->run($this->cache->redis->get('foo'), 'is_false'); - - $this->unit->run($this->cache->redis->cache_info(), 'is_array'); - - echo $this->unit->report(); - } - -} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 5a1d953e8a492326b8e8cbd0473b1593fe42cfa6 Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Mon, 23 Jan 2012 23:20:26 +0100 Subject: Updated redis driver doc block. --- system/libraries/Cache/drivers/Cache_redis.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index f3acc6e46..5d42905cb 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -4,12 +4,24 @@ * * An open source application development framework for PHP 5.1.6 or newer * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 2.0 + * NOTICE OF LICENSE + * + * 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 + * 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 + * through the world wide web, please send an email to + * licensing@ellislab.com so we can send you a copy immediately. + * + * @package CodeIgniter + * @author EllisLab Dev Team + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * @link http://codeigniter.com + * @since Version 2.0 * @filesource */ -- 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 c8efb8033ae775a5c1c840f867def4e6253b3d9a Mon Sep 17 00:00:00 2001 From: "Thor (atiredmachine)" Date: Tue, 24 Jan 2012 13:33:39 -0800 Subject: Output class now sets HTTP headers match caching settings. --- system/core/Output.php | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index abd8a0ea9..1f214a0b3 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -466,6 +466,9 @@ class CI_Output { @chmod($cache_path, FILE_WRITE_MODE); log_message('debug', 'Cache file written: '.$cache_path); + + // Send HTTP cache-control headers to browser to match file cache settings. + $this->set_cache_header($_SERVER['REQUEST_TIME'],$expire); } // -------------------------------------------------------------------- @@ -503,13 +506,22 @@ class CI_Output { return FALSE; } - // Has the file expired? If so we'll delete it. - if (time() >= trim(str_replace('TS--->', '', $match[1])) && is_really_writable($cache_path)) + $last_modified = filemtime($cache_path); + $expire = trim(str_replace('TS--->', '', $match[1])); + + // Has the file expired? + if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path)) { + // If so we'll delete it. @unlink($filepath); log_message('debug', 'Cache file has expired. File deleted.'); return FALSE; } + else + { + // Or else send the HTTP cache control headers. + $this->set_cache_header($last_modified,$expire); + } // Display the cache $this->_display(str_replace($match[0], '', $cache)); @@ -517,6 +529,35 @@ class CI_Output { return TRUE; } + + // -------------------------------------------------------------------- + /** + * Set the HTTP headers to match the server-side file cache settings + * in order to reduce bandwidth. + * + * @param int timestamp of when the page was last modified + * @param int timestamp of when should the requested page expire from cache + * @return void + */ + public function set_cache_header($last_modified,$expiration) + { + $max_age = $expiration - $_SERVER['REQUEST_TIME']; + + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']))) + { + $this->set_status_header(304); + exit; + } + else + { + header('Pragma: public'); + header('Cache-Control: max-age=' . $max_age . ', public'); + header('Expires: '.gmdate('D, d M Y H:i:s', $expiration).' GMT'); + header('Last-modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT'); + } + } + + } /* End of file Output.php */ -- cgit v1.2.3-24-g4f1b From 63678a27864fdd6bb0ed89e6940a1d331121072a Mon Sep 17 00:00:00 2001 From: "Thor (atiredmachine)" Date: Tue, 24 Jan 2012 16:56:01 -0800 Subject: Rudimentary minifying of output. --- application/config/config.php | 13 +++++++++++++ system/core/Output.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/application/config/config.php b/application/config/config.php index 17b854b29..3231f1d19 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -355,6 +355,18 @@ $config['csrf_exclude_uris'] = array(); */ $config['compress_output'] = FALSE; +/* +|-------------------------------------------------------------------------- +| Minify +|-------------------------------------------------------------------------- +| +| Removes extra characters (usually unnecessary spaces) from your +| output for faster page load speeds. Makes your outputted HTML source +| code less readable. +| +*/ +$config['minify_output'] = FALSE; + /* |-------------------------------------------------------------------------- | Master Time Reference @@ -396,5 +408,6 @@ $config['rewrite_short_tags'] = FALSE; $config['proxy_ips'] = ''; + /* End of file config.php */ /* Location: ./application/config/config.php */ diff --git a/system/core/Output.php b/system/core/Output.php index 1f214a0b3..55a505c34 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -323,6 +323,15 @@ class CI_Output { { $output =& $this->final_output; } + + // -------------------------------------------------------------------- + + // Is minify requested? + if ($CFG->item('minify_output') === TRUE) + { + $output = $this->minify($output); + } + // -------------------------------------------------------------------- @@ -558,6 +567,33 @@ class CI_Output { } + + + // -------------------------------------------------------------------- + /** + * Reduce excessive size of HTML content. + * + * @param string + * @param string + * @return string + */ + public function minify($output,$type='html') + { + switch ($type) + { + case 'html': + + // Replaces multiple spaces with a single space. + $output = preg_replace('!\s{2,}!',' ',$output); + + // ... + break; + } + + return $output; + } + + } /* End of file Output.php */ -- cgit v1.2.3-24-g4f1b From 79db4cdba1a1a80634cd76ab8fc69fce7b1a7ea6 Mon Sep 17 00:00:00 2001 From: "Thor (atiredmachine)" Date: Tue, 24 Jan 2012 20:44:51 -0800 Subject: Improved minifier to restore
 contents, remove even more spaces,
 and process CSS with its own rules.

---
 system/core/Output.php | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/system/core/Output.php b/system/core/Output.php
index 55a505c34..bb39a7f31 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -582,12 +582,45 @@ class CI_Output {
 		switch ($type)
 		{
 			case 'html':
+			
+				// Keep track of 
 tags as they were before processing.
+				// We'll want to return them to this state later.
+				preg_match_all('{}msU',$output,$pres_clean);
+
+				// Keep track of 
 tags as they were before processing.
+				// We'll want to return them to this state later.
+				preg_match_all('{}msU',$output,$style_clean);
 				
+				// Run }msU',$output,$style_clean);
-				
-				// Run }msU',$output,$style_clean);
 				foreach ($style_clean[0] as $s)
 				{
-					$output = str_replace($s, $this->minify($s,'css'), $output);
+					$output = str_replace($s, $this->minify($s,'text/css'), $output);
 				}
 
 				// Replace multiple spaces with a single space.
@@ -614,7 +614,7 @@ class CI_Output {
 			break;
 			
 			
-			case 'css':
+			case 'text/css':
 			
 				// Remove spaces around curly brackets, colons, and semi-colons
 				$output = preg_replace('!\s*(:|;|}|{)\s*!','$1',$output);
-- 
cgit v1.2.3-24-g4f1b


From 5de117549f69465a1ce0f2e128428d9adadd8a6d Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Tue, 24 Jan 2012 22:08:36 -0800
Subject: Strips out HTML comments.

---
 system/core/Output.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/system/core/Output.php b/system/core/Output.php
index 47c00acd8..8992fc1f1 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -600,6 +600,9 @@ class CI_Output {
 				// Replace multiple spaces with a single space.
 				$output = preg_replace('!\s{2,}!',"\n",$output);
 				
+				// Remove comments (non-MSIE conditionals)
+				$output = preg_replace('{\s*\s*}msU','',$output);
+
 				// Remove spaces around block-level elements.
 				$output = preg_replace('{\s*()\s*}', '$1', $output);
 
-- 
cgit v1.2.3-24-g4f1b


From f59ec6fe4fab3bd5ff71d920e13f983454a9fb65 Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Tue, 24 Jan 2012 22:19:14 -0800
Subject: Logs 'debug' message that shows how much % was shaved off.

---
 system/core/Output.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/system/core/Output.php b/system/core/Output.php
index 8992fc1f1..c95f551ec 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -582,7 +582,9 @@ class CI_Output {
 		switch ($type)
 		{
 			case 'text/html':
-			
+
+				$size_before = strlen($output);
+
 				// Keep track of 
  and }msU',$output,$textareas_clean);
+				preg_match_all('{}msU', $output, $pres_clean);
+				preg_match_all('{}msU', $output, $codes_clean);
+				preg_match_all('{}msU', $output, $textareas_clean);
 
 				// Minify the CSS in all the }msU',$output,$style_clean);
+				preg_match_all('{}msU', $output, $style_clean);
 				foreach ($style_clean[0] as $s)
 				{
 					$output = str_replace($s, $this->minify($s,'text/css'), $output);
 				}
 
 				// Replace multiple spaces with a single space.
-				$output = preg_replace('!\s{2,}!',"\n",$output);
+				$output = preg_replace('!\s{2,}!', "\n", $output);
 				
 				// Remove comments (non-MSIE conditionals)
-				$output = preg_replace('{\s*\s*}msU','',$output);
+				$output = preg_replace('{\s*\s*}msU', '', $output);
 
 				// Remove spaces around block-level elements.
 				$output = preg_replace('{\s*()\s*}', '$1', $output);
 
 				// Replace mangled 
 etc. tags with unprocessed ones.
-				preg_match_all('{}msU',$output,$pres_messed);
-				preg_match_all('{}msU',$output,$codes_messed);
-				preg_match_all('{}msU',$output,$textareas_messed);
-				$output = str_replace($pres_messed[0],$pres_clean[0],$output);
-				$output = str_replace($codes_messed[0],$codes_clean[0],$output);
-				$output = str_replace($textareas_messed[0],$textareas_clean[0],$output);
+				preg_match_all('{}msU', $output, $pres_messed);
+				preg_match_all('{}msU', $output, $codes_messed);
+				preg_match_all('{}msU', $output, $textareas_messed);
+				$output = str_replace($pres_messed[0], $pres_clean[0], $output);
+				$output = str_replace($codes_messed[0], $codes_clean[0], $output);
+				$output = str_replace($textareas_messed[0], $textareas_clean[0], $output);
 				
 				$size_after = strlen($output);
 				$savings_percent = round(100 - ($size_after / $size_before * 100));
@@ -640,10 +635,10 @@ class CI_Output {
 			case 'text/css':
 			
 				// Remove spaces around curly brackets, colons, and semi-colons
-				$output = preg_replace('!\s*(:|;|}|{)\s*!','$1',$output);
+				$output = preg_replace('!\s*(:|;|}|{)\s*!', '$1', $output);
 				
 				// Replace spaces with line breaks to limit line lengths
-				$output = preg_replace('!\s+!',"\n",$output);
+				$output = preg_replace('!\s+!', "\n", $output);
 
 			break;
 		}
-- 
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 7f55d6133b70346a428ae481d1fe57bf4d4d2320 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 13:44:28 +0200
Subject: Improve the CUBRID database driver

---
 system/database/drivers/cubrid/cubrid_driver.php  | 284 ++++++++--------------
 system/database/drivers/cubrid/cubrid_forge.php   | 136 ++++-------
 system/database/drivers/cubrid/cubrid_result.php  |  68 ++----
 system/database/drivers/cubrid/cubrid_utility.php |  35 +--
 4 files changed, 183 insertions(+), 340 deletions(-)

diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index cde719eae..1cfaf3e42 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -1,13 +1,13 @@
-port == '')
 		{
-			$this->port = self::DEFAULT_PORT;
+			// Default CUBRID broker port
+			$this->port = 33000;
 		}
+	}
 
+	/**
+	 * Non-persistent database connection
+	 *
+	 * @return	resource
+	 */
+	public function db_connect()
+	{
 		$conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password);
 
 		if ($conn)
@@ -112,7 +109,7 @@ class CI_DB_cubrid_driver extends CI_DB {
 	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_pconnect()
+	public function db_pconnect()
 	{
 		return $this->db_connect();
 	}
@@ -125,10 +122,9 @@ class CI_DB_cubrid_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()
 	{
 		if (cubrid_ping($this->conn_id) === FALSE)
 		{
@@ -141,10 +137,9 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * Select the database
 	 *
-	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_select()
+	public function db_select()
 	{
 		// In CUBRID there is no need to select a database as the database
 		// is chosen at the connection time.
@@ -158,12 +153,11 @@ class CI_DB_cubrid_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)
 	{
 		// In CUBRID, there is no need to set charset or collation.
 		// This is why returning true will allow the application continue
@@ -176,16 +170,10 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * Version number query string
 	 *
-	 * @access	public
 	 * @return	string
 	 */
-	function _version()
+	protected function _version()
 	{
-		// To obtain the CUBRID Server version, no need to run the SQL query.
-		// CUBRID PHP API provides a function to determin this value.
-		// This is why we also need to add 'cubrid' value to the list of
-		// $driver_version_exceptions array in DB_driver class in
-		// version() function.
 		return cubrid_get_server_info($this->conn_id);
 	}
 
@@ -194,11 +182,10 @@ class CI_DB_cubrid_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 @cubrid_query($sql, $this->conn_id);
@@ -211,11 +198,10 @@ class CI_DB_cubrid_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)
 	{
 		// No need to prepare
 		return $sql;
@@ -226,18 +212,12 @@ class CI_DB_cubrid_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;
 		}
@@ -245,7 +225,7 @@ class CI_DB_cubrid_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);
 
 		if (cubrid_get_autocommit($this->conn_id))
 		{
@@ -260,18 +240,12 @@ class CI_DB_cubrid_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;
 		}
@@ -291,18 +265,12 @@ class CI_DB_cubrid_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;
 		}
@@ -322,12 +290,11 @@ class CI_DB_cubrid_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))
 		{
@@ -339,7 +306,7 @@ class CI_DB_cubrid_driver extends CI_DB {
 			return $str;
 		}
 
-		if (function_exists('cubrid_real_escape_string') AND is_resource($this->conn_id))
+		if (function_exists('cubrid_real_escape_string') && is_resource($this->conn_id))
 		{
 			$str = cubrid_real_escape_string($str, $this->conn_id);
 		}
@@ -351,7 +318,7 @@ class CI_DB_cubrid_driver extends CI_DB {
 		// escape LIKE condition wildcards
 		if ($like === TRUE)
 		{
-			$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
+			return str_replace(array('%', '_'), array('\\%', '\\_'), $str);
 		}
 
 		return $str;
@@ -362,10 +329,9 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * Affected Rows
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function affected_rows()
+	public function affected_rows()
 	{
 		return @cubrid_affected_rows($this->conn_id);
 	}
@@ -375,10 +341,9 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * Insert ID
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function insert_id()
+	public function insert_id()
 	{
 		return @cubrid_insert_id($this->conn_id);
 	}
@@ -391,27 +356,24 @@ class CI_DB_cubrid_driver extends CI_DB {
 	 * Generates a platform-specific query string that counts all records in
 	 * the specified table
 	 *
-	 * @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;
 	}
 
 	// --------------------------------------------------------------------
@@ -421,17 +383,16 @@ class CI_DB_cubrid_driver extends CI_DB {
 	 *
 	 * Generates a platform-specific query string so that the table names can be fetched
 	 *
-	 * @access	private
 	 * @param	boolean
 	 * @return	string
 	 */
-	function _list_tables($prefix_limit = FALSE)
+	protected function _list_tables($prefix_limit = FALSE)
 	{
-		$sql = "SHOW TABLES";
+		$sql = 'SHOW TABLES';
 
-		if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+		if ($prefix_limit !== FALSE && $this->dbprefix != '')
 		{
-			$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
+			return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
 		}
 
 		return $sql;
@@ -444,13 +405,12 @@ class CI_DB_cubrid_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
 	 */
-	function _list_columns($table = '')
+	protected function _list_columns($table = '')
 	{
-		return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
+		return 'SHOW COLUMNS FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE);
 	}
 
 	// --------------------------------------------------------------------
@@ -460,13 +420,12 @@ class CI_DB_cubrid_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';
 	}
 
 	// --------------------------------------------------------------------
@@ -474,10 +433,9 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * The error message string
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _error_message()
+	protected function _error_message()
 	{
 		return cubrid_error($this->conn_id);
 	}
@@ -487,10 +445,9 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * The error message number
 	 *
-	 * @access	private
-	 * @return	integer
+	 * @return	int
 	 */
-	function _error_number()
+	protected function _error_number()
 	{
 		return cubrid_errno($this->conn_id);
 	}
@@ -502,11 +459,10 @@ class CI_DB_cubrid_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 == '')
 		{
@@ -517,24 +473,20 @@ class CI_DB_cubrid_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -545,11 +497,10 @@ class CI_DB_cubrid_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	string	the table name
+	 * @return	string
 	 */
-	function _from_tables($tables)
+	protected function _from_tables($tables)
 	{
 		if ( ! is_array($tables))
 		{
@@ -566,15 +517,14 @@ class CI_DB_cubrid_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).')';
 	}
 
 	// --------------------------------------------------------------------
@@ -585,15 +535,14 @@ class CI_DB_cubrid_driver extends CI_DB {
 	 *
 	 * Generates a platform-specific replace 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 _replace($table, $keys, $values)
+	protected function _replace($table, $keys, $values)
 	{
-		return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
+		return 'REPLACE INTO '.$table.' ("'.implode('", "', $keys).'") VALUES ('.implode(', ', $values).')';
 	}
 
 	// --------------------------------------------------------------------
@@ -603,26 +552,23 @@ class CI_DB_cubrid_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_batch($table, $keys, $values)
+	protected function _insert_batch($table, $keys, $values)
 	{
-		return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values);
+		return 'INSERT INTO '.$table.' ("'.implode('", "', $keys).'") VALUES '.implode(', ', $values);
 	}
 
 	// --------------------------------------------------------------------
 
-
 	/**
 	 * Update statement
 	 *
 	 * 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
@@ -630,24 +576,17 @@ class CI_DB_cubrid_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[] = sprintf('"%s" = %s', $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);
 	}
 
 	// --------------------------------------------------------------------
@@ -658,16 +597,15 @@ class CI_DB_cubrid_driver extends CI_DB {
 	 *
 	 * Generates a platform-specific batch update string from the supplied data
 	 *
-	 * @access	public
 	 * @param	string	the table name
 	 * @param	array	the update data
 	 * @param	array	the where clause
 	 * @return	string
 	 */
-	function _update_batch($table, $values, $index, $where = NULL)
+	protected function _update_batch($table, $values, $index, $where = NULL)
 	{
 		$ids = array();
-		$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
+		$where = ($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '';
 
 		foreach ($values as $key => $val)
 		{
@@ -682,30 +620,23 @@ class CI_DB_cubrid_driver extends CI_DB {
 			}
 		}
 
-		$sql = "UPDATE ".$table." SET ";
+		$sql = 'UPDATE '.$table.' SET ';
 		$cases = '';
 
 		foreach ($final as $k => $v)
 		{
-			$cases .= $k.' = CASE '."\n";
-			foreach ($v as $row)
-			{
-				$cases .= $row."\n";
-			}
-
-			$cases .= 'ELSE '.$k.' END, ';
+			$cases .= $k." = CASE \n"
+				.implode("\n", $v)
+				.'ELSE '.$k.' END, ';
 		}
 
-		$sql .= substr($cases, 0, -2);
-
-		$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
-
-		return $sql;
+		return $sql.substr($cases, 0, -2)
+			.' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '')
+			.$index.' IN ('.implode(',', $ids).')';
 	}
 
 	// --------------------------------------------------------------------
 
-
 	/**
 	 * Truncate statement
 	 *
@@ -713,13 +644,12 @@ class CI_DB_cubrid_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;
 	}
 
 	// --------------------------------------------------------------------
@@ -729,31 +659,27 @@ class CI_DB_cubrid_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -763,24 +689,14 @@ class CI_DB_cubrid_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;
 	}
 
 	// --------------------------------------------------------------------
@@ -788,17 +704,15 @@ class CI_DB_cubrid_driver extends CI_DB {
 	/**
 	 * Close DB Connection
 	 *
-	 * @access	public
 	 * @param	resource
 	 * @return	void
 	 */
-	function _close($conn_id)
+	protected function _close($conn_id)
 	{
 		@cubrid_close($conn_id);
 	}
 
 }
 
-
 /* End of file cubrid_driver.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 85e740057..ce5aa2098 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -1,13 +1,13 @@
-$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) . "\"";
-
-				if (array_key_exists('NAME', $attributes))
-				{
-					$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
-				}
+				$sql .= "\n\t\"".$this->db->protect_identifiers($field).'"'
+					.(array_key_exists('NAME', $attributes) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '');
 
 				if (array_key_exists('TYPE', $attributes))
 				{
@@ -113,9 +104,8 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 							case 'numeric':
 								$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
 								break;
-							case 'enum': 	// As of version 8.4.0 CUBRID does not support
-											// enum data type.
-											break;
+							case 'enum': // As of version 8.4.0 CUBRID does not support enum data type
+								break;
 							case 'set':
 								$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
 								break;
@@ -125,36 +115,19 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 					}
 				}
 
+			/* As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type.
+			 * Will be supported in the next release as a part of MySQL Compatibility.
+			 *
 				if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
 				{
-					//$sql .= ' UNSIGNED';
-					// As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type.
-					// Will be supported in the next release as a part of MySQL Compatibility.
-				}
-
-				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';
+					$sql .= ' UNSIGNED';
 				}
+			 */
 
-				if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
-				{
-					$sql .= ' AUTO_INCREMENT';
-				}
-
-				if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE)
-				{
-					$sql .= ' UNIQUE';
-				}
+				$sql .= (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' : '')
+					.((array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : '');
 			}
 
 			// don't add a comma on the end of the last field
@@ -172,7 +145,6 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 	/**
 	 * Create Table
 	 *
-	 * @access	private
 	 * @param	string	the table name
 	 * @param	mixed	the fields
 	 * @param	mixed	primary key(s)
@@ -180,28 +152,24 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 	 * @param	boolean	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 ';
 
+		/* As of version 8.4.0 CUBRID does not support this SQL syntax.
 		if ($if_not_exists === TRUE)
 		{
-			//$sql .= 'IF NOT EXISTS ';
-			// As of version 8.4.0 CUBRID does not support this SQL syntax.
+			$sql .= 'IF NOT EXISTS ';
 		}
+		*/
 
-		$sql .= $this->db->_escape_identifiers($table)." (";
-
-		$sql .= $this->_process_fields($fields);
+		$sql .= $this->db->_escape_identifiers($table).' ('.$this->_process_fields($fields);
 
 		// If there is a PK defined
 		if (count($primary_keys) > 0)
 		{
-			$key_name = "pk_" . $table . "_" .
-				$this->db->_protect_identifiers(implode('_', $primary_keys));
-			
-			$primary_keys = $this->db->_protect_identifiers($primary_keys);
-			$sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")";
+			$key_name = 'pk_'.$table.'_'.$this->db->protect_identifiers(implode('_', $primary_keys));
+			$sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->protect_identifiers($primary_keys)).')';
 		}
 
 		if (is_array($keys) && count($keys) > 0)
@@ -210,22 +178,20 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 			{
 				if (is_array($key))
 				{
-					$key_name = $this->db->_protect_identifiers(implode('_', $key));
-					$key = $this->db->_protect_identifiers($key);
+					$key_name = $this->db->protect_identifiers(implode('_', $key));
+					$key = $this->db->protect_identifiers($key);
 				}
 				else
 				{
-					$key_name = $this->db->_protect_identifiers($key);
+					$key_name = $this->db->protect_identifiers($key);
 					$key = array($key_name);
 				}
-				
-				$sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")";
+
+				$sql .= ",\n\tKEY ".$key_name.' ('.implode(', ', $key).')';
 			}
 		}
 
-		$sql .= "\n);";
-
-		return $sql;
+		return $sql."\n);";
 	}
 
 	// --------------------------------------------------------------------
@@ -233,12 +199,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 	/**
 	 * Drop Table
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _drop_table($table)
+	public function _drop_table($table)
 	{
-		return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
+		return 'DROP TABLE IF EXISTS '.$this->db->_escape_identifiers($table);
 	}
 
 	// --------------------------------------------------------------------
@@ -249,31 +214,24 @@ class CI_DB_cubrid_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	array	fields
 	 * @param	string	the field after which we should add the new field
-	 * @return	object
+	 * @return	string
 	 */
-	function _alter_table($alter_type, $table, $fields, $after_field = '')
+	public function _alter_table($alter_type, $table, $fields, $after_field = '')
 	{
-		$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
+		$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
 
 		// DROP has everything it needs now.
-		if ($alter_type == 'DROP')
-		{
-			return $sql.$this->db->_protect_identifiers($fields);
-		}
-
-		$sql .= $this->_process_fields($fields);
-
-		if ($after_field != '')
+		if ($alter_type === 'DROP')
 		{
-			$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+			return $sql.$this->db->protect_identifiers($fields);
 		}
 
-		return $sql;
+		return $sql.$this->_process_fields($fields)
+			.($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : '');
 	}
 
 	// --------------------------------------------------------------------
@@ -283,18 +241,16 @@ class CI_DB_cubrid_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 = 'RENAME TABLE '.$this->db->_protect_identifiers($table_name)." AS ".$this->db->_protect_identifiers($new_table_name);
-		return $sql;
+		return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name);
 	}
 
 }
 
 /* End of file cubrid_forge.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php
index 4c0fede10..7a72cdde4 100644
--- a/system/database/drivers/cubrid/cubrid_result.php
+++ b/system/database/drivers/cubrid/cubrid_result.php
@@ -1,13 +1,13 @@
-result_id);
 	}
@@ -54,10 +51,9 @@ class CI_DB_cubrid_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 @cubrid_num_fields($this->result_id);
 	}
@@ -69,10 +65,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
 	 *
 	 * Generates an array of column names
 	 *
-	 * @access	public
 	 * @return	array
 	 */
-	function list_fields()
+	public function list_fields()
 	{
 		return cubrid_column_names($this->result_id);
 	}
@@ -84,21 +79,18 @@ class CI_DB_cubrid_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();
-
-		$tablePrimaryKeys = array();
+		$retval = $tablePrimaryKeys = array();
 
 		while ($field = cubrid_fetch_field($this->result_id))
 		{
-			$F				= new stdClass();
-			$F->name		= $field->name;
-			$F->type		= $field->type;
-			$F->default		= $field->def;
+			$F		= new stdClass();
+			$F->name	= $field->name;
+			$F->type	= $field->type;
+			$F->default	= $field->def;
 			$F->max_length	= $field->max_length;
 
 			// At this moment primary_key property is not returned when
@@ -115,19 +107,18 @@ class CI_DB_cubrid_result extends CI_DB_result {
 			// The query will search for exact single columns, thus
 			// compound PK is not supported.
 			$res = cubrid_query($this->conn_id,
-				"SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table .
-				"' AND is_primary_key = 'YES' AND index_name = 'pk_" .
-				$field->table . "_" . $field->name . "'"
-			);
+						"SELECT COUNT(*) FROM db_index WHERE class_name = '".$field->table
+						."' AND is_primary_key = 'YES' AND index_name = 'pk_".$field->table.'_'.$field->name."'"
+						);
 
 			if ($res)
 			{
 				$row = cubrid_fetch_array($res, CUBRID_NUM);
-				$F->primary_key = ($row[0] > 0 ? 1 : null);
+				$F->primary_key = ($row[0] > 0 ? 1 : NULL);
 			}
 			else
 			{
-				$F->primary_key = null;
+				$F->primary_key = NULL;
 			}
 
 			if (is_resource($res))
@@ -147,13 +138,12 @@ class CI_DB_cubrid_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) ||
-			get_resource_type($this->result_id) == "Unknown" &&
-			preg_match('/Resource id #/', strval($this->result_id)))
+		if (is_resource($this->result_id) OR
+			(get_resource_type($this->result_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->result_id))))
 		{
 			cubrid_close_request($this->result_id);
 			$this->result_id = FALSE;
@@ -169,10 +159,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
 	 * 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 cubrid_data_seek($this->result_id, $n);
 	}
@@ -184,10 +173,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
 	 *
 	 * Returns the result set as an array
 	 *
-	 * @access	private
 	 * @return	array
 	 */
-	function _fetch_assoc()
+	protected function _fetch_assoc()
 	{
 		return cubrid_fetch_assoc($this->result_id);
 	}
@@ -199,16 +187,14 @@ class CI_DB_cubrid_result extends CI_DB_result {
 	 *
 	 * Returns the result set as an object
 	 *
-	 * @access	private
 	 * @return	object
 	 */
-	function _fetch_object()
+	protected function _fetch_object()
 	{
 		return cubrid_fetch_object($this->result_id);
 	}
 
 }
 
-
 /* End of file cubrid_result.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_result.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_result.php */
diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php
index 750c0d8dd..dbfbe5f6b 100644
--- a/system/database/drivers/cubrid/cubrid_utility.php
+++ b/system/database/drivers/cubrid/cubrid_utility.php
@@ -1,13 +1,13 @@
-conn_id)
-		{
-			return "SELECT '" . $this->database . "'";
-		}
-		else
-		{
-			return FALSE;
-		}
+		return "SELECT '".$this->database."'";
 	}
 
 	// --------------------------------------------------------------------
@@ -66,12 +56,11 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
 	 *
 	 * Generates a platform-specific query so that a table can be optimized
 	 *
-	 * @access	private
 	 * @param	string	the table name
-	 * @return	object
+	 * @return	bool
 	 * @link 	http://www.cubrid.org/manual/840/en/Optimize%20Database
 	 */
-	function _optimize_table($table)
+	public function _optimize_table($table)
 	{
 		// No SQL based support in CUBRID as of version 8.4.0. Database or
 		// table optimization can be performed using CUBRID Manager
@@ -86,12 +75,11 @@ class CI_DB_cubrid_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
 	 * @link 	http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency
 	 */
-	function _repair_table($table)
+	public function _repair_table($table)
 	{
 		// Not supported in CUBRID as of version 8.4.0. Database or
 		// table consistency can be checked using CUBRID Manager
@@ -103,11 +91,10 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
 	/**
 	 * CUBRID Export
 	 *
-	 * @access	private
 	 * @param	array	Preferences
 	 * @return	mixed
 	 */
-	function _backup($params = array())
+	public function _backup($params = array())
 	{
 		// No SQL based support in CUBRID as of version 8.4.0. Database or
 		// table backup can be performed using CUBRID Manager
@@ -117,4 +104,4 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
 }
 
 /* End of file cubrid_utility.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */
-- 
cgit v1.2.3-24-g4f1b


From 69a6093da35640482a8394ca66686e045304b0e3 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 14:04:06 +0200
Subject: Replace array_key_exists() with isset() and ! empty()

---
 system/database/drivers/cubrid/cubrid_forge.php | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index ce5aa2098..d277ca394 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -89,13 +89,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 				$attributes = array_change_key_case($attributes, CASE_UPPER);
 
 				$sql .= "\n\t\"".$this->db->protect_identifiers($field).'"'
-					.(array_key_exists('NAME', $attributes) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '');
+					.(isset($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '');
 
-				if (array_key_exists('TYPE', $attributes))
+				if ( ! empty($attributes['TYPE']))
 				{
 					$sql .= ' '.$attributes['TYPE'];
 
-					if (array_key_exists('CONSTRAINT', $attributes))
+					if (isset($attributes['CONSTRAINT']))
 					{
 						switch ($attributes['TYPE'])
 						{
@@ -118,16 +118,16 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 			/* As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type.
 			 * Will be supported in the next release as a part of MySQL Compatibility.
 			 *
-				if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+				if (isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE)
 				{
 					$sql .= ' UNSIGNED';
 				}
 			 */
 
-				$sql .= (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' : '')
-					.((array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : '');
+				$sql .= (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' : '')
+					.((isset($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : '');
 			}
 
 			// don't add a comma on the end of the last field
-- 
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 c6953f4077fe3ee394abb37eaa0575527bd013cc Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 14:43:16 +0200
Subject: Fix _limit()

---
 system/database/drivers/cubrid/cubrid_driver.php |  2 +-
 system/database/drivers/cubrid/cubrid_forge.php  | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 1cfaf3e42..b89746b7d 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -696,7 +696,7 @@ class CI_DB_cubrid_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/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index d277ca394..4b1c2839a 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -89,13 +89,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 				$attributes = array_change_key_case($attributes, CASE_UPPER);
 
 				$sql .= "\n\t\"".$this->db->protect_identifiers($field).'"'
-					.(isset($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '');
+					.( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '');
 
 				if ( ! empty($attributes['TYPE']))
 				{
 					$sql .= ' '.$attributes['TYPE'];
 
-					if (isset($attributes['CONSTRAINT']))
+					if ( ! empty($attributes['CONSTRAINT']))
 					{
 						switch ($attributes['TYPE'])
 						{
@@ -125,9 +125,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 			 */
 
 				$sql .= (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' : '')
-					.((isset($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : '');
+					.(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+					.(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '')
+					.(( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : '');
 			}
 
 			// 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 b76029d8be1f2d98f1668d61e7f7ac3d9274b8f3 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 15:13:19 +0200
Subject: Improve the ODBC database driver

---
 system/database/drivers/odbc/odbc_driver.php  | 220 +++++++++-----------------
 system/database/drivers/odbc/odbc_forge.php   | 143 +++++------------
 system/database/drivers/odbc/odbc_result.php  | 129 +++++++--------
 system/database/drivers/odbc/odbc_utility.php |  44 ++----
 4 files changed, 185 insertions(+), 351 deletions(-)

diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 6ba39f0cd..a674c390e 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -1,13 +1,13 @@
-hostname, $this->username, $this->password);
 	}
@@ -83,10 +79,9 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * Persistent database connection
 	 *
-	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_pconnect()
+	public function db_pconnect()
 	{
 		return @odbc_pconnect($this->hostname, $this->username, $this->password);
 	}
@@ -99,10 +94,9 @@ class CI_DB_odbc_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 odbc
 	}
@@ -112,10 +106,9 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * Select the database
 	 *
-	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_select()
+	public function db_select()
 	{
 		// Not needed for ODBC
 		return TRUE;
@@ -126,12 +119,11 @@ class CI_DB_odbc_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
 		return TRUE;
@@ -142,12 +134,11 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * Version number query string
 	 *
-	 * @access	public
 	 * @return	string
 	 */
-	function _version()
+	protected function _version()
 	{
-		return "SELECT version() AS ver";
+		return 'SELECT version() AS ver';
 	}
 
 	// --------------------------------------------------------------------
@@ -155,14 +146,12 @@ class CI_DB_odbc_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 @odbc_exec($this->conn_id, $sql);
+		return @odbc_exec($this->conn_id, $this->_prep_query($sql));
 	}
 
 	// --------------------------------------------------------------------
@@ -172,11 +161,10 @@ class CI_DB_odbc_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;
 	}
@@ -186,18 +174,12 @@ class CI_DB_odbc_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;
 		}
@@ -205,7 +187,7 @@ class CI_DB_odbc_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 odbc_autocommit($this->conn_id, FALSE);
 	}
@@ -215,18 +197,12 @@ class CI_DB_odbc_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;
 		}
@@ -241,18 +217,12 @@ class CI_DB_odbc_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;
 		}
@@ -267,12 +237,11 @@ class CI_DB_odbc_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))
 		{
@@ -290,9 +259,9 @@ class CI_DB_odbc_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;
@@ -303,10 +272,9 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * Affected Rows
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function affected_rows()
+	public function affected_rows()
 	{
 		return @odbc_num_rows($this->conn_id);
 	}
@@ -316,10 +284,9 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * Insert ID
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function insert_id()
+	public function insert_id()
 	{
 		return @odbc_insert_id($this->conn_id);
 	}
@@ -332,27 +299,26 @@ class CI_DB_odbc_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;
 	}
 
 	// --------------------------------------------------------------------
@@ -366,11 +332,11 @@ class CI_DB_odbc_driver extends CI_DB {
 	 * @param	boolean
 	 * @return	string
 	 */
-	function _list_tables($prefix_limit = FALSE)
+	protected function _list_tables($prefix_limit = FALSE)
 	{
-		$sql = "SHOW TABLES FROM `".$this->database."`";
+		$sql = 'SHOW TABLES FROM `'.$this->database.'`';
 
-		if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+		if ($prefix_limit !== FALSE && $this->dbprefix != '')
 		{
 			//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
 			return FALSE; // not currently supported
@@ -386,13 +352,12 @@ class CI_DB_odbc_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
 	 */
-	function _list_columns($table = '')
+	protected function _list_columns($table = '')
 	{
-		return "SHOW COLUMNS FROM ".$table;
+		return 'SHOW COLUMNS FROM '.$table;
 	}
 
 	// --------------------------------------------------------------------
@@ -402,13 +367,12 @@ class CI_DB_odbc_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;
 	}
 
 	// --------------------------------------------------------------------
@@ -416,10 +380,9 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * The error message string
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _error_message()
+	protected function _error_message()
 	{
 		return odbc_errormsg($this->conn_id);
 	}
@@ -429,10 +392,9 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * The error message number
 	 *
-	 * @access	private
-	 * @return	integer
+	 * @return	int
 	 */
-	function _error_number()
+	protected function _error_number()
 	{
 		return odbc_error($this->conn_id);
 	}
@@ -444,11 +406,10 @@ class CI_DB_odbc_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 == '')
 		{
@@ -459,24 +420,20 @@ class CI_DB_odbc_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -487,11 +444,10 @@ class CI_DB_odbc_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	string	the table name
+	 * @return	string
 	 */
-	function _from_tables($tables)
+	protected function _from_tables($tables)
 	{
 		if ( ! is_array($tables))
 		{
@@ -508,15 +464,14 @@ class CI_DB_odbc_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).')';
 	}
 
 	// --------------------------------------------------------------------
@@ -526,7 +481,6 @@ class CI_DB_odbc_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
@@ -534,24 +488,17 @@ class CI_DB_odbc_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);
 	}
 
 
@@ -564,11 +511,10 @@ class CI_DB_odbc_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);
 	}
@@ -580,31 +526,27 @@ class CI_DB_odbc_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -614,16 +556,14 @@ class CI_DB_odbc_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)
 	{
-		// Does ODBC doesn't use the LIMIT clause?
-		return $sql;
+		return $sql.($offset == 0 ? '' : $offset.', ').$limit;
 	}
 
 	// --------------------------------------------------------------------
@@ -631,19 +571,15 @@ class CI_DB_odbc_driver extends CI_DB {
 	/**
 	 * Close DB Connection
 	 *
-	 * @access	public
 	 * @param	resource
 	 * @return	void
 	 */
-	function _close($conn_id)
+	protected function _close($conn_id)
 	{
 		@odbc_close($conn_id);
 	}
 
-
 }
 
-
-
 /* End of file odbc_driver.php */
-/* Location: ./system/database/drivers/odbc/odbc_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_driver.php */
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index e0ec687c8..49e5c3e72 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -1,13 +1,13 @@
-db->db_debug)
-		{
-			return $this->db->display_error('db_unsuported_feature');
-		}
-		return FALSE;
+		return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -59,19 +52,14 @@ class CI_DB_odbc_forge extends CI_DB_forge {
 	/**
 	 * Drop database
 	 *
-	 * @access	private
 	 * @param	string	the database name
 	 * @return	bool
 	 */
-	function _drop_database($name)
+	public function _drop_database($name)
 	{
 		// ODBC has no "drop database" command since it's
 		// designed to connect to an existing database
-		if ($this->db->db_debug)
-		{
-			return $this->db->display_error('db_unsuported_feature');
-		}
-		return FALSE;
+		return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -79,7 +67,6 @@ class CI_DB_odbc_forge extends CI_DB_forge {
 	/**
 	 * Create Table
 	 *
-	 * @access	private
 	 * @param	string	the table name
 	 * @param	array	the fields
 	 * @param	mixed	primary key(s)
@@ -87,7 +74,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
 	 * @param	boolean	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 ';
 
@@ -96,54 +83,29 @@ class CI_DB_odbc_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']
+					.( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+					.(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+					.(isset($attributes['DEFAULT'], $attributes) ? " DEFAULT '".$attributes['DEFAULT']."'" : '')
+					.(( ! 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
@@ -155,8 +117,7 @@ class CI_DB_odbc_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->protect_identifiers($primary_keys)).')';
 		}
 
 		if (is_array($keys) && count($keys) > 0)
@@ -165,20 +126,18 @@ class CI_DB_odbc_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)";
 	}
 
 	// --------------------------------------------------------------------
@@ -186,17 +145,12 @@ class CI_DB_odbc_forge extends CI_DB_forge {
 	/**
 	 * Drop Table
 	 *
-	 * @access	private
 	 * @return	bool
 	 */
-	function _drop_table($table)
+	public function _drop_table($table)
 	{
 		// Not a supported ODBC feature
-		if ($this->db->db_debug)
-		{
-			return $this->db->display_error('db_unsuported_feature');
-		}
-		return FALSE;
+		return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -207,49 +161,29 @@ class CI_DB_odbc_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
 	 * @param	string	the column definition
 	 * @param	string	the default value
-	 * @param	boolean	should 'NOT NULL' be added
+	 * @param	bool	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);
+		$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) : '');
 	}
 
 
@@ -260,19 +194,16 @@ class CI_DB_odbc_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 odbc_forge.php */
-/* Location: ./system/database/drivers/odbc/odbc_forge.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_forge.php */
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index ba660856e..509c77a1b 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -1,13 +1,13 @@
-result_id);
 	}
 
-	// --------------------------------------------------------------------
-
 	/**
 	 * Number of fields in the result set
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function num_fields()
+	public function num_fields()
 	{
 		return @odbc_num_fields($this->result_id);
 	}
@@ -69,13 +63,12 @@ class CI_DB_odbc_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[]	= odbc_field_name($this->result_id, $i);
 		}
@@ -90,22 +83,19 @@ class CI_DB_odbc_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		= odbc_field_name($this->result_id, $i);
-			$F->type		= odbc_field_type($this->result_id, $i);
-			$F->max_length	= odbc_field_len($this->result_id, $i);
-			$F->primary_key = 0;
-			$F->default		= '';
-
-			$retval[] = $F;
+			$retval[$i]			= new stdClass();
+			$retval[$i]->name		= odbc_field_name($this->result_id, $i);
+			$retval[$i]->type		= odbc_field_type($this->result_id, $i);
+			$retval[$i]->max_length		= odbc_field_len($this->result_id, $i);
+			$retval[$i]->primary_key	= 0;
+			$retval[$i]->default		= '';
 		}
 
 		return $retval;
@@ -116,9 +106,9 @@ class CI_DB_odbc_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,15 +122,15 @@ class CI_DB_odbc_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)
 	{
+		// Not supported
 		return FALSE;
 	}
 
@@ -151,19 +141,13 @@ class CI_DB_odbc_result extends CI_DB_result {
 	 *
 	 * Returns the result set as an array
 	 *
-	 * @access	private
 	 * @return	array
 	 */
-	function _fetch_assoc()
+	protected function _fetch_assoc()
 	{
-		if (function_exists('odbc_fetch_object'))
-		{
-			return odbc_fetch_array($this->result_id);
-		}
-		else
-		{
-			return $this->_odbc_fetch_array($this->result_id);
-		}
+		return function_exists('odbc_fetch_object')
+			? odbc_fetch_array($this->result_id)
+			: $this->_odbc_fetch_array($this->result_id);
 	}
 
 	// --------------------------------------------------------------------
@@ -173,40 +157,38 @@ class CI_DB_odbc_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('odbc_fetch_object'))
-		{
-			return odbc_fetch_object($this->result_id);
-		}
-		else
-		{
-			return $this->_odbc_fetch_object($this->result_id);
-		}
+		return function_exists('odbc_fetch_object')
+			? odbc_fetch_object($this->result_id)
+			: $this->_odbc_fetch_object($this->result_id);
 	}
 
-
 	/**
 	 * Result - object
 	 *
 	 * subsititutes the odbc_fetch_object function when
 	 * not available (odbc_fetch_object requires unixODBC)
 	 *
-	 * @access	private
 	 * @return	object
 	 */
-	function _odbc_fetch_object(& $odbc_result) {
+	private function _odbc_fetch_object(& $odbc_result)
+	{
 		$rs = array();
-		$rs_obj = FALSE;
-		if (odbc_fetch_into($odbc_result, $rs)) {
-			foreach ($rs as $k=>$v) {
-				$field_name= odbc_field_name($odbc_result, $k+1);
-				$rs_obj->$field_name = $v;
-			}
+		if ( ! odbc_fetch_into($odbc_result, $rs))
+		{
+			return FALSE;
 		}
+
+		$rs_obj = new stdClass();
+		foreach ($rs as $k => $v)
+		{
+			$field_name = odbc_field_name($odbc_result, $k+1);
+			$rs_obj->$field_name = $v;
+		}
+
 		return $rs_obj;
 	}
 
@@ -217,24 +199,27 @@ class CI_DB_odbc_result extends CI_DB_result {
 	 * subsititutes the odbc_fetch_array function when
 	 * not available (odbc_fetch_array requires unixODBC)
 	 *
-	 * @access	private
 	 * @return	array
 	 */
-	function _odbc_fetch_array(& $odbc_result) {
+	private function _odbc_fetch_array(& $odbc_result)
+	{
 		$rs = array();
-		$rs_assoc = FALSE;
-		if (odbc_fetch_into($odbc_result, $rs)) {
-			$rs_assoc=array();
-			foreach ($rs as $k=>$v) {
-				$field_name= odbc_field_name($odbc_result, $k+1);
-				$rs_assoc[$field_name] = $v;
-			}
+		if ( ! odbc_fetch_into($odbc_result, $rs))
+		{
+			return FALSE;
+		}
+
+		$rs_assoc = array();
+		foreach ($rs as $k => $v)
+		{
+			$field_name = odbc_field_name($odbc_result, $k+1);
+			$rs_assoc[$field_name] = $v;
 		}
+
 		return $rs_assoc;
 	}
 
 }
 
-
 /* End of file odbc_result.php */
-/* Location: ./system/database/drivers/odbc/odbc_result.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_result.php */
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index bae3fe853..e71bc5a03 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -1,13 +1,13 @@
-db->db_debug)
-		{
-			return $this->db->display_error('db_unsuported_feature');
-		}
-		return FALSE;
+		return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -59,18 +52,13 @@ class CI_DB_odbc_utility extends CI_DB_utility {
 	 *
 	 * Generates a platform-specific query so that a table can be optimized
 	 *
-	 * @access	private
 	 * @param	string	the table name
-	 * @return	object
+	 * @return	bool
 	 */
-	function _optimize_table($table)
+	public function _optimize_table($table)
 	{
 		// Not a supported ODBC feature
-		if ($this->db->db_debug)
-		{
-			return $this->db->display_error('db_unsuported_feature');
-		}
-		return FALSE;
+		return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -80,18 +68,13 @@ class CI_DB_odbc_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)
 	{
 		// Not a supported ODBC feature
-		if ($this->db->db_debug)
-		{
-			return $this->db->display_error('db_unsuported_feature');
-		}
-		return FALSE;
+		return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 	}
 
 	// --------------------------------------------------------------------
@@ -99,11 +82,10 @@ class CI_DB_odbc_utility extends CI_DB_utility {
 	/**
 	 * ODBC 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');
@@ -112,4 +94,4 @@ class CI_DB_odbc_utility extends CI_DB_utility {
 }
 
 /* End of file odbc_utility.php */
-/* Location: ./system/database/drivers/odbc/odbc_utility.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_utility.php */
-- 
cgit v1.2.3-24-g4f1b


From 214583f1ba4c026141e595dac5868d5074095a7e Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 16:39:09 +0200
Subject: Improve the PostgreSQL database driver

---
 system/database/drivers/postgre/postgre_driver.php | 357 ++++++++++-----------
 system/database/drivers/postgre/postgre_forge.php  | 136 +++-----
 system/database/drivers/postgre/postgre_result.php |  60 ++--
 .../database/drivers/postgre/postgre_utility.php   |  33 +-
 4 files changed, 257 insertions(+), 329 deletions(-)

diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 42329bded..8b8f33371 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -1,13 +1,13 @@
- 'host',
-								'port'		=> 'port',
-								'database'	=> 'dbname',
-								'username'	=> 'user',
-								'password'	=> 'password'
-							);
-
-		$connect_string = "";
+					'hostname'	=> 'host',
+					'port'		=> 'port',
+					'database'	=> 'dbname',
+					'username'	=> 'user',
+					'password'	=> 'password'
+				);
+
 		foreach ($components as $key => $val)
 		{
 			if (isset($this->$key) && $this->$key != '')
 			{
-				$connect_string .= " $val=".$this->$key;
+				$this->_pg_dsn .= $val.'='.$this->$key.' ';
 			}
 		}
-		return trim($connect_string);
+
+		if (strlen($this->_pg_dsn) > 0)
+		{
+			$this->_pg_dsn = rtrim($this->_pg_dsn);
+		}
 	}
 
 	// --------------------------------------------------------------------
@@ -90,12 +97,17 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Non-persistent database connection
 	 *
-	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_connect()
+	public function db_connect()
 	{
-		return @pg_connect($this->_connect_string());
+		$ret = @pg_connect($this->_pg_dsn);
+		if (is_resource($ret) && $this->char_set != '')
+		{
+			pg_set_client_encoding($ret, $this->char_set);
+		}
+
+		return $ret;
 	}
 
 	// --------------------------------------------------------------------
@@ -103,12 +115,17 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Persistent database connection
 	 *
-	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_pconnect()
+	public function db_pconnect()
 	{
-		return @pg_pconnect($this->_connect_string());
+		$ret = @pg_pconnect($this->_pg_dsn);
+		if (is_resource($ret) && $this->char_set != '')
+		{
+			pg_set_client_encoding($ret, $this->char_set);
+		}
+
+		return $ret;
 	}
 
 	// --------------------------------------------------------------------
@@ -119,10 +136,9 @@ class CI_DB_postgre_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()
 	{
 		if (pg_ping($this->conn_id) === FALSE)
 		{
@@ -135,10 +151,9 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Select the database
 	 *
-	 * @access	private called by the base class
 	 * @return	resource
 	 */
-	function db_select()
+	public function db_select()
 	{
 		// Not needed for Postgre so we'll return TRUE
 		return TRUE;
@@ -149,15 +164,35 @@ class CI_DB_postgre_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
-		return TRUE;
+		return (pg_set_client_encoding($this->conn_id, $charset) === 0);
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Database version
+	 *
+	 * This method overrides the one from the base class, as if PHP was
+	 * compiled with PostgreSQL version >= 7.4 libraries, we have a native
+	 * function to get the server's version.
+	 *
+	 * @return	string
+	 */
+
+	public function version()
+	{
+		$version = pg_version($this->conn_id);
+
+		/* If we don't have the server version string - fall back to
+		 * the base driver class' method
+		 */
+		return isset($version['server']) ? $version['server'] : parent::version();
 	}
 
 	// --------------------------------------------------------------------
@@ -165,12 +200,11 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Version number query string
 	 *
-	 * @access	public
 	 * @return	string
 	 */
-	function _version()
+	protected function _version()
 	{
-		return "SELECT version() AS ver";
+		return 'SELECT version() AS ver';
 	}
 
 	// --------------------------------------------------------------------
@@ -178,14 +212,12 @@ class CI_DB_postgre_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 @pg_query($this->conn_id, $sql);
+		return @pg_query($this->conn_id, $this->_prep_query($sql));
 	}
 
 	// --------------------------------------------------------------------
@@ -195,11 +227,10 @@ class CI_DB_postgre_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;
 	}
@@ -209,18 +240,13 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Begin Transaction
 	 *
-	 * @access	public
+	 * @param	bool
 	 * @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;
 		}
@@ -228,9 +254,9 @@ class CI_DB_postgre_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 @pg_exec($this->conn_id, "begin");
+		return (bool) @pg_query($this->conn_id, 'BEGIN');
 	}
 
 	// --------------------------------------------------------------------
@@ -238,23 +264,17 @@ class CI_DB_postgre_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;
 		}
 
-		return @pg_exec($this->conn_id, "commit");
+		return (bool) @pg_query($this->conn_id, 'COMMIT');
 	}
 
 	// --------------------------------------------------------------------
@@ -262,23 +282,17 @@ class CI_DB_postgre_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;
 		}
 
-		return @pg_exec($this->conn_id, "rollback");
+		return (bool) @pg_query($this->conn_id, 'ROLLBACK');
 	}
 
 	// --------------------------------------------------------------------
@@ -286,12 +300,11 @@ class CI_DB_postgre_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))
 		{
@@ -308,9 +321,9 @@ class CI_DB_postgre_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;
@@ -321,10 +334,9 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Affected Rows
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function affected_rows()
+	public function affected_rows()
 	{
 		return @pg_affected_rows($this->result_id);
 	}
@@ -334,40 +346,45 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Insert ID
 	 *
-	 * @access	public
-	 * @return	integer
+	 * @return	int
 	 */
-	function insert_id()
+	public function insert_id()
 	{
-		$v = $this->_version();
-		$v = $v['server'];
+		$v = pg_version($this->conn_id);
+		$v = isset($v['server']) ? $v['server'] : 0; // 'server' key is only available since PosgreSQL 7.4
 
-		$table	= func_num_args() > 0 ? func_get_arg(0) : NULL;
-		$column	= func_num_args() > 1 ? func_get_arg(1) : NULL;
+		$table	= (func_num_args() > 0) ? func_get_arg(0) : NULL;
+		$column	= (func_num_args() > 1) ? func_get_arg(1) : NULL;
 
 		if ($table == NULL && $v >= '8.1')
 		{
-			$sql='SELECT LASTVAL() as ins_id';
-		}
-		elseif ($table != NULL && $column != NULL && $v >= '8.0')
-		{
-			$sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
-			$query = $this->query($sql);
-			$row = $query->row();
-			$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);
+			$sql = 'SELECT LASTVAL() AS ins_id';
 		}
 		elseif ($table != NULL)
 		{
-			// seq_name passed in table parameter
-			$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
+			if ($column != NULL && $v >= '8.0')
+			{
+				$sql = 'SELECT pg_get_serial_sequence(\''.$table."', '".$column."') AS seq";
+				$query = $this->query($sql);
+				$query = $query->row();
+				$seq = $query->seq;
+			}
+			else
+			{
+				// seq_name passed in table parameter
+				$seq = $table;
+			}
+
+			$sql = 'SELECT CURRVAL(\''.$seq."') AS ins_id";
 		}
 		else
 		{
 			return pg_last_oid($this->result_id);
 		}
+
 		$query = $this->query($sql);
-		$row = $query->row();
-		return $row->ins_id;
+		$query = $query->row();
+		return (int) $query->ins_id;
 	}
 
 	// --------------------------------------------------------------------
@@ -378,27 +395,25 @@ class CI_DB_postgre_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;
 		}
 
-		$row = $query->row();
+		$query = $query->row();
 		$this->_reset_select();
-		return (int) $row->numrows;
+		return (int) $query->numrows;
 	}
 
 	// --------------------------------------------------------------------
@@ -408,17 +423,16 @@ class CI_DB_postgre_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 table_name FROM information_schema.tables WHERE table_schema = 'public'";
 
-		if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+		if ($prefix_limit !== FALSE && $this->dbprefix != '')
 		{
-			$sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+			return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
 		}
 
 		return $sql;
@@ -431,13 +445,12 @@ class CI_DB_postgre_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
 	 */
-	function _list_columns($table = '')
+	protected function _list_columns($table = '')
 	{
-		return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
+		return "SELECT column_name FROM information_schema.columns WHERE table_name = '".$table."'";
 	}
 
 	// --------------------------------------------------------------------
@@ -447,13 +460,12 @@ class CI_DB_postgre_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';
 	}
 
 	// --------------------------------------------------------------------
@@ -461,10 +473,9 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * The error message string
 	 *
-	 * @access	private
 	 * @return	string
 	 */
-	function _error_message()
+	protected function _error_message()
 	{
 		return pg_last_error($this->conn_id);
 	}
@@ -474,11 +485,11 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * The error message number
 	 *
-	 * @access	private
-	 * @return	integer
+	 * @return	string
 	 */
-	function _error_number()
+	protected function _error_number()
 	{
+		// Not supported in Postgre
 		return '';
 	}
 
@@ -489,11 +500,10 @@ class CI_DB_postgre_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 == '')
 		{
@@ -504,24 +514,20 @@ class CI_DB_postgre_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -532,11 +538,10 @@ class CI_DB_postgre_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	string	table name
+	 * @return	string
 	 */
-	function _from_tables($tables)
+	protected function _from_tables($tables)
 	{
 		if ( ! is_array($tables))
 		{
@@ -553,15 +558,14 @@ class CI_DB_postgre_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).')';
 	}
 
 	// --------------------------------------------------------------------
@@ -571,15 +575,14 @@ class CI_DB_postgre_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_batch($table, $keys, $values)
+	protected function _insert_batch($table, $keys, $values)
 	{
-		return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
+		return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES '.implode(', ', $values);
 	}
 
 	// --------------------------------------------------------------------
@@ -589,7 +592,6 @@ class CI_DB_postgre_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
@@ -597,24 +599,17 @@ class CI_DB_postgre_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -626,13 +621,12 @@ class CI_DB_postgre_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;
 	}
 
 	// --------------------------------------------------------------------
@@ -642,31 +636,27 @@ class CI_DB_postgre_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);
 	}
 
 	// --------------------------------------------------------------------
@@ -675,22 +665,14 @@ class CI_DB_postgre_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)
 	{
-		$sql .= "LIMIT ".$limit;
-
-		if ($offset > 0)
-		{
-			$sql .= " OFFSET ".$offset;
-		}
-
-		return $sql;
+		return $sql.' LIMIT '.$limit.($offset == 0 ? '' : ' OFFSET '.$offset);
 	}
 
 	// --------------------------------------------------------------------
@@ -698,18 +680,15 @@ class CI_DB_postgre_driver extends CI_DB {
 	/**
 	 * Close DB Connection
 	 *
-	 * @access	public
 	 * @param	resource
 	 * @return	void
 	 */
-	function _close($conn_id)
+	protected function _close($conn_id)
 	{
 		@pg_close($conn_id);
 	}
 
-
 }
 
-
 /* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 756fd347a..5af834b8d 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -1,13 +1,13 @@
-$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 .= "\n\t".$this->db->protect_identifiers($field);
 
-				$is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE);
+				$attributes = array_change_key_case($attributes, CASE_UPPER);
+				$is_unsigned = ( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE);
 
 				// Convert datatypes to be PostgreSQL-compatible
 				switch (strtoupper($attributes['TYPE']))
@@ -122,44 +117,24 @@ class CI_DB_postgre_forge extends CI_DB_forge {
 					case 'BLOB':
 						$attributes['TYPE'] = 'BYTEA';
 						break;
+					default:
+						break;
 				}
 
 				// If this is an auto-incrementing primary key, use the serial data type instead
-				if (in_array($field, $primary_keys) && array_key_exists('AUTO_INCREMENT', $attributes) 
-					&& $attributes['AUTO_INCREMENT'] === TRUE)
-				{
-					$sql .= ' SERIAL';
-				}
-				else
-				{
-					$sql .=  ' '.$attributes['TYPE'];
-				}
+				$sql .= (in_array($field, $primary_keys) && ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE)
+					? ' SERIAL' : ' '.$attributes['TYPE'];
 
 				// Modified to prevent constraints with integer data types
-				if (array_key_exists('CONSTRAINT', $attributes) && strpos($attributes['TYPE'], 'INT') === false)
+				if ( ! empty($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') === FALSE)
 				{
 					$sql .= '('.$attributes['CONSTRAINT'].')';
 				}
 
-				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';
-				}
-
-				// Added new attribute to create unqite fields. Also works with MySQL
-				if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE)
-				{
-					$sql .= ' UNIQUE';
-				}
+				$sql .= (isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '')
+					.(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+					// Added new attribute to create unqite fields. Also works with MySQL
+					.(( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : '');
 			}
 
 			// don't add a comma on the end of the last field
@@ -168,7 +143,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
 				$sql .= ',';
 			}
 		}
-		
+
 		return $sql;
 	}
 
@@ -177,15 +152,14 @@ class CI_DB_postgre_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 ';
 
@@ -198,18 +172,17 @@ class CI_DB_postgre_forge extends CI_DB_forge {
 			}
 		}
 
-		$sql .= $this->db->_escape_identifiers($table)." (";
-		$sql .= $this->_process_fields($fields, $primary_keys);
+		$sql .= $this->db->_escape_identifiers($table).' ('.$this->_process_fields($fields, $primary_keys);
 
 		if (count($primary_keys) > 0)
 		{
-			// Something seems to break when passing an array to _protect_identifiers()
+			// Something seems to break when passing an array to protect_identifiers()
 			foreach ($primary_keys as $index => $key)
 			{
-				$primary_keys[$index] = $this->db->_protect_identifiers($key);
+				$primary_keys[$index] = $this->db->protect_identifiers($key);
 			}
 
-			$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+			$sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')';
 		}
 
 		$sql .= "\n);";
@@ -220,16 +193,16 @@ class CI_DB_postgre_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));
 				}
 
 				foreach ($key as $field)
 				{
-					$sql .= "CREATE INDEX " . $table . "_" . str_replace(array('"', "'"), '', $field) . "_index ON $table ($field); ";
+					$sql .= 'CREATE INDEX '.$table.'_'.str_replace(array('"', "'"), '', $field).'_index ON '.$table.' ('.$field.'); ';
 				}
 			}
 		}
@@ -241,10 +214,13 @@ class CI_DB_postgre_forge extends CI_DB_forge {
 
 	/**
 	 * Drop Table
+	 *
+	 * @param	string	table name
+	 * @return	string
 	 */
-	function _drop_table($table)
+	public function _drop_table($table)
 	{
-		return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE";
+		return 'DROP TABLE IF EXISTS '.$this->db->_escape_identifiers($table).' CASCADE';
 	}
 
 	// --------------------------------------------------------------------
@@ -255,34 +231,27 @@ class CI_DB_postgre_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
 	 * @param	string	the column definition
 	 * @param	string	the default value
-	 * @param	boolean	should 'NOT NULL' be added
+	 * @param	bool	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, $fields, $after_field = '')
+	public function _alter_table($alter_type, $table, $fields, $after_field = '')
  	{
- 		$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
+ 		$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
 
  		// DROP has everything it needs now.
- 		if ($alter_type == 'DROP')
+ 		if ($alter_type === 'DROP')
  		{
- 			return $sql.$this->db->_protect_identifiers($fields);
+ 			return $sql.$this->db->protect_identifiers($fields);
  		}
 
- 		$sql .= $this->_process_fields($fields);
-
- 		if ($after_field != '')
- 		{
- 			$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
- 		}
-
- 		return $sql;
+ 		return $sql.$this->_process_fields($fields)
+			.($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : '');
  	}
 
 	// --------------------------------------------------------------------
@@ -292,17 +261,16 @@ class CI_DB_postgre_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 postgre_forge.php */
-/* Location: ./system/database/drivers/postgre/postgre_forge.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_forge.php */
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index 9161bf955..2cfa997e7 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_result.php
@@ -1,13 +1,13 @@
-result_id);
 	}
@@ -54,10 +51,9 @@ class CI_DB_postgre_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 @pg_num_fields($this->result_id);
 	}
@@ -69,13 +65,12 @@ class CI_DB_postgre_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[] = pg_field_name($this->result_id, $i);
 		}
@@ -90,22 +85,19 @@ class CI_DB_postgre_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		= pg_field_name($this->result_id, $i);
-			$F->type		= pg_field_type($this->result_id, $i);
-			$F->max_length	= pg_field_size($this->result_id, $i);
-			$F->primary_key = 0;
-			$F->default		= '';
-
-			$retval[] = $F;
+			$retval[$i]			= new stdClass();
+			$retval[$i]->name		= pg_field_name($this->result_id, $i);
+			$retval[$i]->type		= pg_field_type($this->result_id, $i);
+			$retval[$i]->max_length		= pg_field_size($this->result_id, $i);
+			$retval[$i]->primary_key	= 0;
+			$retval[$i]->default		= '';
 		}
 
 		return $retval;
@@ -116,9 +108,9 @@ class CI_DB_postgre_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 +124,13 @@ class CI_DB_postgre_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 pg_result_seek($this->result_id, $n);
 	}
@@ -151,10 +142,9 @@ class CI_DB_postgre_result extends CI_DB_result {
 	 *
 	 * Returns the result set as an array
 	 *
-	 * @access	private
 	 * @return	array
 	 */
-	function _fetch_assoc()
+	protected function _fetch_assoc()
 	{
 		return pg_fetch_assoc($this->result_id);
 	}
@@ -166,16 +156,14 @@ class CI_DB_postgre_result extends CI_DB_result {
 	 *
 	 * Returns the result set as an object
 	 *
-	 * @access	private
 	 * @return	object
 	 */
-	function _fetch_object()
+	protected function _fetch_object()
 	{
 		return pg_fetch_object($this->result_id);
 	}
 
 }
 
-
 /* End of file postgre_result.php */
-/* Location: ./system/database/drivers/postgre/postgre_result.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_result.php */
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index dffd8c549..c175a382b 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -1,13 +1,13 @@
-db->display_error('db_unsuported_feature');
 	}
 }
 
-
 /* End of file postgre_utility.php */
-/* Location: ./system/database/drivers/postgre/postgre_utility.php */
\ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_utility.php */
-- 
cgit v1.2.3-24-g4f1b


From 0e5a17f6c736397c1e9581071cb852b5291fa97e Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 16:49:03 +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..0e5b21395 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.
+   -  The PostgreSQL database driver now uses pg_version() for server version checking, when appropriate.
 
 -  Libraries
 
-- 
cgit v1.2.3-24-g4f1b


From ca7e5f1eb15408b9d71e55d9a0e54b96f5ddc6aa Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 26 Jan 2012 17:58:28 +0200
Subject: Call parent::__construct() in our constructor

---
 system/database/drivers/cubrid/cubrid_driver.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index b89746b7d..d1fc5f0fa 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -57,8 +57,10 @@ class CI_DB_cubrid_driver extends CI_DB {
 	protected $_count_string = 'SELECT COUNT(*) AS ';
 	protected $_random_keyword = ' RAND()'; // database specific random keyword
 
-	public function __construct()
+	public function __construct($params)
 	{
+		parent::__construct($params);
+
 		// If no port is defined by the user, use the default value
 		if ($this->port == '')
 		{
-- 
cgit v1.2.3-24-g4f1b


From 5c078ceeb926119fc3b4e55ca7c33ff2d1a207cd Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Thu, 26 Jan 2012 17:18:35 -0800
Subject: Added javascript. Improved based on comments.

---
 system/core/Output.php | 74 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 19 deletions(-)

diff --git a/system/core/Output.php b/system/core/Output.php
index 9bc02fc84..c4eba30bb 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -593,12 +593,12 @@ class CI_Output {
 
 				$size_before = strlen($output);
 
-				// Keep track of 
  and }msU', $output, $textareas_clean);
+				preg_match_all('{}msU', $output, $javascript_clean);
 
 				// Minify the CSS in all the }msU', $output, $style_clean);
@@ -606,39 +606,75 @@ class CI_Output {
 				{
 					$output = str_replace($s, $this->minify($s,'text/css'), $output);
 				}
+				
+				// Minify the javascript in }msU', $output, $javascript_messed);
+					$output = str_replace($javascript_messed[0], $javascript_mini, $output);
+				}
+				
+				$size_removed = $size_before - strlen($output);
+				$savings_percent = round(($size_removed / $size_before * 100));
+
+				log_message('debug', 'Minifier shaved '.($size_removed / 1000).'KB ('.$savings_percent.'%) off final HTML output.');
 
 			break;
 			
 			
 			case 'text/css':
 			
-				// Remove spaces around curly brackets, colons, and semi-colons
-				$output = preg_replace('!\s*(:|;|}|{)\s*!', '$1', $output);
-				
-				// Replace spaces with line breaks to limit line lengths
-				$output = preg_replace('!\s+!', "\n", $output);
+				//Remove CSS comments
+				$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output);
+			
+				// Remove spaces around curly brackets, colons,
+				// semi-colons, parenthesis, commas
+				$output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!', '$1', $output);
+
+			break;
+			
+			
+			case 'text/javascript':
+
+				// Replace multiple spaces with a single newline.
+				$output = preg_replace('!\s{2,}!',"\n", $output);
+
+				// Remove excessive newlines.
+				$output = preg_replace('!(;|{|})\n!','$1', $output);
 
 			break;
 		}
-- 
cgit v1.2.3-24-g4f1b


From 6c5992da5cf3579a29079b0aae3e9ba0700fda5c Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Thu, 26 Jan 2012 18:45:57 -0800
Subject: Removed javascript for now...

---
 system/core/Output.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/system/core/Output.php b/system/core/Output.php
index c4eba30bb..d8c230968 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -670,11 +670,11 @@ class CI_Output {
 			
 			case 'text/javascript':
 
-				// Replace multiple spaces with a single newline.
-				$output = preg_replace('!\s{2,}!',"\n", $output);
+				// Replace multiple whitespace characters with a single newline.
+				//$output = preg_replace('!\s{2,}!',"\n", $output);
 
 				// Remove excessive newlines.
-				$output = preg_replace('!(;|{|})\n!','$1', $output);
+				//$output = preg_replace('!(;|{|})\n!','$1', $output);
 
 			break;
 		}
-- 
cgit v1.2.3-24-g4f1b


From c25c3d3d61ff38a348224252c1b3c9041e50ac32 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 27 Jan 2012 11:35:30 +0200
Subject: Remove an empty line :)

---
 system/database/drivers/postgre/postgre_driver.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 8b8f33371..4e35cd6d7 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -184,7 +184,6 @@ class CI_DB_postgre_driver extends CI_DB {
 	 *
 	 * @return	string
 	 */
-
 	public function version()
 	{
 		$version = pg_version($this->conn_id);
-- 
cgit v1.2.3-24-g4f1b


From 8d5b24a8c55dc1ae7721e10de094c4aba2ca7eae Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 27 Jan 2012 14:37:38 +0200
Subject: Fix issue #128

---
 system/core/Lang.php                | 23 ++++++++++++-----------
 user_guide_src/source/changelog.rst |  1 +
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/system/core/Lang.php b/system/core/Lang.php
index c40a6856e..d68c04812 100755
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * Language Class
  *
@@ -74,22 +72,20 @@ class CI_Lang {
 
 		if ($add_suffix == TRUE)
 		{
-			$langfile = str_replace('_lang.', '', $langfile).'_lang';
+			$langfile = str_replace('_lang', '', $langfile).'_lang';
 		}
 
 		$langfile .= '.php';
 
-		if (in_array($langfile, $this->is_loaded, TRUE))
+		if ($idiom == '')
 		{
-			return;
+			$config =& get_config();
+			$idiom = ( ! empty($config['language'])) ? $config['language'] : 'english';
 		}
 
-		$config =& get_config();
-
-		if ($idiom == '')
+		if ($return == FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom)
 		{
-			$deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
-			$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
+			return;
 		}
 
 		// Determine where the language file is and load it
@@ -121,6 +117,11 @@ class CI_Lang {
 		if ( ! isset($lang) OR ! is_array($lang))
 		{
 			log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
+
+			if ($return == TRUE)
+			{
+				return array();
+			}
 			return;
 		}
 
@@ -129,7 +130,7 @@ class CI_Lang {
 			return $lang;
 		}
 
-		$this->is_loaded[] = $langfile;
+		$this->is_loaded[$langfile] = $idiom;
 		$this->language = array_merge($this->language, $lang);
 		unset($lang);
 
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 48011f208..71143b99b 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -97,6 +97,7 @@ Bug fixes for 3.0
 -  In Pagination library, when use_page_numbers=TRUE previous link and page 1 link do not have the same url
 -  Fixed a bug (#561) - Errors in :doc:`XML-RPC Library ` were not properly escaped.
 -  Fixed a bug (#904) - ``CI_Loader::initialize()`` caused a PHP Fatal error to be triggered if error level E_STRICT is used.
+-  Fixed a bug (#128) - :doc:`Language Library ` did not correctly keep track of loaded language files.
 
 Version 2.1.0
 =============
-- 
cgit v1.2.3-24-g4f1b


From 65571d9d9684573887dc4a481b44f33b13584059 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 27 Jan 2012 14:51:58 +0200
Subject: Remove an unnecessary unset()

---
 system/core/Lang.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/system/core/Lang.php b/system/core/Lang.php
index d68c04812..711ccab70 100755
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -132,7 +132,6 @@ class CI_Lang {
 
 		$this->is_loaded[$langfile] = $idiom;
 		$this->language = array_merge($this->language, $lang);
-		unset($lang);
 
 		log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
 		return TRUE;
-- 
cgit v1.2.3-24-g4f1b


From 7719a037c4648be714ebe577aa38acba012f7d90 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 27 Jan 2012 21:05:55 +0200
Subject: Switch _process_fields() from private to protected

---
 system/database/drivers/cubrid/cubrid_forge.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 4b1c2839a..8423180e9 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -70,7 +70,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
 	 * @param	mixed	the fields
 	 * @return	string
 	 */
-	private function _process_fields($fields)
+	protected function _process_fields($fields)
 	{
 		$current_field_count = 0;
 		$sql = '';
-- 
cgit v1.2.3-24-g4f1b


From 1b8d0ef6491b77375bb068711bc5e10fe4ca4b8f Mon Sep 17 00:00:00 2001
From: Thor 
Date: Sat, 28 Jan 2012 01:48:04 -0800
Subject: Fixed some spaces.

---
 system/core/Output.php | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/system/core/Output.php b/system/core/Output.php
index d8c230968..468274002 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -604,17 +604,17 @@ class CI_Output {
 				preg_match_all('{}msU', $output, $style_clean);
 				foreach ($style_clean[0] as $s)
 				{
-					$output = str_replace($s, $this->minify($s,'text/css'), $output);
+					$output = str_replace($s, $this->minify($s, 'text/css'), $output);
 				}
 				
 				// Minify the javascript in 
-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 827b3f0f6fa3fd62f0276908f38d23a4165f0f41 Mon Sep 17 00:00:00 2001
From: Chris Berthe 
Date: Fri, 27 Apr 2012 23:36:54 -0400
Subject: Important spelling fix to CodeIgniter.php file

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

diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 793c4687e..349f9f2d0 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -153,7 +153,7 @@
  *
  * Note: Order here is rather important as the UTF-8
  * class needs to be used very early on, but it cannot
- * properly determine if UTf-8 can be supported until
+ * properly determine if UTF-8 can be supported until
  * after the Config class is instantiated.
  *
  */
-- 
cgit v1.2.3-24-g4f1b


From 193d448eec149b9b26c89a157c9394266a18ffae Mon Sep 17 00:00:00 2001
From: George Petsagourakis 
Date: Sat, 28 Apr 2012 11:16:18 +0300
Subject: Minor assignment fix. Can not use $array[] for reading.

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

diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 393a1cd75..d0af66de1 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -281,7 +281,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 					$v = trim($v);
 					$this->_track_aliases($v);
 
-					$v = $this->qb_from[] = $this->protect_identifiers($v, TRUE, NULL, FALSE);
+					$this->qb_from[] = $v = $this->protect_identifiers($v, TRUE, NULL, FALSE);
 
 					if ($this->qb_caching === TRUE)
 					{
-- 
cgit v1.2.3-24-g4f1b


From e57411502933afad6fca682efb437db05998e532 Mon Sep 17 00:00:00 2001
From: Phil Sturgeon 
Date: Mon, 30 Apr 2012 17:57:37 +0200
Subject: Reverted recent commit, cookie_prefix was breaking things.

---
 system/core/Input.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/system/core/Input.php b/system/core/Input.php
index 7594a2e45..fc2a550bc 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -226,7 +226,6 @@ class CI_Input {
 	 */
 	public function cookie($index = '', $xss_clean = FALSE)
 	{
-		$index = config_item('cookie_prefix').$index;
 		return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
 	}
 
-- 
cgit v1.2.3-24-g4f1b


From a5918ebb5354f6e8bea0149fd95fc98412d461eb Mon Sep 17 00:00:00 2001
From: Cosmin Atanasiu 
Date: Mon, 30 Apr 2012 22:46:20 -0700
Subject: Update system/libraries/Javascript.php

---
 system/libraries/Javascript.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 21c9e11bd..b56dd9888 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -723,7 +723,14 @@ class CI_Javascript {
 		{
 			if (is_object($result))
 			{
-				$json_result = (array)$result;
+                            if (is_callable( array( $result, "result_array" ) ))
+                            {
+                                $json_result = $result->result_array();
+                            }
+                            else
+                            {
+                                $json_result = (array)$result;
+                            }
 			}
 			elseif (is_array($result))
 			{
-- 
cgit v1.2.3-24-g4f1b


From 0b10a8c71cd8a60281f8dbe872ae4ba0404ac2c3 Mon Sep 17 00:00:00 2001
From: Cosmin Atanasiu 
Date: Mon, 30 Apr 2012 22:51:17 -0700
Subject: Update system/libraries/Javascript.php

---
 system/libraries/Javascript.php | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index b56dd9888..008136192 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -723,14 +723,14 @@ class CI_Javascript {
 		{
 			if (is_object($result))
 			{
-                            if (is_callable( array( $result, "result_array" ) ))
-                            {
-                                $json_result = $result->result_array();
-                            }
-                            else
-                            {
-                                $json_result = (array)$result;
-                            }
+				if (is_callable( array( $result, "result_array" ) ))
+				{
+					$json_result = $result->result_array();
+				}
+				else
+				{
+					$json_result = (array)$result;
+				}
 			}
 			elseif (is_array($result))
 			{
-- 
cgit v1.2.3-24-g4f1b


From 3259e98b2b775d6dd932e03ae37b08c6e0465898 Mon Sep 17 00:00:00 2001
From: Cosmin Atanasiu 
Date: Tue, 1 May 2012 20:41:46 -0700
Subject: Update system/libraries/Javascript.php

---
 system/libraries/Javascript.php | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 008136192..dd2df697c 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -723,14 +723,7 @@ class CI_Javascript {
 		{
 			if (is_object($result))
 			{
-				if (is_callable( array( $result, "result_array" ) ))
-				{
-					$json_result = $result->result_array();
-				}
-				else
-				{
-					$json_result = (array)$result;
-				}
+				$json_result = is_callable(array($result, 'result_array')) ? $result->result_array() : (array) $result;
 			}
 			elseif (is_array($result))
 			{
-- 
cgit v1.2.3-24-g4f1b


From 1a3885babb73870ef99af24297c722d8251480a1 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Wed, 2 May 2012 10:23:12 +0300
Subject: Fix pagination anchor_class with multiple initializations

---
 system/libraries/Pagination.php | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 0fe73d69f..3d2911813 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -94,17 +94,16 @@ class CI_Pagination {
 		{
 			foreach ($params as $key => $val)
 			{
-				if (isset($this->$key))
+				if ($key === 'anchor_class')
+				{
+					$this->anchor_class = ($val != '') ? 'class="'.$val.'" ' : '';
+				}
+				elseif (isset($this->$key))
 				{
 					$this->$key = $val;
 				}
 			}
 		}
-
-		if ($this->anchor_class != '')
-		{
-			$this->anchor_class = 'class="'.$this->anchor_class.'" ';
-		}
 	}
 
 	// --------------------------------------------------------------------
-- 
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 6986479050e7bf02cbafd9dbc82640a9e3865bb9 Mon Sep 17 00:00:00 2001
From: Timothy Warren 
Date: Thu, 3 May 2012 14:05:00 -0400
Subject: Make valid_email helper function more accurate

---
 system/helpers/email_helper.php | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
index 0516e938a..c7b3abada 100644
--- a/system/helpers/email_helper.php
+++ b/system/helpers/email_helper.php
@@ -42,12 +42,40 @@ if ( ! function_exists('valid_email'))
 	/**
 	 * Validate email address
 	 *
+	 * Updated to be more accurate to RFC822
+	 * see: http://www.iamcal.com/publish/articles/php/parsing_email/
+	 *
 	 * @param	string
 	 * @return	bool
 	 */
-	function valid_email($address)
+	function valid_email($email)
 	{
-		return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address);
+		$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
+
+		$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
+
+		$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
+			'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
+
+		$quoted_pair = '\\x5c[\\x00-\\x7f]';
+
+		$domain_literal = "\\x5b({$dtext}|{$quoted_pair})*\\x5d";
+
+		$quoted_string = "\\x22({$qtext}|{$quoted_pair})*\\x22";
+
+		$domain_ref = $atom;
+
+		$sub_domain = "({$domain_ref}|{$domain_literal})";
+
+		$word = "({$atom}|{$quoted_string})";
+
+		$domain = "{$sub_domain}(\\x2e{$sub_domain})*";
+
+		$local_part = "{$word}(\\x2e{$word})*";
+
+		$addr_spec = "{$local_part}\\x40{$domain}";
+
+		return (bool) preg_match("!^{$addr_spec}$!", $email);
 	}
 }
 
-- 
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_DIR PHP_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 + ../../codeigniter PEAR_INSTALL_DIR PHP_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_DIR PHP_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_DIR PHP_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_DIR PHP_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_DIR PHP_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 40dd9b5ffa1a9e0b1b885d4b592636dcc04af023 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 16 May 2012 15:41:05 -0400 Subject: Added filter_var for newer versions of php --- system/helpers/email_helper.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index c7b3abada..449aadfc2 100644 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.php @@ -50,6 +50,13 @@ if ( ! function_exists('valid_email')) */ function valid_email($email) { + // Use PHP's filters if they exist + if (function_exists('filter_var')) + { + return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); + } + + // Fallback based on RFC822 $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; -- 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.
  • -- cgit v1.2.3-24-g4f1b From c3eb672ed01c57a543dd8cdf1b90eb4001498c19 Mon Sep 17 00:00:00 2001 From: Alexander Hofstede Date: Thu, 17 May 2012 10:48:11 +0200 Subject: Use tab for indent --- .project | 13 +++++++++++++ .settings/com.aptana.formatter.epl.prefs | 2 ++ user_guide/changelog.html | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .project create mode 100644 .settings/com.aptana.formatter.epl.prefs diff --git a/.project b/.project new file mode 100644 index 000000000..6f00520a1 --- /dev/null +++ b/.project @@ -0,0 +1,13 @@ + + + CodeIgniter + + + + + + + com.aptana.projects.webnature + com.aptana.editor.php.phpNature + + diff --git a/.settings/com.aptana.formatter.epl.prefs b/.settings/com.aptana.formatter.epl.prefs new file mode 100644 index 000000000..ebd4b7aeb --- /dev/null +++ b/.settings/com.aptana.formatter.epl.prefs @@ -0,0 +1,2 @@ +com.aptana.formatter.profiles.active=com.aptana.formatter.profiles.default +eclipse.preferences.version=1 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 be32f2b25c72517c003010eeaae8b46dae19fe3e Mon Sep 17 00:00:00 2001 From: Alexander Hofstede Date: Thu, 17 May 2012 10:51:05 +0200 Subject: Revert "Use tab for indent" This reverts commit c3eb672ed01c57a543dd8cdf1b90eb4001498c19. --- .project | 13 ------------- .settings/com.aptana.formatter.epl.prefs | 2 -- user_guide/changelog.html | 2 +- 3 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 .project delete mode 100644 .settings/com.aptana.formatter.epl.prefs diff --git a/.project b/.project deleted file mode 100644 index 6f00520a1..000000000 --- a/.project +++ /dev/null @@ -1,13 +0,0 @@ - - - CodeIgniter - - - - - - - com.aptana.projects.webnature - com.aptana.editor.php.phpNature - - diff --git a/.settings/com.aptana.formatter.epl.prefs b/.settings/com.aptana.formatter.epl.prefs deleted file mode 100644 index ebd4b7aeb..000000000 --- a/.settings/com.aptana.formatter.epl.prefs +++ /dev/null @@ -1,2 +0,0 @@ -com.aptana.formatter.profiles.active=com.aptana.formatter.profiles.default -eclipse.preferences.version=1 diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 55fbceeaf..38275955b 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 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 = '

    '.implode('

    ', ( ! is_array($message)) ? array($message) : $message).'

    '; + $message = '

    '.implode('

    ', is_array($message) ? $message : array($message)).'

    '; if (ob_get_level() > $this->ob_level + 1) { @@ -160,7 +162,7 @@ class CI_Exceptions { */ public function show_php_error($severity, $message, $filepath, $line) { - $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; + $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity; $filepath = str_replace('\\', '/', $filepath); // For safety reasons we do not show the full file path @@ -175,7 +177,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include(APPPATH.'errors/'.'error_php.php'); + include(APPPATH.'errors/error_php.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; diff --git a/system/core/Hooks.php b/system/core/Hooks.php index b42ecbe20..5bbb0009a 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -44,14 +44,14 @@ class CI_Hooks { * @var bool */ public $enabled = FALSE; - + /** * List of all hooks set in config/hooks.php * * @var array */ public $hooks = array(); - + /** * Determines wether hook is in progress, used to prevent infinte loops * @@ -152,7 +152,7 @@ class CI_Hooks { // If the script being called happens to have the same // hook call within it a loop can happen - if ($this->in_progress == TRUE) + if ($this->in_progress === TRUE) { return; } diff --git a/system/core/Input.php b/system/core/Input.php index fc2a550bc..e916ac66d 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -44,28 +44,28 @@ class CI_Input { * @var string */ public $ip_address = FALSE; - + /** * user agent (web browser) being used by the current user * * @var string */ public $user_agent = FALSE; - + /** * If FALSE, then $_GET will be set to an empty array * * @var bool */ protected $_allow_get_array = TRUE; - + /** * If TRUE, then newlines are standardized * * @var bool */ protected $_standardize_newlines = TRUE; - + /** * Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered * Set automatically based on config setting @@ -73,7 +73,7 @@ class CI_Input { * @var bool */ protected $_enable_xss = FALSE; - + /** * Enables a CSRF cookie token to be set. * Set automatically based on config setting @@ -81,7 +81,7 @@ class CI_Input { * @var bool */ protected $_enable_csrf = FALSE; - + /** * List of all HTTP request headers * @@ -94,6 +94,8 @@ class CI_Input { * * Sets whether to globally enable the XSS processing * and whether to allow the $_GET array + * + * @return void */ public function __construct() { @@ -438,15 +440,7 @@ class CI_Input { // This is effectively the same as register_globals = off foreach (array($_GET, $_POST, $_COOKIE) as $global) { - if ( ! is_array($global)) - { - if ( ! in_array($global, $protected)) - { - global $$global; - $$global = NULL; - } - } - else + if (is_array($global)) { foreach ($global as $key => $val) { @@ -457,6 +451,11 @@ class CI_Input { } } } + elseif ( ! in_array($global, $protected)) + { + global $$global; + $$global = NULL; + } } // Is $_GET data allowed? If not we'll set the $_GET to an empty array @@ -605,7 +604,7 @@ class CI_Input { * In Apache, you can simply call apache_request_headers(), however for * people running other webservers the function is undefined. * - * @param bool XSS cleaning + * @param bool XSS cleaning * @return array */ public function request_headers($xss_clean = FALSE) diff --git a/system/core/Loader.php b/system/core/Loader.php index bf7f6cb02..3eb09e6ab 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -32,8 +32,8 @@ * * @package CodeIgniter * @subpackage Libraries - * @author EllisLab Dev Team * @category Loader + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/loader.html */ class CI_Loader { @@ -45,77 +45,77 @@ class CI_Loader { * @var int */ protected $_ci_ob_level; - + /** * List of paths to load views from * * @var array */ protected $_ci_view_paths = array(); - + /** * List of paths to load libraries from * * @var array */ protected $_ci_library_paths = array(); - + /** * List of paths to load models from * * @var array */ protected $_ci_model_paths = array(); - + /** * List of paths to load helpers from * * @var array */ protected $_ci_helper_paths = array(); - + /** * List of loaded base classes * * @var array */ protected $_base_classes = array(); // Set by the controller class - + /** * List of cached variables * * @var array */ protected $_ci_cached_vars = array(); - + /** * List of loaded classes * * @var array */ protected $_ci_classes = array(); - + /** * List of loaded files * * @var array */ protected $_ci_loaded_files = array(); - + /** * List of loaded models * * @var array */ protected $_ci_models = array(); - + /** * List of loaded helpers * * @var array */ protected $_ci_helpers = array(); - + /** * List of class name mappings * @@ -130,6 +130,8 @@ class CI_Loader { * Constructor * * Sets the path to the view files and gets the initial output buffering level + * + * @return void */ public function __construct() { @@ -178,12 +180,7 @@ class CI_Loader { */ public function is_loaded($class) { - if (isset($this->_ci_classes[$class])) - { - return $this->_ci_classes[$class]; - } - - return FALSE; + return isset($this->_ci_classes[$class]) ? $this->_ci_classes[$class] : FALSE; } // -------------------------------------------------------------------- @@ -1263,4 +1260,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file diff --git a/system/core/Model.php b/system/core/Model.php index 7c9971970..9bc9f879f 100755 --- a/system/core/Model.php +++ b/system/core/Model.php @@ -38,6 +38,8 @@ class CI_Model { /** * Initialize CI_Model Class + * + * @return void */ public function __construct() { @@ -57,6 +59,7 @@ class CI_Model { $CI =& get_instance(); return $CI->$key; } + } /* End of file Model.php */ diff --git a/system/core/Output.php b/system/core/Output.php index 513c657a6..c8feb4e67 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -44,49 +44,49 @@ class CI_Output { * @var string */ public $final_output; - + /** * Cache expiration time * * @var int */ public $cache_expiration = 0; - + /** * List of server headers * * @var array */ public $headers = array(); - + /** * List of mime types * * @var array */ public $mime_types = array(); - + /** * Determines wether profiler is enabled * * @var book */ public $enable_profiler = FALSE; - + /** * Determines if output compression is enabled * * @var bool */ protected $_zlib_oc = FALSE; - + /** * List of profiler sections * * @var array */ protected $_profiler_sections = array(); - + /** * Whether or not to parse variables like {elapsed_time} and {memory_usage} * @@ -96,6 +96,8 @@ class CI_Output { /** * Set up Output class + * + * @return void */ public function __construct() { @@ -177,7 +179,7 @@ class CI_Output { * * Lets you set a server header which will be outputted with the final display. * - * Note: If a file is cached, headers will not be sent. We need to figure out + * Note: If a file is cached, headers will not be sent. We need to figure out * how to permit header data to be saved with the cache data... * * @param string diff --git a/system/core/Router.php b/system/core/Router.php index 9314052fe..5ea13797b 100755 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -32,8 +32,8 @@ * * @package CodeIgniter * @subpackage Libraries - * @author EllisLab Dev Team * @category Libraries + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/general/routing.html */ class CI_Router { @@ -44,42 +44,42 @@ class CI_Router { * @var object */ public $config; - + /** * List of routes * * @var array */ public $routes = array(); - + /** * List of error routes * * @var array */ public $error_routes = array(); - + /** * Current class name * * @var string */ - public $class = ''; - + public $class = ''; + /** * Current method name * * @var string */ public $method = 'index'; - + /** * Sub-directory that contains the requested controller class * * @var string */ public $directory = ''; - + /** * Default controller (and method if specific) * @@ -91,6 +91,8 @@ class CI_Router { * Constructor * * Runs the route mapping function. + * + * @return void */ public function __construct() { @@ -433,12 +435,7 @@ class CI_Router { */ public function fetch_method() { - if ($this->method == $this->fetch_class()) - { - return 'index'; - } - - return $this->method; + return ($this->method == $this->fetch_class()) ? 'index' : $this->method; } // -------------------------------------------------------------------- diff --git a/system/core/Security.php b/system/core/Security.php index c82b69ff9..81b6602ae 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -102,9 +102,11 @@ class CI_Security { 'Redirect\s+302', "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?" ); - + /** * Initialize security class + * + * @return void */ public function __construct() { @@ -201,11 +203,11 @@ class CI_Security { } setcookie( - $this->_csrf_cookie_name, - $this->_csrf_hash, - $expire, - config_item('cookie_path'), - config_item('cookie_domain'), + $this->_csrf_cookie_name, + $this->_csrf_hash, + $expire, + config_item('cookie_path'), + config_item('cookie_domain'), $secure_cookie, config_item('cookie_httponly') ); @@ -626,7 +628,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 $3$5$6$7', $str, -1, $count); + $str = preg_replace('/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)('.implode('|', $attribs).')(.*?)([\s><])([><]*)/i', '<$1 $3$5$6$7', $str, -1, $count); } } while ($count); @@ -844,4 +846,4 @@ class CI_Security { } /* End of file Security.php */ -/* Location: ./system/core/Security.php */ +/* Location: ./system/core/Security.php */ \ No newline at end of file diff --git a/system/core/URI.php b/system/core/URI.php index cf82c5838..e66cb6dc5 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 + * @filesource */ /** @@ -43,21 +44,21 @@ class CI_URI { * @var array */ public $keyval = array(); - + /** * Current uri string * * @var string */ public $uri_string; - + /** * List of uri segments * * @var array */ public $segments = array(); - + /** * Re-indexed list of uri segments * Starts at 1 instead of 0 @@ -72,6 +73,8 @@ class CI_URI { * Simply globalizes the $RTR object. The front * loads the Router class early on so it's not available * normally as other classes are. + * + * @return void */ public function __construct() { @@ -148,7 +151,7 @@ class CI_URI { return; } - $path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri); + $path = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri); $this->_set_uri_string($path); } @@ -181,7 +184,7 @@ class CI_URI { */ protected function _detect_uri() { - if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME'])) + if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])) { return ''; } @@ -227,20 +230,19 @@ class CI_URI { } // -------------------------------------------------------------------- - + /** * Is cli Request? * * Duplicate of function from the Input class to test to see if a request was made from the command line * - * @return boolean + * @return bool */ protected function _is_cli_request() { - return (php_sapi_name() == 'cli') OR defined('STDIN'); + return (php_sapi_name() === 'cli') OR defined('STDIN'); } - // -------------------------------------------------------------------- /** @@ -253,7 +255,7 @@ class CI_URI { protected function _parse_cli_args() { $args = array_slice($_SERVER['argv'], 1); - return $args ? '/' . implode('/', $args) : ''; + return $args ? '/'.implode('/', $args) : ''; } // -------------------------------------------------------------------- @@ -327,7 +329,7 @@ class CI_URI { } // -------------------------------------------------------------------- - + /** * Re-index Segments * @@ -355,13 +357,13 @@ class CI_URI { * * This function returns the URI segment based on the number provided. * - * @param integer + * @param int * @param bool * @return string */ public function segment($n, $no_result = FALSE) { - return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n]; + return isset($this->segments[$n]) ? $this->segments[$n] : $no_result; } // -------------------------------------------------------------------- @@ -370,16 +372,16 @@ class CI_URI { * Fetch a URI "routed" Segment * * This function returns the re-routed URI segment (assuming routing rules are used) - * based on the number provided. If there is no routing this function returns the + * based on the number provided. If there is no routing this function returns the * same result as $this->segment() * - * @param integer + * @param int * @param bool * @return string */ public function rsegment($n, $no_result = FALSE) { - return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n]; + return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result; } // -------------------------------------------------------------------- @@ -400,7 +402,7 @@ class CI_URI { * gender => male * ) * - * @param integer the starting segment number + * @param int the starting segment number * @param array an array of default values * @return array */ @@ -408,13 +410,13 @@ class CI_URI { { return $this->_uri_to_assoc($n, $default, 'segment'); } - + // -------------------------------------------------------------------- - + /** * Identical to above only it uses the re-routed segment array * - * @param integer the starting segment number + * @param int the starting segment number * @param array an array of default values * @return array */ @@ -428,7 +430,7 @@ class CI_URI { /** * Generate a key value pair from the URI string or Re-routed URI string * - * @param integer the starting segment number + * @param int the starting segment number * @param array an array of default values * @param string which array we should use * @return array @@ -458,12 +460,9 @@ class CI_URI { if ($this->$total_segments() < $n) { - if (count($default) === 0) - { - return array(); - } - - return array_fill_keys($default, FALSE); + return (count($default) === 0) + ? array() + : array_fill_keys($default, FALSE); } $segments = array_slice($this->$segment_array(), ($n - 1)); @@ -512,7 +511,7 @@ class CI_URI { public function assoc_to_uri($array) { $temp = array(); - foreach ((array)$array as $key => $val) + foreach ( (array) $array as $key => $val) { $temp[] = $key; $temp[] = $val; @@ -526,7 +525,7 @@ class CI_URI { /** * Fetch a URI Segment and add a trailing slash * - * @param integer + * @param int * @param string * @return string */ @@ -540,7 +539,7 @@ class CI_URI { /** * Fetch a URI Segment and add a trailing slash * - * @param integer + * @param int * @param string * @return string */ @@ -554,7 +553,7 @@ class CI_URI { /** * Fetch a URI Segment and add a trailing slash - helper function * - * @param integer + * @param int * @param string * @param string * @return string @@ -604,7 +603,7 @@ class CI_URI { /** * Total number of segments * - * @return integer + * @return int */ public function total_segments() { @@ -616,7 +615,7 @@ class CI_URI { /** * Total number of routed segments * - * @return integer + * @return int */ public function total_rsegments() { @@ -651,4 +650,4 @@ class CI_URI { } /* End of file URI.php */ -/* Location: ./system/core/URI.php */ +/* Location: ./system/core/URI.php */ \ No newline at end of file diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 122020aea..a6faa84ec 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -42,6 +42,8 @@ class CI_Utf8 { * Constructor * * Determines if UTF-8 support is to be enabled + * + * @return void */ public function __construct() { @@ -124,7 +126,7 @@ class CI_Utf8 { * Attempts to convert a string to UTF-8 * * @param string - * @param string - input encoding + * @param string input encoding * @return string */ public function convert_to_utf8($str, $encoding) -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Cache/Cache.php | 4 +- system/libraries/Cache/drivers/Cache_file.php | 2 + system/libraries/Cache/drivers/Cache_memcached.php | 4 +- system/libraries/Calendar.php | 41 ++-- system/libraries/Cart.php | 31 +-- system/libraries/Driver.php | 8 +- system/libraries/Email.php | 206 ++++++++--------- system/libraries/Encrypt.php | 12 +- system/libraries/Form_validation.php | 60 +++-- system/libraries/Ftp.php | 2 - system/libraries/Image_lib.php | 252 +++++++++++---------- system/libraries/Log.php | 18 +- system/libraries/Migration.php | 13 +- system/libraries/Pagination.php | 1 + system/libraries/Parser.php | 26 +-- system/libraries/Profiler.php | 1 + system/libraries/Session.php | 1 + system/libraries/Table.php | 16 +- system/libraries/Typography.php | 4 +- system/libraries/Unit_test.php | 4 +- system/libraries/Upload.php | 4 +- system/libraries/Xmlrpcs.php | 9 +- system/libraries/Zip.php | 12 +- system/libraries/javascript/Jquery.php | 66 +++--- 24 files changed, 383 insertions(+), 414 deletions(-) diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 0493d5a6e..ba732ee8e 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -55,14 +55,14 @@ class CI_Cache extends CI_Driver_Library { * @var string */ protected $_cache_path = NULL; - + /** * Reference to the driver * * @var mixed */ protected $_adapter = 'dummy'; - + /** * Fallback driver * diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index ec4195278..f0eb8bdf7 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -45,6 +45,8 @@ class CI_Cache_file extends CI_Driver { /** * Initialize file-based cache + * + * @return void */ public function __construct() { diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 813df4b1c..1df149c2d 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -77,7 +77,7 @@ class CI_Cache_memcached extends CI_Driver { * @param string unique identifier * @param mixed data being cached * @param int time to live - * @return bool true on success, false on failure + * @return bool true on success, false on failure */ public function save($id, $data, $ttl = 60) { @@ -99,7 +99,7 @@ class CI_Cache_memcached extends CI_Driver { * Delete from Cache * * @param mixed key to be deleted. - * @return bool true on success, false on failure + * @return bool true on success, false on failure */ public function delete($id) { diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 4db754f5e..92f372b20 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -44,55 +44,55 @@ class CI_Calendar { * @var object */ protected $CI; - + /** * Current local time * * @var int */ public $local_time; - + /** * Calendar layout template * * @var string */ public $template = ''; - + /** * Day of the week to start the calendar on * * @var string */ public $start_day = 'sunday'; - + /** * How to display months * * @var string */ public $month_type = 'long'; - + /** * How to display names of days * * @var string */ public $day_type = 'abr'; - + /** * Whether to show next/prev month links * * @var bool */ - public $show_next_prev = FALSE; - + public $show_next_prev = FALSE; + /** * Url base to use for next/prev month links * * @var bool */ - public $next_prev_url = ''; + public $next_prev_url = ''; /** * Constructor @@ -187,7 +187,7 @@ class CI_Calendar { // Set the starting day of the week $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6); - $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day]; + $start_day = isset($start_days[$this->start_day]) ? $start_days[$this->start_day] : 0; // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); @@ -290,9 +290,7 @@ class CI_Calendar { $out .= "\n".$this->temp['cal_row_end']."\n"; } - $out .= "\n".$this->temp['table_close']; - - return $out; + return $out .= "\n".$this->temp['table_close']; } // -------------------------------------------------------------------- @@ -317,14 +315,9 @@ class CI_Calendar { $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december'); } - $month = $month_names[$month]; - - if ($this->CI->lang->line($month) === FALSE) - { - return ucfirst(substr($month, 4)); - } - - return $this->CI->lang->line($month); + return ($this->CI->lang->line($month_names[$month]) === FALSE) + ? ucfirst(substr($month_names[$month], 4)) + : $this->CI->lang->line($month_names[$month]); } // -------------------------------------------------------------------- @@ -345,11 +338,11 @@ class CI_Calendar { $this->day_type = $day_type; } - if ($this->day_type == 'long') + if ($this->day_type === 'long') { $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); } - elseif ($this->day_type == 'short') + elseif ($this->day_type === 'short') { $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); } @@ -448,7 +441,7 @@ class CI_Calendar { */ public function default_template() { - return array ( + return array( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index eee123584..b73ed5128 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -39,11 +39,11 @@ class CI_Cart { /** * These are the regular expression rules that we use to validate the product ID and product name * alpha-numeric, dashes, underscores, or periods - * + * * @var string */ public $product_id_rules = '\.a-z0-9_-'; - + /** * These are the regular expression rules that we use to validate the product ID and product name * alpha-numeric, dashes, underscores, colons or periods @@ -51,7 +51,7 @@ class CI_Cart { * @var string */ public $product_name_rules = '\.\:\-_ a-z0-9'; - + /** * only allow safe product names * @@ -62,14 +62,14 @@ class CI_Cart { // -------------------------------------------------------------------------- // Protected variables. Do not change! // -------------------------------------------------------------------------- - + /** * Reference to CodeIgniter instance * * @var object */ protected $CI; - + /** * Contents of the cart * @@ -83,6 +83,7 @@ class CI_Cart { * The constructor loads the Session class, used to store the shopping cart contents. * * @param array + * @return void */ public function __construct($params = array()) { @@ -180,7 +181,7 @@ class CI_Cart { // -------------------------------------------------------------------- // Does the $items array contain an id, quantity, price, and name? These are required - if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name'])) + if ( ! isset($items['id'], $items['qty'], $items['price'], $items['name'])) { log_message('error', 'The cart array must contain a product ID, quantity, price, and name.'); return FALSE; @@ -341,7 +342,7 @@ class CI_Cart { protected function _update($items = array()) { // Without these array indexes there is nothing we can do - if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']])) + if ( ! isset($items['qty'], $items['rowid'], $this->_cart_contents[$items['rowid']])) { return FALSE; } @@ -383,7 +384,7 @@ class CI_Cart { foreach ($this->_cart_contents as $key => $val) { // We make sure the array contains the proper indexes - if ( ! is_array($val) OR ! isset($val['price']) OR ! isset($val['qty'])) + if ( ! is_array($val) OR ! isset($val['price'], $val['qty'])) { continue; } @@ -393,7 +394,7 @@ class CI_Cart { $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } - // Is our cart empty? If so we delete it from the session + // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { $this->CI->session->unset_userdata('cart_contents'); @@ -489,7 +490,7 @@ class CI_Cart { */ public function has_options($rowid = '') { - return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0) ? TRUE : FALSE; + return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0); } // -------------------------------------------------------------------- @@ -519,15 +520,7 @@ class CI_Cart { */ public function format_number($n = '') { - if ($n == '') - { - return ''; - } - - // Remove anything that isn't a number or decimal point. - $n = (float) $n; - - return number_format($n, 2, '.', ','); + return ($n == '') ? '' : number_format( (float) $n, 2, '.', ','); } // -------------------------------------------------------------------- diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index b1fff154d..c79698c7b 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -45,7 +45,7 @@ class CI_Driver_Library { * @var array */ protected $valid_drivers = array(); - + /** * Name of the current class - usually the driver class * @@ -57,8 +57,8 @@ class CI_Driver_Library { * The first time a child is used it won't exist, so we instantiate it * subsequents calls will go straight to the proper child. * - * @param mixed $child - * @return mixed + * @param mixed $child + * @return mixed */ public function __get($child) { @@ -145,7 +145,7 @@ class CI_Driver { * @var array */ protected $_methods = array(); - + /** * List of properties in the parent class * diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 103c3cb25..56d60c802 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -93,6 +93,8 @@ class CI_Email { * Constructor - Sets Email Preferences * * The constructor can be passed an array of config values + * + * @return void */ public function __construct($config = array()) { @@ -303,8 +305,7 @@ class CI_Email { */ public function cc($cc) { - $cc = $this->_str_to_array($cc); - $cc = $this->clean_email($cc); + $cc = $this->clean_email($this->_str_to_array($cc)); if ($this->validate) { @@ -338,8 +339,7 @@ class CI_Email { $this->bcc_batch_size = $limit; } - $bcc = $this->_str_to_array($bcc); - $bcc = $this->clean_email($bcc); + $bcc = $this->clean_email($this->_str_to_array($bcc)); if ($this->validate) { @@ -441,15 +441,11 @@ class CI_Email { { if ( ! is_array($email)) { - if (strpos($email, ',') !== FALSE) - { - $email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY); - } - else - { - $email = (array) trim($email); - } + return (strpos($email, ',') !== FALSE) + ? preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY) + : (array) trim($email); } + return $email; } @@ -477,7 +473,7 @@ class CI_Email { */ public function set_mailtype($type = 'text') { - $this->mailtype = ($type == 'html') ? 'html' : 'text'; + $this->mailtype = ($type === 'html') ? 'html' : 'text'; return $this; } @@ -574,7 +570,7 @@ class CI_Email { protected function _get_message_id() { $from = str_replace(array('>', '<'), '', $this->_headers['Return-Path']); - return '<'.uniqid('').strstr($from, '@').'>'; + return '<'.uniqid('').strstr($from, '@').'>'; } // -------------------------------------------------------------------- @@ -631,13 +627,9 @@ class CI_Email { */ protected function _get_content_type() { - if ($this->mailtype === 'html' && count($this->_attach_name) === 0) - { - return 'html'; - } - elseif ($this->mailtype === 'html' && count($this->_attach_name) > 0) + if ($this->mailtype === 'html') { - return 'html-attach'; + return (count($this->_attach_name) == 0) ? 'html' : 'html-attach'; } elseif ($this->mailtype === 'text' && count($this->_attach_name) > 0) { @@ -731,7 +723,7 @@ class CI_Email { { if ( ! is_array($email)) { - return (preg_match('/\<(.*)\>/', $email, $match)) ? $match[1] : $email; + return preg_match('/\<(.*)\>/', $email, $match) ? $match[1] : $email; } $clean_email = array(); @@ -763,7 +755,7 @@ class CI_Email { return $this->word_wrap($this->alt_message, '76'); } - $body = (preg_match('/\(.*)\<\/body\>/si', $this->_body, $match)) ? $match[1] : $this->_body; + $body = preg_match('/\(.*)\<\/body\>/si', $this->_body, $match) ? $match[1] : $this->_body; $body = str_replace("\t", '', preg_replace('# '.$msg."\n"; + $message .= $level.' '.($level === 'INFO' ? ' -' : '-').' '.date($this->_date_fmt).' --> '.$msg."\n"; flock($fp, LOCK_EX); fwrite($fp, $message); diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index ce4683fc1..0a88e6926 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -45,28 +45,28 @@ class CI_Migration { * @var bool */ protected $_migration_enabled = FALSE; - + /** * Path to migration classes * * @var string */ protected $_migration_path = NULL; - + /** * Current migration version * * @var mixed */ protected $_migration_version = 0; - + /** * Database table with migration info * * @var string */ protected $_migration_table = 'migrations'; - + /** * Whether to automatically run migrations * @@ -85,6 +85,7 @@ class CI_Migration { * Initialize Migration Class * * @param array + * @return void */ public function __construct($config = array()) { @@ -96,7 +97,7 @@ class CI_Migration { foreach ($config as $key => $val) { - $this->{'_' . $key} = $val; + $this->{'_'.$key} = $val; } log_message('debug', 'Migrations class initialized'); @@ -340,7 +341,6 @@ class CI_Migration { } sort($files); - return $files; } @@ -384,6 +384,7 @@ class CI_Migration { { return get_instance()->$var; } + } /* End of file Migration.php */ diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 3d2911813..58f86fa17 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -73,6 +73,7 @@ class CI_Pagination { * Constructor * * @param array initialization parameters + * @return void */ public function __construct($params = array()) { diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index c40f339b4..a0b60ed97 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -42,14 +42,14 @@ class CI_Parser { * @var string */ public $l_delim = '{'; - + /** * Right delimeter character for psuedo vars * * @var string */ public $r_delim = '}'; - + /** * Reference to CodeIgniter instance * @@ -116,14 +116,9 @@ class CI_Parser { foreach ($data as $key => $val) { - if (is_array($val)) - { - $template = $this->_parse_pair($key, $val, $template); - } - else - { - $template = $this->_parse_single($key, (string)$val, $template); - } + $template = is_array($val) + ? $this->_parse_pair($key, $val, $template) + : $template = $this->_parse_single($key, (string) $val, $template); } if ($return == FALSE) @@ -189,14 +184,9 @@ class CI_Parser { $temp = $match[1]; foreach ($row as $key => $val) { - if ( ! is_array($val)) - { - $temp = $this->_parse_single($key, $val, $temp); - } - else - { - $temp = $this->_parse_pair($key, $val, $temp); - } + $temp = is_array($val) + ? $this->_parse_pair($key, $val, $temp) + : $this->_parse_single($key, $val, $temp); } $str .= $temp; diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 1e86f3c61..e219d20f2 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -527,6 +527,7 @@ class CI_Profiler { return $output.''; } + } /* End of file Profiler.php */ diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3195f0a91..783109a60 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -190,6 +190,7 @@ class CI_Session { * whenever the class is instantiated. * * @param array + * @return void */ public function __construct($params = array()) { diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 236129531..f844d6435 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -44,49 +44,49 @@ class CI_Table { * @var array */ public $rows = array(); - + /** * Data for table heading * * @var array */ public $heading = array(); - + /** * Whether or not to automatically create the table header * * @var bool */ public $auto_heading = TRUE; - + /** * Table caption * * @var string */ public $caption = NULL; - + /** - * Table layout template + * Table layout template * * @var array */ public $template = NULL; - + /** * Newline setting * * @var string */ public $newline = "\n"; - + /** * Contents of empty cells * * @var string */ public $empty_cells = ''; - + /** * Callback for custom table layout * diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 50bd12486..6aaa993ae 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -38,7 +38,7 @@ class CI_Typography { /** * Block level elements that should not be wrapped inside

    tags - * + * * @var string */ public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; @@ -52,7 +52,7 @@ class CI_Typography { /** * Tags we want the parser to completely ignore when splitting the string. - * + * * @var string */ public $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 0f6e2dfdd..6ec2dcd5d 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -350,11 +350,11 @@ class CI_Unit_test { */ function is_true($test) { - return (is_bool($test) && $test === TRUE); + return ($test === TRUE); } function is_false($test) { - return (is_bool($test) && $test === FALSE); + return ($test === FALSE); } /* End of file Unit_test.php */ diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 24d4bd4d0..271c6d21f 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1036,7 +1036,7 @@ class CI_Upload { */ if (DIRECTORY_SEPARATOR !== '\\') { - $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1'; + $cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'; if (function_exists('exec')) { @@ -1103,4 +1103,4 @@ class CI_Upload { } /* End of file Upload.php */ -/* Location: ./system/libraries/Upload.php */ +/* Location: ./system/libraries/Upload.php */ \ No newline at end of file diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index f0c5b48e7..1853906ea 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -54,21 +54,21 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @var array */ public $methods = array(); - + /** * Debug Message * * @var string */ public $debug_msg = ''; - + /** * XML RPC Server methods * * @var array */ public $system_methods = array(); - + /** * Configuration object * @@ -79,7 +79,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Initialize XMLRPC class * - * @param array $config + * @param array $config + * @return void */ public function __construct($config = array()) { diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 86d0787b2..e0dc637ad 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -48,35 +48,35 @@ class CI_Zip { * @var string */ public $zipdata = ''; - + /** * Zip data for a directory in string form * * @var string */ public $directory = ''; - + /** * Number of files/folder in zip file * * @var int */ public $entries = 0; - + /** * Number of files in zip * * @var int */ public $file_num = 0; - + /** * relative offset of local header * * @var int */ public $offset = 0; - + /** * Reference to time at init * @@ -87,7 +87,7 @@ class CI_Zip { /** * Initialize zip compression class * - * @return void + * @return void */ public function __construct() { diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index f30d7c639..3c9ae1867 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Jquery Class * @@ -57,7 +55,7 @@ class CI_Jquery extends CI_Javascript { $this->script(); } - log_message('debug', "Jquery Class Initialized"); + log_message('debug', 'Jquery Class Initialized'); } // -------------------------------------------------------------------- @@ -115,7 +113,7 @@ class CI_Jquery extends CI_Javascript { if ($ret_false) { - $js[] = "return false;"; + $js[] = 'return false;'; } return $this->_add_event($element, $js, 'click'); @@ -183,7 +181,7 @@ class CI_Jquery extends CI_Javascript { */ protected function _hover($element = 'this', $over, $out) { - $event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; + $event = "\n\t$(".$this->_prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; $this->jquery_code_for_compile[] = $event; @@ -322,7 +320,7 @@ class CI_Jquery extends CI_Javascript { foreach ($array_js as $js) { - $this->jquery_code_for_compile[] = "\t$js\n"; + $this->jquery_code_for_compile[] = "\t".$js."\n"; } } @@ -389,7 +387,7 @@ class CI_Jquery extends CI_Javascript { protected function _addClass($element = 'this', $class='') { $element = $this->_prep_element($element); - return "$({$element}).addClass(\"$class\");"; + return '$('.$element.').addClass("'.$class.'");'; } // -------------------------------------------------------------------- @@ -411,9 +409,9 @@ class CI_Jquery extends CI_Javascript { $animations = "\t\t\t"; - foreach ($params as $param=>$value) + foreach ($params as $param => $value) { - $animations .= $param.': \''.$value.'\', '; + $animations .= $param.": '".$value."', "; } $animations = substr($animations, 0, -2); // remove the last ", " @@ -428,7 +426,7 @@ class CI_Jquery extends CI_Javascript { $extra = ', '.$extra; } - return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; + return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');'; } // -------------------------------------------------------------------- @@ -478,7 +476,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).fadeOut({$speed}{$callback});"; + return '$('.$element.').fadeOut('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -519,7 +517,7 @@ class CI_Jquery extends CI_Javascript { protected function _removeClass($element = 'this', $class='') { $element = $this->_prep_element($element); - return "$({$element}).removeClass(\"$class\");"; + return '$('.$element.').removeClass("'.$class.'");'; } // -------------------------------------------------------------------- @@ -544,7 +542,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).slideUp({$speed}{$callback});"; + return '$('.$element.').slideUp('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -569,7 +567,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).slideDown({$speed}{$callback});"; + return '$('.$element.').slideDown('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -594,7 +592,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).slideToggle({$speed}{$callback});"; + return '$('.$element.').slideToggle('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -610,7 +608,7 @@ class CI_Jquery extends CI_Javascript { protected function _toggle($element = 'this') { $element = $this->_prep_element($element); - return "$({$element}).toggle();"; + return '$('.$element.').toggle();'; } // -------------------------------------------------------------------- @@ -626,7 +624,7 @@ class CI_Jquery extends CI_Javascript { protected function _toggleClass($element = 'this', $class='') { $element = $this->_prep_element($element); - return "$({$element}).toggleClass(\"$class\");"; + return '$('.$element.').toggleClass("'.$class.'");'; } // -------------------------------------------------------------------- @@ -651,7 +649,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).show({$speed}{$callback});"; + return '$('.$element.').show('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -676,22 +674,22 @@ class CI_Jquery extends CI_Javascript { // ajaxStart and ajaxStop are better choices here... but this is a stop gap if ($this->CI->config->item('javascript_ajax_img') == '') { - $loading_notifier = "Loading..."; + $loading_notifier = 'Loading...'; } else { - $loading_notifier = 'CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'\' alt=\'Loading\' />'; + $loading_notifier = 'Loading'; } - $updater = "$($container).empty();\n" // anything that was in... get it out - . "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image + $updater = '$('.$container.").empty();\n" // anything that was in... get it out + ."\t\t$(".$container.').prepend("'.$loading_notifier."\");\n"; // to replace with an image $request_options = ''; if ($options != '') { $request_options .= ', {' - . (is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'") - . '}'; + .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'") + .'}'; } return $updater."\t\t$($container).load('$controller'$request_options);"; @@ -746,7 +744,7 @@ class CI_Jquery extends CI_Javascript { $corner_style = '"'.$corner_style.'"'; } - return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");"; + return '$('.$this->_prep_element($element).').corner('.$corner_style.');'; } // -------------------------------------------------------------------- @@ -821,16 +819,16 @@ class CI_Jquery extends CI_Javascript { $sort_options = array(); foreach ($options as $k=>$v) { - $sort_options[] = "\n\t\t".$k.': '.$v.""; + $sort_options[] = "\n\t\t".$k.': '.$v; } - $sort_options = implode(",", $sort_options); + $sort_options = implode(',', $sort_options); } else { $sort_options = ''; } - return "$(" . $this->_prep_element($element) . ").sortable({".$sort_options."\n\t});"; + return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});"; } // -------------------------------------------------------------------- @@ -844,7 +842,7 @@ class CI_Jquery extends CI_Javascript { */ public function tablesorter($table = '', $options = '') { - $this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n"; + $this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n"; } // -------------------------------------------------------------------- @@ -869,7 +867,7 @@ class CI_Jquery extends CI_Javascript { } - $event = "\n\t$(" . $this->_prep_element($element) . ").{$event}(function(){\n\t\t{$js}\n\t});\n"; + $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n"; $this->jquery_code_for_compile[] = $event; return $event; } @@ -898,8 +896,8 @@ class CI_Jquery extends CI_Javascript { // Inline references $script = '$(document).ready(function() {'."\n" - . implode('', $this->jquery_code_for_compile) - . '});'; + .implode('', $this->jquery_code_for_compile) + .'});'; $output = ($script_tags === FALSE) ? $script : $this->inline($script); @@ -998,7 +996,7 @@ class CI_Jquery extends CI_Javascript { { return '"'.$speed.'"'; } - elseif (preg_match("/[^0-9]/", $speed)) + elseif (preg_match('/[^0-9]/', $speed)) { return ''; } @@ -1009,4 +1007,4 @@ class CI_Jquery extends CI_Javascript { } /* End of file Jquery.php */ -/* Location: ./system/libraries/Jquery.php */ +/* Location: ./system/libraries/Jquery.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 421d6abf1ad3a1cfb96f9aad326c72c9b6fa3a06 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 07:46:25 -0400 Subject: Remove regex validation in favor of filter_var --- system/helpers/email_helper.php | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index 449aadfc2..ea9f6105d 100644 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.php @@ -50,39 +50,7 @@ if ( ! function_exists('valid_email')) */ function valid_email($email) { - // Use PHP's filters if they exist - if (function_exists('filter_var')) - { - return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); - } - - // Fallback based on RFC822 - $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; - - $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; - - $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'. - '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; - - $quoted_pair = '\\x5c[\\x00-\\x7f]'; - - $domain_literal = "\\x5b({$dtext}|{$quoted_pair})*\\x5d"; - - $quoted_string = "\\x22({$qtext}|{$quoted_pair})*\\x22"; - - $domain_ref = $atom; - - $sub_domain = "({$domain_ref}|{$domain_literal})"; - - $word = "({$atom}|{$quoted_string})"; - - $domain = "{$sub_domain}(\\x2e{$sub_domain})*"; - - $local_part = "{$word}(\\x2e{$word})*"; - - $addr_spec = "{$local_part}\\x40{$domain}"; - - return (bool) preg_match("!^{$addr_spec}$!", $email); + return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); } } -- cgit v1.2.3-24-g4f1b From ae31eb5e75d914fc3ab622a7ac5c23eb1e6d9f9a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:54:15 +0300 Subject: Clean up the helpers --- system/helpers/date_helper.php | 65 ++++++++++++++++++------------------- system/helpers/download_helper.php | 2 +- system/helpers/form_helper.php | 1 - system/helpers/html_helper.php | 8 ++--- system/helpers/inflector_helper.php | 2 +- system/helpers/url_helper.php | 4 +-- 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 531d1d32f..5f0427f7d 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -100,7 +100,7 @@ if ( ! function_exists('mdate')) $datestr = str_replace( '%\\', '', - preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr) + preg_replace('/([a-z]+?){1}/i', '\\\\\\1', $datestr) ); return date($datestr, $time); @@ -316,12 +316,12 @@ if ( ! function_exists('local_to_gmt')) } return mktime( - gmdate("H", $time), - gmdate("i", $time), - gmdate("s", $time), - gmdate("m", $time), - gmdate("d", $time), - gmdate("Y", $time) + gmdate('H', $time), + gmdate('i', $time), + gmdate('s', $time), + gmdate('m', $time), + gmdate('d', $time), + gmdate('Y', $time) ); } } @@ -452,8 +452,7 @@ if ( ! function_exists('human_to_unix')) return FALSE; } - $datestr = trim($datestr); - $datestr = preg_replace("/\040+/", ' ', $datestr); + $datestr = preg_replace('/\040+/', ' ', trim($datestr)); if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr)) { @@ -462,20 +461,20 @@ if ( ! function_exists('human_to_unix')) $split = explode(' ', $datestr); - $ex = explode("-", $split['0']); + $ex = explode('-', $split['0']); - $year = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0']; - $month = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1']; - $day = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2']; + $year = (strlen($ex[0]) === 2) ? '20'.$ex[0] : $ex[0]; + $month = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; + $day = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; - $ex = explode(":", $split['1']); + $ex = explode(':', $split['1']); - $hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0']; - $min = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1']; + $hour = (strlen($ex[0]) === 1) ? '0'.$ex[0] : $ex[0]; + $min = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; - if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2'])) + if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex[2])) { - $sec = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2']; + $sec = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; } else { @@ -485,11 +484,11 @@ if ( ! function_exists('human_to_unix')) if (isset($split['2'])) { - $ampm = strtolower($split['2']); + $ampm = strtolower($split[2]); if (substr($ampm, 0, 1) === 'p' && $hour < 12) { - $hour = $hour + 12; + $hour += 12; } if (substr($ampm, 0, 1) === 'a' && $hour == 12) @@ -497,7 +496,7 @@ if ( ! function_exists('human_to_unix')) $hour = '00'; } - if (strlen($hour) == 1) + if (strlen($hour) === 1) { $hour = '0'.$hour; } @@ -529,7 +528,7 @@ if ( ! function_exists('nice_date')) // Date like: YYYYMM if (preg_match('/^\d{6}$/', $bad_date)) { - if (in_array(substr($bad_date, 0, 2),array('19', '20'))) + if (in_array(substr($bad_date, 0, 2), array('19', '20'))) { $year = substr($bad_date, 0, 4); $month = substr($bad_date, 4, 2); @@ -540,24 +539,24 @@ if ( ! function_exists('nice_date')) $year = substr($bad_date, 2, 4); } - return date($format, strtotime($year . '-' . $month . '-01')); + return date($format, strtotime($year.'-'.$month.'-01')); } // Date Like: YYYYMMDD - if (preg_match('/^\d{8}$/',$bad_date)) + if (preg_match('/^\d{8}$/', $bad_date)) { $month = substr($bad_date, 0, 2); $day = substr($bad_date, 2, 2); $year = substr($bad_date, 4, 4); - return date($format, strtotime($month . '/01/' . $year)); + return date($format, strtotime($month.'/01/'.$year)); } // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) - if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/',$bad_date)) + if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/', $bad_date)) { list($m, $d, $y) = explode('-', $bad_date); - return date($format, strtotime("{$y}-{$m}-{$d}")); + return date($format, strtotime($y.'-'.$m.'-'.$d)); } // Any other kind of string, when converted into UNIX time, @@ -565,7 +564,7 @@ if ( ! function_exists('nice_date')) // return "Invalid Date". if (date('U', strtotime($bad_date)) == '0') { - return "Invalid Date"; + return 'Invalid Date'; } // It's probably a valid-ish date format already @@ -587,7 +586,7 @@ if ( ! function_exists('timezone_menu')) * @param string menu name * @return string */ - function timezone_menu($default = 'UTC', $class = "", $name = 'timezones') + function timezone_menu($default = 'UTC', $class = '', $name = 'timezones') { $CI =& get_instance(); $CI->lang->load('date'); @@ -605,13 +604,11 @@ if ( ! function_exists('timezone_menu')) foreach (timezones() as $key => $val) { - $selected = ($default == $key) ? " selected='selected'" : ''; - $menu .= "\n"; + $selected = ($default == $key) ? ' selected="selected"' : ''; + $menu .= '\n"; } - $menu .= ""; - - return $menu; + return $menu.''; } } diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 97e6986b0..470b61ede 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -100,7 +100,7 @@ if ( ! function_exists('force_download')) $x[count($x) - 1] = strtoupper($extension); $filename = implode('.', $x); } - + // Clean output buffer ob_clean(); diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index b246d72f3..eca6c5f1e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -184,7 +184,6 @@ if ( ! function_exists('form_input')) // ------------------------------------------------------------------------ - if ( ! function_exists('form_password')) { /** diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 124f58009..92a6db477 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -379,10 +379,10 @@ if ( ! function_exists('meta')) $str = ''; foreach ($name as $meta) { - $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv'; - $name = ( ! isset($meta['name'])) ? '' : $meta['name']; - $content = ( ! isset($meta['content'])) ? '' : $meta['content']; - $newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline']; + $type = ( ! isset($meta['type']) OR $meta['type'] === 'name') ? 'name' : 'http-equiv'; + $name = isset($meta['name']) ? $meta['name'] : ''; + $content = isset($meta['content']) ? $meta['content'] : ''; + $newline = isset($meta['newline']) ? $meta['newline'] : "\n"; $str .= ''.$newline; } diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index feeaf57d7..2a9466305 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -201,7 +201,7 @@ if ( ! function_exists('underscore')) * * @param string $str * @param string $separator - * @return str + * @return string */ if ( ! function_exists('humanize')) { diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 5576c2748..cf6df4ef5 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -198,7 +198,7 @@ if ( ! function_exists('anchor_popup')) if ($attributes === FALSE) { - return "".$title.''; + return '".$title.''; } if ( ! is_array($attributes)) @@ -217,7 +217,7 @@ if ( ! function_exists('anchor_popup')) $attributes = _parse_attributes($attributes); } - return "'.$title.''; + return ''.$title.''; } } -- cgit v1.2.3-24-g4f1b From d013c63462b4eaa2ac2f684b2ad498a9c4fb7dd5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:15:47 -0400 Subject: tweak and changelog entry --- system/helpers/email_helper.php | 5 +---- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index ea9f6105d..628667d4d 100644 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.php @@ -42,15 +42,12 @@ if ( ! function_exists('valid_email')) /** * Validate email address * - * Updated to be more accurate to RFC822 - * see: http://www.iamcal.com/publish/articles/php/parsing_email/ - * * @param string * @return bool */ function valid_email($email) { - return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); + return filter_var($email, FILTER_VALIDATE_EMAIL); } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d33a6a635..f835a8c8d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -52,6 +52,7 @@ Release Date: Not Released - set_realpath() can now also handle file paths as opposed to just directories. - do_hash() now uses PHP's native hash() function, supporting more algorithms. - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. + - Updated email helper to use ``filter_var`` to validate email addresses - Database -- cgit v1.2.3-24-g4f1b From 16642c71403f4463dfe6e83c13a0e3120474cd1d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:20:16 -0400 Subject: Update inflector docblocks, add changelog entry --- system/helpers/inflector_helper.php | 10 +++++----- user_guide_src/source/changelog.rst | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 72615671c..647d840e4 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -45,7 +45,7 @@ if ( ! function_exists('singular')) * Takes a plural word and makes it singular * * @param string - * @return str + * @return string */ function singular($str) { @@ -110,7 +110,7 @@ if ( ! function_exists('plural')) * * @param string * @param bool - * @return str + * @return string */ function plural($str, $force = FALSE) { @@ -166,7 +166,7 @@ if ( ! function_exists('camelize')) * Takes multiple words separated by spaces or underscores and camelizes them * * @param string - * @return str + * @return string */ function camelize($str) { @@ -184,7 +184,7 @@ if ( ! function_exists('underscore')) * Takes multiple words separated by spaces and underscores them * * @param string - * @return str + * @return string */ function underscore($str) { @@ -203,7 +203,7 @@ if ( ! function_exists('humanize')) * * @param string $str * @param string $separator - * @return str + * @return string */ function humanize($str, $separator = '_') { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d33a6a635..0066af9ad 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -52,6 +52,7 @@ Release Date: Not Released - set_realpath() can now also handle file paths as opposed to just directories. - do_hash() now uses PHP's native hash() function, supporting more algorithms. - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. + - Removed deprecated helper function ``js_insert_smiley`` from smiley helper. - Database -- cgit v1.2.3-24-g4f1b From f0eb2f133bf43be7ffa1bf71babf4ed28852e71b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:32:11 -0400 Subject: Suggested changes --- system/helpers/number_helper.php | 2 +- system/helpers/smiley_helper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index 2a906ba1b..e49f2f7a0 100644 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.php @@ -42,7 +42,7 @@ if ( ! function_exists('byte_format')) /** * Formats a numbers as bytes, based on size, and adds the appropriate suffix * - * @param mixed // will be cast as int + * @param mixed will be cast as int * @param int * @return string */ diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 4320dd392..5e6de08af 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -130,7 +130,7 @@ if ( ! function_exists('get_clickable_smileys')) * * @param string the URL to the folder containing the smiley images * @param array - * @param array + * @param array * @return array */ function get_clickable_smileys($image_url, $alias = '', $smileys = NULL) -- cgit v1.2.3-24-g4f1b From 98fde46fb938694feb1f36e590c4cfa5c97c3261 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:33:05 -0400 Subject: Add parens to changelog entry --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0066af9ad..7fc5ee5a0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -52,7 +52,7 @@ Release Date: Not Released - set_realpath() can now also handle file paths as opposed to just directories. - do_hash() now uses PHP's native hash() function, supporting more algorithms. - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. - - Removed deprecated helper function ``js_insert_smiley`` from smiley helper. + - Removed deprecated helper function ``js_insert_smiley()`` from smiley helper. - Database -- cgit v1.2.3-24-g4f1b From 97aefa5cd41475d5b404ced56052008beebf8f40 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:55:55 -0400 Subject: Added changelog entry --- 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 7fc5ee5a0..933743c38 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -38,6 +38,7 @@ Release Date: Not Released Only entries in ``$autoload['libraries']`` are auto-loaded now. - Added some more doctypes. - Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties. + - Moved error templates to "application/views/errors" - Helpers -- cgit v1.2.3-24-g4f1b From 7d22f0adbe5df5c93ae1ee367acad7568d555f0a Mon Sep 17 00:00:00 2001 From: Pawel Decowski Date: Thu, 17 May 2012 15:06:25 +0200 Subject: Remove set_time_limit() call. CodeIgniter should respect php.ini setting. --- system/core/CodeIgniter.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 00db6e13a..e1892ee7e 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -99,17 +99,6 @@ get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } -/* - * ------------------------------------------------------ - * Set a liberal script execution time limit - * ------------------------------------------------------ - */ - if (function_exists('set_time_limit') && @ini_get('safe_mode') == 0 - && php_sapi_name() !== 'cli') // Do not override the Time Limit value if running from Command Line - { - @set_time_limit(300); - } - /* * ------------------------------------------------------ * Start the timer... tick tock tick tock... -- cgit v1.2.3-24-g4f1b From 324ef078dda5a3596444152ba49dd591a61adba6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 17 May 2012 14:45:25 +0100 Subject: Added upgrade for 2.1.1 and updated version. --- system/core/CodeIgniter.php | 2 +- system/database/drivers/pdo/pdo_driver.php | 2 +- system/database/drivers/pdo/pdo_forge.php | 2 +- system/database/drivers/pdo/pdo_result.php | 2 +- system/database/drivers/pdo/pdo_utility.php | 2 +- system/libraries/Cache/Cache.php | 2 +- system/libraries/Cache/drivers/Cache_apc.php | 2 +- system/libraries/Cache/drivers/Cache_dummy.php | 2 +- system/libraries/Cache/drivers/Cache_file.php | 2 +- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- system/libraries/Cart.php | 2 +- system/libraries/Driver.php | 2 +- system/libraries/Migration.php | 2 +- user_guide/changelog.html | 4 +- user_guide/database/active_record.html | 4 +- user_guide/database/caching.html | 4 +- user_guide/database/call_function.html | 4 +- user_guide/database/configuration.html | 4 +- user_guide/database/connecting.html | 4 +- user_guide/database/examples.html | 4 +- user_guide/database/fields.html | 4 +- user_guide/database/forge.html | 4 +- user_guide/database/helpers.html | 4 +- user_guide/database/index.html | 4 +- user_guide/database/queries.html | 4 +- user_guide/database/results.html | 4 +- user_guide/database/table_data.html | 4 +- user_guide/database/transactions.html | 4 +- user_guide/database/utilities.html | 4 +- user_guide/doc_style/index.html | 4 +- user_guide/doc_style/template.html | 2 +- user_guide/general/alternative_php.html | 4 +- user_guide/general/ancillary_classes.html | 4 +- user_guide/general/autoloader.html | 4 +- user_guide/general/caching.html | 4 +- user_guide/general/cli.html | 4 +- user_guide/general/common_functions.html | 4 +- user_guide/general/controllers.html | 4 +- user_guide/general/core_classes.html | 4 +- user_guide/general/creating_drivers.html | 4 +- user_guide/general/creating_libraries.html | 4 +- user_guide/general/credits.html | 4 +- user_guide/general/drivers.html | 4 +- user_guide/general/environments.html | 4 +- user_guide/general/errors.html | 4 +- user_guide/general/helpers.html | 4 +- user_guide/general/hooks.html | 4 +- user_guide/general/libraries.html | 4 +- user_guide/general/managing_apps.html | 4 +- user_guide/general/models.html | 4 +- user_guide/general/profiling.html | 4 +- user_guide/general/quick_reference.html | 4 +- user_guide/general/requirements.html | 4 +- user_guide/general/reserved_names.html | 4 +- user_guide/general/routing.html | 4 +- user_guide/general/security.html | 4 +- user_guide/general/styleguide.html | 4 +- user_guide/general/urls.html | 4 +- user_guide/general/views.html | 4 +- user_guide/helpers/array_helper.html | 4 +- user_guide/helpers/captcha_helper.html | 4 +- user_guide/helpers/cookie_helper.html | 4 +- user_guide/helpers/date_helper.html | 4 +- user_guide/helpers/directory_helper.html | 4 +- user_guide/helpers/download_helper.html | 4 +- user_guide/helpers/email_helper.html | 4 +- user_guide/helpers/file_helper.html | 4 +- user_guide/helpers/form_helper.html | 4 +- user_guide/helpers/html_helper.html | 4 +- user_guide/helpers/inflector_helper.html | 4 +- user_guide/helpers/language_helper.html | 4 +- user_guide/helpers/number_helper.html | 4 +- user_guide/helpers/path_helper.html | 4 +- user_guide/helpers/security_helper.html | 4 +- user_guide/helpers/smiley_helper.html | 4 +- user_guide/helpers/string_helper.html | 4 +- user_guide/helpers/text_helper.html | 4 +- user_guide/helpers/typography_helper.html | 4 +- user_guide/helpers/url_helper.html | 4 +- user_guide/helpers/xml_helper.html | 4 +- user_guide/index.html | 4 +- user_guide/installation/downloads.html | 16 ++-- user_guide/installation/index.html | 4 +- user_guide/installation/troubleshooting.html | 4 +- user_guide/installation/upgrade_120.html | 4 +- user_guide/installation/upgrade_130.html | 4 +- user_guide/installation/upgrade_131.html | 4 +- user_guide/installation/upgrade_132.html | 4 +- user_guide/installation/upgrade_133.html | 4 +- user_guide/installation/upgrade_140.html | 4 +- user_guide/installation/upgrade_141.html | 4 +- user_guide/installation/upgrade_150.html | 4 +- user_guide/installation/upgrade_152.html | 4 +- user_guide/installation/upgrade_153.html | 4 +- user_guide/installation/upgrade_154.html | 4 +- user_guide/installation/upgrade_160.html | 4 +- user_guide/installation/upgrade_161.html | 4 +- user_guide/installation/upgrade_162.html | 4 +- user_guide/installation/upgrade_163.html | 4 +- user_guide/installation/upgrade_170.html | 4 +- user_guide/installation/upgrade_171.html | 4 +- user_guide/installation/upgrade_172.html | 4 +- user_guide/installation/upgrade_200.html | 4 +- user_guide/installation/upgrade_201.html | 4 +- user_guide/installation/upgrade_202.html | 4 +- user_guide/installation/upgrade_203.html | 4 +- user_guide/installation/upgrade_210.html | 4 +- user_guide/installation/upgrade_211.html | 89 ++++++++++++++++++++++ user_guide/installation/upgrade_b11.html | 4 +- user_guide/installation/upgrading.html | 5 +- user_guide/libraries/benchmark.html | 4 +- user_guide/libraries/caching.html | 4 +- user_guide/libraries/calendar.html | 4 +- user_guide/libraries/cart.html | 4 +- user_guide/libraries/config.html | 4 +- user_guide/libraries/email.html | 4 +- user_guide/libraries/encryption.html | 4 +- user_guide/libraries/file_uploading.html | 4 +- user_guide/libraries/form_validation.html | 4 +- user_guide/libraries/ftp.html | 4 +- user_guide/libraries/image_lib.html | 4 +- user_guide/libraries/input.html | 4 +- user_guide/libraries/javascript.html | 4 +- user_guide/libraries/language.html | 4 +- user_guide/libraries/loader.html | 4 +- user_guide/libraries/migration.html | 4 +- user_guide/libraries/output.html | 4 +- user_guide/libraries/pagination.html | 4 +- user_guide/libraries/parser.html | 4 +- user_guide/libraries/security.html | 4 +- user_guide/libraries/sessions.html | 4 +- user_guide/libraries/table.html | 4 +- user_guide/libraries/trackback.html | 4 +- user_guide/libraries/typography.html | 4 +- user_guide/libraries/unit_testing.html | 4 +- user_guide/libraries/uri.html | 4 +- user_guide/libraries/user_agent.html | 4 +- user_guide/libraries/xmlrpc.html | 4 +- user_guide/libraries/zip.html | 4 +- user_guide/license.html | 4 +- user_guide/overview/appflow.html | 4 +- user_guide/overview/at_a_glance.html | 4 +- user_guide/overview/cheatsheets.html | 4 +- user_guide/overview/features.html | 4 +- user_guide/overview/getting_started.html | 4 +- user_guide/overview/goals.html | 4 +- user_guide/overview/index.html | 4 +- user_guide/overview/mvc.html | 4 +- user_guide/toc.html | 4 +- user_guide/tutorial/conclusion.html | 4 +- user_guide/tutorial/create_news_items.html | 4 +- user_guide/tutorial/hard_coded_pages.html | 4 +- user_guide/tutorial/index.html | 4 +- user_guide/tutorial/news_section.html | 4 +- user_guide/tutorial/static_pages.html | 4 +- 155 files changed, 391 insertions(+), 299 deletions(-) create mode 100644 user_guide/installation/upgrade_211.html diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index db1aee574..ec7294102 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -33,7 +33,7 @@ * @var string * */ - define('CI_VERSION', '2.1.0'); + define('CI_VERSION', '2.1.1'); /** * CodeIgniter Branch (Core = TRUE, Reactor = FALSE) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 5de2079bb..4fc65aeb4 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -9,7 +9,7 @@ * @license http://codeigniter.com/user_guide/license.html * @author EllisLab Dev Team * @link http://codeigniter.com - * @since Version 2.1.0 + * @since Version 2.1.1 * @filesource */ diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index 1462e8c21..1a076d4a2 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -9,7 +9,7 @@ * @license http://codeigniter.com/user_guide/license.html * @author EllisLab Dev Team * @link http://codeigniter.com - * @since Version 2.1.0 + * @since Version 2.1.1 * @filesource */ diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 7f3058ff0..7c4a2f977 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -9,7 +9,7 @@ * @license http://codeigniter.com/user_guide/license.html * @author EllisLab Dev Team * @link http://codeigniter.com - * @since Version 2.1.0 + * @since Version 2.1.1 * @filesource */ diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php index 29aefca80..fec276458 100644 --- a/system/database/drivers/pdo/pdo_utility.php +++ b/system/database/drivers/pdo/pdo_utility.php @@ -9,7 +9,7 @@ * @license http://codeigniter.com/user_guide/license.html * @author EllisLab Dev Team * @link http://codeigniter.com - * @since Version 2.1.0 + * @since Version 2.1.1 * @filesource */ diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 61e7aa761..261fc367b 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index 79d91b320..f750e6cb7 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index f96a68e27..b11b5b8fc 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 13e2d1af6..c50043660 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index fc586e025..747842091 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index ab5a70c98..da47b5a19 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 9881c1eec..f9959ff81 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 3943ec130..5a41377ea 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 55fbceeaf..d8fa374cb 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -58,7 +58,7 @@ Change Log

    Change Log

    Version 2.1.1

    -

    Release Date: not yet released

    +

    Release Date: May 18, 2012

    • General Changes @@ -1465,7 +1465,7 @@ Previous Topic:  License Agreement User Guide Home   ·   Next Topic:  Credits

      -

      CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

      +

      CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

      diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 17c58c9f1..734b28411 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -27,7 +27,7 @@
    <<
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -817,7 +817,7 @@ Previous Topic:  Query Helper Functions User Guide Home   ·   Next Topic:  Transactions

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index e6e72f269..6cf6ebd98 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -213,7 +213,7 @@ Previous Topic:  Custom Function CallsUser Guide Home   ·   Next Topic:  Database manipulation with Database Forge

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/call_function.html b/user_guide/database/call_function.html index 4fc894743..b28a05050 100644 --- a/user_guide/database/call_function.html +++ b/user_guide/database/call_function.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -111,7 +111,7 @@ Previous Topic:  Field MetaData User Guide Home   ·   Next Topic:  Query Caching

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index 17a291ac2..01a28c0b5 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -157,7 +157,7 @@ Previous Topic:  Quick Start: Usage ExamplesUser Guide Home   ·   Next Topic:  Connecting to your Database

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index f86602269..531f6a104 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -181,7 +181,7 @@ Previous Topic:  Database ConfigurationUser Guide Home   ·   Next Topic:  Queries

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html index 58035557d..1a1d71be6 100644 --- a/user_guide/database/examples.html +++ b/user_guide/database/examples.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -210,7 +210,7 @@ Previous Topic:  Database Class User Guide Home   ·   Next Topic:  Database Configuration

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html index 56c9d9fdf..546a4ca1f 100644 --- a/user_guide/database/fields.html +++ b/user_guide/database/fields.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -156,7 +156,7 @@ Previous Topic:   Table Data User Guide Home   ·   Next Topic:  Custom Function Calls

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index 2289e148e..e6153721d 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -227,7 +227,7 @@ Previous Topic:  DB Caching Class Top of Page   ·   User Guide Home   ·   Next Topic:  Database Utilities Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index 82f5c1d21..db03de1e9 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -144,7 +144,7 @@ Previous Topic:  Query Results User Guide Home   ·   Next Topic:  Active Record Pattern

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/index.html b/user_guide/database/index.html index 8a957ecef..2a08f0a69 100644 --- a/user_guide/database/index.html +++ b/user_guide/database/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -92,7 +92,7 @@ Previous Topic:  Caching Class User Guide Home   ·   Next Topic:  Quick Start: Usage Examples

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html index 3152997ca..263752f52 100644 --- a/user_guide/database/queries.html +++ b/user_guide/database/queries.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -151,7 +151,7 @@ Previous Topic:  Connecting to your Database User Guide Home   ·   Next Topic:  Query Results

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/results.html b/user_guide/database/results.html index 0baf992fb..395714073 100644 --- a/user_guide/database/results.html +++ b/user_guide/database/results.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -252,7 +252,7 @@ Previous Topic:  Queries User Guide Home   ·   Next Topic:  Query Helper Functions

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/table_data.html b/user_guide/database/table_data.html index dc5b54198..5ebe368d8 100644 --- a/user_guide/database/table_data.html +++ b/user_guide/database/table_data.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -106,7 +106,7 @@ Previous Topic:   Transactions User Guide Home   ·   Next Topic:   Field Metadata

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/transactions.html b/user_guide/database/transactions.html index dd5f73ed1..53e667046 100644 --- a/user_guide/database/transactions.html +++ b/user_guide/database/transactions.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -193,7 +193,7 @@ Previous Topic:   Field MetaData   User Guide Home   ·   Next Topic:  Table Metadata

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index 7c30070f6..4a3005f9f 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -307,7 +307,7 @@ Previous Topic:  DB Forge Class Top of Page   ·   User Guide Home   ·   Next Topic:  Javascript Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/doc_style/index.html b/user_guide/doc_style/index.html index aa7fff43d..ad5c65a5b 100644 --- a/user_guide/doc_style/index.html +++ b/user_guide/doc_style/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -80,7 +80,7 @@ Previous Topic:  PHP Style Guide< User Guide Home   ·   Next Topic:  Benchmarking Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/doc_style/template.html b/user_guide/doc_style/template.html index d59d5e4ed..3fde59c9e 100644 --- a/user_guide/doc_style/template.html +++ b/user_guide/doc_style/template.html @@ -121,7 +121,7 @@ Previous Topic:  Previous Class User Guide Home   ·   Next Topic:  Next Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html index 6e601af44..6d2165fda 100644 --- a/user_guide/general/alternative_php.html +++ b/user_guide/general/alternative_php.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -140,7 +140,7 @@ Previous Topic:  Managing ApplicationsUser Guide Home   ·   Next Topic:  Security

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/ancillary_classes.html b/user_guide/general/ancillary_classes.html index 0e3d54deb..9c209c0b7 100644 --- a/user_guide/general/ancillary_classes.html +++ b/user_guide/general/ancillary_classes.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -110,7 +110,7 @@ Previous Topic:  Creating Core Libra User Guide Home   ·   Next Topic:  Auto-loading Resources

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/autoloader.html b/user_guide/general/autoloader.html index 699751202..fdc02e906 100644 --- a/user_guide/general/autoloader.html +++ b/user_guide/general/autoloader.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -93,7 +93,7 @@ Previous Topic:  Hooks - Extending the Core Top of Page   ·   User Guide Home   ·   Next Topic:  Common Functions

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/caching.html b/user_guide/general/caching.html index a0d7596ed..5ccc79190 100644 --- a/user_guide/general/caching.html +++ b/user_guide/general/caching.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -108,7 +108,7 @@ Previous Topic:  Error Handling User Guide Home   ·   Next Topic:  Profiling Your Application

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/cli.html b/user_guide/general/cli.html index 5dda24b56..e21d1de51 100644 --- a/user_guide/general/cli.html +++ b/user_guide/general/cli.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -143,7 +143,7 @@ Previous Topic:  CodeIgniter URLs Top of Page   ·   User Guide Home   ·   Next Topic:  Reserved Names

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/common_functions.html b/user_guide/general/common_functions.html index f290521a9..ac2ff529b 100644 --- a/user_guide/general/common_functions.html +++ b/user_guide/general/common_functions.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -120,7 +120,7 @@ Previous Topic:  Auto-loading Resources< Top of Page   ·   User Guide Home   ·   Next Topic:  URI Routing

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index 91dd95a00..ee482e512 100644 --- a/user_guide/general/controllers.html +++ b/user_guide/general/controllers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -381,7 +381,7 @@ Previous Topic:  CodeIgniter URLs Top of Page   ·   User Guide Home   ·   Next Topic:  Reserved Names

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html index be711903c..ae43eef27 100644 --- a/user_guide/general/core_classes.html +++ b/user_guide/general/core_classes.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -179,7 +179,7 @@ Previous Topic:  Creating Your Own L User Guide Home   ·   Next Topic:  Hooks - Extending the Core

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/creating_drivers.html b/user_guide/general/creating_drivers.html index 77cccd03c..eaa626566 100644 --- a/user_guide/general/creating_drivers.html +++ b/user_guide/general/creating_drivers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -93,7 +93,7 @@ Previous Topic:  Using CodeIgniter Drivers User Guide Home   ·   Next Topic:  Creating Core System Classes

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html index f905bb7c3..977cfae4d 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -286,7 +286,7 @@ Previous Topic:  Using CodeIgniter Libraries< User Guide Home   ·   Next Topic:  Using CodeIgniter Drivers

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/credits.html b/user_guide/general/credits.html index 00c577871..90e7d0306 100644 --- a/user_guide/general/credits.html +++ b/user_guide/general/credits.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -80,7 +80,7 @@ Previous Topic:  Change Log User Guide Home   ·   Next Topic:  Downloading CodeIgniter

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/drivers.html b/user_guide/general/drivers.html index f463adb10..9ea7df6b6 100644 --- a/user_guide/general/drivers.html +++ b/user_guide/general/drivers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -97,7 +97,7 @@ Previous Topic:  Creating Libraries< User Guide Home   ·   Next Topic:  Creating Drivers

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/environments.html b/user_guide/general/environments.html index 0245b085d..38285a662 100644 --- a/user_guide/general/environments.html +++ b/user_guide/general/environments.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -119,7 +119,7 @@ Previous Topic:  Managing ApplicationsUser Guide Home   ·   Next Topic:  Alternative PHP Syntax

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/errors.html b/user_guide/general/errors.html index d6bed9ea1..3f0830419 100644 --- a/user_guide/general/errors.html +++ b/user_guide/general/errors.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -133,7 +133,7 @@ Previous Topic:  URI Routing User Guide Home   ·   Next Topic:  Page Caching

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/helpers.html b/user_guide/general/helpers.html index 619e9ff78..099430bea 100644 --- a/user_guide/general/helpers.html +++ b/user_guide/general/helpers.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -178,7 +178,7 @@ Previous Topic:  Models User Guide Home   ·   Next Topic:  Using Libraries

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/hooks.html b/user_guide/general/hooks.html index 07d302a7d..70fb9648e 100644 --- a/user_guide/general/hooks.html +++ b/user_guide/general/hooks.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -158,7 +158,7 @@ Previous Topic:  Creating Core Classes User Guide Home   ·   Next Topic:  Auto-loading Resources

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/libraries.html b/user_guide/general/libraries.html index 73b642bef..648b6cba9 100644 --- a/user_guide/general/libraries.html +++ b/user_guide/general/libraries.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -91,7 +91,7 @@ Previous Topic:  Helpers User Guide Home   ·   Next Topic:  Creating Libraries

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/managing_apps.html b/user_guide/general/managing_apps.html index 388519796..97312a01e 100644 --- a/user_guide/general/managing_apps.html +++ b/user_guide/general/managing_apps.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -126,7 +126,7 @@ Previous Topic:  Profiling Your ApplicationUser Guide Home   ·   Next Topic:  Alternative PHP Syntax

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/models.html b/user_guide/general/models.html index 7bda4d9a9..a416a80d9 100644 --- a/user_guide/general/models.html +++ b/user_guide/general/models.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -244,7 +244,7 @@ Previous Topic:  Views User Guide Home   ·   Next Topic:  Helpers

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/profiling.html b/user_guide/general/profiling.html index 451b6f9e6..b6d5721fd 100644 --- a/user_guide/general/profiling.html +++ b/user_guide/general/profiling.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -174,7 +174,7 @@ Previous Topic:  Caching User Guide Home   ·   Next Topic:  Managing Applications

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/quick_reference.html b/user_guide/general/quick_reference.html index 6c07b335c..1eb78992b 100644 --- a/user_guide/general/quick_reference.html +++ b/user_guide/general/quick_reference.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -70,7 +70,7 @@ Quick Reference Chart Top of Page   ·   User Guide Home

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/requirements.html b/user_guide/general/requirements.html index 1393b40e0..230ab7809 100644 --- a/user_guide/general/requirements.html +++ b/user_guide/general/requirements.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -75,7 +75,7 @@ Server Requirements User Guide Home   ·   Next Topic:  License Agreement

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/reserved_names.html b/user_guide/general/reserved_names.html index 450c0f667..80df6fd11 100644 --- a/user_guide/general/reserved_names.html +++ b/user_guide/general/reserved_names.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -121,7 +121,7 @@ Previous Topic:  Controllers Top of Page   ·   User Guide Home   ·   Next Topic:  Views

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html index d5c90a1b8..e2252e028 100644 --- a/user_guide/general/routing.html +++ b/user_guide/general/routing.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -164,7 +164,7 @@ Previous Topic:  Common Functions User Guide Home   ·   Next Topic:  Error Handling

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/security.html b/user_guide/general/security.html index 9e78d4c68..b91266f92 100644 --- a/user_guide/general/security.html +++ b/user_guide/general/security.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -157,7 +157,7 @@ Previous Topic:  Alternative PHP User Guide Home   ·   Next Topic:  PHP Style Guide

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html index c94313365..3ca16496b 100644 --- a/user_guide/general/styleguide.html +++ b/user_guide/general/styleguide.html @@ -34,7 +34,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -672,7 +672,7 @@ Previous Topic:  Security User Guide Home   ·   Next Topic:  Writing Documentation

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/urls.html b/user_guide/general/urls.html index edf03309b..d5d85df8a 100644 --- a/user_guide/general/urls.html +++ b/user_guide/general/urls.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -144,7 +144,7 @@ segment based URLs.

    Top of Page   ·   User Guide Home   ·   Next Topic:  Controllers

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/general/views.html b/user_guide/general/views.html index 5dc1d3250..68686e1e6 100644 --- a/user_guide/general/views.html +++ b/user_guide/general/views.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -267,7 +267,7 @@ Previous Topic:  Reserved Names User Guide Home   ·   Next Topic:  Models

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html index 92a11ed69..9b7a90b85 100644 --- a/user_guide/helpers/array_helper.html +++ b/user_guide/helpers/array_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -163,7 +163,7 @@ Previous Topic:   Javascript Cl Top of Page   ·   User Guide Home   ·   Next Topic:  CAPTCHA Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html index 6c2671ad0..d6b46fdc0 100644 --- a/user_guide/helpers/captcha_helper.html +++ b/user_guide/helpers/captcha_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -188,7 +188,7 @@ Previous Topic:  Array Helper Top of Page   ·   User Guide Home   ·   Next Topic:  Cookie Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html index 2fde7f841..beba67a96 100644 --- a/user_guide/helpers/cookie_helper.html +++ b/user_guide/helpers/cookie_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -100,7 +100,7 @@ Previous Topic:  CAPTCHA Helper Top of Page   ·   User Guide Home   ·   Next Topic:  Date Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html index e705593b0..f39971a0c 100644 --- a/user_guide/helpers/date_helper.html +++ b/user_guide/helpers/date_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -401,7 +401,7 @@ Previous Topic:  Cookie Helper User Guide Home   ·   Next Topic:  Directory Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html index 7fd7797af..c5ac082cd 100644 --- a/user_guide/helpers/directory_helper.html +++ b/user_guide/helpers/directory_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -136,7 +136,7 @@ Previous Topic:  Date Helper User Guide Home   ·   Next Topic:  Download Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/download_helper.html b/user_guide/helpers/download_helper.html index ccfe9ac72..b669202ad 100644 --- a/user_guide/helpers/download_helper.html +++ b/user_guide/helpers/download_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -105,7 +105,7 @@ Previous Topic:  Directory Helper Top of Page   ·   User Guide Home   ·   Next Topic:  Email Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/email_helper.html b/user_guide/helpers/email_helper.html index 13ae220fe..ae8d2da0e 100644 --- a/user_guide/helpers/email_helper.html +++ b/user_guide/helpers/email_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -95,7 +95,7 @@ Previous Topic:  Download Helper Top of Page   ·   User Guide Home   ·   Next Topic:  File Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html index 0296191ff..3302cd048 100644 --- a/user_guide/helpers/file_helper.html +++ b/user_guide/helpers/file_helper.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -172,7 +172,7 @@ Previous Topic:  Email Helper Top of Page   ·   User Guide Home   ·   Next Topic:  Form Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html index ce809e946..02952b679 100644 --- a/user_guide/helpers/form_helper.html +++ b/user_guide/helpers/form_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -477,7 +477,7 @@ Previous Topic:  File Helper User Guide Home   ·   Next Topic:  HTML Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html index a8277febe..6ade2d137 100644 --- a/user_guide/helpers/html_helper.html +++ b/user_guide/helpers/html_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -383,7 +383,7 @@ Previous Topic:  Form Helper Top of Page   ·   User Guide Home   ·   Next Topic:   Path Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html index 66982e8b3..d441ca1eb 100644 --- a/user_guide/helpers/inflector_helper.html +++ b/user_guide/helpers/inflector_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -144,7 +144,7 @@ Previous Topic:   HTML Helper User Guide Home   ·   Next Topic:  Number Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/language_helper.html b/user_guide/helpers/language_helper.html index 073c368d8..9761b96b7 100644 --- a/user_guide/helpers/language_helper.html +++ b/user_guide/helpers/language_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -91,7 +91,7 @@ Previous Topic:  Date Helper User Guide Home   ·   Next Topic:  Download Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/number_helper.html b/user_guide/helpers/number_helper.html index c48987e6c..8dd9287a8 100644 --- a/user_guide/helpers/number_helper.html +++ b/user_guide/helpers/number_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -106,7 +106,7 @@ Previous Topic:  Inflector Helper User Guide Home   ·   Next Topic:  Path Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/path_helper.html b/user_guide/helpers/path_helper.html index 00f4aa2ec..04826bb19 100644 --- a/user_guide/helpers/path_helper.html +++ b/user_guide/helpers/path_helper.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -99,7 +99,7 @@ Previous Topic:  Number Helper User Guide Home   ·   Next Topic:  Security Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html index 16d5c51f2..b05d8e076 100644 --- a/user_guide/helpers/security_helper.html +++ b/user_guide/helpers/security_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -125,7 +125,7 @@ Previous Topic:   Path Helper Top of Page   ·   User Guide Home   ·   Next Topic:  Smiley Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html index 8bdd1df2c..3441cd8a3 100644 --- a/user_guide/helpers/smiley_helper.html +++ b/user_guide/helpers/smiley_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -208,7 +208,7 @@ Previous Topic:  Security Helper User Guide Home   ·   Next Topic:  String Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html index 3d7ba1c51..d4023841d 100644 --- a/user_guide/helpers/string_helper.html +++ b/user_guide/helpers/string_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -182,7 +182,7 @@ Previous Topic:  Smiley Helper User Guide Home   ·   Next Topic:  Text Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html index 9f0d22ffc..775ded677 100644 --- a/user_guide/helpers/text_helper.html +++ b/user_guide/helpers/text_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -204,7 +204,7 @@ Previous Topic:  String Helper User Guide Home   ·   Next Topic:  Typography Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html index a6bd809a5..16e3ca989 100644 --- a/user_guide/helpers/typography_helper.html +++ b/user_guide/helpers/typography_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -105,7 +105,7 @@ Previous Topic:  Text Helper User Guide Home   ·   Next Topic:  URL Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html index c23c5ac92..488078c39 100644 --- a/user_guide/helpers/url_helper.html +++ b/user_guide/helpers/url_helper.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -295,7 +295,7 @@ Previous Topic:  Typography HelperUser Guide Home   ·   Next Topic:  XML Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html index f410b2114..ce037c251 100644 --- a/user_guide/helpers/xml_helper.html +++ b/user_guide/helpers/xml_helper.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -98,7 +98,7 @@ Previous Topic:  URL Helper Top of Page   ·   User Guide Home

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/index.html b/user_guide/index.html index fa90983e1..b7ae61887 100644 --- a/user_guide/index.html +++ b/user_guide/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -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 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -58,7 +58,8 @@ Downloading CodeIgniter

    Downloading CodeIgniter

      -
    • CodeIgniter V 2.1.0 (Current version)
    • +
    • CodeIgniter V 2.1.1 (Current version)
    • +
    • CodeIgniter V 2.1.0
    • CodeIgniter V 2.0.3
    • CodeIgniter V 2.0.2
    • CodeIgniter V 2.0.1
    • @@ -91,11 +92,12 @@ Downloading CodeIgniter

      Git Server

      Git is a distributed version control system.

      -

      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.

    @@ -108,7 +110,7 @@ Previous Topic:  Credits User Guide Home   ·   Next Topic:  Installation Instructions

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/index.html b/user_guide/installation/index.html index f01c8b8d5..aca760ca4 100644 --- a/user_guide/installation/index.html +++ b/user_guide/installation/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -101,7 +101,7 @@ Previous Topic:  Credits Next Topic:  Upgrading from a Previous Version

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/troubleshooting.html b/user_guide/installation/troubleshooting.html index e79eb6a9f..bb7cadeba 100644 --- a/user_guide/installation/troubleshooting.html +++ b/user_guide/installation/troubleshooting.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -83,7 +83,7 @@ Previous Topic:  Upgrading from a Previous Ve User Guide Home   ·   Next Topic:  CodeIgniter at a Glance

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_120.html b/user_guide/installation/upgrade_120.html index 2b3d066cd..b80c02ad9 100644 --- a/user_guide/installation/upgrade_120.html +++ b/user_guide/installation/upgrade_120.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -85,7 +85,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_130.html b/user_guide/installation/upgrade_130.html index dd1465617..3a335738e 100644 --- a/user_guide/installation/upgrade_130.html +++ b/user_guide/installation/upgrade_130.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -196,7 +196,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_131.html b/user_guide/installation/upgrade_131.html index 202468dac..4a91c6ceb 100644 --- a/user_guide/installation/upgrade_131.html +++ b/user_guide/installation/upgrade_131.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -95,7 +95,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_132.html b/user_guide/installation/upgrade_132.html index 99f8fd3ab..1763f2b9c 100644 --- a/user_guide/installation/upgrade_132.html +++ b/user_guide/installation/upgrade_132.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -93,7 +93,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_133.html b/user_guide/installation/upgrade_133.html index b9b7a7fd3..fd1887d0e 100644 --- a/user_guide/installation/upgrade_133.html +++ b/user_guide/installation/upgrade_133.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -105,7 +105,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_140.html b/user_guide/installation/upgrade_140.html index 50891b912..d82472551 100644 --- a/user_guide/installation/upgrade_140.html +++ b/user_guide/installation/upgrade_140.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -138,7 +138,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_141.html b/user_guide/installation/upgrade_141.html index afa8018b8..3ed11e7b5 100644 --- a/user_guide/installation/upgrade_141.html +++ b/user_guide/installation/upgrade_141.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -141,7 +141,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_150.html b/user_guide/installation/upgrade_150.html index f910aa039..5909a463a 100644 --- a/user_guide/installation/upgrade_150.html +++ b/user_guide/installation/upgrade_150.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -171,7 +171,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_152.html b/user_guide/installation/upgrade_152.html index 55e43f728..f46aee967 100644 --- a/user_guide/installation/upgrade_152.html +++ b/user_guide/installation/upgrade_152.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -104,7 +104,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_153.html b/user_guide/installation/upgrade_153.html index 3e6af7a38..3d28c6c77 100644 --- a/user_guide/installation/upgrade_153.html +++ b/user_guide/installation/upgrade_153.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -93,7 +93,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_154.html b/user_guide/installation/upgrade_154.html index 627fa0896..d8dffc99d 100644 --- a/user_guide/installation/upgrade_154.html +++ b/user_guide/installation/upgrade_154.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -109,7 +109,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_160.html b/user_guide/installation/upgrade_160.html index 70e589ccf..b90a2e370 100644 --- a/user_guide/installation/upgrade_160.html +++ b/user_guide/installation/upgrade_160.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -118,7 +118,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_161.html b/user_guide/installation/upgrade_161.html index 40877369d..69bf84893 100644 --- a/user_guide/installation/upgrade_161.html +++ b/user_guide/installation/upgrade_161.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -91,7 +91,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_162.html b/user_guide/installation/upgrade_162.html index d67190842..270507c59 100644 --- a/user_guide/installation/upgrade_162.html +++ b/user_guide/installation/upgrade_162.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -99,7 +99,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_163.html b/user_guide/installation/upgrade_163.html index cdf6bdf6f..35e7f5c52 100644 --- a/user_guide/installation/upgrade_163.html +++ b/user_guide/installation/upgrade_163.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -92,7 +92,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_170.html b/user_guide/installation/upgrade_170.html index 7c67f9125..3a7943905 100644 --- a/user_guide/installation/upgrade_170.html +++ b/user_guide/installation/upgrade_170.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -114,7 +114,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_171.html b/user_guide/installation/upgrade_171.html index 014b2c589..43710d444 100644 --- a/user_guide/installation/upgrade_171.html +++ b/user_guide/installation/upgrade_171.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -91,7 +91,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_172.html b/user_guide/installation/upgrade_172.html index 961f3cae1..1882da712 100644 --- a/user_guide/installation/upgrade_172.html +++ b/user_guide/installation/upgrade_172.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -102,7 +102,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_200.html b/user_guide/installation/upgrade_200.html index b5d6e75ec..fb4fdaf71 100644 --- a/user_guide/installation/upgrade_200.html +++ b/user_guide/installation/upgrade_200.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -124,7 +124,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_201.html b/user_guide/installation/upgrade_201.html index 7edd0ba6a..16177e940 100644 --- a/user_guide/installation/upgrade_201.html +++ b/user_guide/installation/upgrade_201.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -98,7 +98,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_202.html b/user_guide/installation/upgrade_202.html index 9aaa561eb..a0d787115 100644 --- a/user_guide/installation/upgrade_202.html +++ b/user_guide/installation/upgrade_202.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -90,7 +90,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_203.html b/user_guide/installation/upgrade_203.html index d4b703af0..0969164df 100644 --- a/user_guide/installation/upgrade_203.html +++ b/user_guide/installation/upgrade_203.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -114,7 +114,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_210.html b/user_guide/installation/upgrade_210.html index d9a7213a9..7c34806e7 100644 --- a/user_guide/installation/upgrade_210.html +++ b/user_guide/installation/upgrade_210.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -82,7 +82,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrade_211.html b/user_guide/installation/upgrade_211.html new file mode 100644 index 000000000..a2afdee2b --- /dev/null +++ b/user_guide/installation/upgrade_211.html @@ -0,0 +1,89 @@ + + + + + +Upgrading from 2.0.3 to 2.1.0 : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +

    CodeIgniter User Guide Version 2.1.1

    +
    + + + + + + + + + +
    + + +
    + + + +
    + +

    Upgrading from 2.1.0 to 2.1.1

    + +

    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.

    + + +
    + + + + + + + \ No newline at end of file diff --git a/user_guide/installation/upgrade_b11.html b/user_guide/installation/upgrade_b11.html index dc3c1f07c..0e52aa601 100644 --- a/user_guide/installation/upgrade_b11.html +++ b/user_guide/installation/upgrade_b11.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -137,7 +137,7 @@ Previous Topic:  Installation Instructions User Guide Home   ·   Next Topic:  Troubleshooting

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/installation/upgrading.html b/user_guide/installation/upgrading.html index c3f5ae6dd..1c8be9025 100644 --- a/user_guide/installation/upgrading.html +++ b/user_guide/installation/upgrading.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -60,6 +60,7 @@ Upgrading from a Previous Version

    Please read the upgrade notes corresponding to the version you are upgrading from.

    diff --git a/user_guide/libraries/benchmark.html b/user_guide/libraries/benchmark.html index 602e6fac0..55592857a 100644 --- a/user_guide/libraries/benchmark.html +++ b/user_guide/libraries/benchmark.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -191,7 +191,7 @@ Previous Topic:  Writing Documentaio User Guide Home   ·   Next Topic:  Calendar Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/caching.html b/user_guide/libraries/caching.html index 9808aaa51..a818fe807 100644 --- a/user_guide/libraries/caching.html +++ b/user_guide/libraries/caching.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -186,7 +186,7 @@ Previous Topic:  Zip Encoding Class User Guide Home   ·   Next Topic:  Database Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/calendar.html b/user_guide/libraries/calendar.html index 2abc43975..ac0c8252a 100644 --- a/user_guide/libraries/calendar.html +++ b/user_guide/libraries/calendar.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -242,7 +242,7 @@ Previous Topic:  Benchmark Class User Guide Home   ·   Next Topic:  Cart Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html index b867b709c..c10ab4488 100644 --- a/user_guide/libraries/cart.html +++ b/user_guide/libraries/cart.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -339,7 +339,7 @@ Previous Topic:  Calendar Class User Guide Home   ·   Next Topic:  Config Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html index 08b612e77..a689bd5cf 100644 --- a/user_guide/libraries/config.html +++ b/user_guide/libraries/config.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -215,7 +215,7 @@ Previous Topic:  Calendaring Class User Guide Home   ·   Next Topic:  Database Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/email.html b/user_guide/libraries/email.html index 7fc56d55b..e418d528d 100644 --- a/user_guide/libraries/email.html +++ b/user_guide/libraries/email.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -300,7 +300,7 @@ Previous Topic:  Database Class User Guide Home   ·   Next Topic:  Encryption Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/encryption.html b/user_guide/libraries/encryption.html index 6ec629f96..935e0bfa0 100644 --- a/user_guide/libraries/encryption.html +++ b/user_guide/libraries/encryption.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -217,7 +217,7 @@ Previous Topic:  Email Class User Guide Home   ·   Next Topic:  File Uploading Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/file_uploading.html b/user_guide/libraries/file_uploading.html index 2cb1ef5ea..2ada111ab 100644 --- a/user_guide/libraries/file_uploading.html +++ b/user_guide/libraries/file_uploading.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -444,7 +444,7 @@ Previous Topic:  Encryption Helper User Guide Home   ·   Next Topic:  Form Validation Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  Ellislab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  Ellislab, Inc.

    diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html index 2028bcd2c..81f2b9582 100644 --- a/user_guide/libraries/form_validation.html +++ b/user_guide/libraries/form_validation.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -1243,7 +1243,7 @@ Previous Topic:  File Uploading ClassUser Guide Home   ·   Next Topic:  FTP Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/ftp.html b/user_guide/libraries/ftp.html index 175efe19b..8cf60893e 100644 --- a/user_guide/libraries/ftp.html +++ b/user_guide/libraries/ftp.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -308,7 +308,7 @@ Previous Topic:  Form Validation Class< User Guide Home   ·   Next Topic:  HTML Table Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/image_lib.html b/user_guide/libraries/image_lib.html index 1caf791d8..8df6976e1 100644 --- a/user_guide/libraries/image_lib.html +++ b/user_guide/libraries/image_lib.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -660,7 +660,7 @@ Previous Topic:  HTML Table Class User Guide Home   ·   Next Topic:  Input Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/input.html b/user_guide/libraries/input.html index 10c84a9ea..2f2d1830b 100644 --- a/user_guide/libraries/input.html +++ b/user_guide/libraries/input.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -288,7 +288,7 @@ Previous Topic:  Image Manipulation Class User Guide Home   ·   Next Topic:  Loader Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/javascript.html b/user_guide/libraries/javascript.html index 3dda1fd69..6b72ed6c2 100644 --- a/user_guide/libraries/javascript.html +++ b/user_guide/libraries/javascript.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -240,7 +240,7 @@ Previous Topic:  Database Class Top of Page   ·   User Guide Home   ·   Next Topic:  Array Helper

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/language.html b/user_guide/libraries/language.html index a9afcef90..44a4cb654 100644 --- a/user_guide/libraries/language.html +++ b/user_guide/libraries/language.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -130,7 +130,7 @@ Previous Topic:  Loader Class User Guide Home   ·   Next Topic:  Output Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 53440c53c..862430b9f 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -266,7 +266,7 @@ Previous Topic:  Input Class User Guide Home   ·   Next Topic:  Language Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/migration.html b/user_guide/libraries/migration.html index ed99044d1..646772198 100644 --- a/user_guide/libraries/migration.html +++ b/user_guide/libraries/migration.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -169,7 +169,7 @@ Previous Topic:  Form Validation Class< User Guide Home   ·   Next Topic:  HTML Table Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html index 77fe464ce..cf2324bd8 100644 --- a/user_guide/libraries/output.html +++ b/user_guide/libraries/output.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -170,7 +170,7 @@ Previous Topic:  Language Class User Guide Home   ·   Next Topic:  Pagination Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html index 6478694d0..54c7efcc2 100644 --- a/user_guide/libraries/pagination.html +++ b/user_guide/libraries/pagination.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -226,7 +226,7 @@ Previous Topic:  Output Class User Guide Home   ·   Next Topic:  Session Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/parser.html b/user_guide/libraries/parser.html index f449145ac..4d909223c 100644 --- a/user_guide/libraries/parser.html +++ b/user_guide/libraries/parser.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -205,7 +205,7 @@ Previous Topic:  Trackback Class User Guide Home   ·   Next Topic:  Typography

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/security.html b/user_guide/libraries/security.html index ad1d9ae86..25f1fe879 100644 --- a/user_guide/libraries/security.html +++ b/user_guide/libraries/security.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -128,7 +128,7 @@ Previous Topic:  Pagination Class User Guide Home   ·   Next Topic:  Session Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html index dfb732491..ba9085f59 100644 --- a/user_guide/libraries/sessions.html +++ b/user_guide/libraries/sessions.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -334,7 +334,7 @@ Previous Topic:  Security Class User Guide Home   ·   Next Topic:  Trackback Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html index 003916ef3..1c46b5fac 100644 --- a/user_guide/libraries/table.html +++ b/user_guide/libraries/table.html @@ -27,7 +27,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -308,7 +308,7 @@ Previous Topic:  FTP Class   &mi User Guide Home   ·   Next Topic:  Image Manipulation Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/trackback.html b/user_guide/libraries/trackback.html index 035158463..f77937a9b 100644 --- a/user_guide/libraries/trackback.html +++ b/user_guide/libraries/trackback.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -239,7 +239,7 @@ Previous Topic:  Session Class User Guide Home   ·   Next Topic:  Template Parser Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/typography.html b/user_guide/libraries/typography.html index 12be119cc..81c244790 100644 --- a/user_guide/libraries/typography.html +++ b/user_guide/libraries/typography.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -153,7 +153,7 @@ Previous Topic:  Template Parser User Guide Home   ·   Next Topic:  Unit Testing Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/unit_testing.html b/user_guide/libraries/unit_testing.html index 7d27ff1dd..df1748e5c 100644 --- a/user_guide/libraries/unit_testing.html +++ b/user_guide/libraries/unit_testing.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -219,7 +219,7 @@ Previous Topic:  Typography Class User Guide Home   ·   Next Topic:  URI Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html index f04bb9f10..9b9b5d889 100644 --- a/user_guide/libraries/uri.html +++ b/user_guide/libraries/uri.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -245,7 +245,7 @@ Previous Topic:  Unit Testing Class User Guide Home   ·   Next Topic:  User Agent Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html index 8b3dcee62..829fdba03 100644 --- a/user_guide/libraries/user_agent.html +++ b/user_guide/libraries/user_agent.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -219,7 +219,7 @@ Previous Topic:  URI Class User Guide Home   ·   Next Topic:  XML-RPC Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/xmlrpc.html b/user_guide/libraries/xmlrpc.html index bb939dff4..ad714efbf 100644 --- a/user_guide/libraries/xmlrpc.html +++ b/user_guide/libraries/xmlrpc.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -512,7 +512,7 @@ Previous Topic:  User Agent Class User Guide Home   ·   Next Topic:  Zip Encoding Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html index 53fc71ef3..3324bd16c 100644 --- a/user_guide/libraries/zip.html +++ b/user_guide/libraries/zip.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -281,7 +281,7 @@ Previous Topic:   XML-RPC Class User Guide Home   ·   Next Topic:  Caching Class

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/license.html b/user_guide/license.html index f9769a417..bc25c30b4 100644 --- a/user_guide/license.html +++ b/user_guide/license.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -100,7 +100,7 @@ Previous Topic:  Server Requiremen User Guide Home   ·   Next Topic:  Change Log

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/appflow.html b/user_guide/overview/appflow.html index 61bf907a6..a59758f0b 100644 --- a/user_guide/overview/appflow.html +++ b/user_guide/overview/appflow.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -88,7 +88,7 @@ Previous Topic:  CodeIgniter Features User Guide Home   ·   Next Topic:  Model-View-Controller

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/at_a_glance.html b/user_guide/overview/at_a_glance.html index 7e93bd2a6..18688d34f 100644 --- a/user_guide/overview/at_a_glance.html +++ b/user_guide/overview/at_a_glance.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -155,7 +155,7 @@ Previous Topic:  Getting Started User Guide Home   ·   Next Topic:  CodeIgniter Cheatsheets

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/cheatsheets.html b/user_guide/overview/cheatsheets.html index 60e655229..005890a55 100644 --- a/user_guide/overview/cheatsheets.html +++ b/user_guide/overview/cheatsheets.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -76,7 +76,7 @@ Previous Topic:  CodeIgniter at a GlanceUser Guide Home   ·   Next Topic:  CodeIgniter Features

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/features.html b/user_guide/overview/features.html index d1d5c8c25..c97044414 100644 --- a/user_guide/overview/features.html +++ b/user_guide/overview/features.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -111,7 +111,7 @@ Previous Topic:  CodeIgniter CheatsheetsUser Guide Home   ·   Next Topic:  Application Flow Chart

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/getting_started.html b/user_guide/overview/getting_started.html index ad6fa01ed..8d8a8af35 100644 --- a/user_guide/overview/getting_started.html +++ b/user_guide/overview/getting_started.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -85,7 +85,7 @@ our Wiki to see code examples posted User Guide Home   ·   Next Topic:  CodeIgniter At a Glance

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/goals.html b/user_guide/overview/goals.html index f2263c7ae..0d2eeb5c9 100644 --- a/user_guide/overview/goals.html +++ b/user_guide/overview/goals.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -91,7 +91,7 @@ Previous Topic:  Model-View-Controller User Guide Home   ·   Next Topic:  Getting Started

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/overview/index.html b/user_guide/overview/index.html index f295d4e81..732a245ff 100644 --- a/user_guide/overview/index.html +++ b/user_guide/overview/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -77,7 +77,7 @@ Introduction diff --git a/user_guide/overview/mvc.html b/user_guide/overview/mvc.html index 4aebb1095..989ad7afb 100644 --- a/user_guide/overview/mvc.html +++ b/user_guide/overview/mvc.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -93,7 +93,7 @@ Previous Topic:  Application Flow Chart User Guide Home   ·   Next Topic:  Architectural Goals

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/toc.html b/user_guide/toc.html index 01b5a7b92..07bfbd234 100644 --- a/user_guide/toc.html +++ b/user_guide/toc.html @@ -29,7 +29,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -221,7 +221,7 @@ Table of Contents diff --git a/user_guide/tutorial/conclusion.html b/user_guide/tutorial/conclusion.html index 9cf146746..b4a1e0005 100644 --- a/user_guide/tutorial/conclusion.html +++ b/user_guide/tutorial/conclusion.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -84,7 +84,7 @@ Previous Topic:  Create news itemsUser Guide Home   ·   Next Topic:  CodeIgniter URLs

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/tutorial/create_news_items.html b/user_guide/tutorial/create_news_items.html index 26b1ed10f..9afeed9ec 100644 --- a/user_guide/tutorial/create_news_items.html +++ b/user_guide/tutorial/create_news_items.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -172,7 +172,7 @@ Previous Topic:  News section User Guide Home   ·   Next Topic:  Conclusion

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/tutorial/hard_coded_pages.html b/user_guide/tutorial/hard_coded_pages.html index b34e9f1be..354dcb0e6 100644 --- a/user_guide/tutorial/hard_coded_pages.html +++ b/user_guide/tutorial/hard_coded_pages.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -151,7 +151,7 @@ Previous Topic:  CodeIgniter CheatsheetsUser Guide Home   ·   Next Topic:  Application Flow Chart

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/tutorial/index.html b/user_guide/tutorial/index.html index 65075fb2a..d3392669e 100644 --- a/user_guide/tutorial/index.html +++ b/user_guide/tutorial/index.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -94,7 +94,7 @@ Previous Topic:  Goals User Guide Home   ·   Next Topic:  Static pages

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/tutorial/news_section.html b/user_guide/tutorial/news_section.html index cf3377ff9..1cb67c66e 100644 --- a/user_guide/tutorial/news_section.html +++ b/user_guide/tutorial/news_section.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -223,7 +223,7 @@ Previous Topic:  Static pages User Guide Home   ·   Next Topic:  Create news items

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    diff --git a/user_guide/tutorial/static_pages.html b/user_guide/tutorial/static_pages.html index da2c58cda..a7112f362 100644 --- a/user_guide/tutorial/static_pages.html +++ b/user_guide/tutorial/static_pages.html @@ -28,7 +28,7 @@
    - +

    CodeIgniter User Guide Version 2.1.0

    CodeIgniter User Guide Version 2.1.1

    @@ -199,7 +199,7 @@ Previous Topic:  Introduction User Guide Home   ·   Next Topic:  News section

    -

    CodeIgniter  ·  Copyright © 2006 - 2011  ·  EllisLab, Inc.

    +

    CodeIgniter  ·  Copyright © 2006 - 2012  ·  EllisLab, Inc.

    -- cgit v1.2.3-24-g4f1b From 1ef19196e32d081bd5db1a7f87599acea0ecac6e Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Thu, 17 May 2012 20:41:12 +0100 Subject: Changed the default controller route to use single quotes instead of double quotes --- application/config/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/routes.php b/application/config/routes.php index 474bda969..001198615 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -64,7 +64,7 @@ | */ -$route['default_controller'] = "welcome"; +$route['default_controller'] = 'welcome'; $route['404_override'] = ''; /* End of file routes.php */ -- cgit v1.2.3-24-g4f1b From 3020b24545381a72add33d67a488a7e39674ec7e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Borda Date: Fri, 18 May 2012 18:27:50 -0300 Subject: added unbuffered_row() to DB_result.php to avoid memory exhausting when dealing with large results. --- system/database/DB_result.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 196febe2c..574cd9858 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -370,6 +370,24 @@ class CI_DB_result { // -------------------------------------------------------------------- + /** + * Returns an unbuffered row and move pointer to next row + * + * @return object + */ + public function unbuffered_row($type = 'object') + { + if ($type == 'object') + { + return $this->_fetch_object(); + } else + { + return $this->_fetch_assoc(); + } + } + + // -------------------------------------------------------------------- + /** * The following functions are normally overloaded by the identically named * methods in the platform-specific driver -- except when query caching -- cgit v1.2.3-24-g4f1b From d981e2915cbd37f866e6f74c3a86a41e8a43e02e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Borda Date: Fri, 18 May 2012 18:29:24 -0300 Subject: Added doc notes for unbuffered_row() function --- user_guide_src/source/database/results.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 865345762..6a0dbf92a 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -136,6 +136,26 @@ parameter: | **$row = $query->next_row('array')** | **$row = $query->previous_row('array')** +.. note:: all the functions above will load the whole result into memory (prefetching) use unbuffered_row() for processing large result sets. + +unbuffered_row($type) +===== + +This function returns a single result row without prefetching the whole result in memory as row() does. +If your query has more than one row, it returns the current row and moves the internal data pointer ahead. +The result is returned as $type could be 'object' (default) or 'array' that will return an associative array. + + + + $query = $this->db->query("YOUR QUERY"); + + while ($row=$query->unbuffered_rows()) + { + echo $row->title; + echo $row->name; + echo $row->body; + } + *********************** Result Helper Functions *********************** -- cgit v1.2.3-24-g4f1b From fbd31c8d98bd7e5eac5c8e8c2f102b05350db93e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 19 May 2012 13:19:43 +0300 Subject: Fix issue #726 --- system/database/drivers/pdo/pdo_driver.php | 16 ++++++++-------- user_guide/changelog.html | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 5de2079bb..c38b79c5a 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -51,23 +51,23 @@ class CI_DB_pdo_driver extends CI_DB { function __construct($params) { parent::__construct($params); - + // clause and character used for LIKE escape sequences if (strpos($this->hostname, 'mysql') !== FALSE) { $this->_like_escape_str = ''; $this->_like_escape_chr = ''; - + //Prior to this version, the charset can't be set in the dsn if(is_php('5.3.6')) { $this->hostname .= ";charset={$this->char_set}"; } - + //Set the charset with the connection options $this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}"; } - else if (strpos($this->hostname, 'odbc') !== FALSE) + elseif (strpos($this->hostname, 'odbc') !== FALSE) { $this->_like_escape_str = " {escape '%s'} "; $this->_like_escape_chr = '!'; @@ -77,9 +77,9 @@ class CI_DB_pdo_driver extends CI_DB { $this->_like_escape_str = " ESCAPE '%s' "; $this->_like_escape_chr = '!'; } - - $this->hostname .= ";dbname=".$this->database; - + + empty($this->database) OR $this->hostname .= ';dbname='.$this->database; + $this->trans_enabled = FALSE; $this->_random_keyword = ' RND('.time().')'; // database specific random keyword @@ -94,7 +94,7 @@ class CI_DB_pdo_driver extends CI_DB { function db_connect() { $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT; - + return new PDO($this->hostname, $this->username, $this->password, $this->options); } diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 55fbceeaf..4e332a013 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -86,6 +86,7 @@ Change Log
  • 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 (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite.
  • -- cgit v1.2.3-24-g4f1b From 67a08ed578350d3a25c77855dc3467320be9e6f6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 19 May 2012 13:35:40 +0300 Subject: Add missing changelog entries from 2.1-stable --- user_guide_src/source/changelog.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 7fc5ee5a0..6192fecfd 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -241,7 +241,9 @@ Bug fixes for 2.1.1 - Fixed a bug - form_open() compared $action against site_url() instead of base_url(). - 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 :doc:`Image Manipulation Library ` 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 - 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 (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite. Version 2.1.0 ============= -- cgit v1.2.3-24-g4f1b From fece884ea610485425208c648ba207fa43593e8b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Borda Date: Sat, 19 May 2012 09:33:07 -0300 Subject: Fixed return line and comments --- system/database/DB_result.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 574cd9858..25b4fb911 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -373,17 +373,12 @@ class CI_DB_result { /** * Returns an unbuffered row and move pointer to next row * - * @return object + * @return mixed either a result object or array */ public function unbuffered_row($type = 'object') { - if ($type == 'object') - { - return $this->_fetch_object(); - } else - { - return $this->_fetch_assoc(); - } + return ($type !== 'array') ? $this->_fetch_object() : $this->_fetch_assoc(); + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 49cbec5870612c30b6e5bd0582616d519d1ea515 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Borda Date: Sat, 19 May 2012 09:34:53 -0300 Subject: Fixed some spaces --- user_guide_src/source/database/results.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 6a0dbf92a..2158c6df6 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -149,7 +149,7 @@ The result is returned as $type could be 'object' (default) or 'array' that will $query = $this->db->query("YOUR QUERY"); - while ($row=$query->unbuffered_rows()) + while ($row = $query->unbuffered_rows()) { echo $row->title; echo $row->name; -- cgit v1.2.3-24-g4f1b From da7c9e033bd33ba27b549dface68e17177115963 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Borda Date: Sat, 19 May 2012 09:42:40 -0300 Subject: Fixed typo --- user_guide_src/source/database/results.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 2158c6df6..ac4fc3733 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -149,7 +149,7 @@ The result is returned as $type could be 'object' (default) or 'array' that will $query = $this->db->query("YOUR QUERY"); - while ($row = $query->unbuffered_rows()) + while ($row = $query->unbuffered_row()) { echo $row->title; echo $row->name; -- cgit v1.2.3-24-g4f1b From 9fa8d404790833a098a8bbd855f1452897d6ff88 Mon Sep 17 00:00:00 2001 From: Rogerio Prado de Jesus Date: Sat, 19 May 2012 13:38:26 -0300 Subject: Fix a issue with affect_rows in CI_DB_pdo_driver::_execute() In case of SELECT queries PDOStatement::rowCount doesn't work as expected. This commit makes affect_rows be initialized properly. Signed-off-by: Rogerio Prado de Jesus --- system/database/drivers/pdo/pdo_driver.php | 13 +++++++++++-- user_guide/changelog.html | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index c38b79c5a..952016848 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -189,11 +189,20 @@ class CI_DB_pdo_driver extends CI_DB { function _execute($sql) { $sql = $this->_prep_query($sql); - $result_id = $this->conn_id->query($sql); + $result_id = $this->conn_id->prepare($sql); + $result_id->execute(); if (is_object($result_id)) { - $this->affect_rows = $result_id->rowCount(); + if (is_numeric(stripos($sql, 'SELECT'))) + { + $this->affect_rows = count($result_id->fetchAll()); + $result_id->execute(); + } + else + { + $this->affect_rows = $result_id->rowCount(); + } } else { diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 4e332a013..e1a87d963 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -87,6 +87,7 @@ Change Log
  • 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 (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite.
  • +
  • Fixed a bug - CI_DB_pdo_driver::affect_row was not being initialized properly with SELECT queries, cause it was relying on PDOStatement::rowCount().
  • -- cgit v1.2.3-24-g4f1b From 27738491fc11d0b9ce5670b2f6a7957fc421ee4b Mon Sep 17 00:00:00 2001 From: Rogerio Prado de Jesus Date: Sat, 19 May 2012 13:45:44 -0300 Subject: Fix a issue with CI_DB_pdo_result::num_rows() In case of SELECT queries PDOStatement::rowCount doesn't work as expected. This commit makes it returns the expected value. --- system/database/drivers/pdo/pdo_result.php | 13 ++++++++++++- user_guide/changelog.html | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php index 7f3058ff0..c05fbc908 100644 --- a/system/database/drivers/pdo/pdo_result.php +++ b/system/database/drivers/pdo/pdo_result.php @@ -34,7 +34,18 @@ class CI_DB_pdo_result extends CI_DB_result { */ function num_rows() { - return $this->result_id->rowCount(); + if (is_numeric(stripos($this->result_id->queryString, 'SELECT'))) + { + $dbh = $this->conn_id; + $query = $dbh->query($this->result_id->queryString); + $result = $query->fetchAll(); + unset($dbh, $query); + return count($result); + } + else + { + return $this->result_id->rowCount(); + } } // -------------------------------------------------------------------- diff --git a/user_guide/changelog.html b/user_guide/changelog.html index e1a87d963..ca1a55bac 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -88,6 +88,7 @@ Change Log
  • 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 (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite.
  • Fixed a bug - CI_DB_pdo_driver::affect_row was not being initialized properly with SELECT queries, cause it was relying on PDOStatement::rowCount().
  • +
  • Fixed a bug - CI_DB_pdo_result::num_rows() was not returning properly value with SELECT queries, cause it was relying on PDOStatement::rowCount().
  • -- cgit v1.2.3-24-g4f1b From f1aff707128865741a70d732283c0702183c52b3 Mon Sep 17 00:00:00 2001 From: Thanasis Polychronakis Date: Sun, 20 May 2012 18:44:21 +0300 Subject: Indended code to meet CI standards --- system/core/Common.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 01b0d8673..eb080aa2b 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -233,7 +233,8 @@ if ( ! function_exists('get_config')) $file_path = APPPATH.'config/config.php'; $found = false; - if (file_exists($file_path)) { + if (file_exists($file_path)) + { $found = true; require($file_path); } @@ -242,7 +243,10 @@ if ( ! function_exists('get_config')) if (defined(ENVIRONMENT) && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) { require($file_path); - } else if (!$found) { + } + else if (!$found) + { + set_status_header(503); exit('The configuration file does not exist.'); } -- cgit v1.2.3-24-g4f1b From 441dfc3a17f48c741a930cfc8a6d667bf0c352ba Mon Sep 17 00:00:00 2001 From: Juan Ignacio Borda Date: Sun, 20 May 2012 21:46:32 -0300 Subject: added a comment for unbuffered_row --- 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 7fc5ee5a0..defac54a2 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -102,6 +102,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 unbuffered_row() function for getting a row without prefetching whole result (consume less memory) - Libraries -- cgit v1.2.3-24-g4f1b From ccbd827076b83a7ff903fb8264192d2beea1260e Mon Sep 17 00:00:00 2001 From: Thanasis Polychronakis Date: Mon, 21 May 2012 14:38:22 +0300 Subject: Edit to meet CI coding standards --- system/core/Common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index eb080aa2b..15082a101 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -232,10 +232,10 @@ if ( ! function_exists('get_config')) } $file_path = APPPATH.'config/config.php'; - $found = false; + $found = FALSE; if (file_exists($file_path)) { - $found = true; + $found = TRUE; require($file_path); } @@ -244,7 +244,7 @@ if ( ! function_exists('get_config')) { require($file_path); } - else if (!$found) + elseif ( ! $found) { set_status_header(503); exit('The configuration file does not exist.'); -- cgit v1.2.3-24-g4f1b From 36237d8305260282b46f52f9fec91b5b7176088f Mon Sep 17 00:00:00 2001 From: Root Date: Mon, 21 May 2012 18:30:00 -0400 Subject: Move closing of database connection to CI_DB_driver->__destruct - #1376 --- system/core/CodeIgniter.php | 10 ---------- system/database/DB_driver.php | 7 +++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 00db6e13a..585bb7b31 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -393,15 +393,5 @@ */ $EXT->call_hook('post_system'); -/* - * ------------------------------------------------------ - * Close the DB connection if one exists - * ------------------------------------------------------ - */ - if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect) - { - $CI->db->close(); - } - /* End of file CodeIgniter.php */ /* Location: ./system/core/CodeIgniter.php */ \ No newline at end of file diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index ef77b594e..c757277ce 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -92,6 +92,13 @@ abstract class CI_DB_driver { // -------------------------------------------------------------------- + public function __destruct() + { + $this->close(); + } + + // -------------------------------------------------------------------- + /** * Initialize Database Settings * -- cgit v1.2.3-24-g4f1b From 4337771961de19f7cffb444aa2bd2866e9dad18a Mon Sep 17 00:00:00 2001 From: Brent Ashley Date: Tue, 22 May 2012 12:45:10 -0300 Subject: Add step to move existing core extensions to new folder --- user_guide_src/source/installation/upgrade_200.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_200.rst b/user_guide_src/source/installation/upgrade_200.rst index b39f4fd23..74b7443d8 100644 --- a/user_guide_src/source/installation/upgrade_200.rst +++ b/user_guide_src/source/installation/upgrade_200.rst @@ -87,7 +87,14 @@ All native CodeIgniter classes now use the PHP 5 \__construct() convention. Please update extended libraries to call parent::\__construct(). -Step 8: Update your user guide +Step 8: Move any core extensions to application/core +==================================================== + +Any extensions to core classes (e.g. MY_Controller.php) in your +application/liblraries folder must be moved to the new +application/core folder. + +Step 9: Update your user guide ============================== Please replace your local copy of the user guide with the new version, -- cgit v1.2.3-24-g4f1b From 0b427951859e393b5c6b31699fe0f1c1ae89b403 Mon Sep 17 00:00:00 2001 From: Brent Ashley Date: Tue, 22 May 2012 16:24:04 -0300 Subject: fix typo in step 8 --- user_guide_src/source/installation/upgrade_200.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_200.rst b/user_guide_src/source/installation/upgrade_200.rst index 74b7443d8..29f44bd9e 100644 --- a/user_guide_src/source/installation/upgrade_200.rst +++ b/user_guide_src/source/installation/upgrade_200.rst @@ -91,7 +91,7 @@ Step 8: Move any core extensions to application/core ==================================================== Any extensions to core classes (e.g. MY_Controller.php) in your -application/liblraries folder must be moved to the new +application/libraries folder must be moved to the new application/core folder. Step 9: Update your user guide -- cgit v1.2.3-24-g4f1b From ab396b4a56d3eaa91c559ccc4df2817c53897aef Mon Sep 17 00:00:00 2001 From: Gints Murans Date: Wed, 23 May 2012 00:21:39 +0300 Subject: Moved destruct to the end of file --- system/database/DB_driver.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index c757277ce..44c864e64 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -90,13 +90,6 @@ abstract class CI_DB_driver { log_message('debug', 'Database Driver Class Initialized'); } - // -------------------------------------------------------------------- - - public function __destruct() - { - $this->close(); - } - // -------------------------------------------------------------------- /** @@ -1397,6 +1390,23 @@ abstract class CI_DB_driver { { } + // -------------------------------------------------------------------- + + /** + * Destructor + * + * Closes the database connection, if needed. + * + * @return void + */ + public function __destruct() + { + if ($this->conn_id && ! $this->pconnect) + { + $this->close(); + } + } + } /* End of file DB_driver.php */ -- cgit v1.2.3-24-g4f1b From 89f77eedf9118dfccd52a7bc3e559d6bac5aa07c Mon Sep 17 00:00:00 2001 From: Gints Murans Date: Wed, 23 May 2012 00:23:50 +0300 Subject: Removed a space after comment line --- 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 44c864e64..a955f45d2 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -90,7 +90,7 @@ abstract class CI_DB_driver { log_message('debug', 'Database Driver Class Initialized'); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- /** * Initialize Database Settings -- cgit v1.2.3-24-g4f1b From 79922c0d963de9728315db02deaf4d2516c94d5b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 23 May 2012 12:27:17 +0300 Subject: Removed the parameter use in database drivers' _close() and added a default _close() method in CI_DB_driver + some changelog fixes --- system/database/DB_driver.php | 20 ++++++-- system/database/DB_result.php | 3 +- system/database/drivers/cubrid/cubrid_driver.php | 9 ++-- .../drivers/interbase/interbase_driver.php | 5 +- system/database/drivers/mssql/mssql_driver.php | 7 ++- system/database/drivers/mysql/mysql_driver.php | 7 ++- system/database/drivers/mysqli/mysqli_driver.php | 6 +-- system/database/drivers/oci8/oci8_driver.php | 7 ++- system/database/drivers/odbc/odbc_driver.php | 7 ++- system/database/drivers/pdo/pdo_driver.php | 15 +----- system/database/drivers/postgre/postgre_driver.php | 5 +- system/database/drivers/sqlite/sqlite_driver.php | 7 ++- system/database/drivers/sqlite3/sqlite3_driver.php | 3 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 7 ++- user_guide_src/source/changelog.rst | 53 ++++++++++------------ 15 files changed, 71 insertions(+), 90 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a955f45d2..a0812d4c7 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1152,13 +1152,27 @@ abstract class CI_DB_driver { { if ($this->conn_id) { - $this->_close($this->conn_id); + $this->_close(); $this->conn_id = FALSE; } } // -------------------------------------------------------------------- + /** + * Close DB Connection + * + * This method would be overriden by most of the drivers. + * + * @return void + */ + protected function _close() + { + $this->conn_id = FALSE; + } + + // -------------------------------------------------------------------- + /** * Display an error message * @@ -1401,7 +1415,7 @@ abstract class CI_DB_driver { */ public function __destruct() { - if ($this->conn_id && ! $this->pconnect) + if ( ! $this->pconnect) { $this->close(); } @@ -1410,4 +1424,4 @@ abstract class CI_DB_driver { } /* End of file DB_driver.php */ -/* Location: ./system/database/DB_driver.php */ +/* Location: ./system/database/DB_driver.php */ \ No newline at end of file diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 25b4fb911..690734b08 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -378,11 +378,10 @@ class CI_DB_result { public function unbuffered_row($type = 'object') { return ($type !== 'array') ? $this->_fetch_object() : $this->_fetch_assoc(); - } // -------------------------------------------------------------------- - + /** * The following functions are normally overloaded by the identically named * methods in the platform-specific driver -- except when query caching diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 1373faa88..944df99b5 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -485,7 +485,7 @@ class CI_DB_cubrid_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Limit string * @@ -506,15 +506,14 @@ class CI_DB_cubrid_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @cubrid_close($conn_id); + @cubrid_close($this->conn_id); } } /* End of file cubrid_driver.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 1b18de803..c457f6340 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -472,12 +472,11 @@ class CI_DB_interbase_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @ibase_close($conn_id); + @ibase_close($this->conn_id); } } diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index f60ec8168..914de499f 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -523,15 +523,14 @@ class CI_DB_mssql_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @mssql_close($conn_id); + @mssql_close($this->conn_id); } } /* End of file mssql_driver.php */ -/* Location: ./system/database/drivers/mssql/mssql_driver.php */ +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 32c51865d..161f99541 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -520,15 +520,14 @@ class CI_DB_mysql_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @mysql_close($conn_id); + @mysql_close($this->conn_id); } } /* End of file mysql_driver.php */ -/* Location: ./system/database/drivers/mysql/mysql_driver.php */ +/* Location: ./system/database/drivers/mysql/mysql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index e2684e4f2..9261883f5 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -523,16 +523,14 @@ class CI_DB_mysqli_driver extends CI_DB { /** * Close DB Connection * - * @param object * @return void */ - protected function _close($conn_id) + protected function _close() { $this->conn_id->close(); - $this->conn_id = FALSE; } } /* End of file mysqli_driver.php */ -/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 33a89df94..e2fa51349 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -671,15 +671,14 @@ class CI_DB_oci8_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @oci_close($conn_id); + @oci_close($this->conn_id); } } /* End of file oci8_driver.php */ -/* Location: ./system/database/drivers/oci8/oci8_driver.php */ +/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index e36f2d233..e3172117a 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -402,15 +402,14 @@ class CI_DB_odbc_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @odbc_close($conn_id); + @odbc_close($this->conn_id); } } /* End of file odbc_driver.php */ -/* Location: ./system/database/drivers/odbc/odbc_driver.php */ +/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 89e69676d..e38c1145c 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -667,20 +667,7 @@ class CI_DB_pdo_driver extends CI_DB { } } - // -------------------------------------------------------------------- - - /** - * Close DB Connection - * - * @param object - * @return void - */ - protected function _close($conn_id) - { - $this->conn_id = NULL; - } - } /* End of file pdo_driver.php */ -/* Location: ./system/database/drivers/pdo/pdo_driver.php */ +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 17bd37b38..0ddfd0abe 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -653,12 +653,11 @@ class CI_DB_postgre_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @pg_close($conn_id); + @pg_close($this->conn_id); } } diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 551704f83..d710b945d 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -450,15 +450,14 @@ class CI_DB_sqlite_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @sqlite_close($conn_id); + @sqlite_close($this->conn_id); } } /* End of file sqlite_driver.php */ -/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index d22f6a442..ad2848ed8 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -417,10 +417,9 @@ class CI_DB_sqlite3_driver extends CI_DB { /** * Close DB Connection * - * @param object (ignored) * @return void */ - protected function _close($conn_id) + protected function _close() { $this->conn_id->close(); } diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 8cc500f55..3e9fa7b1a 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -510,15 +510,14 @@ class CI_DB_sqlsrv_driver extends CI_DB { /** * Close DB Connection * - * @param resource * @return void */ - protected function _close($conn_id) + protected function _close() { - @sqlsrv_close($conn_id); + @sqlsrv_close($this->conn_id); } } /* End of file sqlsrv_driver.php */ -/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_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 45e6ebc07..a65a658ed 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -9,8 +9,7 @@ Release Date: Not Released - License - - CodeIgniter has been relicensed with the Open Software License (3.0), - eliminating its old proprietary licensing. + - CodeIgniter has been relicensed with the Open Software License (3.0), eliminating its old proprietary licensing. - All system files are licensed with OSL 3.0. - Config, error, and sample files shipped in the application folder are @@ -43,7 +42,7 @@ Release Date: Not Released - url_title() will now trim extra dashes from beginning and end. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. - - Changed humanize to include a second param for the separator. + - Changed humanize() to include a second param for the separator. - Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words. - Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). - Added an optional third parameter to ``timespan()`` that constrains the number of time units displayed. @@ -56,21 +55,17 @@ Release Date: Not Released - Database - - 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 + - Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern. - Added the ability to insert objects with insert_batch() in :doc:`Query Builder `. - - Added new :doc:`Query Builder ` methods that return - the SQL string of queries without executing them: get_compiled_select(), - get_compiled_insert(), get_compiled_update(), get_compiled_delete(). - - Adding $escape parameter to the order_by function, this enables ordering by custom fields. + - Added new :doc:`Query Builder ` methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete(). + - Adding $escape parameter to the order_by() method, this enables ordering by custom fields. - Improved support for the MySQLi driver, including: - OOP style of the PHP extension is now used, instead of the procedural aliases. - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. - Added persistent connections support for PHP >= 5.3. - Added 'dsn' configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID). - Improved PDO database support. - - Added Interbase/Firebird database support via the "interbase" driver + - Added Interbase/Firebird database support via the "interbase" driver. - Added an optional database name parameter to db_select(). - Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message. - Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class. @@ -102,7 +97,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 unbuffered_row() function for getting a row without prefetching whole result (consume less memory) + - Added unbuffered_row() method for getting a row without prefetching whole result (consume less memory). - Libraries @@ -110,17 +105,15 @@ Release Date: Not Released - CI_Loader::_ci_autoloader() is now a protected method. - Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname). - Added possibility to send attachment as buffer string in Email::attach() as $this->email->attach($buffer, $disposition, $newname, $mime). - - Cart library changes include: + - :doc:`Cart library ` changes include: - It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites. - - Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe" - - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatability + - Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe". + - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatability. - :doc:`Image Manipulation library ` changes include: - The initialize() method now only sets existing class properties. - Added support for 3-length hex color values for wm_font_color and wm_shadow_color properties, as well as validation for them. - - Class properties wm_font_color, wm_shadow_color and wm_use_drop_shadow are now protected, to avoid breaking the text_watermark() method - if they are set manually after initialization. + - Class properties wm_font_color, wm_shadow_color and wm_use_drop_shadow are now protected, to avoid breaking the text_watermark() method if they are set manually after initialization. - If property maintain_ratio is set to TRUE, image_reproportion() now doesn't need both width and height to be specified. - - Minor speed optimizations and method & property visibility declarations in the Calendar Library. - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. - :doc:`Form Validation library ` changes include: @@ -153,26 +146,26 @@ Release Date: Not Released Bug fixes for 3.0 ------------------ -- Unlink raised an error if cache file did not exist when you try to delete it. +- Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) where a mis-spelling was in the form validation language file. - Fixed a bug (#159, #163) that mishandled Active Record nested transactions because _trans_depth was not getting incremented. - Fixed a bug (#737, #75) where pagination anchor class was not set properly when using initialize method. - Fixed a bug (#419) - auto_link() now recognizes URLs that come after a word boundary. - Fixed a bug (#724) - is_unique in form validation now checks that you are connected to a database. -- Fixed a bug (#647) - _get_mod_time() in Zip library no longer generates stat failed errors -- Fixed a bug (#608) - Fixes an issue with the Image_lib class not clearing properties completely -- Fixed bugs (#157 and #174) - the Image_lib clear() function now resets all variables to their default values. +- Fixed a bug (#647) - _get_mod_time() in Zip library no longer generates stat failed errors. +- Fixed a bug (#608) - Fixes an issue with the Image_lib class not clearing properties completely. +- Fixed a bug (#157, #174) - the Image_lib clear() function now resets all variables to their default values. - Fixed a bug where using $this->dbforge->create_table() with PostgreSQL database could lead to fetching whole table. - Fixed a bug (#795) - Fixed form method and accept-charset when passing an empty array. -- Fixed a bug (#797) - timespan was using incorrect seconds for year and month. +- Fixed a bug (#797) - timespan() was using incorrect seconds for year and month. - Fixed a bug in CI_Cart::contents() where if called without a TRUE (or equal) parameter, it would fail due to a typo. -- Fixed a bug (#696) - make oci_execute calls inside num_rows non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed. -- Fixed a bug (#406) - sqlsrv DB driver not reuturning resource on db_pconnect(). +- Fixed a bug (#696) - make oci_execute() calls inside num_rows() non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed. +- Fixed a bug (#406) - sqlsrv DB driver not reuturning resource on ``db_pconnect()``. - Fixed a bug in CI_Image_lib::gd_loaded() where it was possible for the script execution to end or a PHP E_WARNING message to be emitted. -- In Pagination library, when use_page_numbers=TRUE previous link and page 1 link do not have the same url +- Fixed a bug in the :doc:`Pagination library ` where when use_page_numbers=TRUE previous link and page 1 link did not have the same url. - Fixed a bug (#561) - Errors in :doc:`XML-RPC Library ` were not properly escaped. - Fixed a bug (#904) - ``CI_Loader::initialize()`` caused a PHP Fatal error to be triggered if error level E_STRICT is used. -- Fixed a hosting edge case where an empty $_SERVER['HTTPS'] variable would evaluate to 'on' +- Fixed a hosting edge case where an empty $_SERVER['HTTPS'] variable would evaluate to 'on'. - Fixed a bug (#154) - ``CI_Session::sess_update()`` caused the session to be destroyed on pages where multiple AJAX requests were executed at once. - 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. @@ -183,7 +176,7 @@ Bug fixes for 3.0 - Fixed a bug (#129) - ODBC's num_rows() returned -1 in some cases, due to not all subdrivers supporting the odbc_num_rows() function. - Fixed a bug (#153) - E_NOTICE being generated by getimagesize() in the :doc:`File Uploading Library `. - Fixed a bug (#611) - SQLSRV's error handling methods used to issue warnings when there's no actual error. -- Fixed a bug (#1036) - is_write_type() method in the :doc:`Database Library ` didn't return TRUE for RENAME and OPTIMIZE queries. +- Fixed a bug (#1036) - is_write_type() method in the :doc:`Database Library ` didn't return TRUE for RENAME queries. - Fixed a bug in PDO's _version() method where it used to return the client version as opposed to the server one. - Fixed a bug in PDO's insert_id() method where it could've failed if it's used with Postgre versions prior to 8.1. - Fixed a bug in CUBRID's affected_rows() method where a connection resource was passed to cubrid_affected_rows() instead of a result. @@ -207,7 +200,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. -- Fixed a bug (#122) Where routed uri string was being reported incorrectly in sub-directories +- 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. - Fixed a bug in MSSQL and SQLSrv's _truncate() where the TABLE keyword was missing. @@ -217,7 +210,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 +- 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. -- cgit v1.2.3-24-g4f1b From f46e726cfb726da2ec2095011ffe8625b6f9c816 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 23 May 2012 13:16:00 +0300 Subject: Fix a typo in the changelog --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a65a658ed..2b15c3f55 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -160,7 +160,7 @@ Bug fixes for 3.0 - Fixed a bug (#797) - timespan() was using incorrect seconds for year and month. - Fixed a bug in CI_Cart::contents() where if called without a TRUE (or equal) parameter, it would fail due to a typo. - Fixed a bug (#696) - make oci_execute() calls inside num_rows() non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed. -- Fixed a bug (#406) - sqlsrv DB driver not reuturning resource on ``db_pconnect()``. +- Fixed a bug (#406) - sqlsrv DB driver not returning resource on ``db_pconnect()``. - Fixed a bug in CI_Image_lib::gd_loaded() where it was possible for the script execution to end or a PHP E_WARNING message to be emitted. - Fixed a bug in the :doc:`Pagination library ` where when use_page_numbers=TRUE previous link and page 1 link did not have the same url. - Fixed a bug (#561) - Errors in :doc:`XML-RPC Library ` were not properly escaped. -- cgit v1.2.3-24-g4f1b From 74b648c2da3ee5d92920cea2355ccf36d5e0519e Mon Sep 17 00:00:00 2001 From: Nithin Date: Sun, 21 Aug 2011 01:23:47 -0300 Subject: Added ability to _like paramater side to use 'none', in case one wants to query like instead of where without case being sensitive --- system/database/DB_active_rec.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 7bab729f5..841ede28e 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -660,8 +660,12 @@ class CI_DB_active_record extends CI_DB_driver { $prefix = (count($this->ar_like) == 0) ? '' : $type; $v = $this->escape_like_str($v); - - if ($side == 'before') + + if ($side == 'none') + { + $like_statement = $prefix." $k $not LIKE '{$v}'"; + } + elseif ($side == 'before') { $like_statement = $prefix." $k $not LIKE '%{$v}'"; } -- cgit v1.2.3-24-g4f1b From e65f4893c9b3e7c2b34e0fef7c7de04112329063 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 23 May 2012 19:27:54 +0200 Subject: Removed the starting slash from uri_string() documentation. --- user_guide/libraries/uri.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide/libraries/uri.html b/user_guide/libraries/uri.html index f04bb9f10..663fca5bc 100644 --- a/user_guide/libraries/uri.html +++ b/user_guide/libraries/uri.html @@ -191,7 +191,7 @@ $str = $this->uri->assoc_to_uri($array);

    The function would return this:

    -/news/local/345 +news/local/345

    $this->uri->ruri_string()

    -- cgit v1.2.3-24-g4f1b From 55a6ddb0c7bab1149bb1ddfa3a1aff46612c91d4 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 23 May 2012 18:37:24 +0100 Subject: Input, Session and Cookie get's will return NULL. Read more about this change here: http://codeigniter.com/forums/viewthread/215833 --- system/core/Input.php | 4 ++-- system/core/URI.php | 18 +++++++++--------- system/libraries/Session.php | 6 +++--- tests/codeigniter/core/Input_test.php | 18 ++++++++++-------- user_guide_src/source/libraries/input.rst | 17 +++++------------ user_guide_src/source/libraries/uri.rst | 2 +- 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index e916ac66d..97be9e690 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -135,7 +135,7 @@ class CI_Input { { if ( ! isset($array[$index])) { - return FALSE; + return NULL; } if ($xss_clean === TRUE) @@ -659,7 +659,7 @@ class CI_Input { if ( ! isset($this->headers[$index])) { - return FALSE; + return NULL; } return ($xss_clean === TRUE) diff --git a/system/core/URI.php b/system/core/URI.php index e66cb6dc5..a9432e05d 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -358,10 +358,10 @@ class CI_URI { * This function returns the URI segment based on the number provided. * * @param int - * @param bool + * @param mixed * @return string */ - public function segment($n, $no_result = FALSE) + public function segment($n, $no_result = NULL) { return isset($this->segments[$n]) ? $this->segments[$n] : $no_result; } @@ -376,10 +376,10 @@ class CI_URI { * same result as $this->segment() * * @param int - * @param bool + * @param mixed * @return string */ - public function rsegment($n, $no_result = FALSE) + public function rsegment($n, $no_result = NULL) { return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result; } @@ -462,7 +462,7 @@ class CI_URI { { return (count($default) === 0) ? array() - : array_fill_keys($default, FALSE); + : array_fill_keys($default, NULL); } $segments = array_slice($this->$segment_array(), ($n - 1)); @@ -477,7 +477,7 @@ class CI_URI { } else { - $retval[$seg] = FALSE; + $retval[$seg] = NULL; $lastval = $seg; } @@ -490,7 +490,7 @@ class CI_URI { { if ( ! array_key_exists($val, $retval)) { - $retval[$val] = FALSE; + $retval[$val] = NULL; } } } @@ -511,7 +511,7 @@ class CI_URI { public function assoc_to_uri($array) { $temp = array(); - foreach ( (array) $array as $key => $val) + foreach ((array) $array as $key => $val) { $temp[] = $key; $temp[] = $val; @@ -644,7 +644,7 @@ class CI_URI { */ public function ruri_string() { - return '/'.implode('/', $this->rsegment_array()); + return implode('/', $this->rsegment_array()); } } diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 783109a60..4d6aa0ce8 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -276,7 +276,7 @@ class CI_Session { $session = $this->CI->input->cookie($this->sess_cookie_name); // No cookie? Goodbye cruel world!... - if ($session === FALSE) + if ($session === NULL) { log_message('debug', 'A session cookie was not found.'); return FALSE; @@ -586,7 +586,7 @@ class CI_Session { */ public function userdata($item) { - return isset($this->userdata[$item]) ? $this->userdata[$item] : FALSE; + return isset($this->userdata[$item]) ? $this->userdata[$item] : NULL; } // -------------------------------------------------------------------- @@ -715,7 +715,7 @@ class CI_Session { { // 'old' flashdata gets removed. Here we mark all // flashdata as 'new' to preserve it from _flashdata_sweep() - // Note the function will return FALSE if the $key + // Note the function will return NULL if the $key // provided cannot be found $value = $this->userdata($this->flashdata_key.':old:'.$key); diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index fd0576e38..a066d9960 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -28,11 +28,13 @@ class Input_test extends CI_TestCase { $this->assertTrue( ! $this->input->get()); $this->assertTrue( ! $this->input->get('foo')); - $this->assertTrue($this->input->get() == FALSE); - $this->assertTrue($this->input->get('foo') == FALSE); + // Test we're getting empty results + $this->assertTrue($this->input->get() == NULL); + $this->assertTrue($this->input->get('foo') == NULL); - $this->assertTrue($this->input->get() === FALSE); - $this->assertTrue($this->input->get('foo') === FALSE); + // Test new 3.0 behaviour for non existant results (used to be FALSE) + $this->assertTrue($this->input->get() === NULL); + $this->assertTrue($this->input->get('foo') === NULL); } // -------------------------------------------------------------------- @@ -68,11 +70,11 @@ class Input_test extends CI_TestCase { $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() == NULL); + $this->assertTrue($this->input->post('foo') == NULL); - $this->assertTrue($this->input->post() === FALSE); - $this->assertTrue($this->input->post('foo') === FALSE); + $this->assertTrue($this->input->post() === NULL); + $this->assertTrue($this->input->post('foo') === NULL); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 1f2ea650a..432bac3c7 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -18,7 +18,7 @@ The security filtering function is called automatically when a new :doc:`controller <../general/controllers>` is invoked. It does the following: -- If $config['allow_get_array'] is FALSE(default is TRUE), destroys +- If $config['allow_get_array'] is FALSE (default is TRUE), destroys the global GET array. - Destroys all global variables in the event register_globals is turned on. @@ -53,14 +53,7 @@ false (boolean) if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally you might do something like this:: - if ( ! isset($_POST['something'])) - { - $something = FALSE; - } - else - { - $something = $_POST['something']; - } + $something = isset($_POST['something']) ? $_POST['something'] : NULL; With CodeIgniter's built in functions you can simply do this:: @@ -95,7 +88,7 @@ To return an array of all POST items call without any parameters. To return all POST items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean; -The function returns FALSE (boolean) if there are no items in the POST. +The function returns NULL if there are no items in the POST. :: @@ -115,7 +108,7 @@ To return an array of all GET items call without any parameters. To return all GET items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean; -The function returns FALSE (boolean) if there are no items in the GET. +The function returns NULL if there are no items in the GET. :: @@ -210,7 +203,7 @@ the cookie you are looking for (including any prefixes):: cookie('some_cookie'); -The function returns FALSE (boolean) if the item you are attempting to +The function returns NULL if the item you are attempting to retrieve does not exist. The second optional parameter lets you run the data through the XSS diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index ee60b77d7..cdd76e322 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -25,7 +25,7 @@ The segment numbers would be this: #. metro #. crime_is_up -By default the function returns FALSE (boolean) if the segment does not +By default the function returns NULL if the segment does not exist. There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, this would tell the function to return the number zero in the event of -- cgit v1.2.3-24-g4f1b From f49c407d587d35fc12ad27c045fbcb51f89f59f8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 14:57:33 +0300 Subject: Fix issue #1388 --- system/core/Lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Lang.php b/system/core/Lang.php index 5cb0cad71..73c9127ac 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -65,14 +65,14 @@ class CI_Lang { /** * Load a language file * - * @param mixed the name of the language file to be loaded. Can be an array + * @param mixed the name of the language file to be loaded * @param string the language (english, etc.) * @param bool return loaded array of translations * @param bool add suffix to $langfile * @param string alternative path to look for language file * @return mixed */ - public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') + public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { $langfile = str_replace('.php', '', $langfile); -- cgit v1.2.3-24-g4f1b From 7f57a016358a5ae19470d6c45b09d647246e3462 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 18:40:50 +0300 Subject: Remove the DB destructor (db->close()) --- system/database/DB.php | 2 +- system/database/DB_driver.php | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/system/database/DB.php b/system/database/DB.php index b28439b29..9b96c7fcd 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -159,4 +159,4 @@ function &DB($params = '', $query_builder_override = NULL) } /* End of file DB.php */ -/* Location: ./system/database/DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index a0812d4c7..d8a1c13f0 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1404,23 +1404,6 @@ abstract class CI_DB_driver { { } - // -------------------------------------------------------------------- - - /** - * Destructor - * - * Closes the database connection, if needed. - * - * @return void - */ - public function __destruct() - { - if ( ! $this->pconnect) - { - $this->close(); - } - } - } /* End of file DB_driver.php */ -- cgit v1.2.3-24-g4f1b From d45f9503a45e099ed35df3e83aaa12bd91217dea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 19:31:39 +0300 Subject: Add backwards compatibility work-around for the configuration setting --- system/database/DB.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system/database/DB.php b/system/database/DB.php index 9b96c7fcd..1fe44c0e5 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -118,6 +118,13 @@ function &DB($params = '', $query_builder_override = NULL) { $query_builder = $query_builder_override; } + // Backwards compatibility work-around for keeping the + // $active_record config variable working. Should be + // removed in v3.1 + elseif ( ! isset($query_builder) && isset($active_record)) + { + $query_builder = $active_record; + } require_once(BASEPATH.'database/DB_driver.php'); -- cgit v1.2.3-24-g4f1b From 7b5eb7310e5980ffb23fde8a11261e4a40c3b90e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 20:52:41 +0300 Subject: Fix issue #1273 and some cleanup in Query Builder --- system/database/DB_query_builder.php | 43 +++++++++++++++--------------------- user_guide_src/source/changelog.rst | 7 +++--- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index d0af66de1..cee4354e9 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -211,8 +211,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $alias = $this->_create_alias_from_table(trim($select)); } - $sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias)); - + $sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->escape_identifiers(trim($alias)); + $this->qb_select[] = $sql; $this->qb_no_escape[] = NULL; @@ -256,7 +256,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function distinct($val = TRUE) { - $this->qb_distinct = (is_bool($val)) ? $val : TRUE; + $this->qb_distinct = is_bool($val) ? $val : TRUE; return $this; } @@ -272,7 +272,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function from($from) { - foreach ((array)$from as $val) + foreach ((array) $from as $val) { if (strpos($val, ',') !== FALSE) { @@ -1111,6 +1111,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return $result; } + // -------------------------------------------------------------------- + /** * "Count All Results" query * @@ -1139,6 +1141,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $row = $result->row(); return (int) $row->numrows; } + // -------------------------------------------------------------------- /** @@ -1401,16 +1404,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table == '') + if ($table != '') { - if ( ! isset($this->qb_from[0])) - { - return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; - } + $this->qb_from[0] = $table; } - else + elseif ( ! isset($this->qb_from[0])) { - $this->qb_from[0] = $table; + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; } return TRUE; @@ -1600,16 +1600,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table == '') + if ($table != '') { - if ( ! isset($this->qb_from[0])) - { - return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; - } + $this->qb_from[0] = $table; } - else + elseif ( ! isset($this->qb_from[0])) { - $this->qb_from[0] = $table; + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; } return TRUE; @@ -1696,15 +1693,11 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $index_set = TRUE; } - else - { - $not[] = $k.'-'.$v; - } $clean[$this->protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2); } - if ($index_set == FALSE) + if ($index_set === FALSE) { return $this->display_error('db_batch_missing_index'); } @@ -2102,7 +2095,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param object * @return array */ - public function _object_to_array($object) + protected function _object_to_array($object) { if ( ! is_object($object)) { @@ -2132,7 +2125,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param object * @return array */ - public function _object_to_array_batch($object) + protected function _object_to_array_batch($object) { if ( ! is_object($object)) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e0d745fd8..8ddeb0eac 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -149,7 +149,7 @@ Bug fixes for 3.0 - Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) where a mis-spelling was in the form validation language file. -- Fixed a bug (#159, #163) that mishandled Active Record nested transactions because _trans_depth was not getting incremented. +- Fixed a bug (#159, #163) that mishandled Query Builder nested transactions because _trans_depth was not getting incremented. - Fixed a bug (#737, #75) where pagination anchor class was not set properly when using initialize method. - Fixed a bug (#419) - auto_link() now recognizes URLs that come after a word boundary. - Fixed a bug (#724) - is_unique in form validation now checks that you are connected to a database. @@ -190,7 +190,7 @@ Bug fixes for 3.0 - Fixed a bug (#499) - a CSRF cookie was created even with CSRF protection being disabled. - Fixed a bug (#306) - ODBC's insert_id() method was calling non-existent function odbc_insert_id(), which resulted in a fatal error. - Fixed a bug in Oracle's DB_result class where the cursor id passed to it was always NULL. -- Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. +- Fixed a bug (#64) - Regular expression in DB_query_builder.php failed to handle queries containing SQL bracket delimiters in the join condition. - Fixed a bug in the :doc:`Session Library ` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right. - Fixed a bug (#501) - set_rules() to check if the request method is not 'POST' before aborting, instead of depending on count($_POST) in the :doc:`Form Validation Library `. - Fixed a bug (#940) - csrf_verify() used to set the CSRF cookie while processing a POST request with no actual POST data, which resulted in validating a request that should be considered invalid. @@ -213,7 +213,8 @@ Bug fixes for 3.0 - 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 (#1349) - get_extension() in the `File Uploading Library ` returned the original filename when it didn't have an actual extension. +- Fixed a bug (#1349) - get_extension() in the :doc:`File Uploading Library ` returned the original filename when it didn't have an actual extension. +- Fixed a bug (#1273) - E_NOTICE being generated by :doc:`Query Builder `'s set_update_batch() method. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 389d3cafa7cda7cdf5f891d1a9cd2e00c2711c39 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 01:05:23 +0700 Subject: Update vfsStream reference, run the test --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97ea0422d..d82be5888 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,8 @@ env: - DB=pdo/sqlite before_script: - - pyrus channel-discover pear.php-tools.net - - pyrus install http://pear.php-tools.net/get/vfsStream-0.11.2.tgz + - pyrus channel-discover pear.bovigo.org + - pyrus install bovigo/vfsStream-beta - phpenv rehash - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" @@ -25,4 +25,4 @@ script: phpunit --configuration tests/travis/$DB.phpunit.xml branches: only: - develop - - master \ No newline at end of file + - travis-ci -- cgit v1.2.3-24-g4f1b From 337c35406e9f9588317f8ebedfc5cf89d9ffa236 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 01:12:34 +0700 Subject: Update vfsStream repo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d82be5888..1d9f350fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ env: before_script: - pyrus channel-discover pear.bovigo.org - - pyrus install bovigo/vfsStream-beta + - pyrus install http://pear.bovigo.org/get/vfsStream-0.12.0.tgz - phpenv rehash - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" -- cgit v1.2.3-24-g4f1b From de883e3bdb112ad721926f4274f89f61079a1c81 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 01:27:17 +0700 Subject: Force install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1d9f350fc..bfaf4036a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ env: before_script: - pyrus channel-discover pear.bovigo.org - - pyrus install http://pear.bovigo.org/get/vfsStream-0.12.0.tgz + - pyrus install -f bovigo/vfsStream-beta - phpenv rehash - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" -- cgit v1.2.3-24-g4f1b From f61d9f3758cbc6848d6df2cc83cc262fc36fa156 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 01:38:58 +0700 Subject: Write permission --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bfaf4036a..4076e2bdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,8 @@ env: - DB=pdo/sqlite before_script: - - pyrus channel-discover pear.bovigo.org - - pyrus install -f bovigo/vfsStream-beta + - sudo pyrus channel-discover pear.bovigo.org + - sudo pyrus install -f bovigo/vfsStream-beta - phpenv rehash - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" -- cgit v1.2.3-24-g4f1b From 6bca9f836836f4bea2112cd6635a384e862b4db2 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 01:55:36 +0700 Subject: get vfsStream via composer if its PEAR package not exists --- .travis.yml | 5 ++--- composer.json | 5 +++++ tests/Bootstrap.php | 11 ++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 composer.json diff --git a/.travis.yml b/.travis.yml index 4076e2bdc..5eff68d18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,8 @@ env: - DB=pdo/sqlite before_script: - - sudo pyrus channel-discover pear.bovigo.org - - sudo pyrus install -f bovigo/vfsStream-beta - - phpenv rehash + - curl -s http://getcomposer.org/installer | php + - php composer.phar install - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..fa6dc02e4 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "mikey179/vfsStream": "*" + } +} \ No newline at end of file diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 9f89d1be8..c14a4dee2 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -12,8 +12,17 @@ define('BASEPATH', PROJECT_BASE.'system/'); define('APPPATH', PROJECT_BASE.'application/'); define('VIEWPATH', PROJECT_BASE.''); +// Get vfsStream either via pear or composer +if (file_exists('vfsStream/vfsStream.php')) +{ + require_once 'vfsStream/vfsStream.php'; +} +else +{ + include_once '../vendor/autoload.php'; +} + // Prep our test environment -require_once 'vfsStream/vfsStream.php'; include_once $dir.'/mocks/core/common.php'; include_once $dir.'/mocks/autoloader.php'; spl_autoload_register('autoload'); -- cgit v1.2.3-24-g4f1b From 470805b12a8a25faddc9caafe573c15dbd89f8ed Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 21:57:21 +0300 Subject: Fix issues #44 & #110 --- system/libraries/Upload.php | 2 ++ user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 271c6d21f..7456e922a 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -747,6 +747,8 @@ class CI_Upload { ';', '?', '/', + '!', + '#', '%20', '%22', '%3c', // < diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8ddeb0eac..8ee224fc6 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -215,6 +215,7 @@ Bug fixes for 3.0 - Fixed a bug (#1314) - sess_destroy() did not destroy userdata. - Fixed a bug (#1349) - get_extension() in the :doc:`File Uploading Library ` returned the original filename when it didn't have an actual extension. - Fixed a bug (#1273) - E_NOTICE being generated by :doc:`Query Builder `'s set_update_batch() method. +- Fixed a bug (#44, #110) - :doc:`Upload library `'s clean_file_name() method didn't clear '!' and '#' characters. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 55d3ad4faf2727b900832884e7c219076a255b66 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 22:13:06 +0300 Subject: Fix issue #121 --- system/database/DB_result.php | 16 +++++++++------- system/database/drivers/oci8/oci8_result.php | 16 ++++++++-------- system/database/drivers/sqlite3/sqlite3_result.php | 16 ++++++++-------- user_guide_src/source/changelog.rst | 1 + 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 690734b08..334e08c72 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -242,7 +242,7 @@ class CI_DB_result { $result = $this->custom_result_object($type); if (count($result) === 0) { - return $result; + return NULL; } if ($n != $this->current_row && isset($result[$n])) @@ -253,6 +253,8 @@ class CI_DB_result { return $result[$this->current_row]; } + // -------------------------------------------------------------------- + /** * Returns a single result row - object version * @@ -263,7 +265,7 @@ class CI_DB_result { $result = $this->result_object(); if (count($result) === 0) { - return $result; + return NULL; } if ($n != $this->current_row && isset($result[$n])) @@ -286,7 +288,7 @@ class CI_DB_result { $result = $this->result_array(); if (count($result) === 0) { - return $result; + return NULL; } if ($n != $this->current_row && isset($result[$n])) @@ -307,7 +309,7 @@ class CI_DB_result { public function first_row($type = 'object') { $result = $this->result($type); - return (count($result) === 0) ? $result : $result[0]; + return (count($result) === 0) ? NULL : $result[0]; } // -------------------------------------------------------------------- @@ -320,7 +322,7 @@ class CI_DB_result { public function last_row($type = 'object') { $result = $this->result($type); - return (count($result) === 0) ? $result : $result[count($result) - 1]; + return (count($result) === 0) ? NULL : $result[count($result) - 1]; } // -------------------------------------------------------------------- @@ -335,7 +337,7 @@ class CI_DB_result { $result = $this->result($type); if (count($result) === 0) { - return $result; + return NULL; } if (isset($result[$this->current_row + 1])) @@ -358,7 +360,7 @@ class CI_DB_result { $result = $this->result($type); if (count($result) === 0) { - return $result; + return NULL; } if (isset($result[$this->current_row - 1])) diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 7b05e0a43..6fb6c81f1 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -419,7 +419,7 @@ class CI_DB_oci8_result extends CI_DB_result { OR $n < $this->current_row) { // No such row exists - return array(); + return NULL; } // Get the next row index that would actually need to be fetched @@ -460,7 +460,7 @@ class CI_DB_oci8_result extends CI_DB_result { $this->num_rows = 0; } - return array(); + return NULL; } $this->current_row = $n; @@ -507,7 +507,7 @@ class CI_DB_oci8_result extends CI_DB_result { return (object) $row; } - return array(); + return NULL; } // -------------------------------------------------------------------- @@ -539,19 +539,19 @@ class CI_DB_oci8_result extends CI_DB_result { } else { - return array(); + return NULL; } } elseif ( ! class_exists($class_name)) // No such class exists { - return array(); + return NULL; } $row = $this->row_array($n); - // An array would mean that the row doesn't exist - if (is_array($row)) + // A non-array would mean that the row doesn't exist + if ( ! is_array($row)) { - return $row; + return NULL; } // Convert to the desired class and return diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php index d83d6b2cd..946b36557 100644 --- a/system/database/drivers/sqlite3/sqlite3_result.php +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -386,7 +386,7 @@ class CI_DB_sqlite3_result extends CI_DB_result { OR count($this->result_array) > 0 OR $n < $this->current_row) { // No such row exists - return array(); + return NULL; } // Get the next row index that would actually need to be fetched @@ -427,7 +427,7 @@ class CI_DB_sqlite3_result extends CI_DB_result { $this->num_rows = 0; } - return array(); + return NULL; } $this->current_row = $n; @@ -469,7 +469,7 @@ class CI_DB_sqlite3_result extends CI_DB_result { return (object) $row; } - return array(); + return NULL; } // -------------------------------------------------------------------- @@ -501,19 +501,19 @@ class CI_DB_sqlite3_result extends CI_DB_result { } else { - return array(); + return NULL; } } elseif ( ! class_exists($class_name)) // No such class exists { - return array(); + return NULL; } $row = $this->row_array($n); - // An array would mean that the row doesn't exist - if (is_array($row)) + // A non-array would mean that the row doesn't exist + if ( ! is_array($row)) { - return $row; + return NULL; } // Convert to the desired class and return diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8ee224fc6..67f1271f1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -216,6 +216,7 @@ Bug fixes for 3.0 - Fixed a bug (#1349) - get_extension() in the :doc:`File Uploading Library ` returned the original filename when it didn't have an actual extension. - Fixed a bug (#1273) - E_NOTICE being generated by :doc:`Query Builder `'s set_update_batch() method. - Fixed a bug (#44, #110) - :doc:`Upload library `'s clean_file_name() method didn't clear '!' and '#' characters. +- Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From e13511a1368adb9914a4252d98cb2d0165138e0d Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 02:15:42 +0700 Subject: Global class aliasing, at least until namespace introduced into further release --- tests/Bootstrap.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index c14a4dee2..71394720a 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -12,14 +12,17 @@ define('BASEPATH', PROJECT_BASE.'system/'); define('APPPATH', PROJECT_BASE.'application/'); define('VIEWPATH', PROJECT_BASE.''); -// Get vfsStream either via pear or composer +// Get vfsStream either via PEAR or composer if (file_exists('vfsStream/vfsStream.php')) { require_once 'vfsStream/vfsStream.php'; } else { - include_once '../vendor/autoload.php'; + include_once PROJECT_BASE.'vendor/autoload.php'; + class_alias('org\bovigo\vfs\vfsStream', 'vfsStream'); + class_alias('org\bovigo\vfs\vfsStreamDirectory', 'vfsStreamDirectory'); + class_alias('org\bovigo\vfs\vfsStreamWrapper', 'vfsStreamWrapper'); } // Prep our test environment -- cgit v1.2.3-24-g4f1b From 76e2f034f55b7e0f678f22043eb841b428377fa6 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 02:18:59 +0700 Subject: Remove temporary branch from whitelist --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5eff68d18..6a7d37812 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,4 @@ script: phpunit --configuration tests/travis/$DB.phpunit.xml branches: only: - - develop - - travis-ci + - develop \ No newline at end of file -- cgit v1.2.3-24-g4f1b From eeca6d265c4e104e3a6b34b8581180d2926b3dba Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 03:15:19 +0700 Subject: Backward compatibility, in case someone already has vfsStream in their PEAR or other include_path --- tests/Bootstrap.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 71394720a..1dbd178ca 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -13,11 +13,16 @@ define('APPPATH', PROJECT_BASE.'application/'); define('VIEWPATH', PROJECT_BASE.''); // Get vfsStream either via PEAR or composer -if (file_exists('vfsStream/vfsStream.php')) +foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { - require_once 'vfsStream/vfsStream.php'; + if (file_exists($path.DIRECTORY_SEPARATOR.'vfsStream/vfsStream.phps')) + { + require_once 'vfsStream/vfsStream.php'; + break; + } } -else + +if ( ! class_exists('vfsStream') && file_exists(PROJECT_BASE.'vendor/autoload.php')) { include_once PROJECT_BASE.'vendor/autoload.php'; class_alias('org\bovigo\vfs\vfsStream', 'vfsStream'); -- cgit v1.2.3-24-g4f1b From 846acc7926ccb991d39135353d5047e7de5bcb60 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 24 May 2012 23:27:46 +0300 Subject: Fix issue #319 --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 10 ++++------ user_guide_src/source/changelog.rst | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 3e9fa7b1a..5a24f5532 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -132,11 +132,9 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ protected function _execute($sql) { - return sqlsrv_query($this->conn_id, - $sql, - NULL, - array('Scrollable'=> SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => TRUE) - ); + return (is_write_type($sql) && stripos($sql, 'INSERT') === FALSE) + ? sqlsrv_query($this->conn_id, $sql) + : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => SQLSRV_CURSOR_STATIC)); } // -------------------------------------------------------------------- @@ -237,7 +235,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ public function affected_rows() { - return @sqlrv_rows_affected($this->conn_id); + return sqlrv_rows_affected($this->result_id); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 67f1271f1..f21f1266d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -217,6 +217,7 @@ Bug fixes for 3.0 - Fixed a bug (#1273) - E_NOTICE being generated by :doc:`Query Builder `'s set_update_batch() method. - Fixed a bug (#44, #110) - :doc:`Upload library `'s clean_file_name() method didn't clear '!' and '#' characters. - Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned. +- Fixed a bug (#319) - SQLSRV's affected_rows() method failed due to a scrollable cursor being created for write-type queries. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 2d57445ba66f8b6e5fef526b932d691b0e5690db Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 04:03:56 +0700 Subject: Escape like tests, #136 verification --- tests/Bootstrap.php | 2 +- .../database/query_builder/escape_test.php | 47 ++++++++++++++++++++++ tests/mocks/database/schema/skeleton.php | 21 ++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/codeigniter/database/query_builder/escape_test.php diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 1dbd178ca..38615dd89 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -15,7 +15,7 @@ define('VIEWPATH', PROJECT_BASE.''); // Get vfsStream either via PEAR or composer foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { - if (file_exists($path.DIRECTORY_SEPARATOR.'vfsStream/vfsStream.phps')) + if (file_exists($path.DIRECTORY_SEPARATOR.'vfsStream/vfsStream.php')) { require_once 'vfsStream/vfsStream.php'; break; diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php new file mode 100644 index 000000000..6d220d65d --- /dev/null +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -0,0 +1,47 @@ +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_escape_like_percent_sign() + { + $string = $this->db->escape_like_str('\%foo'); + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; + $res = $this->db->query($sql)->result_array(); + + // Check the result + $this->assertEquals(1, count($res)); + } + + // ------------------------------------------------------------------------ + + /** + * @see ./mocks/schema/skeleton.php + */ + public function test_escape_like_backslash_sign() + { + $string = $this->db->escape_like_str('\\'); + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; + $res = $this->db->query($sql)->result_array(); + + // Check the result + $this->assertEquals(2, count($res)); + } +} \ No newline at end of file diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index 671336cc4..05499f82f 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -88,6 +88,23 @@ class Mock_Database_Schema_Skeleton { )); static::$forge->add_key('id', TRUE); static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE)); + + // Misc Table + static::$forge->add_field(array( + 'id' => array( + 'type' => 'INTEGER', + 'constraint' => 3, + ), + 'key' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + ), + 'value' => array( + 'type' => 'TEXT', + ), + )); + static::$forge->add_key('id', TRUE); + static::$forge->create_table('misc', (strpos(static::$driver, 'pgsql') === FALSE)); } /** @@ -111,6 +128,10 @@ class Mock_Database_Schema_Skeleton { array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'), ), + 'misc' => array( + array('id' => 1, 'key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'), + array('id' => 2, 'key' => '\\%foo456', 'value' => 'Entry with \\%'), + ), ); foreach ($data as $table => $dummy_data) -- cgit v1.2.3-24-g4f1b From 6a43244e1d739db17db266456221099232d120d6 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 04:09:38 +0700 Subject: replace space with tab --- tests/codeigniter/database/query_builder/escape_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 6d220d65d..f2d1b84ca 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -23,8 +23,8 @@ class Escape_test extends CI_TestCase { public function test_escape_like_percent_sign() { $string = $this->db->escape_like_str('\%foo'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; - $res = $this->db->query($sql)->result_array(); + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; + $res = $this->db->query($sql)->result_array(); // Check the result $this->assertEquals(1, count($res)); @@ -38,8 +38,8 @@ class Escape_test extends CI_TestCase { public function test_escape_like_backslash_sign() { $string = $this->db->escape_like_str('\\'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; - $res = $this->db->query($sql)->result_array(); + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; + $res = $this->db->query($sql)->result_array(); // Check the result $this->assertEquals(2, count($res)); -- cgit v1.2.3-24-g4f1b From d06acd85cdfff5411474b46afee36fb77baa1200 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 00:29:09 +0300 Subject: Added update_batch() support for PostgreSQL (issue #356) --- system/database/DB_utility.php | 4 +-- system/database/drivers/postgre/postgre_driver.php | 41 ++++++++++++++++++++++ user_guide_src/source/changelog.rst | 2 ++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 587dfdc01..cb97ff448 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -212,7 +212,7 @@ abstract class CI_DB_utility extends CI_DB_forge { $out = rtrim($out).$newline; // Next blast through the result array and build out the rows - foreach ($query->result_array() as $row) + while ($row = $query->unbuffered_row('array')) { foreach ($row as $item) { @@ -258,7 +258,7 @@ abstract class CI_DB_utility extends CI_DB_forge { // Generate the result $xml = '<'.$root.'>'.$newline; - foreach ($query->result_array() as $row) + while ($row = $query->unbuffered_row()) { $xml .= $tab.'<'.$element.'>'.$newline; foreach ($row as $key => $val) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 0ddfd0abe..30689cc70 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -538,6 +538,47 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string the table name + * @param array the update data + * @param array the where clause + * @return string + */ + protected function _update_batch($table, $values, $index, $where = NULL) + { + $ids = array(); + foreach ($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach (array_keys($val) as $field) + { + if ($field != $index) + { + $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k.' = (CASE '.$k."\n" + .implode("\n", $v)."\n" + .'ELSE '.$k.' END), '; + } + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) + .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .$index.' IN('.implode(',', $ids).')'; + } + + // -------------------------------------------------------------------- + /** * Delete statement * diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f21f1266d..5407fb05e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -75,6 +75,7 @@ Release Date: Not Released - 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 update_batch() support. - 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. @@ -218,6 +219,7 @@ Bug fixes for 3.0 - Fixed a bug (#44, #110) - :doc:`Upload library `'s clean_file_name() method didn't clear '!' and '#' characters. - Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned. - Fixed a bug (#319) - SQLSRV's affected_rows() method failed due to a scrollable cursor being created for write-type queries. +- Fixed a bug (#356) - PostgreSQL driver didn't have an _update_batch() method, which resulted in fatal error being triggered when update_batch() is used with it. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 21cb2d32edd595a38189cdba137e694c3a22e1f0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 01:01:06 +0300 Subject: Fix issue #136 (MySQL escape_like_str()) --- system/database/drivers/mysql/mysql_driver.php | 6 ++++-- system/database/drivers/mysqli/mysqli_driver.php | 6 ++++-- user_guide_src/source/changelog.rst | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 161f99541..d801a9aaf 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -47,7 +47,7 @@ class CI_DB_mysql_driver extends CI_DB { // clause and character used for LIKE escape sequences - not used in MySQL protected $_like_escape_str = ''; - protected $_like_escape_chr = ''; + protected $_like_escape_chr = '\\'; /** * The syntax to count rows is slightly different across different @@ -291,7 +291,9 @@ class CI_DB_mysql_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - return str_replace(array('%', '_'), array('\\%', '\\_'), $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; diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 9261883f5..61761e0c6 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -47,7 +47,7 @@ class CI_DB_mysqli_driver extends CI_DB { // clause and character used for LIKE escape sequences - not used in MySQL protected $_like_escape_str = ''; - protected $_like_escape_chr = ''; + protected $_like_escape_chr = '\\'; /** * The syntax to count rows is slightly different across different @@ -291,7 +291,9 @@ class CI_DB_mysqli_driver extends CI_DB { // escape LIKE condition wildcards if ($like === TRUE) { - return str_replace(array('%', '_'), array('\\%', '\\_'), $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; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 5407fb05e..4b8a0f2d3 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -195,7 +195,7 @@ Bug fixes for 3.0 - Fixed a bug in the :doc:`Session Library ` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right. - Fixed a bug (#501) - set_rules() to check if the request method is not 'POST' before aborting, instead of depending on count($_POST) in the :doc:`Form Validation Library `. - Fixed a bug (#940) - csrf_verify() used to set the CSRF cookie while processing a POST request with no actual POST data, which resulted in validating a request that should be considered invalid. -- Fixed a bug in PostgreSQL's escape_str() where it didn't properly escape LIKE wild characters. +- Fixed a bug (#136) - PostgreSQL, MySQL and MySQLi's escape_str() method didn't properly escape LIKE wild characters. - Fixed a bug in the library loader where some PHP versions wouldn't execute the class constructor. - Fixed a bug (#88) - An unexisting property was used for configuration of the Memcache cache driver. - Fixed a bug (#14) - create_database() method in the :doc:`Database Forge Library ` didn't utilize the configured database character set. -- cgit v1.2.3-24-g4f1b From def568fcc8586db7685c4a1c2efd14c3cd75c8ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 01:06:54 +0300 Subject: Apply fix for issue #136 on PDO+MySQL as well --- system/database/drivers/pdo/pdo_driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index e38c1145c..4784fc65b 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -79,13 +79,13 @@ class CI_DB_pdo_driver extends CI_DB { // clause and character used for LIKE escape sequences // this one depends on the driver being used - if ($this->pdodriver == 'mysql') + if ($this->pdodriver === 'mysql') { $this->_escape_char = '`'; $this->_like_escape_str = ''; - $this->_like_escape_chr = ''; + $this->_like_escape_chr = '\\'; } - elseif ($this->pdodriver == 'odbc') + elseif ($this->pdodriver === 'odbc') { $this->_like_escape_str = " {escape '%s'} "; } -- cgit v1.2.3-24-g4f1b From 98dcac7ea5f82cc1d5cecedd030c5f242f1dc652 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 05:07:51 +0700 Subject: Alter the escape like test, since it use raw SQL via query(), the sql statement would need to add ESCAPE clause for database(s) other than mysql --- .../database/query_builder/escape_test.php | 7 +++++-- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index f2d1b84ca..5dd2da058 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -23,7 +23,9 @@ class Escape_test extends CI_TestCase { public function test_escape_like_percent_sign() { $string = $this->db->escape_like_str('\%foo'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'"; + $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';"; + $res = $this->db->query($sql)->result_array(); // Check the result @@ -38,7 +40,8 @@ class Escape_test extends CI_TestCase { public function test_escape_like_backslash_sign() { $string = $this->db->escape_like_str('\\'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%';"; + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'"; + $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';"; $res = $this->db->query($sql)->result_array(); // Check the result diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index 23a3de2a4..44dcef9ec 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 59d6b4fc4f4d7d5265b59cfd8c0f68f885083f69 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 02:08:00 +0300 Subject: Alter LIKE escaping tests again --- tests/codeigniter/database/DB_driver_test.php | 4 +--- tests/codeigniter/database/DB_test.php | 4 +--- tests/codeigniter/database/query_builder/escape_test.php | 16 ++++++---------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php index fb40f0608..9e16e29b4 100644 --- a/tests/codeigniter/database/DB_driver_test.php +++ b/tests/codeigniter/database/DB_driver_test.php @@ -2,8 +2,6 @@ class DB_driver_test extends CI_TestCase { - // ------------------------------------------------------------------------ - public function test_initialize() { $config = Mock_Database_DB::config(DB_DRIVER); @@ -32,5 +30,5 @@ class DB_driver_test extends CI_TestCase { { return new Mock_Database_Drivers_Postgre($config); } - + } \ No newline at end of file diff --git a/tests/codeigniter/database/DB_test.php b/tests/codeigniter/database/DB_test.php index 9b93e223d..d5c0dea08 100644 --- a/tests/codeigniter/database/DB_test.php +++ b/tests/codeigniter/database/DB_test.php @@ -2,8 +2,6 @@ class DB_test extends CI_TestCase { - // ------------------------------------------------------------------------ - public function test_db_invalid() { $connection = new Mock_Database_DB(array( @@ -45,5 +43,5 @@ class DB_test extends CI_TestCase { $this->assertTrue($db instanceof CI_DB); $this->assertTrue($db instanceof CI_DB_Driver); } - + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 5dd2da058..96fbd078b 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -23,13 +23,10 @@ class Escape_test extends CI_TestCase { public function test_escape_like_percent_sign() { $string = $this->db->escape_like_str('\%foo'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'"; - $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';"; + $res = $this->db->select('value')->from('misc')->like('key', $string, 'after')->get(); - $res = $this->db->query($sql)->result_array(); - // Check the result - $this->assertEquals(1, count($res)); + $this->assertEquals(1, count($res->result_array())); } // ------------------------------------------------------------------------ @@ -40,11 +37,10 @@ class Escape_test extends CI_TestCase { public function test_escape_like_backslash_sign() { $string = $this->db->escape_like_str('\\'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'"; - $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';"; - $res = $this->db->query($sql)->result_array(); - + $res = $this->db->select('value')->from('misc')->like('key', $string, 'after')->get(); + // Check the result - $this->assertEquals(2, count($res)); + $this->assertEquals(2, count($res->result_array())); } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0174d84401b5c5996115a4a6193161f1dab96de2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 02:17:49 +0300 Subject: Alter LIKE escaping tests again --- tests/codeigniter/database/query_builder/escape_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 96fbd078b..9df82c2d0 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -23,7 +23,10 @@ class Escape_test extends CI_TestCase { public function test_escape_like_percent_sign() { $string = $this->db->escape_like_str('\%foo'); - $res = $this->db->select('value')->from('misc')->like('key', $string, 'after')->get(); + $this->db->select('value'); + $this->db->from('misc'); + $this->db->like('key', $string, 'after'); + $res = $this->db->get(); // Check the result $this->assertEquals(1, count($res->result_array())); @@ -38,6 +41,10 @@ class Escape_test extends CI_TestCase { { $string = $this->db->escape_like_str('\\'); $res = $this->db->select('value')->from('misc')->like('key', $string, 'after')->get(); + $this->db->select('value'); + $this->db->from('misc'); + $this->db->like('key', $string, 'after'); + $res = $this->db->get(); // Check the result $this->assertEquals(2, count($res->result_array())); -- cgit v1.2.3-24-g4f1b From f33e2ff30b0a9c54d6e8adbe88662838b9bd525e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 25 May 2012 02:24:17 +0300 Subject: Again ... escape_like_str() tests --- tests/codeigniter/database/query_builder/escape_test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 9df82c2d0..50685922a 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -22,7 +22,8 @@ class Escape_test extends CI_TestCase { */ public function test_escape_like_percent_sign() { - $string = $this->db->escape_like_str('\%foo'); + $string = '\%foo' +; $this->db->select('value'); $this->db->from('misc'); $this->db->like('key', $string, 'after'); @@ -39,8 +40,8 @@ class Escape_test extends CI_TestCase { */ public function test_escape_like_backslash_sign() { - $string = $this->db->escape_like_str('\\'); - $res = $this->db->select('value')->from('misc')->like('key', $string, 'after')->get(); + $string = '\\'; + $this->db->select('value'); $this->db->from('misc'); $this->db->like('key', $string, 'after'); -- cgit v1.2.3-24-g4f1b From 502942bd94fef292970df331b15652ef6e1385e7 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 07:00:41 +0700 Subject: Explicitely testing escape_like_str API --- tests/codeigniter/database/query_builder/escape_test.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 5dd2da058..ac1c8f659 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -13,6 +13,9 @@ class Escape_test extends CI_TestCase { Mock_Database_Schema_Skeleton::create_tables(); Mock_Database_Schema_Skeleton::create_data(); + + $this->pre = (strpos(DB_DRIVER, 'pgsql') === FALSE) ? '`' : '"'; + $this->esc = (strpos(DB_DRIVER, 'mysql') === FALSE) ? '!' : ''; } // ------------------------------------------------------------------------ @@ -23,8 +26,8 @@ class Escape_test extends CI_TestCase { public function test_escape_like_percent_sign() { $string = $this->db->escape_like_str('\%foo'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'"; - $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';"; + + $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';"; $res = $this->db->query($sql)->result_array(); @@ -40,8 +43,9 @@ class Escape_test extends CI_TestCase { public function test_escape_like_backslash_sign() { $string = $this->db->escape_like_str('\\'); - $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%'"; - $sql .= (strpos(DB_DRIVER, 'mysql') !== FALSE) ? ";" : "ESCAPE '!';"; + + $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';"; + $res = $this->db->query($sql)->result_array(); // Check the result -- cgit v1.2.3-24-g4f1b From 3c5abf93d3031064c8181069cfee83ebfb54dcf0 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 07:17:26 +0700 Subject: Clean up --- tests/codeigniter/database/query_builder/escape_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index fe225436a..5df812ca6 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -32,7 +32,7 @@ class Escape_test extends CI_TestCase { $res = $this->db->query($sql)->result_array(); // Check the result - $this->assertEquals(1, count($res->result_array())); + $this->assertEquals(1, count($res)); } // ------------------------------------------------------------------------ @@ -49,7 +49,7 @@ class Escape_test extends CI_TestCase { $res = $this->db->query($sql)->result_array(); // Check the result - $this->assertEquals(2, count($res->result_array())); + $this->assertEquals(2, count($res)); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 35ac46d4aad12fe723229feca403b4dee3efcc27 Mon Sep 17 00:00:00 2001 From: Root Date: Fri, 25 May 2012 18:51:48 -0400 Subject: Changed instead of turning off of the error messaging to hide them --- index.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index 5a1190112..6ffe4864e 100644 --- a/index.php +++ b/index.php @@ -52,20 +52,23 @@ * By default development will show errors but testing and live will hide them. */ -if (defined('ENVIRONMENT')) +// By default show all except notifications, deprecated and strict errors +error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); + +// Show or hide errors depending on current environment +switch (ENVIRONMENT) { - switch (ENVIRONMENT) - { - case 'development': - error_reporting(-1); - break; - case 'testing': - case 'production': - error_reporting(0); - break; - default: - exit('The application environment is not set correctly.'); - } + case 'development': + ini_set('display_errors', 1); + break; + + case 'testing': + case 'production': + ini_set('display_errors', 0); + break; + + default: + exit('The application environment is not set correctly.'); } /* -- cgit v1.2.3-24-g4f1b From 1af5b47ad6f95f805d9f411ce020f2e2fa88b302 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sat, 26 May 2012 16:04:39 +0700 Subject: Remove ternary --- .../database/query_builder/escape_test.php | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 5df812ca6..5d575a37b 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -13,9 +13,6 @@ class Escape_test extends CI_TestCase { Mock_Database_Schema_Skeleton::create_tables(); Mock_Database_Schema_Skeleton::create_data(); - - $this->pre = (strpos(DB_DRIVER, 'pgsql') === FALSE) ? '`' : '"'; - $this->esc = (strpos(DB_DRIVER, 'mysql') === FALSE) ? '!' : ''; } // ------------------------------------------------------------------------ @@ -25,9 +22,17 @@ class Escape_test extends CI_TestCase { */ public function test_escape_like_percent_sign() { + // Escape the like string $string = $this->db->escape_like_str('\%foo'); - $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';"; + if (strpos(DB_DRIVER, 'mysql') !== FALSE) + { + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '';"; + } + else + { + $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';'; + } $res = $this->db->query($sql)->result_array(); @@ -42,14 +47,21 @@ class Escape_test extends CI_TestCase { */ public function test_escape_like_backslash_sign() { + // Escape the like string $string = $this->db->escape_like_str('\\'); - $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';"; + if (strpos(DB_DRIVER, 'mysql') !== FALSE) + { + $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '';"; + } + else + { + $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';'; + } $res = $this->db->query($sql)->result_array(); // Check the result $this->assertEquals(2, count($res)); } - } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4912f8b25cd8fa1b88b4babd1bad2b6bf29dd235 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sat, 26 May 2012 22:09:58 +0700 Subject: Allowing main constants defined via phpunit config or other bootstraper --- tests/Bootstrap.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 38615dd89..5216038c6 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -7,10 +7,10 @@ error_reporting(E_ALL | E_STRICT); $dir = realpath(dirname(__FILE__)); // Path constants -define('PROJECT_BASE', realpath($dir.'/../').'/'); -define('BASEPATH', PROJECT_BASE.'system/'); -define('APPPATH', PROJECT_BASE.'application/'); -define('VIEWPATH', PROJECT_BASE.''); +defined('PROJECT_BASE') OR define('PROJECT_BASE', realpath($dir.'/../').'/'); +defined('BASEPATH') OR define('BASEPATH', PROJECT_BASE.'system/'); +defined('APPPATH') OR define('APPPATH', PROJECT_BASE.'application/'); +defined('VIEWPATH') OR define('VIEWPATH', PROJECT_BASE.''); // Get vfsStream either via PEAR or composer foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) -- cgit v1.2.3-24-g4f1b From 16bb9bd93698335fc1692adcfbd20d8e4fda6268 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 26 May 2012 18:21:14 +0300 Subject: Move count_all() from the drivers to CI_DB_driver --- system/database/DB_driver.php | 32 ++++++++++++++++++++-- system/database/drivers/cubrid/cubrid_driver.php | 29 -------------------- .../drivers/interbase/interbase_driver.php | 29 -------------------- system/database/drivers/mssql/mssql_driver.php | 29 -------------------- system/database/drivers/mysql/mysql_driver.php | 29 -------------------- system/database/drivers/mysqli/mysqli_driver.php | 29 -------------------- system/database/drivers/oci8/oci8_driver.php | 29 -------------------- system/database/drivers/odbc/odbc_driver.php | 30 -------------------- system/database/drivers/pdo/pdo_driver.php | 32 ---------------------- system/database/drivers/postgre/postgre_driver.php | 29 -------------------- system/database/drivers/sqlite/sqlite_driver.php | 29 -------------------- system/database/drivers/sqlite3/sqlite3_driver.php | 24 ---------------- system/database/drivers/sqlsrv/sqlsrv_driver.php | 29 -------------------- 13 files changed, 30 insertions(+), 349 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index d8a1c13f0..bbb7b7a80 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -741,6 +741,35 @@ abstract class CI_DB_driver { // -------------------------------------------------------------------- + /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified database + * + * @param string + * @return int + */ + public function count_all($table = '') + { + if ($table == '') + { + return 0; + } + + $query = $this->query($this->_count_string.$this->escape_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); + if ($query->num_rows() == 0) + { + return 0; + } + + $query = $query->row(); + $this->_reset_select(); + return (int) $query->numrows; + } + + // -------------------------------------------------------------------- + /** * Returns an array of table names * @@ -1395,8 +1424,7 @@ abstract class CI_DB_driver { /** * Dummy method that allows Query Builder class to be disabled - * - * This function is used extensively by every db driver. + * and keep count_all() working. * * @return void */ diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 944df99b5..817dfdc98 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -328,35 +328,6 @@ class CI_DB_cubrid_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified table - * - * @param string - * @return int - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $query = $query->row(); - $this->_reset_select(); - return (int) $query->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index c457f6340..49d3cda87 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -243,35 +243,6 @@ class CI_DB_interbase_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $query = $query->row(); - $this->_reset_select(); - return (int) $query->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 914de499f..342ff2647 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -303,35 +303,6 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $row = $query->row(); - $this->_reset_select(); - return (int) $row->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index d801a9aaf..7a1a7b9a2 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -325,35 +325,6 @@ class CI_DB_mysql_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $query = $query->row(); - $this->_reset_select(); - return (int) $query->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 61761e0c6..dd544f686 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -325,35 +325,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $query = $query->row(); - $this->_reset_select(); - return (int) $query->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index e2fa51349..b979c8a17 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -454,35 +454,6 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return int - */ - 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)); - if ($query == FALSE) - { - return 0; - } - - $row = $query->row(); - $this->_reset_select(); - return (int) $row->numrows; - } - - // -------------------------------------------------------------------- - /** * Show table query * diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index e3172117a..98fd806a8 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -244,36 +244,6 @@ class CI_DB_odbc_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - - if ($query->num_rows() == 0) - { - return 0; - } - - $row = $query->row(); - $this->_reset_select(); - return (int) $row->numrows; - } - - // -------------------------------------------------------------------- - /** * Show table query * diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 4784fc65b..ec7f3e19b 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -408,38 +408,6 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - public function count_all($table = '') - { - if ($table == '') - { - return 0; - } - - $sql = $this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); - $query = $this->query($sql); - - if ($query->num_rows() == 0) - { - return 0; - } - - $row = $query->row(); - $this->_reset_select(); - - return (int) $row->numrows; - } - - // -------------------------------------------------------------------- - /** * Show table query * diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 30689cc70..c2a188416 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -389,35 +389,6 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $query = $query->row(); - $this->_reset_select(); - return (int) $query->numrows; - } - - // -------------------------------------------------------------------- - /** * Show table query * diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index d710b945d..d8b869c2e 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -267,35 +267,6 @@ class CI_DB_sqlite_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return string - */ - 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)); - if ($query->num_rows() == 0) - { - return 0; - } - - $row = $query->row(); - $this->_reset_select(); - return (int) $row->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index ad2848ed8..ea4cf2d4f 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -244,30 +244,6 @@ class CI_DB_sqlite3_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return int - */ - public function count_all($table = '') - { - if ($table == '') - { - return 0; - } - - $result = $this->conn_id->querySingle($this->_count_string.$this->protect_identifiers('numrows') - .' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); - - return empty($result) ? 0 : (int) $result; - } - - // -------------------------------------------------------------------- - /** * Show table query * diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 5a24f5532..961066da7 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -278,35 +278,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * "Count All" query - * - * Generates a platform-specific query string that counts all records in - * the specified database - * - * @param string - * @return int - */ - 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(); - $this->_reset_select(); - return (int) $row->numrows; - } - - // -------------------------------------------------------------------- - /** * List table query * -- cgit v1.2.3-24-g4f1b From 650f2a2bc15dd575f50446dcc1315c131652ca49 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 26 May 2012 18:56:29 +0300 Subject: Fix issue #862 --- system/database/drivers/mssql/mssql_forge.php | 39 ++++++++----------------- system/database/drivers/sqlsrv/sqlsrv_forge.php | 39 ++++++++----------------- user_guide_src/source/changelog.rst | 1 + 3 files changed, 25 insertions(+), 54 deletions(-) diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index 8f8e7c5b9..bbf2d9685 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -48,16 +48,13 @@ class CI_DB_mssql_forge extends CI_DB_forge { */ protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { - $sql = 'CREATE TABLE '; + $sql = ($if_not_exists === TRUE) + ? "IF NOT EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'".$table."') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" + : ''; - if ($if_not_exists === TRUE) - { - $sql .= 'IF NOT EXISTS '; - } + $sql .= 'CREATE TABLE '.$this->db->escape_identifiers($table).' ('; - $sql .= $this->db->escape_identifiers($table).' ('; $current_field_count = 0; - foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is @@ -65,15 +62,13 @@ 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']; + $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; if (array_key_exists('CONSTRAINT', $attributes)) { @@ -115,7 +110,7 @@ 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) . ")"; + $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')'; } if (is_array($keys) && count($keys) > 0) @@ -131,13 +126,11 @@ class CI_DB_mssql_forge extends CI_DB_forge { $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)"; } // -------------------------------------------------------------------- @@ -167,21 +160,14 @@ class CI_DB_mssql_forge extends CI_DB_forge { return $sql; } - $sql .= " $column_definition"; + $sql .= " ".$column_definition; if ($default_value != '') { - $sql .= " DEFAULT \"$default_value\""; + $sql .= " DEFAULT '".$default_value."'"; } - if ($null === NULL) - { - $sql .= ' NULL'; - } - else - { - $sql .= ' NOT NULL'; - } + $sql .= ($null === NULL) ? ' NULL' : ' NOT NULL'; if ($after_field != '') { @@ -189,7 +175,6 @@ class CI_DB_mssql_forge extends CI_DB_forge { } return $sql; - } } diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index e9143b269..c817c2c5d 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -48,16 +48,13 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { - $sql = 'CREATE TABLE '; + $sql = ($if_not_exists === TRUE) + ? "IF NOT EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'".$table."') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" + : ''; - if ($if_not_exists === TRUE) - { - $sql .= 'IF NOT EXISTS '; - } + $sql .= 'CREATE TABLE '.$this->db->escape_identifiers($table).' ('; - $sql .= $this->db->escape_identifiers($table).' ('; $current_field_count = 0; - foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is @@ -65,15 +62,13 @@ class CI_DB_sqlsrv_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']; + $sql .= "\n\t".$this->db->escape_identifiers($field).' '.$attributes['TYPE']; if (array_key_exists('CONSTRAINT', $attributes)) { @@ -115,7 +110,7 @@ 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) . ")"; + $sql .= ",\n\tPRIMARY KEY (".implode(', ', $primary_keys).')'; } if (is_array($keys) && count($keys) > 0) @@ -131,13 +126,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { $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)"; } // -------------------------------------------------------------------- @@ -167,21 +160,14 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { return $sql; } - $sql .= " $column_definition"; + $sql .= ' '.$column_definition; if ($default_value != '') { - $sql .= " DEFAULT \"$default_value\""; + $sql .= " DEFAULT '".$default_value."'"; } - if ($null === NULL) - { - $sql .= ' NULL'; - } - else - { - $sql .= ' NOT NULL'; - } + $sql .= ($null === NULL) ? ' NULL' : ' NOT NULL'; if ($after_field != '') { @@ -189,7 +175,6 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { } return $sql; - } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4b8a0f2d3..a234d6969 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -220,6 +220,7 @@ Bug fixes for 3.0 - Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned. - Fixed a bug (#319) - SQLSRV's affected_rows() method failed due to a scrollable cursor being created for write-type queries. - Fixed a bug (#356) - PostgreSQL driver didn't have an _update_batch() method, which resulted in fatal error being triggered when update_batch() is used with it. +- Fixed a bug (#862) - create_table() failed on SQLSRV/MSSQL when used with 'IF NOT EXISTS'. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 6c7526c95b3fbd502dc8105a67fd38da793caa4e Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 27 May 2012 13:51:27 +0700 Subject: Continuation for Security and Table code-coverage, add coverage report to travis --- .travis.yml | 2 +- system/core/Security.php | 1 + tests/codeigniter/core/Security_test.php | 32 ++++++++++++++++++++++++++++++ tests/codeigniter/libraries/Table_test.php | 24 ++++++++++++++++++++-- tests/mocks/autoloader.php | 4 ++-- tests/travis/mysql.phpunit.xml | 11 +++++----- tests/travis/pdo/mysql.phpunit.xml | 11 +++++----- tests/travis/pdo/pgsql.phpunit.xml | 11 +++++----- tests/travis/pdo/sqlite.phpunit.xml | 11 +++++----- tests/travis/pgsql.phpunit.xml | 11 +++++----- tests/travis/sqlite.phpunit.xml | 11 +++++----- 11 files changed, 88 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a7d37812..31b74b13b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_script: - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" -script: phpunit --configuration tests/travis/$DB.phpunit.xml +script: phpunit --coverage-text --configuration tests/travis/$DB.phpunit.xml branches: only: diff --git a/system/core/Security.php b/system/core/Security.php index f953011eb..9b7ba5799 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -191,6 +191,7 @@ class CI_Security { * Set Cross Site Request Forgery Protection Cookie * * @return object + * @codeCoverageIgnore */ public function csrf_set_cookie() { diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 1796ba74d..b2f8c69d2 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -70,4 +70,36 @@ class Security_test extends CI_TestCase { $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_string); } + + // -------------------------------------------------------------------- + + public function test_xss_hash() + { + $this->assertEmpty($this->security->xss_hash); + + // Perform hash + $this->security->xss_hash(); + + $this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1); + } + + // -------------------------------------------------------------------- + + public function test_entity_decode() + { + $encoded = '<div>Hello <b>Booya</b></div>'; + $decoded = $this->security->entity_decode($encoded); + + $this->assertEquals('
    Hello Booya
    ', $decoded); + } + + // -------------------------------------------------------------------- + + public function test_sanitize_filename() + { + $filename = './'; + $safe_filename = $this->security->sanitize_filename($filename); + + $this->assertEquals('foo', $safe_filename); + } } \ No newline at end of file diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php index 13f338c6b..f5133de1e 100644 --- a/tests/codeigniter/libraries/Table_test.php +++ b/tests/codeigniter/libraries/Table_test.php @@ -291,6 +291,26 @@ class Table_test extends CI_TestCase { ); } - // Test main generate method - // -------------------------------------------------------------------- + function test_generate() + { + // Prepare the data + $data = array( + array('Name', 'Color', 'Size'), + array('Fred', 'Blue', 'Small'), + array('Mary', 'Red', 'Large'), + array('John', 'Green', 'Medium') + ); + + $table = $this->table->generate($data); + + // Test the table header + $this->assertTrue(strpos($table, 'Name') !== FALSE); + $this->assertTrue(strpos($table, 'Color') !== FALSE); + $this->assertTrue(strpos($table, 'Size') !== FALSE); + + // Test the first entry + $this->assertTrue(strpos($table, 'Fred') !== FALSE); + $this->assertTrue(strpos($table, 'Blue') !== FALSE); + $this->assertTrue(strpos($table, 'Small') !== FALSE); + } } \ No newline at end of file diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 92c9bea59..441c88944 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -22,7 +22,7 @@ function autoload($class) ); $ci_libraries = array( - 'Calendar', 'Cart', 'Driver', + 'Calendar', 'Cart', 'Driver_Library', 'Email', 'Encrypt', 'Form_validation', 'Ftp', 'Image_lib', 'Javascript', 'Log', 'Migration', 'Pagination', @@ -50,7 +50,7 @@ function autoload($class) elseif (in_array($subclass, $ci_libraries)) { $dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR; - $class = $subclass; + $class = ($subclass == 'Driver_Library') ? 'Driver' : $subclass; } elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3) { diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml index 1792ae38d..38c8eba48 100644 --- a/tests/travis/mysql.phpunit.xml +++ b/tests/travis/mysql.phpunit.xml @@ -17,10 +17,9 @@ ../codeigniter - - - PEAR_INSTALL_DIR - PHP_LIBDIR - - + + + ../../system + + \ No newline at end of file diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml index 602030d4e..c3113a66f 100644 --- a/tests/travis/pdo/mysql.phpunit.xml +++ b/tests/travis/pdo/mysql.phpunit.xml @@ -17,10 +17,9 @@ ../../codeigniter - - - PEAR_INSTALL_DIR - PHP_LIBDIR - - + + + ../../../system + + \ No newline at end of file diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml index 77e1493c6..232025523 100644 --- a/tests/travis/pdo/pgsql.phpunit.xml +++ b/tests/travis/pdo/pgsql.phpunit.xml @@ -17,10 +17,9 @@ ../../codeigniter - - - PEAR_INSTALL_DIR - PHP_LIBDIR - - + + + ../../../system + + \ No newline at end of file diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml index cdccef017..3d1256721 100644 --- a/tests/travis/pdo/sqlite.phpunit.xml +++ b/tests/travis/pdo/sqlite.phpunit.xml @@ -17,10 +17,9 @@ ../../codeigniter - - - PEAR_INSTALL_DIR - PHP_LIBDIR - - + + + ../../../system + + \ No newline at end of file diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml index dfc1bff1c..51e433d76 100644 --- a/tests/travis/pgsql.phpunit.xml +++ b/tests/travis/pgsql.phpunit.xml @@ -17,10 +17,9 @@ ../codeigniter - - - PEAR_INSTALL_DIR - PHP_LIBDIR - - + + + ../../system + + \ No newline at end of file diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml index 3223da5e7..701165734 100644 --- a/tests/travis/sqlite.phpunit.xml +++ b/tests/travis/sqlite.phpunit.xml @@ -17,10 +17,9 @@ ../codeigniter - - - PEAR_INSTALL_DIR - PHP_LIBDIR - - + + + ../../system + + \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b2e10b7de0d8979ce19fed5859e696904e2923dd Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 27 May 2012 15:31:53 +0700 Subject: Adding more flexibilities to mock-common --- tests/mocks/core/common.php | 167 +++++++++++++++++++++++++++----------------- 1 file changed, 103 insertions(+), 64 deletions(-) diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index fc94d7fff..e74576626 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -2,53 +2,65 @@ // Set up the global CI functions in their most minimal core representation -function &get_instance() +if ( ! function_exists('get_instance')) { - $test = CI_TestCase::instance(); - $instance = $test->ci_instance(); - return $instance; + function &get_instance() + { + $test = CI_TestCase::instance(); + $instance = $test->ci_instance(); + return $instance; + } } // -------------------------------------------------------------------- -function &get_config() { - $test = CI_TestCase::instance(); - $config = $test->ci_get_config(); - - return $config; +if ( ! function_exists('get_config')) +{ + function &get_config() { + $test = CI_TestCase::instance(); + $config = $test->ci_get_config(); + + return $config; + } } -function config_item($item) +if ( ! function_exists('config_item')) { - $config =& get_config(); - - if ( ! isset($config[$item])) + function config_item($item) { - return FALSE; + $config =& get_config(); + + if ( ! isset($config[$item])) + { + return FALSE; + } + + return $config[$item]; } - - return $config[$item]; } // -------------------------------------------------------------------- -function load_class($class, $directory = 'libraries', $prefix = 'CI_') +if ( ! function_exists('load_class')) { - 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)) + function load_class($class, $directory = 'libraries', $prefix = 'CI_') { - throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class.''); + 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; } - - return $obj; } // This is sort of meh. Should probably be mocked up with @@ -57,76 +69,103 @@ function load_class($class, $directory = 'libraries', $prefix = 'CI_') // bootstrap testsuite. // -------------------------------------------------------------------- -function remove_invisible_characters($str, $url_encoded = TRUE) +if ( ! function_exists('remove_invisible_characters')) { - $non_displayables = array(); - - // every control character except newline (dec 10) - // carriage return (dec 13), and horizontal tab (dec 09) - - if ($url_encoded) + function remove_invisible_characters($str, $url_encoded = TRUE) { - $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 + $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); + do + { + $str = preg_replace($non_displayables, '', $str, -1, $count); + } + while ($count); - return $str; + return $str; + } } // Clean up error messages // -------------------------------------------------------------------- -function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') +if ( ! function_exists('show_error')) { - throw new RuntimeException('CI Error: '.$message); + 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) +if ( ! function_exists('show_404')) { - throw new RuntimeException('CI Error: 404'); + function show_404($page = '', $log_error = TRUE) + { + throw new RuntimeException('CI Error: 404'); + } } -function _exception_handler($severity, $message, $filepath, $line) +if ( ! function_exists('_exception_handler')) { - throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line); + 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') +if ( ! function_exists('is_php')) { - return ! (version_compare(PHP_VERSION, $version) < 0); + function is_php($version = '5.0.0') + { + return ! (version_compare(PHP_VERSION, $version) < 0); + } } -function is_really_writable($file) +if ( ! function_exists('is_really_writable')) { - return is_writable($file); + function is_really_writable($file) + { + return is_writable($file); + } } -function is_loaded() +if ( ! function_exists('is_loaded')) { - throw new Exception('Bad Isolation: mock up environment'); + function is_loaded() + { + throw new Exception('Bad Isolation: mock up environment'); + } } -function log_message($level = 'error', $message, $php_error = FALSE) +if ( ! function_exists('log_message')) { - return TRUE; + function log_message($level = 'error', $message, $php_error = FALSE) + { + return TRUE; + } } -function set_status_header($code = 200, $text = '') +if ( ! function_exists('set_status_header')) { - return TRUE; + function set_status_header($code = 200, $text = '') + { + return TRUE; + } } // EOF \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bf50a3b15c70441a72ec3012319cd63425ba4d20 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Sun, 27 May 2012 19:04:43 -0500 Subject: Fix issue where cache backup is ignored on first call. --- system/libraries/Cache/Cache.php | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index ba732ee8e..53f9f81a7 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -68,7 +68,7 @@ class CI_Cache extends CI_Driver_Library { * * @param string */ - protected $_backup_driver; + protected $_backup_driver = 'dummy'; /** * Constructor @@ -102,6 +102,22 @@ class CI_Cache extends CI_Driver_Library { $this->_backup_driver = $config['backup']; } } + + // If the specified adapter isn't available, check the backup. + if ( ! $this->is_supported($this->_adapter)) + { + if ( ! $this->is_supported($this->_backup_driver)) + { + // Backup isn't supported either. Default to 'Dummy' driver. + log_message('error', 'Cache adapter "'.$this->_adapter.'" and backup "'.$this->_backup_driver.'" are both unavailable. Cache is now using "Dummy" adapter.'); + $this->_adapter = 'dummy'; + } + else + { + // Backup is supported. Set it to primary. + $this->_adapter = $this->_backup_driver; + } + } } // ------------------------------------------------------------------------ @@ -206,26 +222,6 @@ class CI_Cache extends CI_Driver_Library { return $support[$driver]; } - // ------------------------------------------------------------------------ - - /** - * __get() - * - * @param child - * @return object - */ - public function __get($child) - { - $obj = parent::__get($child); - - if ( ! $this->is_supported($child)) - { - $this->_adapter = $this->_backup_driver; - } - - return $obj; - } - } /* End of file Cache.php */ -- cgit v1.2.3-24-g4f1b From 3cc8502b48946f7298797393cea0a7183c325244 Mon Sep 17 00:00:00 2001 From: Root Date: Sun, 27 May 2012 20:06:10 -0400 Subject: Changed to show all the errors on dev --- index.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 6ffe4864e..c212cac84 100644 --- a/index.php +++ b/index.php @@ -52,18 +52,16 @@ * By default development will show errors but testing and live will hide them. */ -// By default show all except notifications, deprecated and strict errors -error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); - -// Show or hide errors depending on current environment switch (ENVIRONMENT) { case 'development': + error_reporting(E_ALL); ini_set('display_errors', 1); break; case 'testing': case 'production': + error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); ini_set('display_errors', 0); break; -- cgit v1.2.3-24-g4f1b From fa5a9e5f28b2ae61748bb20c2f644c3c156c3d5e Mon Sep 17 00:00:00 2001 From: madhazelnut Date: Wed, 30 May 2012 18:50:39 +0300 Subject: create_captcha() helper documentation --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a234d6969..6e528584b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -40,7 +40,7 @@ Release Date: Not Released - Moved error templates to "application/views/errors" - Helpers - + - create_captcha() accepts additional colors parameter, allowing for color customization - url_title() will now trim extra dashes from beginning and end. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. - Changed humanize() to include a second param for the separator. -- cgit v1.2.3-24-g4f1b From 8d021e647f6a094b6097d1ea89119a4047efc8dd Mon Sep 17 00:00:00 2001 From: Gints Murans Date: Wed, 30 May 2012 21:15:08 +0300 Subject: E_ALL -> -1 --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index c212cac84..a11c5c1f2 100644 --- a/index.php +++ b/index.php @@ -55,7 +55,7 @@ switch (ENVIRONMENT) { case 'development': - error_reporting(E_ALL); + error_reporting(-1); ini_set('display_errors', 1); break; -- cgit v1.2.3-24-g4f1b From 8bbf4e09b68a4aa9beb85edbdb0bec75c7a51de6 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 31 May 2012 13:30:22 +0200 Subject: automatic list formatting was broken --- 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 6e528584b..da3be3adb 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -40,6 +40,7 @@ Release Date: Not Released - Moved error templates to "application/views/errors" - Helpers + - create_captcha() accepts additional colors parameter, allowing for color customization - url_title() will now trim extra dashes from beginning and end. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. @@ -110,7 +111,7 @@ Release Date: Not Released - :doc:`Cart library ` changes include: - It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites. - Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe". - - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatability. + - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility. - :doc:`Image Manipulation library ` changes include: - The initialize() method now only sets existing class properties. - Added support for 3-length hex color values for wm_font_color and wm_shadow_color properties, as well as validation for them. -- cgit v1.2.3-24-g4f1b From b6e0b588522055ddffc44e63e5479309fa3b4b14 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 4b733ac97..f468747c6 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 8991cb85b9d9955270bdbbd96a08ba9141c5e11d Mon Sep 17 00:00:00 2001 From: Thanasis Polychronakis Date: Sun, 20 May 2012 18:44:21 +0300 Subject: Indended code to meet CI standards --- system/core/Common.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index f468747c6..8ed18cdae 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -233,7 +233,8 @@ if ( ! function_exists('get_config')) $file_path = APPPATH.'config/config.php'; $found = false; - if (file_exists($file_path)) { + if (file_exists($file_path)) + { $found = true; require($file_path); } @@ -242,7 +243,10 @@ if ( ! function_exists('get_config')) if (defined(ENVIRONMENT) && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) { require($file_path); - } else if (!$found) { + } + else if (!$found) + { + set_status_header(503); exit('The configuration file does not exist.'); } -- cgit v1.2.3-24-g4f1b From 142eef9c0024420fdc1442eafe8e5cdd357451bb Mon Sep 17 00:00:00 2001 From: Thanasis Polychronakis Date: Mon, 21 May 2012 14:38:22 +0300 Subject: Edit to meet CI coding standards --- system/core/Common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 8ed18cdae..159cc0d2b 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -232,10 +232,10 @@ if ( ! function_exists('get_config')) } $file_path = APPPATH.'config/config.php'; - $found = false; + $found = FALSE; if (file_exists($file_path)) { - $found = true; + $found = TRUE; require($file_path); } @@ -244,7 +244,7 @@ if ( ! function_exists('get_config')) { require($file_path); } - else if (!$found) + elseif ( ! $found) { set_status_header(503); exit('The configuration file does not exist.'); -- cgit v1.2.3-24-g4f1b From 991cfa2e5843df05c6295445133882b9f35e3f7b Mon Sep 17 00:00:00 2001 From: Thanasis Polychronakis Date: Thu, 31 May 2012 21:54:35 +0300 Subject: Changed documentation and added note to changelog as per @philsturgeon request --- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/config.rst | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index da3be3adb..3989b52d2 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -38,6 +38,7 @@ Release Date: Not Released - Added some more doctypes. - Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties. - Moved error templates to "application/views/errors" + - Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per Env. - Helpers diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index c81cad7b3..08d9c2905 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -149,11 +149,13 @@ folders: - Your own custom configuration files .. note:: - CodeIgniter always tries to load the configuration files for - the current environment first. If the file does not exist, the global - config file (i.e., the one in application/config/) is loaded. This means - you are not obligated to place **all** of your configuration files in an - environment folder − only the files that change per environment. + CodeIgniter always loads the global config file first (i.e., the one in application/config/), + then tries to load the configuration files for the current environment. + This means you are not obligated to place **all** of your configuration files in an + environment folder. Only the files that change per environment. Additionally you don't + have to copy **all** the config items in the environment config file. Only the config items + that you wish to change for your environment. The config items declared in your environment + folders always overwrite those in your global config files. Helper Functions ================ -- cgit v1.2.3-24-g4f1b From bfc1cad4fbf6d6640d782f39169af6c3799fa3e8 Mon Sep 17 00:00:00 2001 From: Mickey Wu Date: Thu, 31 May 2012 22:28:40 -0700 Subject: Made set_header() public in Email library and updated documentation. --- system/libraries/Email.php | 32 +++++++++++++++---------------- user_guide_src/source/libraries/email.rst | 8 ++++++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 56d60c802..07a0dd584 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -166,8 +166,8 @@ class CI_Email { $this->_headers = array(); $this->_debug_msg = array(); - $this->_set_header('User-Agent', $this->useragent); - $this->_set_header('Date', $this->_set_date()); + $this->set_header('User-Agent', $this->useragent); + $this->set_header('Date', $this->_set_date()); if ($clear_attachments !== FALSE) { @@ -215,8 +215,8 @@ class CI_Email { } } - $this->_set_header('From', $name.' <'.$from.'>'); - $this->_set_header('Return-Path', '<'.$from.'>'); + $this->set_header('From', $name.' <'.$from.'>'); + $this->set_header('Return-Path', '<'.$from.'>'); return $this; } @@ -252,7 +252,7 @@ class CI_Email { $name = '"'.$name.'"'; } - $this->_set_header('Reply-To', $name.' <'.$replyto.'>'); + $this->set_header('Reply-To', $name.' <'.$replyto.'>'); $this->_replyto_flag = TRUE; return $this; @@ -278,7 +278,7 @@ class CI_Email { if ($this->_get_protocol() !== 'mail') { - $this->_set_header('To', implode(', ', $to)); + $this->set_header('To', implode(', ', $to)); } switch ($this->_get_protocol()) @@ -312,7 +312,7 @@ class CI_Email { $this->validate_email($cc); } - $this->_set_header('Cc', implode(', ', $cc)); + $this->set_header('Cc', implode(', ', $cc)); if ($this->_get_protocol() === 'smtp') { @@ -352,7 +352,7 @@ class CI_Email { } else { - $this->_set_header('Bcc', implode(', ', $bcc)); + $this->set_header('Bcc', implode(', ', $bcc)); } return $this; @@ -369,7 +369,7 @@ class CI_Email { public function subject($subject) { $subject = $this->_prep_q_encoding($subject); - $this->_set_header('Subject', $subject); + $this->set_header('Subject', $subject); return $this; } @@ -424,7 +424,7 @@ class CI_Email { * @param string * @return void */ - protected function _set_header($header, $value) + public function set_header($header, $value) { $this->_headers[$header] = $value; } @@ -867,11 +867,11 @@ class CI_Email { */ protected function _build_headers() { - $this->_set_header('X-Sender', $this->clean_email($this->_headers['From'])); - $this->_set_header('X-Mailer', $this->useragent); - $this->_set_header('X-Priority', $this->_priorities[$this->priority - 1]); - $this->_set_header('Message-ID', $this->_get_message_id()); - $this->_set_header('Mime-Version', '1.0'); + $this->set_header('X-Sender', $this->clean_email($this->_headers['From'])); + $this->set_header('X-Mailer', $this->useragent); + $this->set_header('X-Priority', $this->_priorities[$this->priority - 1]); + $this->set_header('Message-ID', $this->_get_message_id()); + $this->set_header('Mime-Version', '1.0'); } // -------------------------------------------------------------------- @@ -1305,7 +1305,7 @@ class CI_Email { if ($this->protocol !== 'smtp') { - $this->_set_header('Bcc', implode(', ', $bcc)); + $this->set_header('Bcc', implode(', ', $bcc)); } else { diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index daf000907..f99eb91df 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -182,6 +182,14 @@ formatting which is added to the header string for people who do not accept HTML email. If you do not set your own message CodeIgniter will extract the message from your HTML email and strip the tags. +$this->email->set_header() +----------------------- + +Appends additional headers to the e-mail:: + + $this->email->set_header('Header1', 'Value1'); + $this->email->set_header('Header2', 'Value2'); + $this->email->clear() --------------------- -- cgit v1.2.3-24-g4f1b From 2e757d844caede9784da0b30faa7d5c405c6b172 Mon Sep 17 00:00:00 2001 From: Mickey Wu Date: Fri, 1 Jun 2012 10:24:22 -0700 Subject: Update user_guide_src/source/changelog.rst --- 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 da3be3adb..13482d826 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -132,6 +132,7 @@ Release Date: Not Released - Allowed for setting table class defaults in a config file. - Added a Wincache driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. + - Enabled public access to Email library's set_header() for adding additional headers to e-mails. - Core -- cgit v1.2.3-24-g4f1b From ed944a3c70a0bad158cd5a6ca5ce1f2e717aff5d Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:07:47 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/core --- system/core/Benchmark.php | 2 +- system/core/CodeIgniter.php | 4 ++-- system/core/Common.php | 14 +++++++------- system/core/Config.php | 14 +++++++------- system/core/Hooks.php | 2 +- system/core/Input.php | 18 +++++++++--------- system/core/Lang.php | 14 +++++++------- system/core/Loader.php | 26 +++++++++++++------------- system/core/Output.php | 14 +++++++------- system/core/Router.php | 8 ++++---- system/core/Security.php | 8 ++++---- system/core/URI.php | 14 +++++++------- system/core/Utf8.php | 2 +- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index bb630f40b..2fabdf46e 100755 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -79,7 +79,7 @@ class CI_Benchmark { */ public function elapsed_time($point1 = '', $point2 = '', $decimals = 4) { - if ($point1 == '') + if ($point1 === '') { return '{elapsed_time}'; } diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index c8245fcfa..182f17ab3 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -94,7 +94,7 @@ * Note: Since the config file data is cached it doesn't * hurt to load it here. */ - if (isset($assign_to_config['subclass_prefix']) && $assign_to_config['subclass_prefix'] != '') + if (isset($assign_to_config['subclass_prefix']) && $assign_to_config['subclass_prefix'] !== '') { get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } @@ -182,7 +182,7 @@ * ------------------------------------------------------ */ if ($EXT->call_hook('cache_override') === FALSE - && $OUT->_display_cache($CFG, $URI) == TRUE) + && $OUT->_display_cache($CFG, $URI) === TRUE) { exit; } diff --git a/system/core/Common.php b/system/core/Common.php index 159cc0d2b..a773c4f20 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -200,7 +200,7 @@ if ( ! function_exists('is_loaded')) { static $_is_loaded = array(); - if ($class != '') + if ($class !== '') { $_is_loaded[strtolower($class)] = $class; } @@ -370,7 +370,7 @@ if ( ! function_exists('log_message')) { static $_log; - if (config_item('log_threshold') == 0) + if (config_item('log_threshold') === 0) { return; } @@ -436,17 +436,17 @@ if ( ! function_exists('set_status_header')) 505 => 'HTTP Version Not Supported' ); - if ($code == '' OR ! is_numeric($code)) + if ($code === '' OR ! is_numeric($code)) { show_error('Status codes must be numeric', 500); } - if (isset($stati[$code]) && $text == '') + if (isset($stati[$code]) && $text === '') { $text = $stati[$code]; } - if ($text == '') + if ($text === '') { show_error('No status text available. Please check your status code number or supply your own message text.', 500); } @@ -495,13 +495,13 @@ if ( ! function_exists('_exception_handler')) // Should we display the error? We'll get the current error_reporting // level and add its bits with the severity bits to find out. - if (($severity & error_reporting()) == $severity) + if (($severity & error_reporting()) === $severity) { $_error->show_php_error($severity, $message, $filepath, $line); } // Should we log the error? No? We're done... - if (config_item('log_threshold') == 0) + if (config_item('log_threshold') === 0) { return; } diff --git a/system/core/Config.php b/system/core/Config.php index c07ffa591..0e5fa5265 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -100,7 +100,7 @@ class CI_Config { */ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { - $file = ($file == '') ? 'config' : str_replace('.php', '', $file); + $file = ($file === '') ? 'config' : str_replace('.php', '', $file); $found = $loaded = FALSE; foreach ($this->_config_paths as $path) @@ -189,7 +189,7 @@ class CI_Config { */ public function item($item, $index = '') { - if ($index == '') + if ($index === '') { return isset($this->config[$item]) ? $this->config[$item] : FALSE; } @@ -211,7 +211,7 @@ class CI_Config { { return FALSE; } - elseif (trim($this->config[$item]) == '') + elseif (trim($this->config[$item]) === '') { return ''; } @@ -230,14 +230,14 @@ class CI_Config { */ public function site_url($uri = '') { - if ($uri == '') + if ($uri === '') { return $this->slash_item('base_url').$this->item('index_page'); } - if ($this->item('enable_query_strings') == FALSE) + if ($this->item('enable_query_strings') === FALSE) { - $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); + $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; } else @@ -270,7 +270,7 @@ class CI_Config { */ protected function _uri_string($uri) { - if ($this->item('enable_query_strings') == FALSE) + if ($this->item('enable_query_strings') === FALSE) { if (is_array($uri)) { diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 5bbb0009a..29fd88201 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -72,7 +72,7 @@ class CI_Hooks { // If hooks are not enabled in the config file // there is nothing else to do - if ($CFG->item('enable_hooks') == FALSE) + if ($CFG->item('enable_hooks') === FALSE) { return; } diff --git a/system/core/Input.php b/system/core/Input.php index 97be9e690..284b15697 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -263,23 +263,23 @@ class CI_Input { } } - if ($prefix == '' && config_item('cookie_prefix') != '') + if ($prefix === '' && config_item('cookie_prefix') !== '') { $prefix = config_item('cookie_prefix'); } - if ($domain == '' && config_item('cookie_domain') != '') + if ($domain === '' && config_item('cookie_domain') !== '') { $domain = config_item('cookie_domain'); } - if ($path == '/' && config_item('cookie_path') !== '/') + if ($path === '/' && config_item('cookie_path') !== '/') { $path = config_item('cookie_path'); } - if ($secure == FALSE && config_item('cookie_secure') != FALSE) + if ($secure === FALSE && config_item('cookie_secure') !== FALSE) { $secure = config_item('cookie_secure'); } - if ($httponly == FALSE && config_item('cookie_httponly') != FALSE) + if ($httponly === FALSE && config_item('cookie_httponly') !== FALSE) { $httponly = config_item('cookie_httponly'); } @@ -324,7 +324,7 @@ class CI_Input { return $this->ip_address; } - if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR')) + if (config_item('proxy_ips') !== '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR')) { $proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY); $proxies = is_array($proxies) ? $proxies : array($proxies); @@ -459,7 +459,7 @@ class CI_Input { } // Is $_GET data allowed? If not we'll set the $_GET to an empty array - if ($this->_allow_get_array == FALSE) + if ($this->_allow_get_array === FALSE) { $_GET = array(); } @@ -502,7 +502,7 @@ class CI_Input { $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); // CSRF Protection check - if ($this->_enable_csrf == TRUE) + if ($this->_enable_csrf === TRUE) { $this->security->csrf_verify(); } @@ -559,7 +559,7 @@ class CI_Input { } // Standardize newlines if needed - if ($this->_standardize_newlines == TRUE && strpos($str, "\r") !== FALSE) + if ($this->_standardize_newlines === TRUE && strpos($str, "\r") !== FALSE) { return str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } diff --git a/system/core/Lang.php b/system/core/Lang.php index 73c9127ac..3001f1b13 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -76,26 +76,26 @@ class CI_Lang { { $langfile = str_replace('.php', '', $langfile); - if ($add_suffix == TRUE) + if ($add_suffix === TRUE) { $langfile = str_replace('_lang', '', $langfile).'_lang'; } $langfile .= '.php'; - if ($idiom == '') + if ($idiom === '') { $config =& get_config(); $idiom = ( ! empty($config['language'])) ? $config['language'] : 'english'; } - if ($return == FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) + if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { return; } // Determine where the language file is and load it - if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) + if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) { include($alt_path.'language/'.$idiom.'/'.$langfile); } @@ -124,14 +124,14 @@ class CI_Lang { { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); - if ($return == TRUE) + if ($return === TRUE) { return array(); } return; } - if ($return == TRUE) + if ($return === TRUE) { return $lang; } @@ -153,7 +153,7 @@ class CI_Lang { */ public function line($line = '') { - $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; // Because killer robots like unicorns! if ($value === FALSE) diff --git a/system/core/Loader.php b/system/core/Loader.php index 3eb09e6ab..adfe92845 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -208,7 +208,7 @@ class CI_Loader { return; } - if ($library == '' OR isset($this->_base_classes[$library])) + if ($library === '' OR isset($this->_base_classes[$library])) { return FALSE; } @@ -244,7 +244,7 @@ class CI_Loader { return; } - if ($model == '') + if ($model === '') { return; } @@ -261,7 +261,7 @@ class CI_Loader { $model = substr($model, $last_slash); } - if ($name == '') + if ($name === '') { $name = $model; } @@ -329,7 +329,7 @@ class CI_Loader { $CI =& get_instance(); // Do we even need to load the database class? - if (class_exists('CI_DB') && $return == FALSE && $query_builder == NULL && isset($CI->db) && is_object($CI->db)) + if (class_exists('CI_DB') && $return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db)) { return FALSE; } @@ -452,7 +452,7 @@ class CI_Loader { */ public function vars($vars = array(), $val = '') { - if ($val != '' && is_string($vars)) + if ($val !== '' && is_string($vars)) { $vars = array($vars => $val); } @@ -642,7 +642,7 @@ class CI_Loader { require BASEPATH.'libraries/Driver.php'; } - if ($library == '') + if ($library === '') { return FALSE; } @@ -714,7 +714,7 @@ class CI_Loader { { $config =& $this->_ci_get_component('config'); - if ($path == '') + if ($path === '') { array_shift($this->_ci_library_paths); array_shift($this->_ci_model_paths); @@ -775,7 +775,7 @@ class CI_Loader { $file_exists = FALSE; // Set the path to the requested file - if ($_ci_path != '') + if ($_ci_path !== '') { $_ci_x = explode('/', $_ci_path); $_ci_file = end($_ci_x); @@ -783,7 +783,7 @@ class CI_Loader { else { $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); - $_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view; + $_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view; foreach ($this->_ci_view_paths as $view_file => $cascade) { @@ -847,7 +847,7 @@ class CI_Loader { // If the PHP installation does not support short tags we'll // do a little string replacement, changing the short tags // to standard PHP echo statements. - if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') == TRUE) + if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') === TRUE) { echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('_ci_load_class($path, $params); @@ -1008,7 +1008,7 @@ class CI_Loader { // If we got this far we were unable to find the requested class. // We do not issue errors if the load call failed due to a duplicate request - if ($is_duplicate == FALSE) + if ($is_duplicate === FALSE) { log_message('error', 'Unable to load the requested class: '.$class); show_error('Unable to load the requested class: '.$class); @@ -1067,7 +1067,7 @@ class CI_Loader { } } - if ($prefix == '') + if ($prefix === '') { if (class_exists('CI_'.$class)) { diff --git a/system/core/Output.php b/system/core/Output.php index c8feb4e67..496948ab7 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -160,7 +160,7 @@ class CI_Output { */ public function append_output($output) { - if ($this->final_output == '') + if ($this->final_output === '') { $this->final_output = $output; } @@ -192,7 +192,7 @@ class CI_Output { // but it will not modify the content-length header to compensate for // the reduction, causing the browser to hang waiting for more data. // We'll just skip content-length in those cases. - if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0) + if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0) { return; } @@ -349,7 +349,7 @@ class CI_Output { // -------------------------------------------------------------------- // Set the output data - if ($output == '') + if ($output === '') { $output =& $this->final_output; } @@ -381,7 +381,7 @@ class CI_Output { // -------------------------------------------------------------------- // Is compression requested? - if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE + if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc === FALSE && extension_loaded('zlib') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) { @@ -416,7 +416,7 @@ class CI_Output { // Do we need to generate profile data? // If so, load the Profile class and run it. - if ($this->enable_profiler == TRUE) + if ($this->enable_profiler === TRUE) { $CI->load->library('profiler'); if ( ! empty($this->_profiler_sections)) @@ -460,7 +460,7 @@ class CI_Output { { $CI =& get_instance(); $path = $CI->config->item('cache_path'); - $cache_path = ($path == '') ? APPPATH.'cache/' : $path; + $cache_path = ($path === '') ? APPPATH.'cache/' : $path; if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path)) { @@ -509,7 +509,7 @@ class CI_Output { */ public function _display_cache(&$CFG, &$URI) { - $cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path'); + $cache_path = ($CFG->item('cache_path') === '') ? APPPATH.'cache/' : $CFG->item('cache_path'); // Build the file path. The file name is an MD5 hash of the full URI $uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string; diff --git a/system/core/Router.php b/system/core/Router.php index 5ea13797b..93875bdd9 100755 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -165,7 +165,7 @@ class CI_Router { $this->uri->_fetch_uri_string(); // Is there a URI string? If not, the default controller specified in the "routes" file will be shown. - if ($this->uri->uri_string == '') + if ($this->uri->uri_string === '') { return $this->_set_default_controller(); } @@ -435,7 +435,7 @@ class CI_Router { */ public function fetch_method() { - return ($this->method == $this->fetch_class()) ? 'index' : $this->method; + return ($this->method === $this->fetch_class()) ? 'index' : $this->method; } // -------------------------------------------------------------------- @@ -483,14 +483,14 @@ class CI_Router { $this->set_directory($routing['directory']); } - if (isset($routing['controller']) && $routing['controller'] != '') + if (isset($routing['controller']) && $routing['controller'] !== '') { $this->set_class($routing['controller']); } if (isset($routing['function'])) { - $routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function']; + $routing['function'] = ($routing['function'] === '') ? 'index' : $routing['function']; $this->set_method($routing['function']); } } diff --git a/system/core/Security.php b/system/core/Security.php index 9b7ba5799..9cbcd9248 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -162,7 +162,7 @@ class CI_Security { // Do the tokens exist in both the _POST and _COOKIE arrays? if ( ! isset($_POST[$this->_csrf_token_name]) OR ! isset($_COOKIE[$this->_csrf_cookie_name]) - OR $_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name]) // Do the tokens match? + OR $_POST[$this->_csrf_token_name] !== $_COOKIE[$this->_csrf_cookie_name]) // Do the tokens match? { $this->csrf_show_error(); } @@ -408,7 +408,7 @@ class CI_Security { $str = preg_replace('#<(/*)(script|xss)(.*?)\>#si', '[removed]', $str); } } - while($original != $str); + while($original !== $str); unset($original); @@ -475,7 +475,7 @@ class CI_Security { */ public function xss_hash() { - if ($this->_xss_hash == '') + if ($this->_xss_hash === '') { mt_srand(); $this->_xss_hash = md5(time() + mt_rand(0, 1999999999)); @@ -825,7 +825,7 @@ class CI_Security { */ protected function _csrf_set_hash() { - if ($this->_csrf_hash == '') + if ($this->_csrf_hash === '') { // If the cookie exists we will use it's value. // We don't necessarily want to regenerate it with diff --git a/system/core/URI.php b/system/core/URI.php index a9432e05d..9c5025128 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -112,7 +112,7 @@ class CI_URI { // Is there a PATH_INFO variable? // Note: some servers seem to have trouble with getenv() so we'll test it two ways $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); - if (trim($path, '/') != '' && $path !== '/'.SELF) + if (trim($path, '/') !== '' && $path !== '/'.SELF) { $this->_set_uri_string($path); return; @@ -120,14 +120,14 @@ class CI_URI { // No PATH_INFO?... What about QUERY_STRING? $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); - if (trim($path, '/') != '') + if (trim($path, '/') !== '') { $this->_set_uri_string($path); return; } // As a last ditch effort lets try using the $_GET array - if (is_array($_GET) && count($_GET) === 1 && trim(key($_GET), '/') != '') + if (is_array($_GET) && count($_GET) === 1 && trim(key($_GET), '/') !== '') { $this->_set_uri_string(key($_GET)); return; @@ -218,7 +218,7 @@ class CI_URI { $_GET = array(); } - if ($uri == '/' OR empty($uri)) + if ($uri === '/' OR empty($uri)) { return '/'; } @@ -270,7 +270,7 @@ class CI_URI { */ public function _filter_uri($str) { - if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) + if ($str !== '' && $this->config->item('permitted_uri_chars') !== '' && $this->config->item('enable_query_strings') === FALSE) { // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern @@ -298,7 +298,7 @@ class CI_URI { */ public function _remove_url_suffix() { - if ($this->config->item('url_suffix') != '') + if ($this->config->item('url_suffix') !== '') { $this->uri_string = preg_replace('|'.preg_quote($this->config->item('url_suffix')).'$|', '', $this->uri_string); } @@ -321,7 +321,7 @@ class CI_URI { // Filter segments for security $val = trim($this->_filter_uri($val)); - if ($val != '') + if ($val !== '') { $this->segments[] = $val; } diff --git a/system/core/Utf8.php b/system/core/Utf8.php index a6faa84ec..2b5a1f5eb 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -54,7 +54,7 @@ class CI_Utf8 { if ( @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 && function_exists('iconv') // iconv must be installed - && @ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled + && @ini_get('mbstring.func_overload') !== 1 // Multibyte string function overloading cannot be enabled && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 ) { -- cgit v1.2.3-24-g4f1b From 48a2baf0e288accd206f5da5031d29076e130792 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:09:54 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/database --- system/database/DB.php | 10 ++-- system/database/DB_cache.php | 20 ++++---- system/database/DB_driver.php | 50 +++++++++--------- system/database/DB_forge.php | 22 ++++---- system/database/DB_query_builder.php | 60 +++++++++++----------- system/database/DB_result.php | 14 ++--- system/database/DB_utility.php | 4 +- system/database/drivers/cubrid/cubrid_driver.php | 10 ++-- system/database/drivers/cubrid/cubrid_forge.php | 2 +- .../drivers/interbase/interbase_driver.php | 2 +- .../database/drivers/interbase/interbase_forge.php | 4 +- system/database/drivers/mssql/mssql_driver.php | 6 +-- system/database/drivers/mssql/mssql_forge.php | 6 +-- system/database/drivers/mysql/mysql_driver.php | 12 ++--- system/database/drivers/mysql/mysql_forge.php | 2 +- system/database/drivers/mysql/mysql_utility.php | 8 +-- system/database/drivers/mysqli/mysqli_driver.php | 14 ++--- system/database/drivers/mysqli/mysqli_forge.php | 2 +- system/database/drivers/oci8/oci8_driver.php | 6 +-- system/database/drivers/oci8/oci8_forge.php | 4 +- system/database/drivers/odbc/odbc_driver.php | 4 +- system/database/drivers/odbc/odbc_forge.php | 6 +-- system/database/drivers/pdo/pdo_driver.php | 22 ++++---- system/database/drivers/pdo/pdo_forge.php | 8 +-- system/database/drivers/postgre/postgre_driver.php | 14 ++--- system/database/drivers/postgre/postgre_forge.php | 2 +- system/database/drivers/sqlite/sqlite_driver.php | 4 +- system/database/drivers/sqlite/sqlite_forge.php | 6 +-- system/database/drivers/sqlite3/sqlite3_driver.php | 2 +- system/database/drivers/sqlite3/sqlite3_forge.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_forge.php | 6 +-- 31 files changed, 167 insertions(+), 167 deletions(-) diff --git a/system/database/DB.php b/system/database/DB.php index 1fe44c0e5..b0113b6f4 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -53,7 +53,7 @@ function &DB($params = '', $query_builder_override = NULL) show_error('No database connection settings were found in the database config file.'); } - if ($params != '') + if ($params !== '') { $active_group = $params; } @@ -106,7 +106,7 @@ function &DB($params = '', $query_builder_override = NULL) } // No DB specified yet? Beat them senseless... - if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '') + if ( ! isset($params['dbdriver']) OR $params['dbdriver'] === '') { show_error('You have not selected a database type to connect to.'); } @@ -128,7 +128,7 @@ function &DB($params = '', $query_builder_override = NULL) require_once(BASEPATH.'database/DB_driver.php'); - if ( ! isset($query_builder) OR $query_builder == TRUE) + if ( ! isset($query_builder) OR $query_builder === TRUE) { require_once(BASEPATH.'database/DB_query_builder.php'); if ( ! class_exists('CI_DB')) @@ -152,12 +152,12 @@ function &DB($params = '', $query_builder_override = NULL) $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; $DB = new $driver($params); - if ($DB->autoinit == TRUE) + if ($DB->autoinit === TRUE) { $DB->initialize(); } - if (isset($params['stricton']) && $params['stricton'] == TRUE) + if (isset($params['stricton']) && $params['stricton'] === TRUE) { $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); } diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index ff942856b..443bbce5f 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -55,9 +55,9 @@ class CI_DB_Cache { */ public function check_path($path = '') { - if ($path == '') + if ($path === '') { - if ($this->db->cachedir == '') + if ($this->db->cachedir === '') { return $this->db->cache_off(); } @@ -95,8 +95,8 @@ class CI_DB_Cache { return $this->db->cache_off(); } - $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); - $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); + $segment_one = ($this->CI->uri->segment(1) === FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_two = ($this->CI->uri->segment(2) === FALSE) ? 'index' : $this->CI->uri->segment(2); $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); if (FALSE === ($cachedata = read_file($filepath))) @@ -121,8 +121,8 @@ class CI_DB_Cache { return $this->db->cache_off(); } - $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); - $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); + $segment_one = ($this->CI->uri->segment(1) === FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_two = ($this->CI->uri->segment(2) === FALSE) ? 'index' : $this->CI->uri->segment(2); $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; $filename = md5($sql); @@ -154,14 +154,14 @@ class CI_DB_Cache { */ public function delete($segment_one = '', $segment_two = '') { - if ($segment_one == '') + if ($segment_one === '') { - $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_one = ($this->CI->uri->segment(1) === FALSE) ? 'default' : $this->CI->uri->segment(1); } - if ($segment_two == '') + if ($segment_two === '') { - $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); + $segment_two = ($this->CI->uri->segment(2) === FALSE) ? 'index' : $this->CI->uri->segment(2); } $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index bbb7b7a80..39c19cdf7 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -113,7 +113,7 @@ abstract class CI_DB_driver { // ---------------------------------------------------------------- // Connect to the database and set the connection ID - $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); + $this->conn_id = ($this->pconnect === FALSE) ? $this->db_connect() : $this->db_pconnect(); // No connection resource? Check if there is a failover else throw an error if ( ! $this->conn_id) @@ -131,7 +131,7 @@ abstract class CI_DB_driver { } // Try to connect - $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); + $this->conn_id = ($this->pconnect === FALSE) ? $this->db_connect() : $this->db_pconnect(); // If a connection is made break the foreach loop if ($this->conn_id) @@ -297,7 +297,7 @@ abstract class CI_DB_driver { */ public function query($sql, $binds = FALSE, $return_object = TRUE) { - if ($sql == '') + if ($sql === '') { log_message('error', 'Invalid query: '.$sql); @@ -305,7 +305,7 @@ abstract class CI_DB_driver { } // Verify table prefix and replace if necessary - if ($this->dbprefix != '' && $this->swap_pre != '' && $this->dbprefix != $this->swap_pre) + if ($this->dbprefix !== '' && $this->swap_pre !== '' && $this->dbprefix !== $this->swap_pre) { $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql); } @@ -319,7 +319,7 @@ abstract class CI_DB_driver { // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists - if ($this->cache_on == TRUE && stripos($sql, 'SELECT') !== FALSE && $this->_cache_init()) + if ($this->cache_on === TRUE && stripos($sql, 'SELECT') !== FALSE && $this->_cache_init()) { $this->load_rdriver(); if (FALSE !== ($cache = $this->CACHE->read($sql))) @@ -329,7 +329,7 @@ abstract class CI_DB_driver { } // Save the query for debugging - if ($this->save_queries == TRUE) + if ($this->save_queries === TRUE) { $this->queries[] = $sql; } @@ -340,7 +340,7 @@ abstract class CI_DB_driver { // Run the Query if (FALSE === ($this->result_id = $this->simple_query($sql))) { - if ($this->save_queries == TRUE) + if ($this->save_queries === TRUE) { $this->query_times[] = 0; } @@ -373,7 +373,7 @@ abstract class CI_DB_driver { $time_end = microtime(TRUE); $this->benchmark += $time_end - $time_start; - if ($this->save_queries == TRUE) + if ($this->save_queries === TRUE) { $this->query_times[] = $time_end - $time_start; } @@ -387,7 +387,7 @@ abstract class CI_DB_driver { { // If caching is enabled we'll auto-cleanup any // existing files related to this particular URI - if ($this->cache_on == TRUE && $this->cache_autodel == TRUE && $this->_cache_init()) + if ($this->cache_on === TRUE && $this->cache_autodel === TRUE && $this->_cache_init()) { $this->CACHE->delete(); } @@ -409,7 +409,7 @@ abstract class CI_DB_driver { // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. - if ($this->cache_on == TRUE && $this->_cache_init()) + if ($this->cache_on === TRUE && $this->_cache_init()) { // We'll create a new instance of the result object // only without the platform specific driver since @@ -752,13 +752,13 @@ abstract class CI_DB_driver { */ public function count_all($table = '') { - if ($table == '') + if ($table === '') { return 0; } $query = $this->query($this->_count_string.$this->escape_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); - if ($query->num_rows() == 0) + if ($query->num_rows() === 0) { return 0; } @@ -850,7 +850,7 @@ abstract class CI_DB_driver { return $this->data_cache['field_names'][$table]; } - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -918,7 +918,7 @@ abstract class CI_DB_driver { */ public function field_data($table = '') { - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -939,7 +939,7 @@ abstract class CI_DB_driver { */ public function escape_identifiers($item) { - if ($this->_escape_char == '') + if ($this->_escape_char === '') { return $item; } @@ -998,7 +998,7 @@ abstract class CI_DB_driver { */ public function update_string($table, $data, $where) { - if ($where == '') + if ($where === '') { return FALSE; } @@ -1018,7 +1018,7 @@ abstract class CI_DB_driver { $dest = array(); foreach ($where as $key => $val) { - $prefix = (count($dest) == 0) ? '' : ' AND '; + $prefix = (count($dest) === 0) ? '' : ' AND '; $key = $this->protect_identifiers($key); if ($val !== '') @@ -1062,7 +1062,7 @@ abstract class CI_DB_driver { */ public function call_function($function) { - $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; + $driver = ($this->dbdriver === 'postgre') ? 'pg_' : $this->dbdriver.'_'; if (FALSE === strpos($driver, $function)) { @@ -1217,7 +1217,7 @@ abstract class CI_DB_driver { $heading = $LANG->line('db_error_heading'); - if ($native == TRUE) + if ($native === TRUE) { $message = (array) $error; } @@ -1345,7 +1345,7 @@ abstract class CI_DB_driver { } // Is there a table prefix defined in the config file? If not, no need to do anything - if ($this->dbprefix != '') + if ($this->dbprefix !== '') { // We now add the table prefix based on some logic. // Do we have 4 segments (hostname.database.table.column)? @@ -1369,13 +1369,13 @@ abstract class CI_DB_driver { // This flag is set when the supplied $item does not contain a field name. // This can happen when this function is being called from a JOIN. - if ($field_exists == FALSE) + if ($field_exists === FALSE) { $i++; } // Verify table prefix and replace if necessary - if ($this->swap_pre != '' && strpos($parts[$i], $this->swap_pre) === 0) + if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0) { $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]); } @@ -1398,15 +1398,15 @@ abstract class CI_DB_driver { } // Is there a table prefix? If not, no need to insert it - if ($this->dbprefix != '') + if ($this->dbprefix !== '') { // Verify table prefix and replace if necessary - if ($this->swap_pre != '' && strpos($item, $this->swap_pre) === 0) + if ($this->swap_pre !== '' && strpos($item, $this->swap_pre) === 0) { $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item); } // Do we prefix an item with no segments? - elseif ($prefix_single == TRUE && strpos($item, $this->dbprefix) !== 0) + elseif ($prefix_single === TRUE && strpos($item, $this->dbprefix) !== 0) { $item = $this->dbprefix.$item; } diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index a519575f0..ff5eb3fe6 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -85,7 +85,7 @@ abstract class CI_DB_forge { */ public function drop_database($db_name) { - if ($db_name == '') + if ($db_name === '') { show_error('A table name is required for that operation.'); return FALSE; @@ -123,7 +123,7 @@ abstract class CI_DB_forge { return; } - if ($key == '') + if ($key === '') { show_error('Key information is required for that operation.'); } @@ -150,7 +150,7 @@ abstract class CI_DB_forge { */ public function add_field($field = '') { - if ($field == '') + if ($field === '') { show_error('Field information is required.'); } @@ -197,7 +197,7 @@ abstract class CI_DB_forge { */ public function create_table($table = '', $if_not_exists = FALSE) { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } @@ -222,7 +222,7 @@ abstract class CI_DB_forge { */ public function drop_table($table_name) { - if ($table_name == '') + if ($table_name === '') { return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE; } @@ -245,7 +245,7 @@ abstract class CI_DB_forge { */ public function rename_table($table_name, $new_table_name) { - if ($table_name == '' OR $new_table_name == '') + if ($table_name === '' OR $new_table_name === '') { show_error('A table name is required for that operation.'); return FALSE; @@ -273,7 +273,7 @@ abstract class CI_DB_forge { */ public function add_column($table = '', $field = array(), $after_field = '') { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } @@ -284,7 +284,7 @@ abstract class CI_DB_forge { { $this->add_field(array($k => $field[$k])); - if (count($this->fields) == 0) + if (count($this->fields) === 0) { show_error('Field information is required.'); } @@ -312,12 +312,12 @@ abstract class CI_DB_forge { */ public function drop_column($table = '', $column_name = '') { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } - if ($column_name == '') + if ($column_name === '') { show_error('A column name is required for that operation.'); } @@ -337,7 +337,7 @@ abstract class CI_DB_forge { */ public function modify_column($table = '', $field = array()) { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index cee4354e9..45d68cd39 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -97,7 +97,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $val = trim($val); - if ($val != '') + if ($val !== '') { $this->qb_select[] = $val; $this->qb_no_escape[] = $escape; @@ -194,7 +194,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX') { - if ( ! is_string($select) OR $select == '') + if ( ! is_string($select) OR $select === '') { $this->display_error('db_invalid_query'); } @@ -206,7 +206,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { show_error('Invalid function type: '.$type); } - if ($alias == '') + if ($alias === '') { $alias = $this->_create_alias_from_table(trim($select)); } @@ -325,7 +325,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function join($table, $cond, $type = '') { - if ($type != '') + if ($type !== '') { $type = strtoupper(trim($type)); @@ -691,7 +691,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // some platforms require an escape sequence definition for LIKE wildcards - if ($this->_like_escape_str != '') + if ($this->_like_escape_str !== '') { $like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -829,7 +829,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $val = trim($val); - if ($val != '') + if ($val !== '') { $this->qb_groupby[] = $val = $this->protect_identifiers($val); @@ -908,7 +908,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $k .= ' = '; } - if ($v != '') + if ($v !== '') { $v = ' '.$this->escape($v); } @@ -941,7 +941,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $orderby = ''; // Random results want or don't need a field name $direction = $this->_random_keyword; } - elseif (trim($direction) != '') + elseif (trim($direction) !== '') { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC'; } @@ -963,7 +963,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $orderby = implode(', ', $temp); } - elseif ($direction != $this->_random_keyword) + elseif ($direction !== $this->_random_keyword) { if ($escape === TRUE) { @@ -1064,7 +1064,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function get_compiled_select($table = '', $reset = TRUE) { - if ($table != '') + if ($table !== '') { $this->_track_aliases($table); $this->from($table); @@ -1095,7 +1095,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function get($table = '', $limit = null, $offset = null) { - if ($table != '') + if ($table !== '') { $this->_track_aliases($table); $this->from($table); @@ -1124,7 +1124,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function count_all_results($table = '') { - if ($table != '') + if ($table !== '') { $this->_track_aliases($table); $this->from($table); @@ -1156,7 +1156,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function get_where($table = '', $where = null, $limit = null, $offset = null) { - if ($table != '') + if ($table !== '') { $this->from($table); } @@ -1204,7 +1204,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return FALSE; } - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1404,7 +1404,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table != '') + if ($table !== '') { $this->qb_from[0] = $table; } @@ -1439,7 +1439,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1530,12 +1530,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return FALSE; } - if ($where != NULL) + if ($where !== NULL) { $this->where($where); } - if ($limit != NULL) + if ($limit !== NULL) { $this->limit($limit); } @@ -1595,12 +1595,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ protected function _validate_update($table = '') { - if (count($this->qb_set) == 0) + if (count($this->qb_set) === 0) { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table != '') + if ($table !== '') { $this->qb_from[0] = $table; } @@ -1644,7 +1644,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1689,7 +1689,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $clean = array(); foreach ($v as $k2 => $v2) { - if ($k2 == $index) + if ($k2 === $index) { $index_set = TRUE; } @@ -1720,7 +1720,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function empty_table($table = '') { - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1753,7 +1753,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function truncate($table = '') { - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1827,7 +1827,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Combine any cached components with the current statements $this->_merge_cache(); - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1851,12 +1851,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); } - if ($where != '') + if ($where !== '') { $this->where($where); } - if ($limit != NULL) + if ($limit !== NULL) { $this->limit($limit); } @@ -1912,7 +1912,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function dbprefix($table = '') { - if ($table == '') + if ($table === '') { $this->display_error('db_table_name_required'); } @@ -2072,7 +2072,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $sql .= "\nORDER BY ".implode(', ', $this->qb_orderby); if ($this->qb_order !== FALSE) { - $sql .= ($this->qb_order == 'desc') ? ' DESC' : ' ASC'; + $sql .= ($this->qb_order === 'desc') ? ' DESC' : ' ASC'; } } @@ -2106,7 +2106,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { foreach (get_object_vars($object) as $key => $val) { // There are some built in keys we need to ignore for this conversion - if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name') + if ( ! is_object($val) && ! is_array($val) && $key !== '_parent_name') { $array[$key] = $val; } diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 334e08c72..991f6ba94 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -81,7 +81,7 @@ class CI_DB_result { return $this->custom_result_object[$class_name]; } - if ($this->result_id === FALSE OR $this->num_rows() == 0) + if ($this->result_id === FALSE OR $this->num_rows() === 0) { return array(); } @@ -122,7 +122,7 @@ class CI_DB_result { // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so // we'll simply return an empty array. - if ($this->result_id === FALSE OR $this->num_rows() == 0) + if ($this->result_id === FALSE OR $this->num_rows() === 0) { return array(); } @@ -153,7 +153,7 @@ class CI_DB_result { // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so // we'll simply return an empty array. - if ($this->result_id === FALSE OR $this->num_rows() == 0) + if ($this->result_id === FALSE OR $this->num_rows() === 0) { return array(); } @@ -224,7 +224,7 @@ class CI_DB_result { return; } - if ($key != '' && ! is_null($value)) + if ($key !== '' && ! is_null($value)) { $this->row_data[$key] = $value; } @@ -245,7 +245,7 @@ class CI_DB_result { return NULL; } - if ($n != $this->current_row && isset($result[$n])) + if ($n !== $this->current_row && isset($result[$n])) { $this->current_row = $n; } @@ -268,7 +268,7 @@ class CI_DB_result { return NULL; } - if ($n != $this->current_row && isset($result[$n])) + if ($n !== $this->current_row && isset($result[$n])) { $this->current_row = $n; } @@ -291,7 +291,7 @@ class CI_DB_result { return NULL; } - if ($n != $this->current_row && isset($result[$n])) + if ($n !== $this->current_row && isset($result[$n])) { $this->current_row = $n; } diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index cb97ff448..02c921834 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -343,7 +343,7 @@ abstract class CI_DB_utility extends CI_DB_forge { if ($prefs['format'] === 'zip') { // Set the filename if not provided (only needed with Zip files) - if ($prefs['filename'] == '') + if ($prefs['filename'] === '') { $prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database) .date('Y-m-d_H-i', time()).'.sql'; @@ -369,7 +369,7 @@ abstract class CI_DB_utility extends CI_DB_forge { $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); return $CI->zip->get_zip(); } - elseif ($prefs['format'] == 'txt') // Was a text file requested? + elseif ($prefs['format'] === 'txt') // Was a text file requested? { return $this->_backup($prefs); } diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 817dfdc98..b7763d90f 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -74,7 +74,7 @@ class CI_DB_cubrid_driver extends CI_DB { else { // If no port is defined by the user, use the default value - $this->port == '' OR $this->port = 33000; + $this->port === '' OR $this->port = 33000; } } @@ -340,7 +340,7 @@ class CI_DB_cubrid_driver extends CI_DB { { $sql = 'SHOW TABLES'; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } @@ -435,7 +435,7 @@ class CI_DB_cubrid_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -451,7 +451,7 @@ class CI_DB_cubrid_driver extends CI_DB { } return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN ('.implode(',', $ids).')'; } @@ -469,7 +469,7 @@ class CI_DB_cubrid_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return $sql.'LIMIT '.($offset == 0 ? '' : $offset.', ').$limit; + return $sql.'LIMIT '.($offset === 0 ? '' : $offset.', ').$limit; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 4e66f81e3..fb9716226 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -193,7 +193,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 49d3cda87..8cbbfa17d 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -255,7 +255,7 @@ class CI_DB_interbase_driver extends CI_DB { { $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\''; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index c850656a8..5470179a1 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -195,7 +195,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { $sql .= " {$column_definition}"; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT \"{$default_value}\""; } @@ -209,7 +209,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { $sql .= ' AFTER ' . $this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 342ff2647..5bd666960 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -64,7 +64,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_connect() { - if ($this->port != '') + if ($this->port !== '') { $this->hostname .= ','.$this->port; } @@ -81,7 +81,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_pconnect() { - if ($this->port != '') + if ($this->port !== '') { $this->hostname .= ','.$this->port; } @@ -316,7 +316,7 @@ class CI_DB_mssql_driver extends CI_DB { $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; // for future compatibility - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE AND $this->dbprefix !== '') { //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index bbf2d9685..3708c2233 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -155,21 +155,21 @@ class CI_DB_mssql_forge extends CI_DB_forge { $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 != '') + if ($default_value !== '') { $sql .= " DEFAULT '".$default_value."'"; } $sql .= ($null === NULL) ? ' NULL' : ' NOT NULL'; - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7a1a7b9a2..41e86f315 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -68,7 +68,7 @@ class CI_DB_mysql_driver extends CI_DB { { parent::__construct($params); - if ($this->port != '') + if ($this->port !== '') { $this->hostname .= ':'.$this->port; } @@ -337,7 +337,7 @@ class CI_DB_mysql_driver extends CI_DB { { $sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } @@ -370,7 +370,7 @@ class CI_DB_mysql_driver extends CI_DB { */ public function field_data($table = '') { - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -451,7 +451,7 @@ class CI_DB_mysql_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -467,7 +467,7 @@ class CI_DB_mysql_driver extends CI_DB { } return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN('.implode(',', $ids).')'; } @@ -485,7 +485,7 @@ class CI_DB_mysql_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return $sql.' LIMIT '.($offset == 0 ? '' : $offset.', ').$limit; + return $sql.' LIMIT '.($offset === 0 ? '' : $offset.', ').$limit; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 0e39affa7..ffd374fbf 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -178,7 +178,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 642323dbd..643682fde 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -76,7 +76,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Write out the table schema $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; - if ($add_drop == TRUE) + if ($add_drop === TRUE) { $output .= 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table).';'.$newline.$newline; } @@ -92,7 +92,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { } // If inserts are not needed we're done... - if ($add_insert == FALSE) + if ($add_insert === FALSE) { continue; } @@ -100,7 +100,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Grab all the data from the current table $query = $this->db->query('SELECT * FROM '.$this->db->protect_identifiers($table)); - if ($query->num_rows() == 0) + if ($query->num_rows() === 0) { continue; } @@ -143,7 +143,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { else { // Escape the data if it's not an integer - $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v; + $val_str .= ($is_int[$i] === FALSE) ? $this->db->escape($v) : $v; } // Append a comma diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index dd544f686..5814aceb9 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -71,7 +71,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function db_connect() { - return ($this->port != '') + return ($this->port !== '') ? @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port) : @new mysqli($this->hostname, $this->username, $this->password, $this->database); } @@ -91,7 +91,7 @@ class CI_DB_mysqli_driver extends CI_DB { return $this->db_connect(); } - return ($this->port != '') + return ($this->port !== '') ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port) : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database); } @@ -337,7 +337,7 @@ class CI_DB_mysqli_driver extends CI_DB { { $sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } @@ -370,7 +370,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function field_data($table = '') { - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -451,7 +451,7 @@ class CI_DB_mysqli_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -466,10 +466,10 @@ class CI_DB_mysqli_driver extends CI_DB { .'ELSE '.$k.' END, '; } - $where = ($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : ''; + $where = ($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : ''; return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN('.implode(',', $ids).')'; } diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 503574dfc..b00bfde49 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -179,7 +179,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index b979c8a17..e78091614 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -262,7 +262,7 @@ class CI_DB_oci8_driver extends CI_DB { */ public function stored_procedure($package, $procedure, $params) { - if ($package == '' OR $procedure == '' OR ! is_array($params)) + if ($package === '' OR $procedure === '' OR ! is_array($params)) { if ($this->db_debug) { @@ -466,7 +466,7 @@ class CI_DB_oci8_driver extends CI_DB { { $sql = 'SELECT TABLE_NAME FROM ALL_TABLES'; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -634,7 +634,7 @@ class CI_DB_oci8_driver extends CI_DB { { $this->limit_used = TRUE; return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($offset + $limit).')' - .($offset != 0 ? ' WHERE rnum >= '.$offset : ''); + .($offset !== 0 ? ' WHERE rnum >= '.$offset : ''); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index bd265b6e0..837e7eaad 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -141,9 +141,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { } return $sql.' '.$column_definition - .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '') + .($default_value !== '' ? ' DEFAULT "'.$default_value.'"' : '') .($null === NULL ? ' NULL' : ' NOT NULL') - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 98fd806a8..b493e9335 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -64,7 +64,7 @@ class CI_DB_odbc_driver extends CI_DB { $this->_random_keyword = ' RND('.time().')'; // database specific random keyword // Legacy support for DSN in the hostname field - if ($this->dsn == '') + if ($this->dsn === '') { $this->dsn = $this->hostname; } @@ -256,7 +256,7 @@ class CI_DB_odbc_driver extends CI_DB { { $sql = "SHOW TABLES FROM `".$this->database."`"; - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE AND $this->dbprefix !== '') { //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index d59b8a911..ce7a1d2ef 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -163,14 +163,14 @@ class CI_DB_odbc_forge extends CI_DB_forge { $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 != '') + if ($default_value !== '') { $sql .= " DEFAULT \"$default_value\""; } @@ -184,7 +184,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index ec7f3e19b..dbbcda342 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -65,7 +65,7 @@ class CI_DB_pdo_driver extends CI_DB { { parent::__construct($params); - if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) == 2) + if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) === 2) { // If there is a minimum valid dsn string pattern found, we're done // This is for general PDO users, who tend to have a full DSN string. @@ -418,12 +418,12 @@ class CI_DB_pdo_driver extends CI_DB { */ protected function _list_tables($prefix_limit = FALSE) { - if ($this->pdodriver == 'pgsql') + if ($this->pdodriver === 'pgsql') { // Analog function to show all tables in postgre $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; } - elseif ($this->pdodriver == 'sqlite') + elseif ($this->pdodriver === 'sqlite') { // Analog function to show all tables in sqlite $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"; @@ -433,7 +433,7 @@ class CI_DB_pdo_driver extends CI_DB { $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database); } - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE AND $this->dbprefix !== '') { return FALSE; } @@ -468,17 +468,17 @@ class CI_DB_pdo_driver extends CI_DB { */ protected function _field_data($table) { - if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql') + if ($this->pdodriver === 'mysql' or $this->pdodriver === 'pgsql') { // Analog function for mysql and postgre return 'SELECT * FROM '.$this->escape_identifiers($table).' LIMIT 1'; } - elseif ($this->pdodriver == 'oci') + elseif ($this->pdodriver === 'oci') { // Analog function for oci return 'SELECT * FROM '.$this->escape_identifiers($table).' WHERE ROWNUM <= 1'; } - elseif ($this->pdodriver == 'sqlite') + elseif ($this->pdodriver === 'sqlite') { // Analog function for sqlite return 'PRAGMA table_info('.$this->escape_identifiers($table).')'; @@ -552,7 +552,7 @@ class CI_DB_pdo_driver extends CI_DB { protected function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); - $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; + $where = ($where !== '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; foreach ($values as $key => $val) { @@ -560,7 +560,7 @@ class CI_DB_pdo_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -620,9 +620,9 @@ class CI_DB_pdo_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') + if ($this->pdodriver === 'cubrid' OR $this->pdodriver === 'sqlite') { - $offset = ($offset == 0) ? '' : $offset.', '; + $offset = ($offset === 0) ? '' : $offset.', '; return $sql.'LIMIT '.$offset.$limit; } diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index ca8657a0f..aee8f718a 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -80,7 +80,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { if (array_key_exists('CONSTRAINT', $attributes)) { // Exception for Postgre numeric which not too happy with constraint within those type - if ( ! ($this->db->pdodriver == 'pgsql' && in_array($attributes['TYPE'], $numeric))) + if ( ! ($this->db->pdodriver === 'pgsql' && in_array($attributes['TYPE'], $numeric))) { $sql .= '('.$attributes['CONSTRAINT'].')'; } @@ -168,14 +168,14 @@ class CI_DB_pdo_forge extends CI_DB_forge { $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 != '') + if ($default_value !== '') { $sql .= " DEFAULT \"$default_value\""; } @@ -189,7 +189,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index c2a188416..8c5168400 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -356,13 +356,13 @@ class CI_DB_postgre_driver extends CI_DB { $table = (func_num_args() > 0) ? func_get_arg(0) : NULL; $column = (func_num_args() > 1) ? func_get_arg(1) : NULL; - if ($table == NULL && $v >= '8.1') + if ($table === NULL && $v >= '8.1') { $sql = 'SELECT LASTVAL() AS ins_id'; } - elseif ($table != NULL) + elseif ($table !== NULL) { - if ($column != NULL && $v >= '8.0') + if ($column !== NULL && $v >= '8.0') { $sql = 'SELECT pg_get_serial_sequence(\''.$table."', '".$column."') AS seq"; $query = $this->query($sql); @@ -401,7 +401,7 @@ class CI_DB_postgre_driver extends CI_DB { { $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -528,7 +528,7 @@ class CI_DB_postgre_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; } @@ -544,7 +544,7 @@ class CI_DB_postgre_driver extends CI_DB { } return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN('.implode(',', $ids).')'; } @@ -585,7 +585,7 @@ class CI_DB_postgre_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return $sql.' LIMIT '.$limit.($offset == 0 ? '' : ' OFFSET '.$offset); + return $sql.' LIMIT '.$limit.($offset === 0 ? '' : ' OFFSET '.$offset); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 94c97af50..af1c45f9b 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -214,7 +214,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index d8b869c2e..e50239027 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -279,7 +279,7 @@ class CI_DB_sqlite_driver extends CI_DB { { $sql = "SELECT name from sqlite_master WHERE type='table'"; - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE AND $this->dbprefix !== '') { $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -404,7 +404,7 @@ class CI_DB_sqlite_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - if ($offset == 0) + if ($offset === 0) { $offset = ''; } diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index dd6f0f78d..35be1b74b 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -194,7 +194,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $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') { // SQLite does not support dropping columns // http://www.sqlite.org/omitted.html @@ -204,7 +204,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $sql .= " $column_definition"; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT \"$default_value\""; } @@ -218,7 +218,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index ea4cf2d4f..ea7e6d43c 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -255,7 +255,7 @@ class CI_DB_sqlite3_driver extends CI_DB { protected function _list_tables($prefix_limit = FALSE) { return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\'' - .(($prefix_limit !== FALSE && $this->dbprefix != '') + .(($prefix_limit !== FALSE && $this->dbprefix !== '') ? ' AND "NAME" LIKE \''.$this->escape_like_str($this->dbprefix).'%\' '.sprintf($this->_like_escape_str, $this->_like_escape_chr) : ''); } diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index 20f1e6f63..0a5dc9211 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -184,7 +184,7 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { return 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name) .' '.$column_definition - .($default_value != '' ? ' DEFAULT '.$default_value : '') + .($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'); } diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index c817c2c5d..1529b2a21 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -155,21 +155,21 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { $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 != '') + if ($default_value !== '') { $sql .= " DEFAULT '".$default_value."'"; } $sql .= ($null === NULL) ? ' NULL' : ' NOT NULL'; - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } -- cgit v1.2.3-24-g4f1b From 773ccc318f2769c9b7579630569b5d8ba47b114b Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:11:08 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/helpers --- system/helpers/captcha_helper.php | 6 +++--- system/helpers/date_helper.php | 38 ++++++++++++++++++------------------- system/helpers/directory_helper.php | 2 +- system/helpers/download_helper.php | 2 +- system/helpers/file_helper.php | 4 ++-- system/helpers/form_helper.php | 32 +++++++++++++++---------------- system/helpers/html_helper.php | 6 +++--- system/helpers/language_helper.php | 2 +- system/helpers/smiley_helper.php | 4 ++-- system/helpers/string_helper.php | 2 +- system/helpers/text_helper.php | 10 +++++----- system/helpers/url_helper.php | 24 +++++++++++------------ system/helpers/xml_helper.php | 4 ++-- 13 files changed, 68 insertions(+), 68 deletions(-) diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index b11670658..4676b2a65 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -64,7 +64,7 @@ if ( ! function_exists('create_captcha')) } } - if ($img_path == '' OR $img_url == '' + if ($img_path === '' OR $img_url === '' OR ! @is_dir($img_path) OR ! is_writeable($img_path) OR ! extension_loaded('gd')) { @@ -93,7 +93,7 @@ if ( ! function_exists('create_captcha')) // Do we have a "word" yet? // ----------------------------------- - if ($word == '') + if ($word === '') { $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $word = ''; @@ -156,7 +156,7 @@ if ( ! function_exists('create_captcha')) // Write the text // ----------------------------------- - $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext')); + $use_font = ($font_path !== '' && file_exists($font_path) && function_exists('imagettftext')); if ($use_font === FALSE) { $font_size = 5; diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 5f0427f7d..0bda33378 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -50,7 +50,7 @@ if ( ! function_exists('now')) { $CI =& get_instance(); - if (strtolower($CI->config->item('time_reference')) == 'gmt') + if (strtolower($CI->config->item('time_reference')) === 'gmt') { $now = time(); $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); @@ -90,12 +90,12 @@ if ( ! function_exists('mdate')) */ function mdate($datestr = '', $time = '') { - if ($datestr == '') + if ($datestr === '') { return ''; } - $time = ($time == '') ? now() : $time; + $time = ($time === '') ? now() : $time; $datestr = str_replace( '%\\', @@ -280,14 +280,14 @@ if ( ! function_exists('days_in_month')) return 0; } - if ( ! is_numeric($year) OR strlen($year) != 4) + if ( ! is_numeric($year) OR strlen($year) !== 4) { $year = date('Y'); } - if ($month == 2) + if ($month === 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) + if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) { return 29; } @@ -310,7 +310,7 @@ if ( ! function_exists('local_to_gmt')) */ function local_to_gmt($time = '') { - if ($time == '') + if ($time === '') { $time = time(); } @@ -344,14 +344,14 @@ if ( ! function_exists('gmt_to_local')) */ function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) { - if ($time == '') + if ($time === '') { return now(); } $time += timezones($timezone) * 3600; - if ($dst == TRUE) + if ($dst === TRUE) { $time += 3600; } @@ -410,7 +410,7 @@ if ( ! function_exists('unix_to_human')) { $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; - if ($fmt == 'us') + if ($fmt === 'us') { $r .= date('h', $time).':'.date('i', $time); } @@ -424,7 +424,7 @@ if ( ! function_exists('unix_to_human')) $r .= ':'.date('s', $time); } - if ($fmt == 'us') + if ($fmt === 'us') { $r .= ' '.date('A', $time); } @@ -447,7 +447,7 @@ if ( ! function_exists('human_to_unix')) */ function human_to_unix($datestr = '') { - if ($datestr == '') + if ($datestr === '') { return FALSE; } @@ -491,7 +491,7 @@ if ( ! function_exists('human_to_unix')) $hour += 12; } - if (substr($ampm, 0, 1) === 'a' && $hour == 12) + if (substr($ampm, 0, 1) === 'a' && $hour === 12) { $hour = '00'; } @@ -562,7 +562,7 @@ if ( ! function_exists('nice_date')) // Any other kind of string, when converted into UNIX time, // produces "0 seconds after epoc..." is probably bad... // return "Invalid Date". - if (date('U', strtotime($bad_date)) == '0') + if (date('U', strtotime($bad_date)) === '0') { return 'Invalid Date'; } @@ -591,11 +591,11 @@ if ( ! function_exists('timezone_menu')) $CI =& get_instance(); $CI->lang->load('date'); - $default = ($default == 'GMT') ? 'UTC' : $default; + $default = ($default === 'GMT') ? 'UTC' : $default; $menu = ' EOH; - + $shirts_on_sale = array('small', 'large'); - + $this->assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale)); - + $options = array( 'Swedish Cars' => array( - 'volvo' => 'Volvo', - 'saab' => 'Saab' + 'volvo' => 'Volvo', + 'saab' => 'Saab' ), 'German Cars' => array( - 'mercedes' => 'Mercedes', - 'audi' => 'Audi' + 'mercedes' => 'Mercedes', + 'audi' => 'Audi' ) ); - + $expected = << @@ -124,13 +124,10 @@ EOH; EOH; - - $cars_on_sale = array('volvo', 'audi'); - - $this->assertEquals($expected, form_dropdown('cars', $options, $cars_on_sale)); - + + $this->assertEquals($expected, form_dropdown('cars', $options, array('volvo', 'audi'))); } - + public function test_form_multiselect() { $expected = << EOH; - + $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', - ); - + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ); + $this->assertEquals($expected, form_multiselect('shirts[]', $options, array('med', 'large'))); } - + public function test_form_fieldset() { $expected = <<Address Information EOH; - + $this->assertEquals($expected, form_fieldset('Address Information')); } @@ -169,10 +166,10 @@ EOH; $expected = <<
    EOH; - + $this->assertEquals($expected, form_fieldset_close('')); } - + public function test_form_checkbox() { $expected = <<assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); } - + public function test_form_radio() { $expected = <<assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); } - + public function test_form_submit() { $expected = <<assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); } - + public function test_form_label() { $expected = <<assertEquals($expected, form_label('What is your Name', 'username')); } - + public function test_form_reset() { $expected = <<assertEquals($expected, form_reset('myreset', 'Reset')); } - + public function test_form_button() { $expected = <<assertEquals($expected, form_button('name','content')); + $this->assertEquals($expected, form_button('name', 'content')); } - + public function test_form_close() { $expected = <<assertEquals($expected, form_close('')); } - + public function test_form_prep() { - $expected = "Here is a string containing "quoted" text."; - + $expected = 'Here is a string containing "quoted" text.'; + $this->assertEquals($expected, form_prep('Here is a string containing "quoted" text.')); } + } /* End of file form_helper_test.php */ \ No newline at end of file diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php index 28974b0f8..9a7bb48bf 100644 --- a/tests/codeigniter/helpers/html_helper_test.php +++ b/tests/codeigniter/helpers/html_helper_test.php @@ -6,16 +6,16 @@ class Html_helper_test extends CI_TestCase { { $this->helper('html'); } - + // ------------------------------------------------------------------------ - + public function test_br() { $this->assertEquals('

    ', br(2)); } - + // ------------------------------------------------------------------------ - + public function test_heading() { $this->assertEquals('

    foobar

    ', heading('foobar')); @@ -23,7 +23,7 @@ class Html_helper_test extends CI_TestCase { } // ------------------------------------------------------------------------ - + public function test_Ul() { $expect = <<assertEquals($expect, ul($list)); + $this->assertEquals(ltrim($expect), ul($list)); $expect = << @@ -51,13 +49,11 @@ EOH; $expect = ltrim($expect); - $list = array('foo', 'bar'); - $this->assertEquals($expect, ul($list, 'class="test"')); $this->assertEquals($expect, ul($list, array('class' => 'test'))); } - + // ------------------------------------------------------------------------ public function test_NBS() @@ -66,15 +62,15 @@ EOH; } // ------------------------------------------------------------------------ - + public function test_meta() { $this->assertEquals("\n", meta('test', 'foo')); - + $expect = "\n"; - + $this->assertEquals($expect, meta(array('name' => 'foo'))); - + } - + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php index 9e9478711..f3b0ebbe8 100644 --- a/tests/codeigniter/helpers/inflector_helper_test.php +++ b/tests/codeigniter/helpers/inflector_helper_test.php @@ -1,12 +1,12 @@ helper('inflector'); } - + public function test_singular() { $strs = array( @@ -16,15 +16,15 @@ class Inflector_helper_test extends CI_TestCase { 'smells' => 'smell', 'equipment' => 'equipment' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, singular($str)); } } - + // -------------------------------------------------------------------- - + public function test_plural() { $strs = array( @@ -35,15 +35,15 @@ class Inflector_helper_test extends CI_TestCase { 'witch' => 'witches', 'equipment' => 'equipment' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, plural($str)); - } - } + } + } // -------------------------------------------------------------------- - + public function test_camelize() { $strs = array( @@ -52,15 +52,15 @@ class Inflector_helper_test extends CI_TestCase { 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'whatDoYouThink-yo?', ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, camelize($str)); } - } + } // -------------------------------------------------------------------- - + public function test_underscore() { $strs = array( @@ -69,7 +69,7 @@ class Inflector_helper_test extends CI_TestCase { 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'what_do_you_think-yo?', ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, underscore($str)); @@ -77,7 +77,7 @@ class Inflector_helper_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_humanize() { $strs = array( @@ -86,10 +86,11 @@ class Inflector_helper_test extends CI_TestCase { 'i-am-playing-a-trick' => 'I-am-playing-a-trick', 'what_do_you_think-yo?' => 'What Do You Think-yo?', ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, humanize($str)); } } + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php index 4bb9a918a..23d5c5c1a 100644 --- a/tests/codeigniter/helpers/number_helper_test.php +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -1,35 +1,35 @@ helper('number'); - + // Grab the core lang class $lang_cls = $this->ci_core_class('lang'); - + // Mock away load, too much going on in there, // we'll just check for the expected parameter - + $lang = $this->getMock($lang_cls, array('load')); $lang->expects($this->once()) ->method('load') ->with($this->equalTo('number')); - + // Assign the proper language array - + $lang->language = $this->_get_lang('number'); - + // We don't have a controller, so just create // a cheap class to act as our super object. // Make sure it has a lang attribute. - + $obj = new StdClass; $obj->lang = $lang; $this->ci_instance($obj); } - + // Quick helper to actually grab the language // file. Consider moving this to ci_testcase? public function _get_lang($name) @@ -37,41 +37,40 @@ class Number_helper_test extends CI_TestCase { require BASEPATH.'language/english/'.$name.'_lang.php'; return $lang; } - + public function test_byte_format() { $this->assertEquals('456 Bytes', byte_format(456)); } - + public function test_kb_format() { $this->assertEquals('4.5 KB', byte_format(4567)); } - + public function test_kb_format_medium() { $this->assertEquals('44.6 KB', byte_format(45678)); } - + public function test_kb_format_large() { $this->assertEquals('446.1 KB', byte_format(456789)); } - + public function test_mb_format() { $this->assertEquals('3.3 MB', byte_format(3456789)); } - + public function test_gb_format() { $this->assertEquals('1.8 GB', byte_format(1932735283.2)); } - + public function test_tb_format() { $this->assertEquals('112,283.3 TB', byte_format(123456789123456789)); } -} -// EOF \ No newline at end of file +} \ No newline at end of file diff --git a/tests/codeigniter/helpers/path_helper_test.php b/tests/codeigniter/helpers/path_helper_test.php index 632f57501..0faf6f383 100644 --- a/tests/codeigniter/helpers/path_helper_test.php +++ b/tests/codeigniter/helpers/path_helper_test.php @@ -8,9 +8,8 @@ class Path_helper_test extends CI_TestCase { } public function test_set_realpath() - { - $expected = getcwd() . DIRECTORY_SEPARATOR; - $this->assertEquals($expected, set_realpath(getcwd())); + { + $this->assertEquals(getcwd().DIRECTORY_SEPARATOR, set_realpath(getcwd())); } public function test_set_realpath_nonexistent_directory() diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php index 29c3d6594..75701ec13 100644 --- a/tests/codeigniter/helpers/string_helper_test.php +++ b/tests/codeigniter/helpers/string_helper_test.php @@ -10,18 +10,18 @@ class String_helper_test extends CI_TestCase { public function test_strip_slashes() { $expected = array( - "Is your name O'reilly?", + "Is your name O'reilly?", "No, my name is O'connor." ); - + $str = array( "Is your name O\'reilly?", "No, my name is O\'connor." ); - + $this->assertEquals($expected, strip_slashes($str)); } - + public function test_trim_slashes() { $strs = array( @@ -144,4 +144,5 @@ class String_helper_test extends CI_TestCase { $this->assertEquals('file-1', increment_string('file', '-', '1')); $this->assertEquals(124, increment_string('123', '')); } + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 73e2b9429..f131469cb 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -3,16 +3,16 @@ class Text_helper_test extends CI_TestCase { private $_long_string; - + public function set_up() { $this->helper('text'); - + $this->_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.'; } - + // ------------------------------------------------------------------------ - + public function test_word_limiter() { $this->assertEquals('Once upon a time,…', word_limiter($this->_long_string, 4)); @@ -20,8 +20,8 @@ class Text_helper_test extends CI_TestCase { $this->assertEquals('', word_limiter('', 4)); } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + public function test_character_limiter() { $this->assertEquals('Once upon a time, a…', character_limiter($this->_long_string, 20)); @@ -30,22 +30,22 @@ class Text_helper_test extends CI_TestCase { $this->assertEquals('Short', character_limiter('Short', 5)); } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + public function test_ascii_to_entities() { $strs = array( '“‘ “test”' => '“‘ “test”', '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, ascii_to_entities($str)); } } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_entities_to_ascii() { @@ -53,27 +53,27 @@ class Text_helper_test extends CI_TestCase { '“‘ “test”' => '“‘ “test”', '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, entities_to_ascii($str)); - } + } } - - // ------------------------------------------------------------------------ - - function test_convert_accented_characters() + + // ------------------------------------------------------------------------ + + public function test_convert_accented_characters() { $this->assertEquals('AAAeEEEIIOOEUUUeY', convert_accented_characters('ÀÂÄÈÊËÎÏÔŒÙÛÜŸ')); $this->assertEquals('a e i o u n ue', convert_accented_characters('á é í ó ú ñ ü')); } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + public function test_censored_words() { $censored = array('boob', 'nerd', 'ass', 'fart'); - + $strs = array( 'Ted bobbled the ball' => 'Ted bobbled the ball', 'Jake is a nerdo' => 'Jake is a nerdo', @@ -81,28 +81,26 @@ class Text_helper_test extends CI_TestCase { 'Did Mary Fart?' => 'Did Mary $*#?', 'Jake is really a boob' => 'Jake is really a $*#' ); - - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, word_censor($str, $censored, '$*#')); } - + // test censored words being sent as a string $this->assertEquals('test', word_censor('test', 'test')); } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_highlight_code() { - $code = ''; $expect = "\n<?php var_dump(\$this); ?> \n\n"; - $this->assertEquals($expect, highlight_code($code)); + $this->assertEquals($expect, highlight_code('')); } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_highlight_phrase() { @@ -113,14 +111,14 @@ class Text_helper_test extends CI_TestCase { 'Or tell me what this is' => 'Or tell me what this is', '' => '' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, highlight_phrase($str, 'this is')); } } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_ellipsize() { @@ -144,32 +142,30 @@ class Text_helper_test extends CI_TestCase { 'short' => 'short' ), ); - + foreach ($strs as $pos => $s) { foreach ($s as $str => $expect) { - $this->assertEquals($expect, ellipsize($str, 10, $pos)); + $this->assertEquals($expect, ellipsize($str, 10, $pos)); } } } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_word_wrap() { - $string = "Here is a simple string of text that will help us demonstrate this function."; - $word_wrapped = word_wrap($string, 25); - $this->assertEquals(substr_count($word_wrapped, "\n"), 4); + $string = 'Here is a simple string of text that will help us demonstrate this function.'; + $this->assertEquals(substr_count(word_wrap($string, 25), "\n"), 4); } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_default_word_wrap_charlim() { $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function."; - $word_wrapped = word_wrap($string); - $this->assertEquals(strpos($word_wrapped, "\n"), 73); + $this->assertEquals(strpos(word_wrap($string), "\n"), 73); } } \ No newline at end of file diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index c561809ce..c81c5f1b8 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -72,4 +72,5 @@ class Url_helper_test extends CI_TestCase { $this->assertEquals($out, auto_link($in, 'url')); } } + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/xml_helper_test.php b/tests/codeigniter/helpers/xml_helper_test.php index a83fef91e..e8cf411da 100644 --- a/tests/codeigniter/helpers/xml_helper_test.php +++ b/tests/codeigniter/helpers/xml_helper_test.php @@ -6,10 +6,10 @@ class Xml_helper_test extends CI_TestCase { { $this->helper('xml'); } - + public function test_xml_convert() { $this->assertEquals('<tag>my & test - </tag>', xml_convert('my & test - ')); } - + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From c186288755aba46a2b6f0c3f104d9a6ce6b11a7f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 23:16:58 +0300 Subject: Cleanup/optimize tests/codeigniter/ --- tests/codeigniter/Setup_test.php | 6 +- tests/codeigniter/core/Benchmark_test.php | 11 +- tests/codeigniter/core/Common_test.php | 6 +- tests/codeigniter/core/Config_test.php | 38 ++-- tests/codeigniter/core/Input_test.php | 28 +-- tests/codeigniter/core/Lang_test.php | 12 +- tests/codeigniter/core/Loader_test.php | 132 ++++++------ tests/codeigniter/core/Security_test.php | 23 ++- tests/codeigniter/core/URI_test.php | 225 +++++++++------------ .../database/query_builder/count_test.php | 12 +- .../database/query_builder/delete_test.php | 16 +- .../database/query_builder/distinct_test.php | 9 +- .../database/query_builder/escape_test.php | 5 +- .../database/query_builder/from_test.php | 18 +- .../database/query_builder/get_test.php | 6 +- .../database/query_builder/group_test.php | 26 ++- .../database/query_builder/join_test.php | 2 +- .../database/query_builder/like_test.php | 2 +- .../database/query_builder/limit_test.php | 7 +- .../database/query_builder/order_test.php | 6 +- .../database/query_builder/select_test.php | 12 +- .../database/query_builder/truncate_test.php | 7 +- .../database/query_builder/update_test.php | 26 +-- .../database/query_builder/where_test.php | 28 +-- tests/codeigniter/helpers/number_helper_test.php | 2 +- tests/codeigniter/libraries/Encrypt_test.php | 131 ++++++------ tests/codeigniter/libraries/Parser_test.php | 61 +++--- tests/codeigniter/libraries/Table_test.php | 153 ++++++-------- tests/codeigniter/libraries/Typography_test.php | 40 ++-- tests/codeigniter/libraries/Useragent_test.php | 6 +- 30 files changed, 463 insertions(+), 593 deletions(-) diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php index b48e32bfb..5317c56c7 100644 --- a/tests/codeigniter/Setup_test.php +++ b/tests/codeigniter/Setup_test.php @@ -1,13 +1,13 @@ 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/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php index 109b38821..a239ba51d 100644 --- a/tests/codeigniter/core/Benchmark_test.php +++ b/tests/codeigniter/core/Benchmark_test.php @@ -1,14 +1,14 @@ benchmark = new Mock_Core_Benchmark(); } - + // -------------------------------------------------------------------- - + public function test_mark() { $this->assertEmpty($this->benchmark->marker); @@ -18,7 +18,7 @@ class Benchmark_test extends CI_TestCase { $this->assertEquals(1, count($this->benchmark->marker)); $this->assertArrayHasKey('code_start', $this->benchmark->marker); } - + // -------------------------------------------------------------------- public function test_elapsed_time() @@ -29,7 +29,7 @@ class Benchmark_test extends CI_TestCase { $this->benchmark->mark('code_start'); sleep(1); $this->benchmark->mark('code_end'); - + $this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1)); } @@ -39,4 +39,5 @@ class Benchmark_test extends CI_TestCase { { $this->assertEquals('{memory_usage}', $this->benchmark->memory_usage()); } + } \ No newline at end of file diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php index dded2e824..f9bf6c27f 100644 --- a/tests/codeigniter/core/Common_test.php +++ b/tests/codeigniter/core/Common_test.php @@ -1,13 +1,13 @@ assertEquals(TRUE, is_php('1.2.0')); $this->assertEquals(FALSE, is_php('9999.9.9')); } - + } \ No newline at end of file diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index 30f0cc61d..30cb90a28 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -5,7 +5,7 @@ class Config_test extends CI_TestCase { public function set_up() { $cls =& $this->ci_core_class('cfg'); - + // set predictable config values $this->ci_set_config(array( 'index_page' => 'index.php', @@ -13,9 +13,9 @@ class Config_test extends CI_TestCase { 'subclass_prefix' => 'MY_' )); - $this->config = new $cls; + $this->config = new $cls; } - + // -------------------------------------------------------------------- public function test_item() @@ -24,30 +24,30 @@ class Config_test extends CI_TestCase { // Bad Config value $this->assertFalse($this->config->item('no_good_item')); - + // Index $this->assertFalse($this->config->item('no_good_item', 'bad_index')); $this->assertFalse($this->config->item('no_good_item', 'default')); } - + // -------------------------------------------------------------------- - + public function test_set_item() { $this->assertFalse($this->config->item('not_yet_set')); - + $this->config->set_item('not_yet_set', 'is set'); - + $this->assertEquals('is set', $this->config->item('not_yet_set')); } // -------------------------------------------------------------------- - + public function test_slash_item() { // Bad Config value $this->assertFalse($this->config->slash_item('no_good_item')); - + $this->assertEquals('http://example.com/', $this->config->slash_item('base_url')); $this->assertEquals('MY_/', $this->config->slash_item('subclass_prefix')); @@ -58,33 +58,33 @@ class Config_test extends CI_TestCase { public function test_site_url() { $this->assertEquals('http://example.com/index.php', $this->config->site_url()); - + $base_url = $this->config->item('base_url'); - + $this->config->set_item('base_url', ''); - + $q_string = $this->config->item('enable_query_strings'); - + $this->config->set_item('enable_query_strings', FALSE); $this->assertEquals('index.php/test', $this->config->site_url('test')); $this->assertEquals('index.php/test/1', $this->config->site_url(array('test', '1'))); - + $this->config->set_item('enable_query_strings', TRUE); $this->assertEquals('index.php?test', $this->config->site_url('test')); $this->assertEquals('index.php?0=test&1=1', $this->config->site_url(array('test', '1'))); - + $this->config->set_item('base_url', $base_url); $this->assertEquals('http://example.com/index.php?test', $this->config->site_url('test')); - + // back to home base - $this->config->set_item('enable_query_strings', $q_string); + $this->config->set_item('enable_query_strings', $q_string); } // -------------------------------------------------------------------- - + public function test_system_url() { $this->assertEquals('http://example.com/system/', $this->config->system_url()); diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index c9322c027..fe8738832 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -1,7 +1,7 @@ input = new Mock_Core_Input($security, $utf8); } - + // -------------------------------------------------------------------- - + public function test_get_not_exists() { $this->assertEmpty($this->input->get()); @@ -38,7 +38,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_get_exist() { $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -49,7 +49,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_get_exist_with_xss_clean() { $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -61,7 +61,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_post_not_exists() { $this->assertEmpty($this->input->post()); @@ -78,7 +78,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_post_exist() { $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -89,7 +89,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_post_exist_with_xss_clean() { $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -101,7 +101,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_get_post() { $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -111,7 +111,7 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_cookie() { $_COOKIE['foo'] = 'bar'; @@ -120,14 +120,14 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_server() { $this->assertEquals('GET', $this->input->server('REQUEST_METHOD')); } // -------------------------------------------------------------------- - + public function test_fetch_from_array() { $data = array( @@ -145,14 +145,14 @@ class Input_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_valid_ip() { $ip_v4 = '192.18.0.1'; $this->assertTrue($this->input->valid_ip($ip_v4)); $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001'); - foreach($ip_v6 as $ip) + foreach ($ip_v6 as $ip) { $this->assertTrue($this->input->valid_ip($ip)); } diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 874230feb..a410dabfa 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -1,9 +1,9 @@ ci_core_class('load'); @@ -12,9 +12,9 @@ class Lang_test extends CI_TestCase { $cls = $this->ci_core_class('lang'); $this->lang = new $cls; } - + // -------------------------------------------------------------------- - + public function test_load() { $this->assertTrue($this->lang->load('profiler', 'english')); @@ -22,11 +22,11 @@ class Lang_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_load_with_unspecified_language() { $this->assertTrue($this->lang->load('profiler')); $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string')); } - + } \ No newline at end of file diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 43008651e..fdea962b7 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -1,35 +1,35 @@ load = new Mock_Core_Loader(); - + // mock up a ci instance - $this->ci_obj = new StdClass; - + $this->ci_obj = new stdClass; + // Fix get_instance() $this->ci_instance($this->ci_obj); } // -------------------------------------------------------------------- - + public function test_library() { $this->_setup_config_mock(); - + // Test loading as an array. $this->assertNull($this->load->library(array('table'))); $this->assertTrue(class_exists('CI_Table'), 'Table class exists'); $this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj); - + // Test no lib given $this->assertEquals(FALSE, $this->load->library()); - + // Test a string given to params $this->assertEquals(NULL, $this->load->library('table', ' ')); } @@ -39,20 +39,18 @@ class Loader_test extends CI_TestCase { public function test_load_library_in_application_dir() { $this->_setup_config_mock(); - + $content = 'withContent($content) - ->at($this->load->libs_dir); - + + $model = vfsStream::newFile('Super_test_library.php')->withContent($content)->at($this->load->libs_dir); $this->assertNull($this->load->library('super_test_library')); - + // Was the model class instantiated. - $this->assertTrue(class_exists('Super_test_library')); + $this->assertTrue(class_exists('Super_test_library')); } - + // -------------------------------------------------------------------- - + private function _setup_config_mock() { // Mock up a config object until we @@ -61,7 +59,7 @@ class Loader_test extends CI_TestCase { $config->expects($this->any()) ->method('load') ->will($this->returnValue(TRUE)); - + // Add the mock to our stdClass $this->ci_instance_var('config', $config); } @@ -73,64 +71,62 @@ class Loader_test extends CI_TestCase { $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php' - ); - + ); + $this->load->model('ci_test_nonexistent_model.php'); } // -------------------------------------------------------------------- - + /** * @coverts CI_Loader::model */ public function test_models() { $this->ci_set_core_class('model', 'CI_Model'); - + $content = 'withContent($content) - ->at($this->load->models_dir); - + + $model = vfsStream::newFile('unit_test_model.php')->withContent($content)->at($this->load->models_dir); + $this->assertNull($this->load->model('unit_test_model')); - + // Was the model class instantiated. $this->assertTrue(class_exists('Unit_test_model')); - + // Test no model given - $this->assertNull($this->load->model('')); + $this->assertNull($this->load->model('')); } // -------------------------------------------------------------------- - + // public function testDatabase() // { // $this->assertEquals(NULL, $this->load->database()); - // $this->assertEquals(NULL, $this->load->dbutil()); + // $this->assertEquals(NULL, $this->load->dbutil()); // } // -------------------------------------------------------------------- - + /** * @coverts CI_Loader::view */ public function test_load_view() { $this->ci_set_core_class('output', 'CI_Output'); - + $content = 'This is my test page. '; - $view = vfsStream::newFile('unit_test_view.php')->withContent($content) - ->at($this->load->views_dir); - + $view = vfsStream::newFile('unit_test_view.php')->withContent($content)->at($this->load->views_dir); + // Use the optional return parameter in this test, so the view is not // run through the output class. $this->assertEquals('This is my test page. World!', $this->load->view('unit_test_view', array('hello' => "World!"), TRUE)); - + } // -------------------------------------------------------------------- - + /** * @coverts CI_Loader::view */ @@ -139,8 +135,8 @@ class Loader_test extends CI_TestCase { $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php' - ); - + ); + $this->load->view('ci_test_nonexistent_view', array('foo' => 'bar')); } @@ -149,87 +145,77 @@ class Loader_test extends CI_TestCase { public function test_file() { $content = 'Here is a test file, which we will load now.'; - $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content) - ->at($this->load->views_dir); - + $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content)->at($this->load->views_dir); + // Just like load->view(), take the output class out of the mix here. - $load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php', - TRUE); - + $load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php', TRUE); + $this->assertEquals($content, $load); - + $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to load the requested file: ci_test_file_not_exists' - ); - + ); + $this->load->file('ci_test_file_not_exists', TRUE); - } // -------------------------------------------------------------------- - + public function test_vars() { - $vars = array( - 'foo' => 'bar' - ); - - $this->assertNull($this->load->vars($vars)); + $this->assertNull($this->load->vars(array('foo' => 'bar'))); $this->assertNull($this->load->vars('foo', 'bar')); } // -------------------------------------------------------------------- - + public function test_helper() { $this->assertEquals(NULL, $this->load->helper('array')); - + $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to load the requested file: helpers/bad_helper.php' - ); - + ); + $this->load->helper('bad'); } - + // -------------------------------------------------------------------- public function test_loading_multiple_helpers() { $this->assertEquals(NULL, $this->load->helpers(array('file', 'array', 'string'))); } - + // -------------------------------------------------------------------- - + // public function testLanguage() // { // $this->assertEquals(NULL, $this->load->language('test')); - // } + // } // -------------------------------------------------------------------- public function test_load_config() { $this->_setup_config_mock(); - $this->assertNull($this->load->config('config', FALSE)); } - + // -------------------------------------------------------------------- public function test_load_bad_config() { $this->_setup_config_mock(); - + $this->setExpectedException( 'RuntimeException', 'CI Error: The configuration file foobar.php does not exist.' - ); - + ); + $this->load->config('foobar', FALSE); } - // -------------------------------------------------------------------- - -} +} \ No newline at end of file diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index b2f8c69d2..3f6e3b07a 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -1,7 +1,7 @@ security = new Mock_Core_Security(); } - + // -------------------------------------------------------------------- - + public function test_csrf_verify() { $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -25,7 +25,7 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_csrf_verify_invalid() { // Without issuing $_POST[csrf_token_name], this request will triggering CSRF error @@ -37,7 +37,7 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_csrf_verify_valid() { $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -47,21 +47,21 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + 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"; @@ -72,7 +72,7 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_xss_hash() { $this->assertEmpty($this->security->xss_hash); @@ -84,7 +84,7 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_entity_decode() { $encoded = '<div>Hello <b>Booya</b></div>'; @@ -94,7 +94,7 @@ class Security_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_sanitize_filename() { $filename = './'; @@ -102,4 +102,5 @@ class Security_test extends CI_TestCase { $this->assertEquals('foo', $safe_filename); } + } \ No newline at end of file diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index e340ddf73..0ba694b46 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -1,7 +1,7 @@ uri = new Mock_Core_URI(); @@ -13,19 +13,12 @@ class URI_test extends CI_TestCase { { // Slashes get killed $this->uri->_set_uri_string('/'); - - $a = ''; - $b =& $this->uri->uri_string; - - $this->assertEquals($a, $b); - + $this->assertEquals('', $this->uri->uri_string); + $this->uri->_set_uri_string('nice/uri'); - - $a = 'nice/uri'; - - $this->assertEquals($a, $b); + $this->assertEquals('nice/uri', $this->uri->uri_string); } - + // -------------------------------------------------------------------- public function test_fetch_uri_string() @@ -34,75 +27,61 @@ class URI_test extends CI_TestCase { // uri_protocol: AUTO $this->uri->config->set_item('uri_protocol', 'AUTO'); - + // Test a variety of request uris $requests = array( '/index.php/controller/method' => 'controller/method', '/index.php?/controller/method' => 'controller/method', '/index.php?/controller/method/?var=foo' => 'controller/method' ); - + foreach($requests as $request => $expected) { $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['REQUEST_URI'] = $request; - + $this->uri->_fetch_uri_string(); $this->assertEquals($expected, $this->uri->uri_string ); } - + // Test a subfolder $_SERVER['SCRIPT_NAME'] = '/subfolder/index.php'; $_SERVER['REQUEST_URI'] = '/subfolder/index.php/controller/method'; - + $this->uri->_fetch_uri_string(); - - $a = 'controller/method'; - $b = $this->uri->uri_string; - - $this->assertEquals($a, $b); - + $this->assertEquals('controller/method', $this->uri->uri_string); + // death to request uri unset($_SERVER['REQUEST_URI']); - + // life to path info - $_SERVER['PATH_INFO'] = '/controller/method/'; - + $_SERVER['PATH_INFO'] = $a = '/controller/method/'; + $this->uri->_fetch_uri_string(); - - $a = '/controller/method/'; - $b =& $this->uri->uri_string; + $this->assertEquals($a, $this->uri->uri_string); - $this->assertEquals($a, $b); - // death to path info // At this point your server must be seriously drunk unset($_SERVER['PATH_INFO']); - + $_SERVER['QUERY_STRING'] = '/controller/method/'; - + $this->uri->_fetch_uri_string(); + $this->assertEquals($a, $this->uri->uri_string); - $a = '/controller/method/'; - $b = $this->uri->uri_string; - - $this->assertEquals($a, $b); - // At this point your server is a labotomy victim - unset($_SERVER['QUERY_STRING']); - + $_GET['/controller/method/'] = ''; - + $this->uri->_fetch_uri_string(); - $this->assertEquals($a, $b); + $this->assertEquals($a, $this->uri->uri_string); // Test coverage implies that these will work // uri_protocol: REQUEST_URI // uri_protocol: CLI - } - + // -------------------------------------------------------------------- public function test_explode_segments() @@ -113,18 +92,15 @@ class URI_test extends CI_TestCase { '/test2/uri2' => array('test2', 'uri2'), '//test3/test3///' => array('test3', 'test3') ); - - foreach($uris as $uri => $a) + + foreach ($uris as $uri => $a) { $this->uri->segments = array(); $this->uri->uri_string = $uri; $this->uri->_explode_segments(); - - $b = $this->uri->segments; - - $this->assertEquals($a, $b); + + $this->assertEquals($a, $this->uri->segments); } - } // -------------------------------------------------------------------- @@ -133,7 +109,7 @@ class URI_test extends CI_TestCase { { $this->uri->config->set_item('enable_query_strings', FALSE); $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-'); - + $str_in = 'abc01239~%.:_-'; $str = $this->uri->_filter_uri($str_in); @@ -145,52 +121,52 @@ class URI_test extends CI_TestCase { public function test_filter_uri_escaping() { // ensure escaping even if dodgey characters are permitted - + $this->uri->config->set_item('enable_query_strings', FALSE); $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-()$'); $str = $this->uri->_filter_uri('$destroy_app(foo)'); - + $this->assertEquals($str, '$destroy_app(foo)'); } // -------------------------------------------------------------------- - public function test_filter_uri_throws_error() - { + public function test_filter_uri_throws_error() + { $this->setExpectedException('RuntimeException'); - + $this->uri->config->set_item('enable_query_strings', FALSE); $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-'); $this->uri->_filter_uri('$this()'); - } + } // -------------------------------------------------------------------- public function test_remove_url_suffix() { $this->uri->config->set_item('url_suffix', '.html'); - + $this->uri->uri_string = 'controller/method/index.html'; $this->uri->_remove_url_suffix(); - + $this->assertEquals($this->uri->uri_string, 'controller/method/index'); - + $this->uri->uri_string = 'controller/method/index.htmlify.html'; $this->uri->_remove_url_suffix(); - + $this->assertEquals($this->uri->uri_string, 'controller/method/index.htmlify'); } // -------------------------------------------------------------------- - + public function test_segment() { $this->uri->segments = array(1 => 'controller'); $this->assertEquals($this->uri->segment(1), 'controller'); $this->assertEquals($this->uri->segment(2, 'default'), 'default'); } - + // -------------------------------------------------------------------- public function test_rsegment() @@ -205,32 +181,33 @@ class URI_test extends CI_TestCase { public function test_uri_to_assoc() { $this->uri->segments = array('a', '1', 'b', '2', 'c', '3'); - - $a = array('a' => '1', 'b' => '2', 'c' => '3'); - $b = $this->uri->uri_to_assoc(1); - $this->assertEquals($a, $b); - - $a = array('b' => '2', 'c' => '3'); - $b = $this->uri->uri_to_assoc(3); - $this->assertEquals($a, $b); - - + + $this->assertEquals( + array('a' => '1', 'b' => '2', 'c' => '3'), + $this->uri->uri_to_assoc(1) + ); + + $this->assertEquals( + array('b' => '2', 'c' => '3'), + $this->uri->uri_to_assoc(3) + ); + $this->uri->keyval = array(); // reset cache - $this->uri->segments = array('a', '1', 'b', '2', 'c'); - - $a = array('a' => '1', 'b' => '2', 'c' => FALSE); - $b = $this->uri->uri_to_assoc(1); - $this->assertEquals($a, $b); - + + $this->assertEquals( + array('a' => '1', 'b' => '2', 'c' => FALSE), + $this->uri->uri_to_assoc(1) + ); + $this->uri->keyval = array(); // reset cache - $this->uri->segments = array('a', '1'); - + // test default - $a = array('a' => '1', 'b' => FALSE); - $b = $this->uri->uri_to_assoc(1, array('a', 'b')); - $this->assertEquals($a, $b); + $this->assertEquals( + array('a' => '1', 'b' => FALSE), + $this->uri->uri_to_assoc(1, array('a', 'b')) + ); } // -------------------------------------------------------------------- @@ -238,33 +215,33 @@ class URI_test extends CI_TestCase { public function test_ruri_to_assoc() { $this->uri->rsegments = array('x', '1', 'y', '2', 'z', '3'); - - $a = array('x' => '1', 'y' => '2', 'z' => '3'); - $b = $this->uri->ruri_to_assoc(1); - $this->assertEquals($a, $b); - - $a = array('y' => '2', 'z' => '3'); - $b = $this->uri->ruri_to_assoc(3); - $this->assertEquals($a, $b); - - + + $this->assertEquals( + array('x' => '1', 'y' => '2', 'z' => '3'), + $this->uri->ruri_to_assoc(1) + ); + + $this->assertEquals( + array('y' => '2', 'z' => '3'), + $this->uri->ruri_to_assoc(3) + ); + $this->uri->keyval = array(); // reset cache - $this->uri->rsegments = array('x', '1', 'y', '2', 'z'); - - $a = array('x' => '1', 'y' => '2', 'z' => FALSE); - $b = $this->uri->ruri_to_assoc(1); - $this->assertEquals($a, $b); - + + $this->assertEquals( + array('x' => '1', 'y' => '2', 'z' => FALSE), + $this->uri->ruri_to_assoc(1) + ); + $this->uri->keyval = array(); // reset cache - $this->uri->rsegments = array('x', '1'); - - // test default - $a = array('x' => '1', 'y' => FALSE); - $b = $this->uri->ruri_to_assoc(1, array('x', 'y')); - $this->assertEquals($a, $b); + // test default + $this->assertEquals( + array('x' => '1', 'y' => FALSE), + $this->uri->ruri_to_assoc(1, array('x', 'y')) + ); } // -------------------------------------------------------------------- @@ -272,11 +249,7 @@ class URI_test extends CI_TestCase { public function test_assoc_to_uri() { $this->uri->config->set_item('uri_string_slashes', 'none'); - - $arr = array('a' => 1, 'b' => 2); - $a = 'a/1/b/2'; - $b = $this->uri->assoc_to_uri($arr); - $this->assertEquals($a, $b); + $this->assertEquals('a/1/b/2', $this->uri->assoc_to_uri(array('a' => '1', 'b' => '2'))); } // -------------------------------------------------------------------- @@ -286,28 +259,18 @@ class URI_test extends CI_TestCase { $this->uri->segments[1] = 'segment'; $this->uri->rsegments[1] = 'segment'; - $a = '/segment/'; - $b = $this->uri->slash_segment(1, 'both'); - $this->assertEquals($a, $b); - $b = $this->uri->slash_rsegment(1, 'both'); - $this->assertEquals($a, $b); - + $this->assertEquals('/segment/', $this->uri->slash_segment(1, 'both')); + $this->assertEquals('/segment/', $this->uri->slash_rsegment(1, 'both')); + $a = '/segment'; - $b = $this->uri->slash_segment(1, 'leading'); - $this->assertEquals($a, $b); - $b = $this->uri->slash_rsegment(1, 'leading'); - $this->assertEquals($a, $b); - - $a = 'segment/'; - $b = $this->uri->slash_segment(1, 'trailing'); - $this->assertEquals($a, $b); - $b = $this->uri->slash_rsegment(1, 'trailing'); - $this->assertEquals($a, $b); - } + $this->assertEquals('/segment', $this->uri->slash_segment(1, 'leading')); + $this->assertEquals('/segment', $this->uri->slash_rsegment(1, 'leading')); + $this->assertEquals('segment/', $this->uri->slash_segment(1, 'trailing')); + $this->assertEquals('segment/', $this->uri->slash_rsegment(1, 'trailing')); + } } -// END URI_test Class /* End of file URI_test.php */ -/* Location: ./tests/core/URI_test.php */ +/* Location: ./tests/core/URI_test.php */ \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php index 5e691692d..90ac5283e 100644 --- a/tests/codeigniter/database/query_builder/count_test.php +++ b/tests/codeigniter/database/query_builder/count_test.php @@ -22,10 +22,7 @@ class Count_test extends CI_TestCase { */ public function test_count_all() { - $job_count = $this->db->count_all('job'); - - // Check the result - $this->assertEquals(4, $job_count); + $this->assertEquals(4, $this->db->count_all('job')); } // ------------------------------------------------------------------------ @@ -35,10 +32,7 @@ class Count_test extends CI_TestCase { */ 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); + $this->assertEquals(2, $this->db->like('name', 'ian')->count_all_results('job')); } + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php index 84ea7616f..ab9d97f56 100644 --- a/tests/codeigniter/database/query_builder/delete_test.php +++ b/tests/codeigniter/database/query_builder/delete_test.php @@ -23,9 +23,7 @@ class Delete_test extends CI_TestCase { public function test_delete() { // Check initial record - $job1 = $this->db->where('id', 1) - ->get('job') - ->row(); + $job1 = $this->db->where('id', 1)->get('job')->row(); $this->assertEquals('Developer', $job1->name); @@ -33,8 +31,7 @@ class Delete_test extends CI_TestCase { $this->db->delete('job', array('id' => 1)); // Check the record - $job1 = $this->db->where('id', 1) - ->get('job'); + $job1 = $this->db->where('id', 1)->get('job'); $this->assertEmpty($job1->result_array()); } @@ -47,13 +44,8 @@ class Delete_test extends CI_TestCase { 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(); + $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); diff --git a/tests/codeigniter/database/query_builder/distinct_test.php b/tests/codeigniter/database/query_builder/distinct_test.php index 925eadb19..cc98009ce 100644 --- a/tests/codeigniter/database/query_builder/distinct_test.php +++ b/tests/codeigniter/database/query_builder/distinct_test.php @@ -23,11 +23,10 @@ class Distinct_test extends CI_TestCase { public function test_distinct() { $users = $this->db->select('country') - ->distinct() - ->get('user') - ->result_array(); - - // Check the result + ->distinct() + ->get('user') + ->result_array(); + $this->assertEquals(3, count($users)); } diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php index 5d575a37b..c6380ddf1 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -35,7 +35,7 @@ class Escape_test extends CI_TestCase { } $res = $this->db->query($sql)->result_array(); - + // Check the result $this->assertEquals(1, count($res)); } @@ -60,8 +60,9 @@ class Escape_test extends CI_TestCase { } $res = $this->db->query($sql)->result_array(); - + // Check the result $this->assertEquals(2, count($res)); } + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/from_test.php b/tests/codeigniter/database/query_builder/from_test.php index 95ae4dfdb..7aaae348d 100644 --- a/tests/codeigniter/database/query_builder/from_test.php +++ b/tests/codeigniter/database/query_builder/from_test.php @@ -23,10 +23,9 @@ class From_test extends CI_TestCase { public function test_from_simple() { $jobs = $this->db->from('job') - ->get() - ->result_array(); - - // Check items + ->get() + ->result_array(); + $this->assertEquals(4, count($jobs)); } @@ -38,14 +37,13 @@ class From_test extends CI_TestCase { public function test_from_with_where() { $job1 = $this->db->from('job') - ->where('id', 1) - ->get() - ->row(); - - // Check the result + ->where('id', 1) + ->get() + ->row(); + $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 diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php index 0751c9332..699d2906a 100644 --- a/tests/codeigniter/database/query_builder/get_test.php +++ b/tests/codeigniter/database/query_builder/get_test.php @@ -23,7 +23,7 @@ class Get_test extends CI_TestCase { public function test_get_simple() { $jobs = $this->db->get('job')->result_array(); - + // Dummy jobs contain 4 rows $this->assertCount(4, $jobs); @@ -42,12 +42,12 @@ class Get_test extends CI_TestCase { public function test_get_where() { $job1 = $this->db->get('job', array('id' => 1))->result_array(); - + // Dummy jobs contain 1 rows $this->assertCount(1, $job1); // Check rows item $this->assertEquals('Developer', $job1[0]['name']); } - + } \ 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 index 7d8abc33f..5249f7c87 100644 --- a/tests/codeigniter/database/query_builder/group_test.php +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -23,12 +23,11 @@ class Group_test extends CI_TestCase { public function test_group_by() { $jobs = $this->db->select('name') - ->from('job') - ->group_by('name') - ->get() - ->result_array(); - - // Check the result + ->from('job') + ->group_by('name') + ->get() + ->result_array(); + $this->assertEquals(4, count($jobs)); } @@ -40,14 +39,13 @@ class Group_test extends CI_TestCase { 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 + ->from('job') + ->group_by('name') + ->having('SUM(id) > 2') + ->get() + ->result_array(); + $this->assertEquals(2, count($jobs)); } - + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php index e05329d67..b8cf2a822 100644 --- a/tests/codeigniter/database/query_builder/join_test.php +++ b/tests/codeigniter/database/query_builder/join_test.php @@ -34,5 +34,5 @@ class Join_test extends CI_TestCase { $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/codeigniter/database/query_builder/like_test.php b/tests/codeigniter/database/query_builder/like_test.php index df98c713f..5f3e52228 100644 --- a/tests/codeigniter/database/query_builder/like_test.php +++ b/tests/codeigniter/database/query_builder/like_test.php @@ -86,5 +86,5 @@ class Like_test extends CI_TestCase { $this->assertEquals('Accountant', $jobs[1]['name']); $this->assertEquals('Musician', $jobs[2]['name']); } - + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php index 704f3b651..a0954c7ab 100644 --- a/tests/codeigniter/database/query_builder/limit_test.php +++ b/tests/codeigniter/database/query_builder/limit_test.php @@ -25,8 +25,7 @@ class Limit_test extends CI_TestCase { $jobs = $this->db->limit(2) ->get('job') ->result_array(); - - // Check the result + $this->assertEquals(2, count($jobs)); } @@ -40,10 +39,10 @@ class Limit_test extends CI_TestCase { $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 diff --git a/tests/codeigniter/database/query_builder/order_test.php b/tests/codeigniter/database/query_builder/order_test.php index 01aa1c2b4..46f452bae 100644 --- a/tests/codeigniter/database/query_builder/order_test.php +++ b/tests/codeigniter/database/query_builder/order_test.php @@ -25,7 +25,7 @@ class Order_test extends CI_TestCase { $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']); @@ -44,12 +44,12 @@ class Order_test extends CI_TestCase { $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 diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php index 0d299ed16..877b5d8c0 100644 --- a/tests/codeigniter/database/query_builder/select_test.php +++ b/tests/codeigniter/database/query_builder/select_test.php @@ -25,7 +25,7 @@ class Select_test extends CI_TestCase { $jobs_name = $this->db->select('name') ->get('job') ->result_array(); - + // Check rows item $this->assertArrayHasKey('name',$jobs_name[0]); $this->assertFalse(array_key_exists('id', $jobs_name[0])); @@ -42,7 +42,7 @@ class Select_test extends CI_TestCase { $job_min = $this->db->select_min('id') ->get('job') ->row(); - + // Minimum id was 1 $this->assertEquals('1', $job_min->id); } @@ -57,7 +57,7 @@ class Select_test extends CI_TestCase { $job_max = $this->db->select_max('id') ->get('job') ->row(); - + // Maximum id was 4 $this->assertEquals('4', $job_max->id); } @@ -72,7 +72,7 @@ class Select_test extends CI_TestCase { $job_avg = $this->db->select_avg('id') ->get('job') ->row(); - + // Average should be 2.5 $this->assertEquals('2.5', $job_avg->id); } @@ -87,9 +87,9 @@ class Select_test extends CI_TestCase { $job_sum = $this->db->select_sum('id') ->get('job') ->row(); - + // Sum of ids should be 10 $this->assertEquals('10', $job_sum->id); } - + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/truncate_test.php b/tests/codeigniter/database/query_builder/truncate_test.php index 2a9c8a91e..09923c7f1 100644 --- a/tests/codeigniter/database/query_builder/truncate_test.php +++ b/tests/codeigniter/database/query_builder/truncate_test.php @@ -24,7 +24,6 @@ class Truncate_test extends CI_TestCase { { // Check initial record $jobs = $this->db->get('job')->result_array(); - $this->assertEquals(4, count($jobs)); // Do the empty @@ -32,7 +31,6 @@ class Truncate_test extends CI_TestCase { // Check the record $jobs = $this->db->get('job'); - $this->assertEmpty($jobs->result_array()); } @@ -45,16 +43,13 @@ class Truncate_test extends CI_TestCase { { // Check initial record $users = $this->db->get('user')->result_array(); - $this->assertEquals(4, count($users)); // Do the empty - $this->db->from('user') - ->truncate(); + $this->db->from('user')->truncate(); // Check the record $users = $this->db->get('user'); - $this->assertEmpty($users->result_array()); } diff --git a/tests/codeigniter/database/query_builder/update_test.php b/tests/codeigniter/database/query_builder/update_test.php index f5bbffd4f..27a647c45 100644 --- a/tests/codeigniter/database/query_builder/update_test.php +++ b/tests/codeigniter/database/query_builder/update_test.php @@ -23,23 +23,14 @@ class Update_test extends CI_TestCase { public function test_update() { // Check initial record - $job1 = $this->db->where('id', 1) - ->get('job') - ->row(); - + $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); + $this->db->where('id', 1)->update('job', array('name' => 'Programmer')); // Check updated record - $job1 = $this->db->where('id', 1) - ->get('job') - ->row(); - + $job1 = $this->db->where('id', 1)->get('job')->row(); $this->assertEquals('Programmer', $job1->name); } @@ -51,10 +42,7 @@ class Update_test extends CI_TestCase { public function test_update_with_set() { // Check initial record - $job1 = $this->db->where('id', 4) - ->get('job') - ->row(); - + $job1 = $this->db->where('id', 4)->get('job')->row(); $this->assertEquals('Musician', $job1->name); // Do the update @@ -62,10 +50,8 @@ class Update_test extends CI_TestCase { $this->db->update('job', NULL, 'id = 4'); // Check updated record - $job1 = $this->db->where('id', 4) - ->get('job') - ->row(); - + $job1 = $this->db->where('id', 4)->get('job')->row(); $this->assertEquals('Vocalist', $job1->name); } + } \ No newline at end of file diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php index 607eaa076..20b7a567c 100644 --- a/tests/codeigniter/database/query_builder/where_test.php +++ b/tests/codeigniter/database/query_builder/where_test.php @@ -22,11 +22,8 @@ class Where_test extends CI_TestCase { */ public function test_where_simple_key_value() { - $job1 = $this->db->where('id', 1) - ->get('job') - ->row(); + $job1 = $this->db->where('id', 1)->get('job')->row(); - // Check the result $this->assertEquals('1', $job1->id); $this->assertEquals('Developer', $job1->name); } @@ -38,11 +35,7 @@ class Where_test extends CI_TestCase { */ public function test_where_custom_key_value() { - $jobs = $this->db->where('id !=', 1) - ->get('job') - ->result_array(); - - // Check the result + $jobs = $this->db->where('id !=', 1)->get('job')->result_array(); $this->assertEquals(3, count($jobs)); } @@ -54,16 +47,12 @@ class Where_test extends CI_TestCase { public function test_where_associative_array() { $where = array('id >' => 2, 'name !=' => 'Accountant'); - $jobs = $this->db->where($where) - ->get('job') - ->result_array(); + $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']); } @@ -75,16 +64,12 @@ class Where_test extends CI_TestCase { public function test_where_custom_string() { $where = "id > 2 AND name != 'Accountant'"; - $jobs = $this->db->where($where) - ->get('job') - ->result_array(); + $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']); } @@ -100,7 +85,6 @@ class Where_test extends CI_TestCase { ->get('job') ->result_array(); - // Check the result $this->assertEquals(3, count($jobs)); $this->assertEquals('Developer', $jobs[0]['name']); $this->assertEquals('Politician', $jobs[1]['name']); @@ -118,7 +102,6 @@ class Where_test extends CI_TestCase { ->get('job') ->result_array(); - // Check the result $this->assertEquals(2, count($jobs)); $this->assertEquals('Politician', $jobs[0]['name']); $this->assertEquals('Accountant', $jobs[1]['name']); @@ -135,10 +118,9 @@ class Where_test extends CI_TestCase { ->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 diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php index 23d5c5c1a..ef6aae138 100644 --- a/tests/codeigniter/helpers/number_helper_test.php +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -25,7 +25,7 @@ class Number_helper_test extends CI_TestCase { // a cheap class to act as our super object. // Make sure it has a lang attribute. - $obj = new StdClass; + $obj = new stdClass; $obj->lang = $lang; $this->ci_instance($obj); } diff --git a/tests/codeigniter/libraries/Encrypt_test.php b/tests/codeigniter/libraries/Encrypt_test.php index 066990186..153a25e1d 100644 --- a/tests/codeigniter/libraries/Encrypt_test.php +++ b/tests/codeigniter/libraries/Encrypt_test.php @@ -2,70 +2,71 @@ class Encrypt_test extends CI_TestCase { - public function set_up() - { - $obj = new StdClass; - $obj->encrypt = new Mock_Libraries_Encrypt(); - - $this->ci_instance($obj); - $this->encrypt = $obj->encrypt; - - $this->ci_set_config('encryption_key', "Encryptin'glike@boss!"); - $this->msg = 'My secret message'; - } - - // -------------------------------------------------------------------- - - public function test_encode() - { - $this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg)); - } - - // -------------------------------------------------------------------- - - public function test_decode() - { - $encoded_msg = $this->encrypt->encode($this->msg); - $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg)); - } - - // -------------------------------------------------------------------- - - public function test_optional_key() - { - $key = 'Ohai!ù0129°03182%HD1892P0'; - $encoded_msg = $this->encrypt->encode($this->msg, $key); - $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key)); - } - - // -------------------------------------------------------------------- - - public function test_default_cipher() - { - $this->assertEquals('rijndael-256', $this->encrypt->get_cipher()); - } - - // -------------------------------------------------------------------- - - public function test_set_cipher() - { - $this->encrypt->set_cipher(MCRYPT_BLOWFISH); - $this->assertEquals('blowfish', $this->encrypt->get_cipher()); - } - - // -------------------------------------------------------------------- - - public function test_default_mode() - { - $this->assertEquals('cbc', $this->encrypt->get_mode()); - } - - // -------------------------------------------------------------------- - - public function test_set_mode() - { - $this->encrypt->set_mode(MCRYPT_MODE_CFB); - $this->assertEquals('cfb', $this->encrypt->get_mode()); - } + public function set_up() + { + $obj = new stdClass; + $obj->encrypt = new Mock_Libraries_Encrypt(); + + $this->ci_instance($obj); + $this->encrypt = $obj->encrypt; + + $this->ci_set_config('encryption_key', "Encryptin'glike@boss!"); + $this->msg = 'My secret message'; + } + + // -------------------------------------------------------------------- + + public function test_encode() + { + $this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg)); + } + + // -------------------------------------------------------------------- + + public function test_decode() + { + $encoded_msg = $this->encrypt->encode($this->msg); + $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg)); + } + + // -------------------------------------------------------------------- + + public function test_optional_key() + { + $key = 'Ohai!ù0129°03182%HD1892P0'; + $encoded_msg = $this->encrypt->encode($this->msg, $key); + $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key)); + } + + // -------------------------------------------------------------------- + + public function test_default_cipher() + { + $this->assertEquals('rijndael-256', $this->encrypt->get_cipher()); + } + + // -------------------------------------------------------------------- + + + public function test_set_cipher() + { + $this->encrypt->set_cipher(MCRYPT_BLOWFISH); + $this->assertEquals('blowfish', $this->encrypt->get_cipher()); + } + + // -------------------------------------------------------------------- + + public function test_default_mode() + { + $this->assertEquals('cbc', $this->encrypt->get_mode()); + } + + // -------------------------------------------------------------------- + + public function test_set_mode() + { + $this->encrypt->set_mode(MCRYPT_MODE_CFB); + $this->assertEquals('cfb', $this->encrypt->get_mode()); + } } \ No newline at end of file diff --git a/tests/codeigniter/libraries/Parser_test.php b/tests/codeigniter/libraries/Parser_test.php index c3d88fa85..b68f44a33 100644 --- a/tests/codeigniter/libraries/Parser_test.php +++ b/tests/codeigniter/libraries/Parser_test.php @@ -1,73 +1,74 @@ parser = new Mock_Libraries_Parser(); - + $this->ci_instance($obj); - + $this->parser = $obj->parser; } + // -------------------------------------------------------------------- - + public function test_set_delimiters() { // Make sure default delimiters are there $this->assertEquals('{', $this->parser->l_delim); $this->assertEquals('}', $this->parser->r_delim); - + // Change them to square brackets $this->parser->set_delimiters('[', ']'); - + // Make sure they changed $this->assertEquals('[', $this->parser->l_delim); $this->assertEquals(']', $this->parser->r_delim); - + // Reset them $this->parser->set_delimiters(); - + // Make sure default delimiters are there $this->assertEquals('{', $this->parser->l_delim); $this->assertEquals('}', $this->parser->r_delim); } - + // -------------------------------------------------------------------- - + public function test_parse_simple_string() { $data = array( 'title' => 'Page Title', 'body' => 'Lorem ipsum dolor sit amet.' ); - + $template = "{title}\n{body}"; - + $result = implode("\n", $data); - + $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE)); } - + // -------------------------------------------------------------------- - + public function test_parse() { $this->_parse_no_template(); $this->_parse_var_pair(); $this->_mismatched_var_pair(); } - + // -------------------------------------------------------------------- - + private function _parse_no_template() { $this->assertFalse($this->parser->parse_string('', '', TRUE)); } - + // -------------------------------------------------------------------- - + private function _parse_var_pair() { $data = array( @@ -78,16 +79,14 @@ class Parser_test extends CI_TestCase { 'flying' => 'no'), ) ); - + $template = "{title}\n{powers}{invisibility}\n{flying}{/powers}"; - - $result = "Super Heroes\nyes\nno"; - - $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE)); + + $this->assertEquals("Super Heroes\nyes\nno", $this->parser->parse_string($template, $data, TRUE)); } - + // -------------------------------------------------------------------- - + private function _mismatched_var_pair() { $data = array( @@ -98,13 +97,11 @@ class Parser_test extends CI_TestCase { 'flying' => 'no'), ) ); - + $template = "{title}\n{powers}{invisibility}\n{flying}"; - $result = "Super Heroes\n{powers}{invisibility}\n{flying}"; - - $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE)); + + $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE)); } - // -------------------------------------------------------------------- } \ No newline at end of file diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php index f5133de1e..edfc83dd0 100644 --- a/tests/codeigniter/libraries/Table_test.php +++ b/tests/codeigniter/libraries/Table_test.php @@ -4,43 +4,39 @@ class Table_test extends CI_TestCase { public function set_up() { - $obj = new StdClass; + $obj = new stdClass; $obj->table = new Mock_Libraries_Table(); - + $this->ci_instance($obj); - + $this->table = $obj->table; } - // Setter Methods // -------------------------------------------------------------------- - + public function test_set_template() { $this->assertFalse($this->table->set_template('not an array')); - - $template = array( - 'a' => 'b' - ); - + + $template = array('a' => 'b'); + $this->table->set_template($template); $this->assertEquals($template, $this->table->template); } - + public function test_set_empty() { $this->table->set_empty('nada'); $this->assertEquals('nada', $this->table->empty_cells); } - + public function test_set_caption() { $this->table->set_caption('awesome cap'); $this->assertEquals('awesome cap', $this->table->caption); } - - + /* * @depends testPrepArgs */ @@ -49,9 +45,9 @@ class Table_test extends CI_TestCase { // uses _prep_args internally, so we'll just do a quick // check to verify that func_get_args and prep_args are // being called. - + $this->table->set_heading('name', 'color', 'size'); - + $this->assertEquals( array( array('data' => 'name'), @@ -61,8 +57,7 @@ class Table_test extends CI_TestCase { $this->table->heading ); } - - + /* * @depends testPrepArgs */ @@ -71,13 +66,13 @@ class Table_test extends CI_TestCase { // uses _prep_args internally, so we'll just do a quick // check to verify that func_get_args and prep_args are // being called. - + $this->table->add_row('my', 'pony', 'sings'); $this->table->add_row('your', 'pony', 'stinks'); $this->table->add_row('my pony', '>', 'your pony'); - + $this->assertEquals(count($this->table->rows), 3); - + $this->assertEquals( array( array('data' => 'your'), @@ -87,11 +82,10 @@ class Table_test extends CI_TestCase { $this->table->rows[1] ); } - - + // Uility Methods // -------------------------------------------------------------------- - + public function test_prep_args() { $expected = array( @@ -99,7 +93,7 @@ class Table_test extends CI_TestCase { array('data' => 'color'), array('data' => 'size') ); - + $this->assertEquals( $expected, $this->table->prep_args(array('name', 'color', 'size')) @@ -114,7 +108,7 @@ class Table_test extends CI_TestCase { $this->table->prep_args(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome'))) ); } - + public function test_default_template_keys() { $keys = array( @@ -126,132 +120,124 @@ class Table_test extends CI_TestCase { 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close' ); - + foreach ($keys as $key) { $this->assertArrayHasKey($key, $this->table->default_template()); } } - + public function test_compile_template() { $this->assertFalse($this->table->set_template('invalid_junk')); - + // non default key $this->table->set_template(array('nonsense' => 'foo')); $this->table->compile_template(); - + $this->assertArrayHasKey('nonsense', $this->table->template); $this->assertEquals('foo', $this->table->template['nonsense']); - + // override default $this->table->set_template(array('table_close' => '')); $this->table->compile_template(); - + $this->assertArrayHasKey('table_close', $this->table->template); $this->assertEquals('', $this->table->template['table_close']); } - + public function test_make_columns() { // Test bogus parameters $this->assertFalse($this->table->make_columns('invalid_junk')); $this->assertFalse($this->table->make_columns(array())); $this->assertFalse($this->table->make_columns(array('one', 'two'), '2.5')); - - + // Now on to the actual column creation - + $five_values = array( 'Laura', 'Red', '15', 'Katie', 'Blue' ); - + // No column count - no changes to the array $this->assertEquals( $five_values, $this->table->make_columns($five_values) ); - + // Column count of 3 leaves us with one   $this->assertEquals( array( array('Laura', 'Red', '15'), - array('Katie', 'Blue', ' ') + array('Katie', 'Blue', ' ') ), $this->table->make_columns($five_values, 3) ); } - + public function test_clear() { $this->table->set_heading('Name', 'Color', 'Size'); - + // Make columns changes auto_heading $rows = $this->table->make_columns(array( 'Laura', 'Red', '15', 'Katie', 'Blue' ), 3); - + foreach ($rows as $row) { $this->table->add_row($row); } - + $this->assertFalse($this->table->auto_heading); $this->assertEquals(count($this->table->heading), 3); $this->assertEquals(count($this->table->rows), 2); - + $this->table->clear(); - + $this->assertTrue($this->table->auto_heading); $this->assertEmpty($this->table->heading); $this->assertEmpty($this->table->rows); } - - + public function test_set_from_array() { $this->assertFalse($this->table->set_from_array('bogus')); $this->assertFalse($this->table->set_from_array(NULL)); - + $data = array( array('name', 'color', 'number'), array('Laura', 'Red', '22'), - array('Katie', 'Blue') + array('Katie', 'Blue') ); - + $this->table->set_from_array($data, FALSE); $this->assertEmpty($this->table->heading); - + $this->table->clear(); - - $expected_heading = array( + + $this->table->set_from_array($data); + $this->assertEquals(count($this->table->rows), 2); + + $expected = array( array('data' => 'name'), array('data' => 'color'), array('data' => 'number') ); - - $expected_second = array( + + $this->assertEquals($expected, $this->table->heading); + + $expected = array( array('data' => 'Katie'), array('data' => 'Blue'), ); - - $this->table->set_from_array($data); - $this->assertEquals(count($this->table->rows), 2); - - $this->assertEquals( - $expected_heading, - $this->table->heading - ); - - $this->assertEquals( - $expected_second, - $this->table->rows[1] - ); + + $this->assertEquals($expected, $this->table->rows[1]); } - - function test_set_from_object() + + public function test_set_from_object() { // Make a stub of query instance $query = new CI_TestCase(); @@ -268,37 +254,31 @@ class Table_test extends CI_TestCase { return 2; }; - $expected_heading = array( + $this->table->set_from_object($query); + + $expected = array( array('data' => 'name'), array('data' => 'email') ); - $expected_second = array( + $this->assertEquals($expected, $this->table->heading); + + $expected = array( 'name' => array('data' => 'Foo Bar'), 'email' => array('data' => 'foo@bar.com'), ); - $this->table->set_from_object($query); - - $this->assertEquals( - $expected_heading, - $this->table->heading - ); - - $this->assertEquals( - $expected_second, - $this->table->rows[1] - ); + $this->assertEquals($expected, $this->table->rows[1]); } - - function test_generate() + + public function test_generate() { // Prepare the data $data = array( array('Name', 'Color', 'Size'), array('Fred', 'Blue', 'Small'), array('Mary', 'Red', 'Large'), - array('John', 'Green', 'Medium') + array('John', 'Green', 'Medium') ); $table = $this->table->generate($data); @@ -313,4 +293,5 @@ class Table_test extends CI_TestCase { $this->assertTrue(strpos($table, 'Blue') !== FALSE); $this->assertTrue(strpos($table, 'Small') !== FALSE); } + } \ No newline at end of file diff --git a/tests/codeigniter/libraries/Typography_test.php b/tests/codeigniter/libraries/Typography_test.php index 250aefb24..eb6dacb73 100644 --- a/tests/codeigniter/libraries/Typography_test.php +++ b/tests/codeigniter/libraries/Typography_test.php @@ -4,11 +4,11 @@ class Typography_test extends CI_TestCase { public function set_up() { - $obj = new StdClass; + $obj = new stdClass; $obj->type = new Mock_Libraries_Typography(); - + $this->ci_instance($obj); - + $this->type = $obj->type; } @@ -33,18 +33,18 @@ class Typography_test extends CI_TestCase { 'foo..' => 'foo..', 'foo...bar.' => 'foo…bar.', 'test. new' => 'test.  new', - ); - + ); + foreach ($strs as $str => $expected) { - $this->assertEquals($expected, $this->type->format_characters($str)); + $this->assertEquals($expected, $this->type->format_characters($str)); } } // -------------------------------------------------------------------- public function test_nl2br_except_pre() - { + { $str = << The End. EOH; - $this->assertEquals($expected, - $this->type->nl2br_except_pre($str)); + $this->assertEquals($expected, $this->type->nl2br_except_pre($str)); } // -------------------------------------------------------------------- - + public function test_auto_typography() { $this->_blank_string(); @@ -103,7 +102,7 @@ EOH; } // -------------------------------------------------------------------- - + private function _blank_string() { // Test blank string @@ -131,7 +130,7 @@ EOH; { $str = "This has way too many linebreaks.\n\n\n\nSee?"; $expect = "

    This has way too many linebreaks.

    \n\n

    See?

    "; - + $this->assertEquals($expect, $this->type->auto_typography($str, TRUE)); } @@ -141,7 +140,7 @@ EOH; { $str = ' But no!'; $expect = '

      But no!

    '; - + $this->assertEquals($expect, $this->type->auto_typography($str)); } @@ -151,7 +150,7 @@ EOH; { $str = '

    My Sentence

    var_dump($this);
    '; $expect = '

    My Sentence

    var_dump($this);
    '; - + $this->assertEquals($expect, $this->type->auto_typography($str)); } @@ -161,7 +160,7 @@ EOH; { $str = 'My Sentence
    var_dump($this);
    '; $expect = '

    My Sentence

    var_dump($this);
    '; - + $this->assertEquals($expect, $this->type->auto_typography($str)); } @@ -170,19 +169,18 @@ EOH; public function _protect_braced_quotes() { $this->type->protect_braced_quotes = TRUE; - + $str = 'Test {parse="foobar"}'; $expect = '

    Test {parse="foobar"}

    '; - + $this->assertEquals($expect, $this->type->auto_typography($str)); $this->type->protect_braced_quotes = FALSE; - + $str = 'Test {parse="foobar"}'; $expect = '

    Test {parse=“foobar”}

    '; - - $this->assertEquals($expect, $this->type->auto_typography($str)); - + $this->assertEquals($expect, $this->type->auto_typography($str)); } + } \ No newline at end of file diff --git a/tests/codeigniter/libraries/Useragent_test.php b/tests/codeigniter/libraries/Useragent_test.php index 7dad7ac54..89383f807 100644 --- a/tests/codeigniter/libraries/Useragent_test.php +++ b/tests/codeigniter/libraries/Useragent_test.php @@ -1,7 +1,7 @@ _user_agent; - $obj = new StdClass; + $obj = new stdClass; $obj->agent = new Mock_Libraries_UserAgent(); $this->ci_instance($obj); @@ -82,6 +82,4 @@ class UserAgent_test extends CI_TestCase { $this->assertFalse($this->agent->accept_charset()); } - // -------------------------------------------------------------------- - } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f243ce13b4baf5bf8bebf36586514bb243dfc355 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 23:34:21 +0300 Subject: Cleanup/optimize tests/mocks/ --- tests/mocks/autoloader.php | 4 +- tests/mocks/ci_testcase.php | 84 +++++++++++++++--------------- tests/mocks/core/common.php | 36 ++++++------- tests/mocks/core/input.php | 6 +-- tests/mocks/core/loader.php | 7 +-- tests/mocks/core/security.php | 2 +- tests/mocks/core/uri.php | 9 ++-- tests/mocks/core/utf8.php | 11 ++-- tests/mocks/database/config/mysql.php | 10 ++-- tests/mocks/database/config/pdo/mysql.php | 12 ++--- tests/mocks/database/config/pdo/pgsql.php | 12 ++--- tests/mocks/database/config/pdo/sqlite.php | 12 ++--- tests/mocks/database/config/pgsql.php | 10 ++-- tests/mocks/database/config/sqlite.php | 10 ++-- tests/mocks/database/db.php | 18 +++---- tests/mocks/database/db/driver.php | 7 ++- tests/mocks/database/db/querybuilder.php | 9 +--- tests/mocks/database/drivers/mysql.php | 9 ++-- tests/mocks/database/drivers/pdo.php | 8 +-- tests/mocks/database/drivers/postgre.php | 9 ++-- tests/mocks/database/drivers/sqlite.php | 7 +-- tests/mocks/database/schema/skeleton.php | 48 ++++++++--------- tests/mocks/libraries/encrypt.php | 21 ++++---- tests/mocks/libraries/table.php | 3 +- 24 files changed, 180 insertions(+), 184 deletions(-) diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 90aabcbe6..e3ff7a8bd 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -69,7 +69,7 @@ function autoload($class) } } - $file = (isset($file)) ? $file : $dir.$class.'.php'; + $file = isset($file) ? $file : $dir.$class.'.php'; if ( ! file_exists($file)) { @@ -82,7 +82,7 @@ function autoload($class) return FALSE; } - throw new InvalidArgumentException("Unable to load $class."); + throw new InvalidArgumentException("Unable to load {$class}."); } include_once($file); diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index f327e6b07..eda9e1b60 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -1,11 +1,11 @@ 'bm', 'config' => 'cfg', @@ -19,18 +19,17 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { 'loader' => 'load', 'model' => 'model' ); - + // -------------------------------------------------------------------- - + public function __construct() { parent::__construct(); - $this->ci_config = array(); } - + // -------------------------------------------------------------------- - + public function setUp() { if (method_exists($this, 'set_up')) @@ -38,10 +37,10 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { $this->set_up(); } } - + // -------------------------------------------------------------------- - - public function tearDown() + + public function tearDown() { if (method_exists($this, 'tear_down')) { @@ -50,15 +49,15 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { } // -------------------------------------------------------------------- - + public static function instance() { return self::$ci_test_instance; } - + // -------------------------------------------------------------------- - - function ci_set_config($key, $val = '') + + public function ci_set_config($key, $val = '') { if (is_array($key)) { @@ -71,36 +70,36 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { } // -------------------------------------------------------------------- - - function ci_get_config() + + public function ci_get_config() { return $this->ci_config; } - + // -------------------------------------------------------------------- - - function ci_instance($obj = FALSE) + + public function ci_instance($obj = FALSE) { if ( ! is_object($obj)) { return $this->ci_instance; } - + $this->ci_instance = $obj; } - + // -------------------------------------------------------------------- - - function ci_instance_var($name, $obj = FALSE) + + public function ci_instance_var($name, $obj = FALSE) { if ( ! is_object($obj)) { return $this->ci_instance->$name; } - + $this->ci_instance->$name =& $obj; } - + // -------------------------------------------------------------------- /** @@ -112,10 +111,10 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { * test can modify the variable it assigns to and * still maintain the global. */ - function &ci_core_class($name) + public function &ci_core_class($name) { $name = strtolower($name); - + if (isset($this->global_map[$name])) { $class_name = ucfirst($name); @@ -130,29 +129,29 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { { 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) + public function ci_set_core_class($name, $obj) { $orig =& $this->ci_core_class($name); $orig = $obj; } - + // -------------------------------------------------------------------- // Internals // -------------------------------------------------------------------- - + /** * Overwrite runBare * @@ -169,28 +168,27 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { } // -------------------------------------------------------------------- - - function helper($name) + + public 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) + public function __call($method, $args) { - if ($this->{$method} instanceof Closure) + if ($this->{$method} instanceof Closure) { return call_user_func_array($this->{$method},$args); - } - else + } + else { return parent::__call($method, $args); } } -} -// EOF \ No newline at end of file +} \ No newline at end of file diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index e1c493aa0..8466e47f8 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -4,11 +4,10 @@ if ( ! function_exists('get_instance')) { - function &get_instance() + function &get_instance() { $test = CI_TestCase::instance(); - $instance = $test->ci_instance(); - return $instance; + return $test->ci_instance(); } } @@ -16,11 +15,10 @@ if ( ! function_exists('get_instance')) if ( ! function_exists('get_config')) { - function &get_config() { + function &get_config() + { $test = CI_TestCase::instance(); - $config = $test->ci_get_config(); - - return $config; + return $test->ci_get_config(); } } @@ -29,12 +27,12 @@ if ( ! function_exists('config_item')) function config_item($item) { $config =& get_config(); - + if ( ! isset($config[$item])) { return FALSE; } - + return $config[$item]; } } @@ -49,16 +47,16 @@ if ( ! function_exists('load_class')) { 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.''); + throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class); } - + return $obj; } } @@ -74,16 +72,16 @@ if ( ! function_exists('remove_invisible_characters')) 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 @@ -166,6 +164,4 @@ if ( ! function_exists('set_status_header')) { return TRUE; } -} - -// EOF \ No newline at end of file +} \ No newline at end of file diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php index 8a337d2ef..2a4aa4997 100644 --- a/tests/mocks/core/input.php +++ b/tests/mocks/core/input.php @@ -1,10 +1,10 @@ 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/security.php b/tests/mocks/core/security.php index d7ea0e6bd..e19a8b20b 100644 --- a/tests/mocks/core/security.php +++ b/tests/mocks/core/security.php @@ -1,7 +1,7 @@ ci_core_class('cfg'); - + // set predictable config values $test->ci_set_config(array( 'index_page' => 'index.php', @@ -14,12 +14,13 @@ class Mock_Core_URI extends CI_URI { 'subclass_prefix' => 'MY_' )); - $this->config = new $cls; + $this->config = new $cls; } - + protected function _is_cli_request() { return FALSE; } + } \ No newline at end of file diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php index b77d717e7..068e74ac1 100644 --- a/tests/mocks/core/utf8.php +++ b/tests/mocks/core/utf8.php @@ -1,27 +1,26 @@ array( 'dsn' => '', @@ -9,7 +9,7 @@ return array( 'username' => 'travis', 'password' => '', 'database' => 'ci_test', - 'dbdriver' => 'mysql', + 'dbdriver' => 'mysql' ), // Database configuration with failover @@ -28,7 +28,7 @@ return array( 'password' => '', 'database' => 'ci_test', 'dbdriver' => 'mysql', - ), - ), - ), + ) + ) + ) ); \ No newline at end of file diff --git a/tests/mocks/database/config/pdo/mysql.php b/tests/mocks/database/config/pdo/mysql.php index cefb6b008..fefe0d624 100644 --- a/tests/mocks/database/config/pdo/mysql.php +++ b/tests/mocks/database/config/pdo/mysql.php @@ -1,7 +1,7 @@ array( 'dsn' => '', @@ -10,7 +10,7 @@ return array( 'password' => '', 'database' => 'ci_test', 'dbdriver' => 'pdo', - 'pdodriver' => 'mysql', + 'pdodriver' => 'mysql' ), // Database configuration with failover @@ -30,8 +30,8 @@ return array( 'password' => '', 'database' => 'ci_test', 'dbdriver' => 'pdo', - 'pdodriver' => 'mysql', - ), - ), - ), + 'pdodriver' => 'mysql' + ) + ) + ) ); \ No newline at end of file diff --git a/tests/mocks/database/config/pdo/pgsql.php b/tests/mocks/database/config/pdo/pgsql.php index 5196e9ad9..ddd638c8a 100644 --- a/tests/mocks/database/config/pdo/pgsql.php +++ b/tests/mocks/database/config/pdo/pgsql.php @@ -1,7 +1,7 @@ array( 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;', @@ -10,7 +10,7 @@ return array( 'password' => '', 'database' => 'ci_test', 'dbdriver' => 'pdo', - 'pdodriver' => 'pgsql', + 'pdodriver' => 'pgsql' ), // Database configuration with failover @@ -30,8 +30,8 @@ return array( 'password' => '', 'database' => 'ci_test', 'dbdriver' => 'pdo', - 'pdodriver' => 'pgsql', - ), - ), - ), + 'pdodriver' => 'pgsql' + ) + ) + ) ); \ No newline at end of file diff --git a/tests/mocks/database/config/pdo/sqlite.php b/tests/mocks/database/config/pdo/sqlite.php index c68b4b213..36461843d 100644 --- a/tests/mocks/database/config/pdo/sqlite.php +++ b/tests/mocks/database/config/pdo/sqlite.php @@ -10,7 +10,7 @@ return array( 'password' => 'sqlite', 'database' => 'sqlite', 'dbdriver' => 'pdo', - 'pdodriver' => 'sqlite', + 'pdodriver' => 'sqlite' ), // Database configuration with failover @@ -29,9 +29,9 @@ return array( 'username' => 'sqlite', 'password' => 'sqlite', 'database' => 'sqlite', - 'dbdriver' => 'pdo', - 'pdodriver' => 'sqlite', - ), - ), - ), + 'dbdriver' => 'pdo', + 'pdodriver' => 'sqlite' + ) + ) + ) ); \ No newline at end of file diff --git a/tests/mocks/database/config/pgsql.php b/tests/mocks/database/config/pgsql.php index c06af8ce0..1444b0066 100644 --- a/tests/mocks/database/config/pgsql.php +++ b/tests/mocks/database/config/pgsql.php @@ -1,7 +1,7 @@ array( 'dsn' => '', @@ -9,7 +9,7 @@ return array( 'username' => 'postgres', 'password' => '', 'database' => 'ci_test', - 'dbdriver' => 'postgre', + 'dbdriver' => 'postgre' ), // Database configuration with failover @@ -28,7 +28,7 @@ return array( 'password' => '', 'database' => 'ci_test', 'dbdriver' => 'postgre', - ), - ), - ), + ) + ) + ) ); \ No newline at end of file diff --git a/tests/mocks/database/config/sqlite.php b/tests/mocks/database/config/sqlite.php index 755ce2a3a..d37ee4871 100644 --- a/tests/mocks/database/config/sqlite.php +++ b/tests/mocks/database/config/sqlite.php @@ -9,7 +9,7 @@ return array( 'username' => 'sqlite', 'password' => 'sqlite', 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite', - 'dbdriver' => 'sqlite3', + 'dbdriver' => 'sqlite3' ), // Database configuration with failover @@ -27,8 +27,8 @@ return array( 'username' => 'sqlite', 'password' => 'sqlite', 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite', - 'dbdriver' => 'sqlite3', - ), - ), - ), + 'dbdriver' => 'sqlite3' + ) + ) + ) ); \ No newline at end of file diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php index 59028ed9c..30504bba6 100644 --- a/tests/mocks/database/db.php +++ b/tests/mocks/database/db.php @@ -6,7 +6,7 @@ class Mock_Database_DB { * @var array DB configuration */ private $config = array(); - + /** * Prepare database configuration skeleton * @@ -21,7 +21,7 @@ class Mock_Database_DB { /** * Build DSN connection string for DB driver instantiate process * - * @param string Group name + * @param string Group name * @return string DSN Connection string */ public function set_dsn($group = 'default') @@ -65,28 +65,27 @@ class Mock_Database_DB { * Return a database config array * * @see ./config - * @param string Driver based configuration - * @return array + * @param string Driver based configuration + * @return array */ public static function config($driver) { $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR; - return include($dir.'config'.DIRECTORY_SEPARATOR.$driver.'.php'); } /** * Main DB method wrapper * - * @param string Group or DSN string - * @param bool - * @return object + * @param string Group or DSN string + * @param bool + * @return object */ public static function DB($group, $query_builder = FALSE) { include_once(BASEPATH.'database/DB.php'); - try + try { $db = DB($group, $query_builder); } @@ -97,4 +96,5 @@ class Mock_Database_DB { return $db; } + } \ No newline at end of file diff --git a/tests/mocks/database/db/driver.php b/tests/mocks/database/db/driver.php index cb1820277..65ac2c4cc 100644 --- a/tests/mocks/database/db/driver.php +++ b/tests/mocks/database/db/driver.php @@ -1,7 +1,7 @@ ci_db_driver = new $driver_class($config); + if (is_string($driver_class)) + { + $this->ci_db_driver = new $driver_class($config); + } } /** diff --git a/tests/mocks/database/db/querybuilder.php b/tests/mocks/database/db/querybuilder.php index 1b95c92af..3f2252622 100644 --- a/tests/mocks/database/db/querybuilder.php +++ b/tests/mocks/database/db/querybuilder.php @@ -1,10 +1,3 @@ add_field(array( 'id' => array( 'type' => 'INTEGER', - 'constraint' => 3, + 'constraint' => 3 ), 'name' => array( 'type' => 'VARCHAR', - 'constraint' => 40, + 'constraint' => 40 ), 'email' => array( 'type' => 'VARCHAR', - 'constraint' => 100, + 'constraint' => 100 ), 'country' => array( 'type' => 'VARCHAR', - 'constraint' => 40, - ), + 'constraint' => 40 + ) )); static::$forge->add_key('id', TRUE); static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE)); @@ -76,15 +75,15 @@ class Mock_Database_Schema_Skeleton { static::$forge->add_field(array( 'id' => array( 'type' => 'INTEGER', - 'constraint' => 3, + 'constraint' => 3 ), 'name' => array( 'type' => 'VARCHAR', - 'constraint' => 40, + 'constraint' => 40 ), 'description' => array( - 'type' => 'TEXT', - ), + 'type' => 'TEXT' + ) )); static::$forge->add_key('id', TRUE); static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE)); @@ -93,15 +92,15 @@ class Mock_Database_Schema_Skeleton { static::$forge->add_field(array( 'id' => array( 'type' => 'INTEGER', - 'constraint' => 3, + 'constraint' => 3 ), 'key' => array( 'type' => 'VARCHAR', - 'constraint' => 40, + 'constraint' => 40 ), 'value' => array( - 'type' => 'TEXT', - ), + 'type' => 'TEXT' + ) )); static::$forge->add_key('id', TRUE); static::$forge->create_table('misc', (strpos(static::$driver, 'pgsql') === FALSE)); @@ -120,28 +119,29 @@ class Mock_Database_Schema_Skeleton { 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'), + 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'), + 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'), - array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), - array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'), + array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), + array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician') ), 'misc' => array( - array('id' => 1, 'key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'), - array('id' => 2, 'key' => '\\%foo456', 'value' => 'Entry with \\%'), - ), + array('id' => 1, 'key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'), + array('id' => 2, 'key' => '\\%foo456', 'value' => 'Entry with \\%') + ) ); - foreach ($data as $table => $dummy_data) + foreach ($data as $table => $dummy_data) { static::$db->truncate($table); foreach ($dummy_data as $single_dummy_data) { - static::$db->insert($table, $single_dummy_data); + static::$db->insert($table, $single_dummy_data); } } } + } \ No newline at end of file diff --git a/tests/mocks/libraries/encrypt.php b/tests/mocks/libraries/encrypt.php index a9bbaafdc..f1859398f 100644 --- a/tests/mocks/libraries/encrypt.php +++ b/tests/mocks/libraries/encrypt.php @@ -2,14 +2,15 @@ class Mock_Libraries_Encrypt extends CI_Encrypt { - // 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'); - } + // 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 97fbb30bd..87c278bce 100644 --- a/tests/mocks/libraries/table.php +++ b/tests/mocks/libraries/table.php @@ -1,7 +1,7 @@ Date: Sat, 9 Jun 2012 23:37:17 +0300 Subject: Fix defined() usage in system/core/Common.php --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Common.php b/system/core/Common.php index c08755c91..1708653e7 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -240,7 +240,7 @@ if ( ! function_exists('get_config')) } // Is the config file in the environment folder? - if (defined(ENVIRONMENT) && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + if (defined('ENVIRONMENT') && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) { require($file_path); } -- cgit v1.2.3-24-g4f1b From e15e3dde9dca15e2d65f098010d3fb7004cef5e7 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Sat, 9 Jun 2012 23:52:27 +0200 Subject: Fixed timezone change in index.php Now it does not ever change the local timezone, and it adds the option to get the 'local' time() --- index.php | 2 -- system/helpers/date_helper.php | 14 ++++++++++---- user_guide_src/source/helpers/date_helper.rst | 3 ++- user_guide_src/source/installation/upgrade_300.rst | 3 ++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 62fc2ab1b..3b00dd360 100644 --- a/index.php +++ b/index.php @@ -162,8 +162,6 @@ if (defined('ENVIRONMENT')) // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE // -------------------------------------------------------------------- -date_default_timezone_set('UTC'); - /* * --------------------------------------------------------------- * Resolve the system path for increased reliability diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 3b0c3289d..d5acec23f 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -57,10 +57,16 @@ if ( ! function_exists('now')) $timezone = $CI->config->item('timezone'); } - $timezone = new DateTimeZone($timezone); - $now = new DateTime('now', $timezone); - $offset = $timezone->getOffset($now); - $time = time() + $offset; + $time = time(); + if(strtolower($timezone) != 'local') + { + $local = new DateTime(NULL, new DateTimeZone(date_default_timezone_get())); + $now = new DateTime(NULL, new DateTimeZone($timezone)); + $lcl_offset = $local->getOffset(); + $tz_offset = $now->getOffset(); + $offset = $tz_offset - $lcl_offset; + $time = $time + $offset; + } return $time; } diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index b6c6ed4bb..33b39bd5b 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -21,7 +21,8 @@ now() ===== Returns the current time as a Unix timestamp, based on the "timezone" parameter. -All PHP available timezones are supported. +All PHP available timezones are supported. You can also use 'local' timezone, and +it will return time(). .. php:method:: now($timezone = NULL) diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index e86ef67da..c2c3899ee 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -47,7 +47,8 @@ Step 5: Change your use of the Date helper's now() function Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>` You must replace $config['time_reference'] with $config['timezone'] in your config.php file. You can select all -PHP supported timezones, listed here: `PHP's supported timezones `_. +PHP supported timezones, listed here: `Supported timezones `_. You can also +use 'local' if you want to get time(). Step 6: Move your errors folder =============================== -- cgit v1.2.3-24-g4f1b From a9617a35ce4af051d3ad1298c2c24453460754cc Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Sun, 10 Jun 2012 00:13:04 +0200 Subject: Changed the default timezone to local and explained in the config file. --- application/config/config.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index eb3ddddb0..12ef77c76 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -363,10 +363,11 @@ $config['compress_output'] = FALSE; |-------------------------------------------------------------------------- | | You can set any PHP supported timezones to be the master timezone when -| you call the now() function. +| you call the now() function. 'local' string can be used to get the local +| time. | */ -$config['timezone'] = 'UTC'; +$config['timezone'] = 'local'; /* -- cgit v1.2.3-24-g4f1b From 5a257187c4ca09ea61c19999bf061cec3f224cc2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 06:18:14 +0300 Subject: Merge branch 2.1-stable into develop --- system/core/Input.php | 20 ++++++++++++++++---- system/database/DB_driver.php | 10 ++++++---- system/database/DB_query_builder.php | 2 +- system/libraries/Form_validation.php | 5 +++-- user_guide_src/source/changelog.rst | 6 +++++- user_guide_src/source/installation/upgrading.rst | 3 ++- user_guide_src/source/libraries/form_validation.rst | 1 + user_guide_src/source/libraries/input.rst | 3 +++ user_guide_src/source/libraries/sessions.rst | 2 +- user_guide_src/source/libraries/uri.rst | 2 +- 10 files changed, 39 insertions(+), 15 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index b986c4973..162e40c85 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -376,14 +376,26 @@ class CI_Input { /** * Validate IP Address * - * Updated version suggested by Geert De Deckere - * * @param string + * @param string 'ipv4' or 'ipv6' * @return bool */ - public function valid_ip($ip) + public function valid_ip($ip, $which = '') { - return (bool) filter_var($ip, FILTER_VALIDATE_IP); + switch (strtolower($which)) + { + case 'ipv4': + $which = FILTER_FLAG_IPV4; + break; + case 'ipv6': + $which = FILTER_FLAG_IPV6; + break; + default: + $which = NULL; + break; + } + + return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which); } // -------------------------------------------------------------------- diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 65f1f18d0..f5a7e2ac0 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1307,14 +1307,16 @@ abstract class CI_DB_driver { } // Convert tabs or multiple spaces into single spaces - $item = preg_replace('/[\t ]+/', ' ', $item); + $item = preg_replace('/\s+/', ' ', $item); // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space - if (strpos($item, ' ') !== FALSE) + if (preg_match('/^([^\s]+) (AS )*(.+)$/i', $item, $matches)) { - $alias = strstr($item, ' '); - $item = substr($item, 0, - strlen($alias)); + $item = $matches[1]; + + // Escape the alias + $alias = ' '.$matches[2].$this->escape_identifiers($matches[3]); } else { diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 5d0a2ae2c..3b45bbada 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1985,7 +1985,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { if (strpos($table, ' ') !== FALSE) { // if the alias is written with the AS keyword, remove it - $table = preg_replace('/ AS /i', ' ', $table); + $table = preg_replace('/\s+AS\s+/i', ' ', $table); // Grab the alias $table = trim(strrchr($table, ' ')); diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 225325d6f..77c968e7c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1089,11 +1089,12 @@ class CI_Form_validation { * Validate IP Address * * @param string + * @param string 'ipv4' or 'ipv6' to validate a specific IP format * @return bool */ - public function valid_ip($ip) + public function valid_ip($ip, $which = '') { - return $this->CI->input->valid_ip($ip); + return $this->CI->input->valid_ip($ip, $which); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 17b360b62..70d622b4b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -145,7 +145,6 @@ Release Date: Not Released - Added a Wincache driver to the :doc:`Caching Library `. - Added a Redis driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - - Input library now supports IPv6. - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. - Core @@ -256,6 +255,8 @@ Release Date: Not Released - Libraries - Further improved MIME type detection in the :doc:`File Uploading Library `. + - Added support for IPv6 to the :doc:`Input Library `. + - Added support for the IP format parameter to the :doc:`Form Validation Library `. - Helpers - url_title() performance and output improved. You can now use any string as the word delimiter, but 'dash' and 'underscore' are still supported. @@ -270,6 +271,9 @@ Bug fixes for 2.1.1 - 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 (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite. +- Fixed a bug - CI_DB_pdo_driver::num_rows() was not returning properly value with SELECT queries, cause it was relying on PDOStatement::rowCount(). +- Fixed a bug (#1059) - CI_Image_lib::clear() was not correctly clearing all necessary object properties, namely width and height. +- Fixed a bud (#1387) - Active Record's ``from()`` method didn't escape table aliases. Version 2.1.0 ============= diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst index 2badffc93..255c6a557 100644 --- a/user_guide_src/source/installation/upgrading.rst +++ b/user_guide_src/source/installation/upgrading.rst @@ -5,7 +5,8 @@ Upgrading From a Previous Version Please read the upgrade notes corresponding to the version you are upgrading from. -- :doc:`Upgrading from 2.0.3 to 2.1.0 ` +- :doc:`Upgrading from 2.1.1 to 3.0.0 ` +- :doc:`Upgrading from 2.1.0 to 2.1.1 ` - :doc:`Upgrading from 2.0.2 to 2.0.3 ` - :doc:`Upgrading from 2.0.1 to 2.0.2 ` - :doc:`Upgrading from 2.0 to 2.0.1 ` diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 028b61c4c..3c0e6eda4 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -884,6 +884,7 @@ Rule Parameter Description **valid_email** No Returns FALSE if the form element does not contain a valid email address. **valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email. **valid_ip** No Returns FALSE if the supplied IP is not valid. + Accepts an optional parameter of 'ipv4' or 'ipv6' to specify an IP format. **valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters. ========================= ========== ============================================================================================= ======================= diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 432bac3c7..7f995f050 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -242,6 +242,9 @@ validates the IP automatically. echo 'Valid'; } +Accepts an optional second string parameter of 'ipv4' or 'ipv6' to specify +an IP format. The default checks for both formats. + $this->input->user_agent() =========================== diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index e8332ee97..5400524a9 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -245,7 +245,7 @@ session class:: CREATE TABLE IF NOT EXISTS `ci_sessions` ( session_id varchar(40) DEFAULT '0' NOT NULL, - ip_address varchar(16) DEFAULT '0' NOT NULL, + ip_address varchar(45) DEFAULT '0' NOT NULL, user_agent varchar(120) NOT NULL, last_activity int(10) unsigned DEFAULT 0 NOT NULL, user_data text NOT NULL, diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index cdd76e322..bb959b002 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -146,7 +146,7 @@ full URL:: The function would return this:: - /news/local/345 + news/local/345 $this->uri->ruri_string() ========================== -- cgit v1.2.3-24-g4f1b From bf94058d537efc78ed2df7009db8b3261ff44619 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 07:05:05 +0300 Subject: Fix issue #1452 --- system/database/DB_driver.php | 51 +++++++++++++++++------ system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_forge.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_result.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_utility.php | 2 +- user_guide_src/source/changelog.rst | 2 + 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index f5a7e2ac0..e34021e50 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1300,38 +1300,63 @@ abstract class CI_DB_driver { $escaped_array = array(); foreach ($item as $k => $v) { - $escaped_array[$this->protect_identifiers($k)] = $this->protect_identifiers($v); + $escaped_array[$this->protect_identifiers($k)] = $this->protect_identifiers($v, $prefix_single, $protect_identifiers, $field_exists); } return $escaped_array; } + // This is basically a bug fix for queries that use MAX, MIN, etc. + // If a parenthesis is found we know that we do not need to + // escape the data or add a prefix. There's probably a more graceful + // way to deal with this, but I'm not thinking of it -- Rick + if (strpos($item, '(') !== FALSE) + { + return $item.$alias; + } + // Convert tabs or multiple spaces into single spaces $item = preg_replace('/\s+/', ' ', $item); + static $preg_ec = array(); + + if (empty($preg_ec)) + { + if (is_array($this->_escape_char)) + { + $preg_ec = array(preg_quote($this->_escape_char[0]), preg_quote($this->_escape_char[1])); + } + else + { + $preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char); + } + } + // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space - if (preg_match('/^([^\s]+) (AS )*(.+)$/i', $item, $matches)) + preg_match('/^(('.$preg_ec[0].'[^'.$preg_ec[1].']+'.$preg_ec[1].')|([^'.$preg_ec[0].'][^\s]+))( AS)*(.+)*$/i', 'Test table]', $matches); + + if (isset($matches[4])) { $item = $matches[1]; - // Escape the alias - $alias = ' '.$matches[2].$this->escape_identifiers($matches[3]); + // Escape the alias, if needed + if ($protect_identifiers === TRUE) + { + $alias = empty($matches[5]) + ? ' '.$this->escape_identifiers(ltrim($matches[4])) + : $matches[4].' '.$this->escape_identifiers(ltrim($matches[5])); + } + else + { + $alias = $matches[4].$matches[5]; + } } else { $alias = ''; } - // This is basically a bug fix for queries that use MAX, MIN, etc. - // If a parenthesis is found we know that we do not need to - // escape the data or add a prefix. There's probably a more graceful - // way to deal with this, but I'm not thinking of it -- Rick - if (strpos($item, '(') !== FALSE) - { - return $item.$alias; - } - // Break the string apart if it contains periods, then insert the table prefix // in the correct location, assuming the period doesn't indicate that we're dealing // with an alias. While we're at it, we will escape the components diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 655a9e90b..eebd6bff8 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 1.0 + * @since Version 2.0.3 * @filesource */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index e6f7e1ac1..ccdb36929 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 1.0 + * @since Version 2.0.3 * @filesource */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index f802383d2..f9d5a0d29 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 1.0 + * @since Version 2.0.3 * @filesource */ diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 5a71b1628..d518cc15a 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 1.0 + * @since Version 2.0.3 * @filesource */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 70d622b4b..5b2f59e7e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -244,6 +244,8 @@ Bug fixes for 3.0 - Fixed a bug (#666) - :doc:`Output library `'s set_content_type() method didn't set the document charset. - Fixed a bug (#784, #861) - :doc:`Database Forge ` method ``create_table()`` used to accept constraints for MSSQL/SQLSRV integer-type columns. - Fixed a bug (#706) - SQLSRV/MSSSQL didn't escape field names. +- Fixed a bug (#1452) - protect_identifiers() didn't properly detect identifiers with spaces in their names. +- Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 62fd52d3cfeea4a2ec73ac5b943e84eeb38953d2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 07:11:41 +0300 Subject: Revert a change in tests/mocks/core/common.php --- tests/mocks/core/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index 8466e47f8..55506a1f6 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -18,7 +18,8 @@ if ( ! function_exists('get_config')) function &get_config() { $test = CI_TestCase::instance(); - return $test->ci_get_config(); + $config = $test->ci_get_config(); + return $config; } } -- cgit v1.2.3-24-g4f1b From 36de42e4a6c1ef552be8b7b3cb0fb86a4363c7d6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 13:55:55 +0300 Subject: Revert a change in tests/mocks/core/common.php --- tests/mocks/core/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index 55506a1f6..a655ee1db 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -7,7 +7,8 @@ if ( ! function_exists('get_instance')) function &get_instance() { $test = CI_TestCase::instance(); - return $test->ci_instance(); + $test = $test->ci_instance(); + return $test; } } -- cgit v1.2.3-24-g4f1b From b30426d50d84631201bcdc93439feaa37ce71df9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 14:08:29 +0300 Subject: Fix count_all() --- 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 e34021e50..d6f9f9c17 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1334,7 +1334,7 @@ abstract class CI_DB_driver { // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space - preg_match('/^(('.$preg_ec[0].'[^'.$preg_ec[1].']+'.$preg_ec[1].')|([^'.$preg_ec[0].'][^\s]+))( AS)*(.+)*$/i', 'Test table]', $matches); + preg_match('/^(('.$preg_ec[0].'[^'.$preg_ec[1].']+'.$preg_ec[1].')|([^'.$preg_ec[0].'][^\s]+))( AS)*(.+)*$/i', $item, $matches); if (isset($matches[4])) { -- cgit v1.2.3-24-g4f1b From 9c14f650c86f54f950695e0c628b33a59d4dd10b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 14:35:07 +0300 Subject: Fix _where() escaping operators --- system/database/DB_query_builder.php | 9 ++++----- system/database/drivers/postgre/postgre_driver.php | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 3b45bbada..7a54fce48 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -426,6 +426,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; + $k = $this->_has_operator($k) + ? $this->protect_identifiers(substr($k, 0, strrpos(rtrim($k), ' ')), FALSE, $escape).strrchr(rtrim($k), ' ') + : $this->protect_identifiers($k, FALSE, $escape); + if (is_null($v) && ! $this->_has_operator($k)) { // value appears not to have been set, assign the test to IS NULL @@ -436,7 +440,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { if ($escape === TRUE) { - $k = $this->protect_identifiers($k, FALSE, $escape); $v = ' '.$this->escape($v); } @@ -445,10 +448,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $k .= ' = '; } } - else - { - $k = $this->protect_identifiers($k, FALSE, $escape); - } $this->qb_where[] = $prefix.$k.$v; if ($this->qb_caching === TRUE) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 7375fbf71..9cce1a403 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -615,6 +615,10 @@ class CI_DB_postgre_driver extends CI_DB { { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; + $k = $this->_has_operator($k) + ? $this->protect_identifiers(substr($k, 0, strrpos(rtrim($k), ' ')), FALSE, $escape).strrchr(rtrim($k), ' ') + : $this->protect_identifiers($k, FALSE, $escape); + if (is_null($v) && ! $this->_has_operator($k)) { // value appears not to have been set, assign the test to IS NULL @@ -625,7 +629,6 @@ class CI_DB_postgre_driver extends CI_DB { { if ($escape === TRUE) { - $k = $this->protect_identifiers($k, FALSE, $escape); $v = ' '.$this->escape($v); } elseif (is_bool($v)) @@ -638,10 +641,6 @@ class CI_DB_postgre_driver extends CI_DB { $k .= ' = '; } } - else - { - $k = $this->protect_identifiers($k, FALSE, $escape); - } $this->qb_where[] = $prefix.$k.$v; if ($this->qb_caching === TRUE) -- cgit v1.2.3-24-g4f1b From d454f0e413ba6df6494b6c0da4d32fac8a17de1c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 14:51:04 +0300 Subject: Add BETWEEN to _has_operator() --- system/database/DB_driver.php | 2 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index d6f9f9c17..48f9fb5ac 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1062,7 +1062,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(\s|<|>|!|=|IS NULL|IS NOT NULL)/i', trim($str)); + return (bool) preg_match('/(\s|<|>|!|=|IS NULL|IS NOT NULL|BETWEEN)/i', trim($str)); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 5b2f59e7e..027163db7 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -246,6 +246,7 @@ Bug fixes for 3.0 - Fixed a bug (#706) - SQLSRV/MSSSQL didn't escape field names. - Fixed a bug (#1452) - protect_identifiers() didn't properly detect identifiers with spaces in their names. - Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array. +- Fixed a bug where _has_operator() didn't detect BETWEEN. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 392b6ad264f045a5b9c19d51d09cb9f5a8675e8a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 15:08:59 +0300 Subject: Fix _where() with multiple condition custom query --- system/database/DB_query_builder.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 7a54fce48..65e2fa749 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -427,7 +427,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; $k = $this->_has_operator($k) - ? $this->protect_identifiers(substr($k, 0, strrpos(rtrim($k), ' ')), FALSE, $escape).strrchr(rtrim($k), ' ') + ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') : $this->protect_identifiers($k, FALSE, $escape); if (is_null($v) && ! $this->_has_operator($k)) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 9cce1a403..ad9ac9000 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -616,7 +616,7 @@ class CI_DB_postgre_driver extends CI_DB { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; $k = $this->_has_operator($k) - ? $this->protect_identifiers(substr($k, 0, strrpos(rtrim($k), ' ')), FALSE, $escape).strrchr(rtrim($k), ' ') + ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') : $this->protect_identifiers($k, FALSE, $escape); if (is_null($v) && ! $this->_has_operator($k)) -- cgit v1.2.3-24-g4f1b From 4db16326a0418776f10802ecdcccb385ff67e363 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 15:12:02 +0300 Subject: Remove a non-existent variable usage --- 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 48f9fb5ac..079ee8d05 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1312,7 +1312,7 @@ abstract class CI_DB_driver { // way to deal with this, but I'm not thinking of it -- Rick if (strpos($item, '(') !== FALSE) { - return $item.$alias; + return $item; } // Convert tabs or multiple spaces into single spaces -- cgit v1.2.3-24-g4f1b From dca9f23d2d24ccf412d239693d2d156a8ee7fabe Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 11 Jun 2012 09:17:14 +0200 Subject: get upload data with index key --- system/libraries/Upload.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 1f6aeeb6b..e422edb6c 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -347,26 +347,34 @@ class CI_Upload { * Returns an associative array containing all of the information * related to the upload, allowing the developer easy access in one array. * + * @param string * @return array */ - public function data() + public function data($index = NULL) { - return array( - 'file_name' => $this->file_name, - 'file_type' => $this->file_type, - 'file_path' => $this->upload_path, - 'full_path' => $this->upload_path.$this->file_name, - 'raw_name' => str_replace($this->file_ext, '', $this->file_name), - 'orig_name' => $this->orig_name, + $data = array( + 'file_name' => $this->file_name, + 'file_type' => $this->file_type, + 'file_path' => $this->upload_path, + 'full_path' => $this->upload_path.$this->file_name, + 'raw_name' => str_replace($this->file_ext, '', $this->file_name), + 'orig_name' => $this->orig_name, 'client_name' => $this->client_name, - 'file_ext' => $this->file_ext, - 'file_size' => $this->file_size, - 'is_image' => $this->is_image(), + 'file_ext' => $this->file_ext, + 'file_size' => $this->file_size, + 'is_image' => $this->is_image(), 'image_width' => $this->image_width, 'image_height' => $this->image_height, 'image_type' => $this->image_type, 'image_size_str' => $this->image_size_str, ); + + if ($index === NULL OR ! isset($data[$index])) + { + return $data; + } + + return $data[$index]; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 37ec30c6d89448cd11c24788c01ff06326de128b Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 11 Jun 2012 09:26:33 +0200 Subject: changelog --- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/libraries/file_uploading.rst | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 027163db7..984183a13 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -146,6 +146,7 @@ Release Date: Not Released - Added a Redis driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. + - Added a index parameter to the data() function in the Upload library. - Core diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index d573fc770..414d84f0b 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -287,6 +287,10 @@ data related to the file you uploaded. Here is the array prototype:: [image_size_str] => width="800" height="200" ) +To return one element from the array:: + + $this->upload->data('file_name'); // Returns: mypic.jpg + Explanation *********** -- cgit v1.2.3-24-g4f1b From 3a7fb04fec6d5a389b8ab40b32403c9db0c40389 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 11 Jun 2012 09:29:16 +0200 Subject: tab fixes --- system/libraries/Upload.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index e422edb6c..287e28106 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -353,16 +353,16 @@ class CI_Upload { public function data($index = NULL) { $data = array( - 'file_name' => $this->file_name, - 'file_type' => $this->file_type, - 'file_path' => $this->upload_path, - 'full_path' => $this->upload_path.$this->file_name, - 'raw_name' => str_replace($this->file_ext, '', $this->file_name), - 'orig_name' => $this->orig_name, + 'file_name' => $this->file_name, + 'file_type' => $this->file_type, + 'file_path' => $this->upload_path, + 'full_path' => $this->upload_path.$this->file_name, + 'raw_name' => str_replace($this->file_ext, '', $this->file_name), + 'orig_name' => $this->orig_name, 'client_name' => $this->client_name, - 'file_ext' => $this->file_ext, - 'file_size' => $this->file_size, - 'is_image' => $this->is_image(), + 'file_ext' => $this->file_ext, + 'file_size' => $this->file_size, + 'is_image' => $this->is_image(), 'image_width' => $this->image_width, 'image_height' => $this->image_height, 'image_type' => $this->image_type, -- cgit v1.2.3-24-g4f1b From 46a0429a02bdf9dcf63c44c3f344417a1e9a5f0f Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 11 Jun 2012 10:37:52 +0200 Subject: fixes --- system/libraries/Upload.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 287e28106..b1d6ad6ca 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -369,12 +369,12 @@ class CI_Upload { 'image_size_str' => $this->image_size_str, ); - if ($index === NULL OR ! isset($data[$index])) + if ( ! empty($index)) { - return $data; + return isset($data[$index]) ? $data[$index] : NULL; } - return $data[$index]; + return $data; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0ee287ea08de5f3098a27230dcd8ca242b2eb793 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 11 Jun 2012 10:38:14 +0200 Subject: fixes --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index b1d6ad6ca..c96daaf15 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -348,7 +348,7 @@ class CI_Upload { * related to the upload, allowing the developer easy access in one array. * * @param string - * @return array + * @return mixed */ public function data($index = NULL) { -- cgit v1.2.3-24-g4f1b From 650b4c000242ad90ed1ca1e56bdee7d42dbdedaa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 12:07:15 +0300 Subject: Remove unused qb_order property + other minor changes --- system/database/DB_query_builder.php | 46 +++++++++++++----------------------- user_guide_src/source/changelog.rst | 2 +- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 65e2fa749..b9d77f1fb 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -53,7 +53,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver { protected $qb_keys = array(); protected $qb_limit = FALSE; protected $qb_offset = FALSE; - protected $qb_order = FALSE; protected $qb_orderby = array(); protected $qb_set = array(); protected $qb_wherein = array(); @@ -942,7 +941,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } elseif (trim($direction) !== '') { - $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC'; + $direction = in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE) ? ' '.$direction : ' ASC'; } @@ -962,12 +961,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $orderby = implode(', ', $temp); } - elseif ($direction !== $this->_random_keyword) + elseif ($direction !== $this->_random_keyword && $escape === TRUE) { - if ($escape === TRUE) - { - $orderby = $this->protect_identifiers($orderby); - } + $orderby = $this->protect_identifiers($orderby); } $this->qb_orderby[] = $orderby_statement = $orderby.$direction; @@ -994,7 +990,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $this->qb_limit = (int) $value; - if ( ! is_null($offset)) + if ( ! empty($offset)) { $this->qb_offset = (int) $offset; } @@ -1069,7 +1065,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->from($table); } - $select = $this->_compile_select(); + $select = $this->_compile_select(); if ($reset === TRUE) { @@ -1092,7 +1088,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string the offset clause * @return object */ - public function get($table = '', $limit = null, $offset = null) + public function get($table = '', $limit = NULL, $offset = NULL) { if ($table !== '') { @@ -1100,7 +1096,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->from($table); } - if ( ! is_null($limit)) + if ( ! empty($limit)) { $this->limit($limit, $offset); } @@ -1165,7 +1161,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->where($where); } - if ( ! is_null($limit)) + if ( ! empty($limit)) { $this->limit($limit, $offset); } @@ -1274,11 +1270,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { ksort($row); // puts $row in the same order as our keys - if ($escape === FALSE) - { - $this->qb_set[] = '('.implode(',', $row).')'; - } - else + if ($escape !== FALSE) { $clean = array(); foreach ($row as $value) @@ -1286,8 +1278,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $clean[] = $this->escape($value); } - $this->qb_set[] = '('.implode(',', $clean).')'; + $row = $clean; } + + $this->qb_set[] = '('.implode(',', $row).')'; } foreach ($keys as $k) @@ -1552,7 +1546,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->where($where); } - if ($limit != NULL) + if ( ! empty($limit)) { $this->limit($limit); } @@ -1873,7 +1867,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->where($where); } - if ($limit != NULL) + if ( ! empty($limit)) { $this->limit($limit); } @@ -1914,7 +1908,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return 'DELETE FROM '.$table .(count($conditions) > 0 ? ' WHERE '.implode(' AND ', $conditions) : '') - .($limit ? ' LIMIT '.$limit : ''); + .($limit ? ' LIMIT '.(int) $limit : ''); } // -------------------------------------------------------------------- @@ -2087,10 +2081,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver { if (count($this->qb_orderby) > 0) { $sql .= "\nORDER BY ".implode(', ', $this->qb_orderby); - if ($this->qb_order !== FALSE) - { - $sql .= ($this->qb_order === 'desc') ? ' DESC' : ' ASC'; - } } // Write the "LIMIT" portion of the query @@ -2320,8 +2310,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { 'qb_no_escape' => array(), 'qb_distinct' => FALSE, 'qb_limit' => FALSE, - 'qb_offset' => FALSE, - 'qb_order' => FALSE + 'qb_offset' => FALSE ) ); } @@ -2344,8 +2333,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { 'qb_like' => array(), 'qb_orderby' => array(), 'qb_keys' => array(), - 'qb_limit' => FALSE, - 'qb_order' => FALSE + 'qb_limit' => FALSE ) ); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 984183a13..259f4e732 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -146,7 +146,7 @@ Release Date: Not Released - Added a Redis driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. - - Added a index parameter to the data() function in the Upload library. + - Added an "index" parameter to the data() method in the :doc:`Upload library `. - Core -- cgit v1.2.3-24-g4f1b From ba2617646eb072be0ecfec8818e332345010fc03 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 14:11:35 +0300 Subject: Fix issue #1455 (introduct in d261b1e89c3d4d5191036d5a5660ef6764e593a0) --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index c70144f7c..09f217530 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1599,7 +1599,7 @@ class CI_Email { $this->_debug_msg[] = '
    '.$cmd.': '.$reply.'
    '; - if (substr($reply, 0, 3) !== $resp) + if ( (int) substr($reply, 0, 3) !== $resp) { $this->_set_error_message('lang:email_smtp_error', $reply); return FALSE; -- cgit v1.2.3-24-g4f1b From c88daba688d309150a7dce43817ab76ec7834bda Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Mon, 11 Jun 2012 13:58:30 +0200 Subject: Optimized now() function. Thanks to @narfbg --- system/helpers/date_helper.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index d5acec23f..b818da9d8 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -50,25 +50,20 @@ if ( ! function_exists('now')) */ function now($timezone = NULL) { - $CI =& get_instance(); - - if (is_null($timezone)) + if (empty($timezone)) { - $timezone = $CI->config->item('timezone'); + $timezone = config_item('timezone'); } - $time = time(); - if(strtolower($timezone) != 'local') + if ($timezone === 'local' OR $timezone === date_default_timezone_get()) { - $local = new DateTime(NULL, new DateTimeZone(date_default_timezone_get())); - $now = new DateTime(NULL, new DateTimeZone($timezone)); - $lcl_offset = $local->getOffset(); - $tz_offset = $now->getOffset(); - $offset = $tz_offset - $lcl_offset; - $time = $time + $offset; + return time(); } - return $time; + $datetime = new DateTime('now', new DateTimeZone($timezone)); + sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second); + + return mktime($hour, $minute, $second, $month, $day, $year); } } -- cgit v1.2.3-24-g4f1b From 71379ca89226fe8af0314a8b70e5dc0f57367255 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 16:12:43 +0300 Subject: Add OFFSET support for SQL Server 2005+ in MSSQL/SQLSRV --- system/database/drivers/mssql/mssql_driver.php | 25 +++++++++++++++++++++++- system/database/drivers/sqlsrv/sqlsrv_driver.php | 25 +++++++++++++++++++++--- user_guide_src/source/changelog.rst | 2 +- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 87094e76e..47dc55844 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -504,7 +504,30 @@ class CI_DB_mssql_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql); + // As of SQL Server 2012 (11.0.*) OFFSET is supported + if (version_compare($this->version(), '11', '>=')) + { + return $sql.' OFFSET '.(int) $offset.' ROWS FETCH NEXT '.(int) $limit.' ROWS ONLY'; + } + + $limit = $offset + $limit; + + // As of SQL Server 2005 (9.0.*) ROW_NUMBER() is supported, + // however an ORDER BY clause is required for it to work + if (version_compare($this->version(), '9', '>=') && $offset && ! empty($this->qb_orderby)) + { + $orderby = 'ORDER BY '.implode(', ', $this->qb_orderby); + + // We have to strip the ORDER BY clause + $sql = trim(substr($sql, 0, strrpos($sql, 'ORDER BY '.$orderby))); + + return 'SELECT '.(count($this->qb_select) === 0 ? '*' : implode(', ', $this->qb_select))." FROM (\n" + .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.$orderby.') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) + ."\n) ".$this->escape_identifiers('CI_subquery') + ."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.((int) $offset + 1).' AND '.$limit; + } + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index eebd6bff8..825c02452 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -463,9 +463,28 @@ class CI_DB_sqlsrv_driver extends CI_DB { protected function _limit($sql, $limit, $offset) { // As of SQL Server 2012 (11.0.*) OFFSET is supported - return version_compare($this->version(), '11', '>=') - ? $sql.' OFFSET '.(int) $offset.' ROWS FETCH NEXT '.(int) $limit.' ROWS ONLY' - : preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql); + if (version_compare($this->version(), '11', '>=')) + { + return $sql.' OFFSET '.(int) $offset.' ROWS FETCH NEXT '.(int) $limit.' ROWS ONLY'; + } + + $limit = $offset + $limit; + + // An ORDER BY clause is required for ROW_NUMBER() to work + if ($offset && ! empty($this->qb_orderby)) + { + $orderby = 'ORDER BY '.implode(', ', $this->qb_orderby); + + // We have to strip the ORDER BY clause + $sql = trim(substr($sql, 0, strrpos($sql, 'ORDER BY '.$orderby))); + + return 'SELECT '.(count($this->qb_select) === 0 ? '*' : implode(', ', $this->qb_select))." FROM (\n" + .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.$orderby.') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) + ."\n) ".$this->escape_identifiers('CI_subquery') + ."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.((int) $offset + 1).' AND '.$limit; + } + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 259f4e732..03b541e3d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -98,7 +98,7 @@ Release Date: Not Released - Added support for optimize_table() in :doc:`Database Utility `. - Added escaping with QUOTE_IDENTIFIER setting detection. - Added port handling support for UNIX-based systems (MSSQL driver). - - Added OFFSET support for SQL Server 2012 and above. + - Added OFFSET support for SQL Server 2005 and above. - Improved support of the Oracle (OCI8) driver, including: - Added DSN string support (Easy Connect and TNS). - Added support for dropping tables to :doc:`Database Forge `. -- cgit v1.2.3-24-g4f1b From df242193f3e785f4c9b802be3432f373fbc34a14 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 16:16:49 +0300 Subject: Alter documentation on requirements for the SQLSRV driver --- user_guide_src/source/general/requirements.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/general/requirements.rst b/user_guide_src/source/general/requirements.rst index d97b7b4b2..d9edfba6d 100644 --- a/user_guide_src/source/general/requirements.rst +++ b/user_guide_src/source/general/requirements.rst @@ -4,5 +4,6 @@ Server Requirements - `PHP `_ version 5.2.4 or newer. - A Database is required for most web application programming. Current - supported databases are MySQL (5.1+), MySQLi, MS SQL, SQLSRV, Oracle, - PostgreSQL, SQLite, SQLite3, CUBRID, Interbase, ODBC and PDO. + supported databases are MySQL (5.1+), MySQLi, Oracle, PostgreSQL, + MS SQL, SQLSRV (SQL Server 2005+), SQLite, SQLite3, CUBRID, Interbase, + ODBC and PDO. -- cgit v1.2.3-24-g4f1b From 88cb278a1e52dd7db5b0ebe2037c12f0dd69c0c1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 20:40:50 +0300 Subject: Fix issue #1456 --- system/database/DB_query_builder.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index b9d77f1fb..7490639dd 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -953,7 +953,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $part = trim($part); if ( ! in_array($part, $this->qb_aliased_tables)) { - $part = $this->protect_identifiers(trim($part)); + $part = preg_match('/^(.+)\s+(ASC|DESC)$/i', $part, $matches) + ? $this->protect_identifiers(rtrim($matches[1])).' '.$matches[2] + : $this->protect_identifiers($part); } $temp[] = $part; @@ -963,7 +965,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } elseif ($direction !== $this->_random_keyword && $escape === TRUE) { - $orderby = $this->protect_identifiers($orderby); + $part = preg_match('/^(.+)\s+(ASC|DESC)$/i', $orderby, $matches) + ? $this->protect_identifiers(rtrim($matches[1])).' '.$matches[2] + : $this->protect_identifiers($orderby); } $this->qb_orderby[] = $orderby_statement = $orderby.$direction; -- cgit v1.2.3-24-g4f1b From e6302791d229e42c8fc42a3982a10eb63508197f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 21:28:22 +0300 Subject: Fix a join() issue --- system/database/DB_query_builder.php | 2 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 7490639dd..b99d4c607 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -343,7 +343,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->_track_aliases($table); // Strip apart the condition and protect the identifiers - if (preg_match('/([\[\w\.]+)([\W\s]+)(.+)/', $cond, $match)) + if (preg_match('/([\[\w\.-]+)([\W\s]+)(.+)/', $cond, $match)) { $cond = $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 03b541e3d..5627f0221 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -248,6 +248,7 @@ Bug fixes for 3.0 - Fixed a bug (#1452) - protect_identifiers() didn't properly detect identifiers with spaces in their names. - Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array. - Fixed a bug where _has_operator() didn't detect BETWEEN. +- Fixed a bug where :doc:`Query Builder `'s join failed with identifiers containing dashes. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 5d28176a76355b230f1c4e1858475def4e34fa4c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 22:05:40 +0300 Subject: Fix issue #1264 --- system/database/DB_forge.php | 54 ++++++++++++++++++++-- system/database/DB_utility.php | 13 +++--- system/database/drivers/cubrid/cubrid_utility.php | 6 +-- .../database/drivers/interbase/interbase_forge.php | 8 ++++ system/database/drivers/sqlite/sqlite_forge.php | 8 ++++ system/database/drivers/sqlite3/sqlite3_forge.php | 8 ++++ user_guide_src/source/changelog.rst | 1 + 7 files changed, 85 insertions(+), 13 deletions(-) diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index ff5eb3fe6..9b7639289 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -72,6 +72,11 @@ abstract class CI_DB_forge { return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; } + if ( ! empty($this->db->data_cache['db_names'])) + { + $this->db->data_cache['db_names'][] = $db_name; + } + return TRUE; } @@ -99,6 +104,15 @@ abstract class CI_DB_forge { return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; } + if ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($db_name), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + return TRUE; } @@ -209,7 +223,18 @@ abstract class CI_DB_forge { $sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists); $this->_reset(); - return is_bool($sql) ? $sql : $this->db->query($sql); + + if (is_bool($sql)) + { + return $sql; + } + + if (($result = $this->db->query($sql)) !== FALSE && ! empty($this->db->data_cache['table_names'])) + { + $this->db->data_cache['table_names'][] = $$this->db->dbprefix.$table; + } + + return $result; } // -------------------------------------------------------------------- @@ -231,7 +256,19 @@ abstract class CI_DB_forge { return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - return $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name))); + $result = $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name))); + + // Update table list cache + if ($result && ! empty($this->db->data_cache['table_names'])) + { + $key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['table_names'][$key]); + } + } + + return $result; } // -------------------------------------------------------------------- @@ -255,10 +292,21 @@ abstract class CI_DB_forge { return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - return $this->db->query(sprintf($this->_rename_table, + $result = $this->db->query(sprintf($this->_rename_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name), $this->db->escape_identifiers($this->db->dbprefix.$new_table_name)) ); + + if ($result && ! empty($this->db->data_cache['table_names'])) + { + $key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE); + if ($key !== FALSE) + { + $this->db->data_cache['table_names'][$key] = $this->db->dbprefix.$new_table_name; + } + } + + return $result; } // -------------------------------------------------------------------- diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 02c921834..6a3b40779 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -35,7 +35,6 @@ abstract class CI_DB_utility extends CI_DB_forge { public $db; - public $data_cache = array(); // Platform specific SQL strings // Just setting those defaults to FALSE as they are mostly MySQL-specific @@ -60,29 +59,29 @@ abstract class CI_DB_utility extends CI_DB_forge { public function list_databases() { // Is there a cached result? - if (isset($this->data_cache['db_names'])) + if (isset($this->db->data_cache['db_names'])) { - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } elseif ($this->_list_databases === FALSE) { return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - $this->data_cache['db_names'] = array(); + $this->db->data_cache['db_names'] = array(); $query = $this->db->query($this->_list_databases); if ($query === FALSE) { - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } for ($i = 0, $c = count($query); $i < $c; $i++) { - $this->data_cache['db_names'] = current($query[$i]); + $this->db->data_cache['db_names'] = current($query[$i]); } - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php index c8cee99b6..ea8feb4e2 100644 --- a/system/database/drivers/cubrid/cubrid_utility.php +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -41,12 +41,12 @@ class CI_DB_cubrid_utility extends CI_DB_utility { */ public function list_databases() { - if (isset($this->data_cache['db_names'])) + if (isset($this->db->data_cache['db_names'])) { - return $this->data_cache['db_names']; + return $this->db->data_cache['db_names']; } - return $this->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id); + return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index 3f9967f1f..d1b006e80 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -67,6 +67,14 @@ class CI_DB_interbase_forge extends CI_DB_forge { { return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } return TRUE; } diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index 71eed7df4..e02e327f3 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -61,6 +61,14 @@ class CI_DB_sqlite_forge extends CI_DB_forge { { return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } return TRUE; } diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index f8bd11656..6a76ba929 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -66,6 +66,14 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { { return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } return TRUE; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 5627f0221..fb137e460 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -249,6 +249,7 @@ Bug fixes for 3.0 - Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array. - Fixed a bug where _has_operator() didn't detect BETWEEN. - Fixed a bug where :doc:`Query Builder `'s join failed with identifiers containing dashes. +- Fixed a bug (#1264) - :doc:`Database Forge ` and :doc:`Database Utilities ` didn't update/reset the databases and tables list cache when a table or a database is created, dropped or renamed. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 1d1d7ffc3868fd76b46fdce093fab0ce89320e94 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jun 2012 22:35:35 +0300 Subject: Fix an issue introduced in 88cb278a1e52dd7db5b0ebe2037c12f0dd69c0c1 --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index b99d4c607..645ac3969 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -965,7 +965,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } elseif ($direction !== $this->_random_keyword && $escape === TRUE) { - $part = preg_match('/^(.+)\s+(ASC|DESC)$/i', $orderby, $matches) + $orderby = preg_match('/^(.+)\s+(ASC|DESC)$/i', $orderby, $matches) ? $this->protect_identifiers(rtrim($matches[1])).' '.$matches[2] : $this->protect_identifiers($orderby); } -- cgit v1.2.3-24-g4f1b From 428702387ca071db4686ec6d6c60bd35b01c33e4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 01:30:20 +0300 Subject: join() with multiple conditions and optional escape parameter --- system/database/DB_query_builder.php | 52 ++++++++++++++++++++++++++++++------ user_guide_src/source/changelog.rst | 50 ++++++++++++++++++---------------- 2 files changed, 71 insertions(+), 31 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 645ac3969..488b294e4 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -83,6 +83,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * Generates the SELECT portion of the query * * @param string + * @param mixed * @return object */ public function select($select = '*', $escape = NULL) @@ -92,6 +93,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $select = explode(',', $select); } + // If the escape value was not set will will base it on the global setting + is_bool($escape) OR $escape = $this->_protect_identifiers; + foreach ($select as $val) { $val = trim($val); @@ -320,15 +324,16 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string * @param string the join condition * @param string the type of join + * @param string wether not to try to escape identifiers * @return object */ - public function join($table, $cond, $type = '') + public function join($table, $cond, $type = '', $escape = TRUE) { if ($type !== '') { $type = strtoupper(trim($type)); - if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'))) + if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'), TRUE)) { $type = ''; } @@ -342,12 +347,39 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // in the protect_identifiers to know whether to add a table prefix $this->_track_aliases($table); - // Strip apart the condition and protect the identifiers - if (preg_match('/([\[\w\.-]+)([\W\s]+)(.+)/', $cond, $match)) + // Split multiple conditions + if ($escape === TRUE && preg_match_all('/\sAND\s|\sOR\s/i', $cond, $m, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) + { + $newcond = ''; + $m[0][] = array('', strlen($cond)); + + for ($i = 0, $c = count($m[0]), $s = 0; + $i < $c; + $s += $m[0][$i][1] + strlen($m[0][$i][0]), $i++) + { + $temp = substr($cond, $s, $m[0][$i][1]); + + $newcond .= preg_match('/([\[\w\.-]+)([\W\s]+)(.+)/i', $temp, $match) + ? $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]) + : $temp; + + $newcond .= $m[0][$i][0]; + } + + $cond = $newcond; + } + // Split apart the condition and protect the identifiers + elseif ($escape === TRUE && preg_match('/([\[\w\.-]+)([\W\s]+)(.+)/i', $cond, $match)) { $cond = $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); } + // Do we want to escape the table name? + if ($escape === TRUE) + { + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); + } + // Assemble the JOIN statement $this->qb_join[] = $join = $type.'JOIN '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; @@ -370,6 +402,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * * @param mixed * @param mixed + * @param bool * @return object */ public function where($key, $value = NULL, $escape = TRUE) @@ -387,6 +420,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * * @param mixed * @param mixed + * @param bool * @return object */ public function or_where($key, $value = NULL, $escape = TRUE) @@ -404,6 +438,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param mixed * @param mixed * @param string + * @param mixed * @return object */ protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL) @@ -416,10 +451,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // If the escape value was not set will will base it on the global setting - if ( ! is_bool($escape)) - { - $escape = $this->_protect_identifiers; - } + $escape = $this->_protect_identifiers; foreach ($key as $k => $v) { @@ -851,6 +883,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * * @param string * @param string + * @param bool * @return object */ public function having($key, $value = '', $escape = TRUE) @@ -867,6 +900,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * * @param string * @param string + * @param bool * @return object */ public function or_having($key, $value = '', $escape = TRUE) @@ -883,6 +917,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * * @param string * @param string + * @param string + * @param bool * @return object */ protected function _having($key, $value = '', $type = 'AND ', $escape = TRUE) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index fb137e460..2c76ea43f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -63,14 +63,17 @@ Release Date: Not Released - Database - - Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern. - - Added the ability to insert objects with insert_batch() in :doc:`Query Builder `. - - Added new :doc:`Query Builder ` methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete(). - - Adding $escape parameter to the order_by() method, this enables ordering by custom fields. + - :doc:`Query Builder ` changes include: + - Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern. + - Added the ability to insert objects with insert_batch(). + - Added new methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete(). + - Added an optional order_by() parameter that allows to disable escaping (useful for custom fields). + - Added an optional join() parameter that allows to disable escaping. + - Added support for join() with multiple conditions. - Improved support for the MySQLi driver, including: - - OOP style of the PHP extension is now used, instead of the procedural aliases. - - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. - - Added persistent connections support for PHP >= 5.3. + - OOP style of the PHP extension is now used, instead of the procedural aliases. + - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. + - Added persistent connections support for PHP >= 5.3. - Added 'dsn' configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID). - Improved PDO database support. - Added Interbase/Firebird database support via the "interbase" driver. @@ -78,14 +81,16 @@ Release Date: Not Released - Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message. - Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class. - Improved support of the PostgreSQL driver, including: - - 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 update_batch() support. - - Removed limit() and order_by() support for UPDATE and DELETE queries in as PostgreSQL does not support those features. + - 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 update_batch() support. + - Removed limit() and order_by() support for UPDATE and DELETE queries in as PostgreSQL does not support those features. - 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 protect_identifiers() and renamed internal method _protect_identifiers() to it instead - it was just an alias. + - Renamed internal method _escape_identifiers() to escape_identifiers(). + - Updated escape_identifiers() to accept an array of fields as well as strings. - MySQL and MySQLi drivers now require at least MySQL version 5.1. - db_set_charset() now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1). - Added support for SQLite3 database driver. @@ -100,16 +105,15 @@ Release Date: Not Released - Added port handling support for UNIX-based systems (MSSQL driver). - Added OFFSET support for SQL Server 2005 and above. - Improved support of the Oracle (OCI8) driver, including: - - Added DSN string support (Easy Connect and TNS). - - Added support for dropping tables to :doc:`Database Forge `. - - Added support for listing database schemas to :doc:`Database Utilities `. - - Generally improved for speed and cleaned up all of its components. - - *Row* result methods now really only fetch only the needed number of rows, instead of depending entirely on result(). - - num_rows() is now only called explicitly by the developer and no longer re-executes statements. - - Added replace() support for SQLite. - - Renamed internal method _escape_identifiers() to escape_identifiers(). - - Updated escape_identifiers() to accept an array of fields as well as strings. - - Added SQLite support for drop_table() in :doc:`Database Forge `. + - Added DSN string support (Easy Connect and TNS). + - Added support for drop_table() in :doc:`Database Forge `. + - Added support for list_databases() in :doc:`Database Utilities `. + - Generally improved for speed and cleaned up all of its components. + - *Row* result methods now really only fetch only the needed number of rows, instead of depending entirely on result(). + - num_rows() is now only called explicitly by the developer and no longer re-executes statements. + - Improved support of the Sqlite driver, including: + - Added support for replace() in :doc:`Query Builder `. + - Added support for drop_table() in :doc:`Database Forge `. - Added ODBC support for create_database(), drop_database() and drop_table() in :doc:`Database Forge `. - Added PDO support for create_database(), drop_database and drop_table() in :doc:`Database Forge `. - Added unbuffered_row() method for getting a row without prefetching whole result (consume less memory). -- cgit v1.2.3-24-g4f1b From c73df1de471d4dc849942e718e17d97a04c6fd20 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 01:43:03 +0300 Subject: Add changelog entry for issue #7 --- 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 2c76ea43f..6d2971103 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -252,8 +252,9 @@ Bug fixes for 3.0 - Fixed a bug (#1452) - protect_identifiers() didn't properly detect identifiers with spaces in their names. - Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array. - Fixed a bug where _has_operator() didn't detect BETWEEN. -- Fixed a bug where :doc:`Query Builder `'s join failed with identifiers containing dashes. +- Fixed a bug where :doc:`Query Builder `'s join() method failed with identifiers containing dashes. - Fixed a bug (#1264) - :doc:`Database Forge ` and :doc:`Database Utilities ` didn't update/reset the databases and tables list cache when a table or a database is created, dropped or renamed. +- Fixed a bug (#7) - :doc:`Query Builder `'s join() method only escaped one set of conditions. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 079fbfcde095230f304e889217f897031a948f61 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 02:26:58 +0300 Subject: Changed APPPATH, BASEPATH and VIEWPATH to be absolute paths (fixes issue #1321) and removed EXT constant --- index.php | 46 +++++++++++++++++++++++++------------ user_guide_src/source/changelog.rst | 8 +++++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/index.php b/index.php index 3b00dd360..680dccfea 100644 --- a/index.php +++ b/index.php @@ -178,9 +178,11 @@ if (defined('ENVIRONMENT')) { $system_path = realpath($system_path).'/'; } - - // ensure there's a trailing slash - $system_path = rtrim($system_path, '/').'/'; + else + { + // Ensure there's a trailing slash + $system_path = rtrim($system_path, '/').'/'; + } // Is the system path correct? if ( ! is_dir($system_path)) @@ -196,10 +198,6 @@ if (defined('ENVIRONMENT')) // The name of THIS file define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); - // The PHP file extension - // this global constant is deprecated. - define('EXT', '.php'); - // Path to the system folder define('BASEPATH', str_replace('\\', '/', $system_path)); @@ -212,6 +210,11 @@ if (defined('ENVIRONMENT')) // The path to the "application" folder if (is_dir($application_folder)) { + if (realpath($system_path) !== FALSE) + { + $application_folder = realpath($application_folder); + } + define('APPPATH', $application_folder.'/'); } else @@ -226,20 +229,33 @@ if (defined('ENVIRONMENT')) } // The path to the "views" folder - if (is_dir($view_folder)) - { - define ('VIEWPATH', $view_folder .'/'); - } - else + if ( ! is_dir($view_folder)) { - if ( ! is_dir(APPPATH.'views/')) + if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.'/')) + { + $view_folder = APPPATH.$view_folder; + } + elseif ( ! is_dir(APPPATH.'views/')) { header('HTTP/1.1 503 Service Unavailable.', TRUE, '503'); exit('Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF); } + else + { + $view_folder = APPPATH.'views'; + } + } - define ('VIEWPATH', APPPATH.'views/' ); + if (realpath($view_folder) !== FALSE) + { + $view_folder = realpath($view_folder).'/'; } + else + { + $view_folder = rtrim($view_folder, '/').'/'; + } + + define ('VIEWPATH', $view_folder); /* * -------------------------------------------------------------------- @@ -251,4 +267,4 @@ if (defined('ENVIRONMENT')) require_once BASEPATH.'core/CodeIgniter.php'; /* End of file index.php */ -/* Location: ./index.php */ +/* Location: ./index.php */ \ No newline at end of file diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 6d2971103..ebf29791b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -33,15 +33,18 @@ Release Date: Not Released - Added support for ics Calendar files to mimes.php - Updated support for xml ('application/xml') and xsl ('application/xml', 'text/xsl') files in mimes.php. - Updated support for doc files in mimes.php. + - Added some more doctypes. - Added Romanian and Greek characters in foreign_characters.php. - Changed logger to only chmod when file is first created. - Removed previously deprecated SHA1 Library. - Removed previously deprecated use of ``$autoload['core']`` in application/config/autoload.php. Only entries in ``$autoload['libraries']`` are auto-loaded now. - - Added some more doctypes. + - Removed previously deprecated EXT constant. - Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties. - Moved error templates to "application/views/errors" - - Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per Env. + - Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per environment. + - Changed detection of ``$view_folder`` so that if it's not found in the current path, it will now also be searched for under the application folder. + - Path constants BASEPATH, APPPATH and VIEWPATH are now (internally) defined as absolute paths. - Helpers @@ -255,6 +258,7 @@ Bug fixes for 3.0 - Fixed a bug where :doc:`Query Builder `'s join() method failed with identifiers containing dashes. - Fixed a bug (#1264) - :doc:`Database Forge ` and :doc:`Database Utilities ` didn't update/reset the databases and tables list cache when a table or a database is created, dropped or renamed. - Fixed a bug (#7) - :doc:`Query Builder `'s join() method only escaped one set of conditions. +- Fixed a bug (#1321) - Core Exceptions class couldn't find the errors/ folder in some cases. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 0d2c06ea1d96ea3f35dd1e7856977a24cec43233 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 02:33:45 +0300 Subject: Change file permissions for system/core/*.php and system/database/DB.php so that they don't differ from the rest --- system/core/Benchmark.php | 0 system/core/CodeIgniter.php | 0 system/core/Config.php | 0 system/core/Exceptions.php | 0 system/core/Hooks.php | 0 system/core/Input.php | 0 system/core/Lang.php | 0 system/core/Model.php | 0 system/core/Output.php | 0 system/core/Router.php | 0 system/core/Security.php | 0 system/core/URI.php | 0 system/database/DB.php | 0 13 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 system/core/Benchmark.php mode change 100755 => 100644 system/core/CodeIgniter.php mode change 100755 => 100644 system/core/Config.php mode change 100755 => 100644 system/core/Exceptions.php mode change 100755 => 100644 system/core/Hooks.php mode change 100755 => 100644 system/core/Input.php mode change 100755 => 100644 system/core/Lang.php mode change 100755 => 100644 system/core/Model.php mode change 100755 => 100644 system/core/Output.php mode change 100755 => 100644 system/core/Router.php mode change 100755 => 100644 system/core/Security.php mode change 100755 => 100644 system/core/URI.php mode change 100755 => 100644 system/database/DB.php diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php old mode 100755 new mode 100644 diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php old mode 100755 new mode 100644 diff --git a/system/core/Config.php b/system/core/Config.php old mode 100755 new mode 100644 diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php old mode 100755 new mode 100644 diff --git a/system/core/Hooks.php b/system/core/Hooks.php old mode 100755 new mode 100644 diff --git a/system/core/Input.php b/system/core/Input.php old mode 100755 new mode 100644 diff --git a/system/core/Lang.php b/system/core/Lang.php old mode 100755 new mode 100644 diff --git a/system/core/Model.php b/system/core/Model.php old mode 100755 new mode 100644 diff --git a/system/core/Output.php b/system/core/Output.php old mode 100755 new mode 100644 diff --git a/system/core/Router.php b/system/core/Router.php old mode 100755 new mode 100644 diff --git a/system/core/Security.php b/system/core/Security.php old mode 100755 new mode 100644 diff --git a/system/core/URI.php b/system/core/URI.php old mode 100755 new mode 100644 diff --git a/system/database/DB.php b/system/database/DB.php old mode 100755 new mode 100644 -- cgit v1.2.3-24-g4f1b From 782de1101f37b21ff2183fde5b2ed8569d8c287d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 03:04:50 +0300 Subject: Added MySQLi backup() support --- system/database/drivers/mysqli/mysqli_utility.php | 119 +++++++++++++++++++++- user_guide_src/source/changelog.rst | 5 +- 2 files changed, 120 insertions(+), 4 deletions(-) diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 27d4ef817..5d2bdbce0 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -46,9 +46,124 @@ class CI_DB_mysqli_utility extends CI_DB_utility { */ protected function _backup($params = array()) { - // Currently unsupported - return $this->db->display_error('db_unsuported_feature'); + if (count($params) === 0) + { + return FALSE; + } + + // Extract the prefs for simplicity + extract($params); + + // Build the output + $output = ''; + foreach ( (array) $tables as $table) + { + // Is the table in the "ignore" list? + if (in_array($table, (array) $ignore, TRUE)) + { + continue; + } + + // Get the table schema + $query = $this->db->query('SHOW CREATE TABLE '.$this->db->escape_identifiers($this->db->database.'.'.$table)); + + // No result means the table name was invalid + if ($query === FALSE) + { + continue; + } + + // Write out the table schema + $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; + + if ($add_drop === TRUE) + { + $output .= 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table).';'.$newline.$newline; + } + + $i = 0; + $result = $query->result_array(); + foreach ($result[0] as $val) + { + if ($i++ % 2) + { + $output .= $val.';'.$newline.$newline; + } + } + + // If inserts are not needed we're done... + if ($add_insert === FALSE) + { + continue; + } + + // Grab all the data from the current table + $query = $this->db->query('SELECT * FROM '.$this->db->protect_identifiers($table)); + + if ($query->num_rows() === 0) + { + continue; + } + + // Fetch the field names and determine if the field is an + // integer type. We use this info to decide whether to + // surround the data with quotes or not + + $i = 0; + $field_str = ''; + $is_int = array(); + while ($field = $query->result_id->fetch_field()) + { + // Most versions of MySQL store timestamp as a string + $is_int[$i] = in_array(strtolower($field->type), + array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'), + TRUE); + + // Create a string of field names + $field_str .= $this->db->escape_identifiers($field->name).', '; + $i++; + } + + // Trim off the end comma + $field_str = preg_replace('/, $/' , '', $field_str); + + // Build the insert string + foreach ($query->result_array() as $row) + { + $val_str = ''; + + $i = 0; + foreach ($row as $v) + { + // Is the value NULL? + if ($v === NULL) + { + $val_str .= 'NULL'; + } + else + { + // Escape the data if it's not an integer + $val_str .= ($is_int[$i] === FALSE) ? $this->db->escape($v) : $v; + } + + // Append a comma + $val_str .= ', '; + $i++; + } + + // Remove the comma at the end of the string + $val_str = preg_replace('/, $/' , '', $val_str); + + // Build the INSERT string + $output .= 'INSERT INTO '.$this->db->protect_identifiers($table).' ('.$field_str.') VALUES ('.$val_str.');'.$newline; + } + + $output .= $newline.$newline; + } + + return $output; } + } /* End of file mysqli_utility.php */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ebf29791b..f91a1dc99 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -77,6 +77,7 @@ Release Date: Not Released - OOP style of the PHP extension is now used, instead of the procedural aliases. - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. - Added persistent connections support for PHP >= 5.3. + - Added support for backup() in :doc:`Database Utilities `. - Added 'dsn' configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID). - Improved PDO database support. - Added Interbase/Firebird database support via the "interbase" driver. @@ -86,7 +87,7 @@ Release Date: Not Released - Improved support of the PostgreSQL driver, including: - 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 support for optimize_table() in :doc:`Database Utilities ` (rebuilds table indexes). - Added boolean data type support in escape(). - Added update_batch() support. - Removed limit() and order_by() support for UPDATE and DELETE queries in as PostgreSQL does not support those features. @@ -114,7 +115,7 @@ Release Date: Not Released - Generally improved for speed and cleaned up all of its components. - *Row* result methods now really only fetch only the needed number of rows, instead of depending entirely on result(). - num_rows() is now only called explicitly by the developer and no longer re-executes statements. - - Improved support of the Sqlite driver, including: + - Improved support of the SQLite driver, including: - Added support for replace() in :doc:`Query Builder `. - Added support for drop_table() in :doc:`Database Forge `. - Added ODBC support for create_database(), drop_database() and drop_table() in :doc:`Database Forge `. -- cgit v1.2.3-24-g4f1b From c9195a75e7d3d06524c9a5ce97f4f4c30c69019b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 03:49:03 +0300 Subject: Add changelog for pull #1017 --- system/libraries/Cache/drivers/Cache_file.php | 4 ++-- user_guide_src/source/changelog.rst | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 1b57c8929..08231963e 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -26,7 +26,7 @@ */ /** - * CodeIgniter Memcached Caching Class + * CodeIgniter File Caching Class * * @package CodeIgniter * @subpackage Libraries @@ -202,4 +202,4 @@ class CI_Cache_file extends CI_Driver { } /* End of file Cache_file.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ \ No newline at end of file diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f91a1dc99..f342abf15 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -256,10 +256,11 @@ Bug fixes for 3.0 - Fixed a bug (#1452) - protect_identifiers() didn't properly detect identifiers with spaces in their names. - Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array. - Fixed a bug where _has_operator() didn't detect BETWEEN. -- Fixed a bug where :doc:`Query Builder `'s join() method failed with identifiers containing dashes. +- Fixed a bug in :doc:`Query Builder `'s join() method where it failed with identifiers containing dashes. - Fixed a bug (#1264) - :doc:`Database Forge ` and :doc:`Database Utilities ` didn't update/reset the databases and tables list cache when a table or a database is created, dropped or renamed. - Fixed a bug (#7) - :doc:`Query Builder `'s join() method only escaped one set of conditions. - Fixed a bug (#1321) - Core Exceptions class couldn't find the errors/ folder in some cases. +- Fixed a bug in the File-based :doc:`Cache Library ` driver's get_metadata() method where a non-existent array key was accessed for the TTL value. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 7eb7ebfaa05b99c12746a7042116afa51d55260e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 10:26:27 +0300 Subject: Switch protected properties in Pagination class to public and fix 2 issues from d261b1e89c3d4d5191036d5a5660ef6764e593a0 --- system/libraries/Pagination.php | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index a91159c98..ed86b89bc 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -36,38 +36,38 @@ */ class CI_Pagination { - protected $base_url = ''; // The page we are linking to - protected $prefix = ''; // A custom prefix added to the path. - protected $suffix = ''; // A custom suffix added to the path. - protected $total_rows = 0; // Total number of items (database results) - protected $per_page = 10; // Max number of items you want shown per page - protected $num_links = 2; // Number of "digit" links to show before/after the currently viewed page - protected $cur_page = 0; // The current page being viewed - protected $use_page_numbers = FALSE; // Use page number for segment instead of offset - protected $first_link = '‹ First'; - protected $next_link = '>'; - protected $prev_link = '<'; - protected $last_link = 'Last ›'; - protected $uri_segment = 3; - protected $full_tag_open = ''; - protected $full_tag_close = ''; - protected $first_tag_open = ''; - protected $first_tag_close = ' '; - protected $last_tag_open = ' '; - protected $last_tag_close = ''; - protected $first_url = ''; // Alternative URL for the First Page. - protected $cur_tag_open = ' '; - protected $cur_tag_close = ''; - protected $next_tag_open = ' '; - protected $next_tag_close = ' '; - protected $prev_tag_open = ' '; - protected $prev_tag_close = ''; - protected $num_tag_open = ' '; - protected $num_tag_close = ''; - protected $page_query_string = FALSE; - protected $query_string_segment = 'per_page'; - protected $display_pages = TRUE; - protected $anchor_class = ''; + public $base_url = ''; // The page we are linking to + public $prefix = ''; // A custom prefix added to the path. + public $suffix = ''; // A custom suffix added to the path. + public $total_rows = 0; // Total number of items (database results) + public $per_page = 10; // Max number of items you want shown per page + public $num_links = 2; // Number of "digit" links to show before/after the currently viewed page + public $cur_page = 0; // The current page being viewed + public $use_page_numbers = FALSE; // Use page number for segment instead of offset + public $first_link = '‹ First'; + public $next_link = '>'; + public $prev_link = '<'; + public $last_link = 'Last ›'; + public $uri_segment = 3; + public $full_tag_open = ''; + public $full_tag_close = ''; + public $first_tag_open = ''; + public $first_tag_close = ' '; + public $last_tag_open = ' '; + public $last_tag_close = ''; + public $first_url = ''; // Alternative URL for the First Page. + public $cur_tag_open = ' '; + public $cur_tag_close = ''; + public $next_tag_open = ' '; + public $next_tag_close = ' '; + public $prev_tag_open = ' '; + public $prev_tag_close = ''; + public $num_tag_open = ' '; + public $num_tag_close = ''; + public $page_query_string = FALSE; + public $query_string_segment = 'per_page'; + public $display_pages = TRUE; + public $anchor_class = ''; /** * Constructor @@ -97,7 +97,7 @@ class CI_Pagination { { if ($key === 'anchor_class') { - $this->anchor_class = ($val !== '') ? 'class="'.$val.'" ' : ''; + $this->anchor_class = ($val) ? 'class="'.$val.'" ' : ''; } elseif (isset($this->$key)) { @@ -145,7 +145,7 @@ class CI_Pagination { if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - if ($CI->input->get($this->query_string_segment) !== $base_page) + if ($CI->input->get($this->query_string_segment) != $base_page) { $this->cur_page = (int) $CI->input->get($this->query_string_segment); } -- cgit v1.2.3-24-g4f1b From 5a1e5e34207b9b30ff42200158074953ca1cabab Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 11:28:26 +0300 Subject: Add support for the anchor 'rel' attribute in the Pagination library --- system/libraries/Pagination.php | 44 ++++++++++++++++++++++---- user_guide_src/source/changelog.rst | 5 +-- user_guide_src/source/libraries/pagination.rst | 24 ++++++++++++++ 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index ed86b89bc..cdec736ff 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -68,6 +68,7 @@ class CI_Pagination { public $query_string_segment = 'per_page'; public $display_pages = TRUE; public $anchor_class = ''; + public $attr_rel = TRUE; /** * Constructor @@ -212,7 +213,8 @@ class CI_Pagination { if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1)) { $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url; - $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'">'.$this->first_link.''.$this->first_tag_close; + $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'"'.$this->_attr_rel('start').'>' + .$this->first_link.''.$this->first_tag_close; } // Render the "previous" link @@ -222,12 +224,14 @@ class CI_Pagination { if ($i === $base_page && $this->first_url !== '') { - $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.''.$this->prev_tag_close; + $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'"'.$this->_attr_rel('prev').'>' + .$this->prev_link.''.$this->prev_tag_close; } else { $i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix; - $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.''.$this->prev_tag_close; + $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'"'.$this->_attr_rel('prev').'>' + .$this->prev_link.''.$this->prev_tag_close; } } @@ -252,13 +256,15 @@ class CI_Pagination { if ($n === '' && $this->first_url !== '') { - $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close; + $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'"'.$this->_attr_rel('start').'>' + .$loop.''.$this->num_tag_close; } else { $n = ($n === '') ? '' : $this->prefix.$n.$this->suffix; - $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close; + $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'"'.$this->_attr_rel().'>' + .$loop.''.$this->num_tag_close; } } } @@ -270,7 +276,8 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page; - $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->next_link.''.$this->next_tag_close; + $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$this->_attr_rel('next').'>' + .$this->next_link.''.$this->next_tag_close; } // Render the "Last" link @@ -278,7 +285,8 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page; - $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.''.$this->last_tag_close; + $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$this->_attr_rel().'>' + .$this->last_link.''.$this->last_tag_close; } // Kill double slashes. Note: Sometimes we can end up with a double slash @@ -289,6 +297,28 @@ class CI_Pagination { return $this->full_tag_open.$output.$this->full_tag_close; } + // -------------------------------------------------------------------- + + /** + * Add "rel" attribute + * + * @param string + * @return string + */ + protected function _attr_rel($value = '') + { + if (empty($this->attr_rel) OR ($this->attr_rel === TRUE && empty($value))) + { + return ''; + } + elseif ( ! is_bool($this->attr_rel)) + { + $value = $this->attr_rel; + } + + return ' rel="'.$value.'"'; + } + } /* End of file Pagination.php */ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f342abf15..82116c9b1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -154,7 +154,8 @@ Release Date: Not Released - Added a Redis driver to the :doc:`Caching Library `. - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. - - Added an "index" parameter to the data() method in the :doc:`Upload library `. + - Added an "index" parameter to the data() method in the :doc:`Upload Library `. + - Added support for the anchor "rel" attribute in the :doc:`Pagination Library `. - Core @@ -177,7 +178,7 @@ Bug fixes for 3.0 - Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) where a mis-spelling was in the form validation language file. - Fixed a bug (#159, #163) that mishandled Query Builder nested transactions because _trans_depth was not getting incremented. -- Fixed a bug (#737, #75) where pagination anchor class was not set properly when using initialize method. +- Fixed a bug (#737, #75) - :doc:`Pagination ` anchor class was not set properly when using initialize method. - Fixed a bug (#419) - auto_link() now recognizes URLs that come after a word boundary. - Fixed a bug (#724) - is_unique in form validation now checks that you are connected to a database. - Fixed a bug (#647) - _get_mod_time() in Zip library no longer generates stat failed errors. diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index f1653c913..560755fb6 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -254,3 +254,27 @@ Adding a class to every anchor If you want to add a class attribute to every link rendered by the pagination class, you can set the config "anchor_class" equal to the classname you want. + +:: + + $config['anchor_class'] = 'myclass'; // class="myclass" + +********************************** +Changing the "rel" attribute value +********************************** + +By default, the rel attribute will be automatically put under the +following conditions: + +- rel="start" for the "first" link +- rel="prev" for the "previous" link +- rel="next" for the "next" link + +If you want to disable the rel attribute, or change its value, you +can set the 'attr_rel' config option:: + + // Disable + $config['attr_rel'] = FALSE; + + // Use a custom value on all anchors + $config['attr_rel'] = 'custom_value'; // produces: rel="custom_value" \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f696c1fe8df29d54a933804a6f4d182a5a59c7a2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 12:14:51 +0300 Subject: Fix issue #1202 --- system/libraries/Encrypt.php | 1 + user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index ce5e030b0..8ffd93aea 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -213,6 +213,7 @@ class CI_Encrypt { $dec = base64_decode($string); if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE) { + $this->set_mode($current_mode); return FALSE; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 82116c9b1..4962caa7d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -262,6 +262,7 @@ Bug fixes for 3.0 - Fixed a bug (#7) - :doc:`Query Builder `'s join() method only escaped one set of conditions. - Fixed a bug (#1321) - Core Exceptions class couldn't find the errors/ folder in some cases. - Fixed a bug in the File-based :doc:`Cache Library ` driver's get_metadata() method where a non-existent array key was accessed for the TTL value. +- Fixed a bug (#1202) - :doc:`Encryption Library ` encode_from_legacy() didn't set back the encrypt mode on failure. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 806ca600d3669343ee7ae90a9b5d65be9dfdbefe Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 12:51:27 +0300 Subject: Some more index.php improvements --- index.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index 680dccfea..380d1017b 100644 --- a/index.php +++ b/index.php @@ -174,9 +174,9 @@ if (defined('ENVIRONMENT')) chdir(dirname(__FILE__)); } - if (realpath($system_path) !== FALSE) + if (($_temp = realpath($system_path)) !== FALSE) { - $system_path = realpath($system_path).'/'; + $system_path = $_temp.'/'; } else { @@ -187,6 +187,7 @@ if (defined('ENVIRONMENT')) // Is the system path correct? if ( ! is_dir($system_path)) { + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); exit('Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME)); } @@ -210,9 +211,9 @@ if (defined('ENVIRONMENT')) // The path to the "application" folder if (is_dir($application_folder)) { - if (realpath($system_path) !== FALSE) + if (($_temp = realpath($system_path)) !== FALSE) { - $application_folder = realpath($application_folder); + $application_folder = $_temp; } define('APPPATH', $application_folder.'/'); @@ -221,7 +222,7 @@ if (defined('ENVIRONMENT')) { if ( ! is_dir(BASEPATH.$application_folder.'/')) { - header('HTTP/1.1 503 Service Unavailable.', TRUE, '503'); + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); exit('Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF); } @@ -237,7 +238,7 @@ if (defined('ENVIRONMENT')) } elseif ( ! is_dir(APPPATH.'views/')) { - header('HTTP/1.1 503 Service Unavailable.', TRUE, '503'); + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); exit('Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF); } else @@ -246,7 +247,7 @@ if (defined('ENVIRONMENT')) } } - if (realpath($view_folder) !== FALSE) + if (($_temp = realpath($view_folder)) !== FALSE) { $view_folder = realpath($view_folder).'/'; } -- cgit v1.2.3-24-g4f1b From cce918033a99186cd76019d022571a8d9321d899 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 13:25:31 +0300 Subject: Fix APPPATH --- index.php | 4 ++-- system/core/Loader.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 380d1017b..ad98013ca 100644 --- a/index.php +++ b/index.php @@ -211,7 +211,7 @@ if (defined('ENVIRONMENT')) // The path to the "application" folder if (is_dir($application_folder)) { - if (($_temp = realpath($system_path)) !== FALSE) + if (($_temp = realpath($application_folder)) !== FALSE) { $application_folder = $_temp; } @@ -256,7 +256,7 @@ if (defined('ENVIRONMENT')) $view_folder = rtrim($view_folder, '/').'/'; } - define ('VIEWPATH', $view_folder); + define('VIEWPATH', $view_folder); /* * -------------------------------------------------------------------- diff --git a/system/core/Loader.php b/system/core/Loader.php index 09e948714..94739c74a 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -668,7 +668,7 @@ class CI_Loader { * @param bool * @return void */ - public function add_package_path($path, $view_cascade=TRUE) + public function add_package_path($path, $view_cascade = TRUE) { $path = rtrim($path, '/').'/'; -- cgit v1.2.3-24-g4f1b From 4e9538fe19b09c0dc588542cfb7f793348b83bf7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 14:16:53 +0300 Subject: Fix issue #145 --- system/database/DB_driver.php | 26 +++++++++----------------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 079ee8d05..88a3b388f 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,35 +596,27 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (strpos($sql, $this->bind_marker) === FALSE) + if (preg_match_all('/(>|<|=|!)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) { return $sql; } - - if ( ! is_array($binds)) + elseif ( ! is_array($binds)) { $binds = array($binds); } - - // Get the sql segments around the bind markers - $segments = explode($this->bind_marker, $sql); - - // The count of bind should be 1 less then the count of segments - // If there are more bind arguments trim it down - if (count($binds) >= count($segments)) + else { - $binds = array_slice($binds, 0, count($segments)-1); + // Make sure we're using numeric keys + $binds = array_values($binds); } - // Construct the binded query - $result = $segments[0]; - $i = 0; - foreach ($binds as $bind) + + for ($i = count($matches) - 1; $i >= 0; $i--) { - $result .= $this->escape($bind).$segments[++$i]; + $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], 1); } - return $result; + return $sql; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4962caa7d..ab3e01394 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -263,6 +263,7 @@ Bug fixes for 3.0 - Fixed a bug (#1321) - Core Exceptions class couldn't find the errors/ folder in some cases. - Fixed a bug in the File-based :doc:`Cache Library ` driver's get_metadata() method where a non-existent array key was accessed for the TTL value. - Fixed a bug (#1202) - :doc:`Encryption Library ` encode_from_legacy() didn't set back the encrypt mode on failure. +- Fixed a bug (#145) - compile_binds() failed when the bind marker was present in a literal string within the query. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 6a56d50cc03ec74a905718e711b48253cc267f00 Mon Sep 17 00:00:00 2001 From: Kevin Wood-Friend Date: Tue, 12 Jun 2012 09:54:01 -0400 Subject: Modified Form Validation class's set_rules() so it can now handle an array of rules, instead of just a string --- system/libraries/Form_validation.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 77c968e7c..6cbe032c7 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -187,6 +187,12 @@ class CI_Form_validation { return $this; } + // Convert an array of rules to a string + if (is_array($rules)) + { + $rules = implode('|', $rules); + } + // No fields? Nothing to do... if ( ! is_string($field) OR ! is_string($rules) OR $field === '') { -- cgit v1.2.3-24-g4f1b From fe8f5e25c8127c0ff7ebb77dd5f9b982e9eb9270 Mon Sep 17 00:00:00 2001 From: Kevin Wood-Friend Date: Tue, 12 Jun 2012 09:56:00 -0400 Subject: Updated changelog for set_rules() accepting an array of rules, as well as a string. --- 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 ab3e01394..33b413163 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -147,6 +147,7 @@ Release Date: Not Released - _execute() now considers input data to be invalid if a specified rule is not found. - Removed method is_numeric() as it exists as a native PHP function and _execute() will find and use that (the 'is_numeric' rule itself is deprecated since 1.6.1). - Native PHP functions used as rules can now accept an additional parameter, other than the data itself. + - Updated set_rules() to accept an array of rules as well as a string. - Changed the :doc:`Session Library ` to select only one row when using database sessions. - Added all_flashdata() method to session class. Returns an associative array of only flashdata. - Allowed for setting table class defaults in a config file. -- cgit v1.2.3-24-g4f1b From feb14dac4e7a417a48344a5188a8ad8074871df4 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 12 Jun 2012 16:09:36 +0200 Subject: Changed the config parameter. The session's _get_time() function has also changed. --- application/config/config.php | 4 ++-- system/helpers/date_helper.php | 2 +- system/libraries/Session.php | 14 +++++++++++--- user_guide_src/source/helpers/date_helper.rst | 6 ++---- user_guide_src/source/installation/upgrade_300.rst | 5 ++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 12ef77c76..fd6a1aeb0 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -359,7 +359,7 @@ $config['compress_output'] = FALSE; /* |-------------------------------------------------------------------------- -| Master Timezone +| Master Time Reference |-------------------------------------------------------------------------- | | You can set any PHP supported timezones to be the master timezone when @@ -367,7 +367,7 @@ $config['compress_output'] = FALSE; | time. | */ -$config['timezone'] = 'local'; +$config['time_reference'] = 'local'; /* diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index b818da9d8..131508f69 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('now')) { if (empty($timezone)) { - $timezone = config_item('timezone'); + $timezone = config_item('time_reference'); } if ($timezone === 'local' OR $timezone === date_default_timezone_get()) diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 7beedd96b..9fdf744c3 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -786,9 +786,17 @@ class CI_Session { */ protected function _get_time() { - return (strtolower($this->time_reference) === 'gmt') - ? mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y')) - : time(); + $timezone = config_item('time_reference'); + + if ($timezone === 'local' OR $timezone === date_default_timezone_get()) + { + return time(); + } + + $datetime = new DateTime('now', new DateTimeZone($timezone)); + sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second); + + return mktime($hour, $minute, $second, $month, $day, $year); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index 33b39bd5b..7bbfd4f15 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -30,11 +30,9 @@ it will return time(). :returns: integer :: + echo now("Australia/Victoria"); - $tz = "Australia/Victoria"; - echo now($tz); - -If a timezone is not provided, it will return time() based on "timezone" setting. +If a timezone is not provided, it will return time() based on "time_reference" setting. mdate() ======= diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index c2c3899ee..debf9662c 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -45,9 +45,8 @@ need to rename the `$active_record` variable to `$query_builder`. Step 5: Change your use of the Date helper's now() function =========================================================== -Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>` -You must replace $config['time_reference'] with $config['timezone'] in your config.php file. You can select all -PHP supported timezones, listed here: `Supported timezones `_. You can also +Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>`. +You can now select all PHP supported timezones in the `time_reference` setting, listed here: `Supported timezones `_. You can also use 'local' if you want to get time(). Step 6: Move your errors folder -- cgit v1.2.3-24-g4f1b From f9311136d9f821b7b0b1f2fa7c933f51803d4f96 Mon Sep 17 00:00:00 2001 From: Kevin Wood-Friend Date: Tue, 12 Jun 2012 10:57:57 -0400 Subject: Updated Form Validation's documentation for set_rules() now accepting an array of rules --- user_guide_src/source/libraries/form_validation.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 3c0e6eda4..3bcad7ba6 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -304,6 +304,10 @@ Give it a try! Submit your form without the proper data and you'll see new error messages that correspond to your new rules. There are numerous rules available which you can read about in the validation reference. +.. note:: You can also pass an array of rules to set_rules(), instead of a string. Example:: + + $this->form_validation->set_rules('username', 'Username', array('required', 'min_length[5]')); + Prepping Data ============= @@ -935,7 +939,7 @@ $this->form_validation->set_rules(); :param string $field: The field name :param string $label: The field label - :param string $rules: The rules, seperated by a pipe "|" + :param mixed $rules: The rules, as a string with rules separated by a pipe "|", or an array or rules. :rtype: Object Permits you to set validation rules, as described in the tutorial -- cgit v1.2.3-24-g4f1b From 97827bc9ddad61f51ceb595e8b8b5441d4d991c2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 21:20:05 +0300 Subject: Fix issue #1460 --- 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 88a3b388f..63d3372cf 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,7 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (preg_match_all('/(>|<|=|!)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) { return $sql; } -- cgit v1.2.3-24-g4f1b From 29953ddc989e2ae26afedefd99e347f2d692d0ec Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 21:48:13 +0300 Subject: Additional improvements to compile_binds() --- system/database/DB_driver.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 63d3372cf..e0266b2b6 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,12 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (empty($binds)) OR empty($this->bind_marker)) + { + return $sql; + } + elseif (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', + $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) { return $sql; } @@ -610,10 +615,9 @@ abstract class CI_DB_driver { $binds = array_values($binds); } - - for ($i = count($matches) - 1; $i >= 0; $i--) + for ($i = count($matches) - 1, $l = strlen($this->bind_marker); $i >= 0; $i--) { - $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], 1); + $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], $l); } return $sql; -- cgit v1.2.3-24-g4f1b From 63779194b6788edfa8899ed3c86c653d0933ce3b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:04:49 +0300 Subject: Fix a syntax error --- 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 e0266b2b6..e04463429 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,7 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (empty($binds)) OR empty($this->bind_marker)) + if (empty($binds) OR empty($this->bind_marker)) { return $sql; } -- cgit v1.2.3-24-g4f1b From 6984d153f68f1f89fa6800143498cc4914441d66 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:10:17 +0300 Subject: Add a changelog entry --- 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 33b413163..e955209b1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -265,6 +265,7 @@ Bug fixes for 3.0 - Fixed a bug in the File-based :doc:`Cache Library ` driver's get_metadata() method where a non-existent array key was accessed for the TTL value. - Fixed a bug (#1202) - :doc:`Encryption Library ` encode_from_legacy() didn't set back the encrypt mode on failure. - Fixed a bug (#145) - compile_binds() failed when the bind marker was present in a literal string within the query. +- Fixed a bug in protect_identifiers() where if passed along with the field names, operators got escaped as well. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 9cf12d1de76c2696233a437e0cdc7266bb846ae6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:19:59 +0300 Subject: Fix docs for Input library (issue #1465) --- user_guide_src/source/libraries/input.rst | 37 +++++++++---------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 7f995f050..8c6f7c849 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -42,14 +42,14 @@ this:: Please refer to the :doc:`Security class ` documentation for information on using XSS Filtering in your application. -Using POST, COOKIE, or SERVER Data -================================== +Using POST, GET, COOKIE, or SERVER Data +======================================= -CodeIgniter comes with three helper functions that let you fetch POST, +CodeIgniter comes with four helper methods that let you fetch POST, GET, COOKIE or SERVER items. The main advantage of using the provided functions rather than fetching an item directly ($_POST['something']) -is that the functions will check to see if the item is set and return -false (boolean) if not. This lets you conveniently use data without +is that the methods will check to see if the item is set and return +NULL if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally you might do something like this:: @@ -73,8 +73,8 @@ looking for:: $this->input->post('some_data'); -The function returns FALSE (boolean) if the item you are attempting to -retrieve does not exist. +The function returns NULL if the item you are attempting to retrieve +does not exist. The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE; @@ -130,7 +130,9 @@ $this->input->cookie() This function is identical to the post function, only it fetches cookie data:: - $this->input->cookie('some_data', TRUE); + $this->input->cookie('some_cookie'); + $this->input->cookie('some_cookie, TRUE); // with XSS filter + $this->input->server() ====================== @@ -195,25 +197,6 @@ parameters:: $this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); -$this->input->cookie() -====================== - -Lets you fetch a cookie. The first parameter will contain the name of -the cookie you are looking for (including any prefixes):: - - cookie('some_cookie'); - -The function returns NULL if the item you are attempting to -retrieve does not exist. - -The second optional parameter lets you run the data through the XSS -filter. It's enabled by setting the second parameter to boolean TRUE; - -:: - - cookie('some_cookie', TRUE); - - $this->input->ip_address() =========================== -- cgit v1.2.3-24-g4f1b From 22c3e73573d2828cec6183866b162359f873a949 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:21:36 +0300 Subject: Another input library docs fix --- user_guide_src/source/libraries/input.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 8c6f7c849..c0b9c6589 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -59,9 +59,10 @@ With CodeIgniter's built in functions you can simply do this:: $something = $this->input->post('something'); -The three functions are: +The four methods are: - $this->input->post() +- $this->input->get() - $this->input->cookie() - $this->input->server() -- cgit v1.2.3-24-g4f1b From 10cbdf091b3cdbc72847dad28a1dce03a92119b6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 13:32:30 +0300 Subject: Really fix compile_binds() --- system/database/DB_driver.php | 44 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index e04463429..1fece5cf7 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,28 +596,54 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (empty($binds) OR empty($this->bind_marker)) - { - return $sql; - } - elseif (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', - $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (empty($binds) OR empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE) { return $sql; } elseif ( ! is_array($binds)) { - $binds = array($binds); + $binds = array($this->escape($binds)); + $bind_count = 1; } else { // Make sure we're using numeric keys $binds = array_values($binds); + $bind_count = count($binds); + + // Escape the bind values + for ($i = 0; $i < $bind_count; $i++) + { + $binds[$i] = $this->escape($binds[$i]); + } } - for ($i = count($matches) - 1, $l = strlen($this->bind_marker); $i >= 0; $i--) + // Make sure not to replace a chunk inside a string that happens to match the bind marker + if ($c = preg_match_all("/'[^']*'/i", $sql, $matches)) + { + $ml = strlen($this->bind_marker); + $c = preg_match_all('/'.preg_quote($this->bind_marker).'/i', + str_replace($matches[0], + str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]), + $sql, $c), + $matches, PREG_OFFSET_CAPTURE); + + // Bind values' count must match the count of markers in the query + if ($bind_count !== $c) + { + return $sql; + } + + do + { + $c--; + $sql = substr_replace($sql, $binds[$c], $matches[0][$c][1], $ml); + } + while ($c !== 0); + } + elseif (substr_count($sql, $this->bind_marker) === count($binds)) { - $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], $l); + return str_replace($this->bind_marker, $binds, $sql, $bind_count); } return $sql; -- cgit v1.2.3-24-g4f1b From af915ce01e4e5424a7a4ea67e4e3018a40752a89 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 19:03:06 +0300 Subject: Switch compile_binds() to use substr_replace() instead of str_replace() --- system/database/DB_driver.php | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 1fece5cf7..d056bdb90 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -602,7 +602,7 @@ abstract class CI_DB_driver { } elseif ( ! is_array($binds)) { - $binds = array($this->escape($binds)); + $binds = array($binds); $bind_count = 1; } else @@ -610,18 +610,14 @@ abstract class CI_DB_driver { // Make sure we're using numeric keys $binds = array_values($binds); $bind_count = count($binds); - - // Escape the bind values - for ($i = 0; $i < $bind_count; $i++) - { - $binds[$i] = $this->escape($binds[$i]); - } } + // We'll need the marker length later + $ml = strlen($this->bind_marker); + // Make sure not to replace a chunk inside a string that happens to match the bind marker if ($c = preg_match_all("/'[^']*'/i", $sql, $matches)) { - $ml = strlen($this->bind_marker); $c = preg_match_all('/'.preg_quote($this->bind_marker).'/i', str_replace($matches[0], str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]), @@ -633,18 +629,18 @@ abstract class CI_DB_driver { { return $sql; } - - do - { - $c--; - $sql = substr_replace($sql, $binds[$c], $matches[0][$c][1], $ml); - } - while ($c !== 0); } - elseif (substr_count($sql, $this->bind_marker) === count($binds)) + elseif (($c = preg_match_all('/'.preg_quote($this->bind_marker).'/i', $sql, $matches, PREG_OFFSET_CAPTURE)) !== $bind_count) + { + return $sql; + } + + do { - return str_replace($this->bind_marker, $binds, $sql, $bind_count); + $c--; + $sql = substr_replace($sql, $this->escape($binds[$c]), $matches[0][$c][1], $ml); } + while ($c !== 0); return $sql; } -- cgit v1.2.3-24-g4f1b From 7400965017f87c3aba18bf75ed7d732359fd577d Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Wed, 13 Jun 2012 22:57:50 +0200 Subject: Fixed some stuff in documentation. --- application/config/config.php | 7 ++++--- system/helpers/date_helper.php | 4 ++-- user_guide_src/source/helpers/date_helper.rst | 9 ++++++--- user_guide_src/source/installation/upgrade_300.rst | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index fd6a1aeb0..31ff2024d 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -362,9 +362,10 @@ $config['compress_output'] = FALSE; | Master Time Reference |-------------------------------------------------------------------------- | -| You can set any PHP supported timezones to be the master timezone when -| you call the now() function. 'local' string can be used to get the local -| time. +| Options are 'local' or any PHP supported timezone. This pref tells the +| system whether to use your server's local time as the master 'now' +| reference, or convert it to any PHP supported timezone. See the 'date +| helper' page of the user guide for information regarding date handling. | */ $config['time_reference'] = 'local'; diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 131508f69..a5c46e47b 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -42,8 +42,8 @@ if ( ! function_exists('now')) /** * Get "now" time * - * Returns time() based on the timezone parameter or on the "timezone" - * setting + * Returns time() based on the timezone parameter or on the + * "time_reference" setting * * @param string * @return int diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index 7bbfd4f15..1b7177fc2 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -20,9 +20,12 @@ The following functions are available: now() ===== -Returns the current time as a Unix timestamp, based on the "timezone" parameter. -All PHP available timezones are supported. You can also use 'local' timezone, and -it will return time(). +Returns the current time as a Unix timestamp, referenced either to your +server's local time or any PHP suported timezone, based on the "time reference" +setting in your config file. If you do not intend to set your master time reference +to any other PHP suported timezone (which you'll typically do if you run a site that +lets each user set their own timezone settings) there is no benefit to using this +function over PHP's time() function. .. php:method:: now($timezone = NULL) diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index debf9662c..d8a3d5bc1 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -46,8 +46,8 @@ Step 5: Change your use of the Date helper's now() function =========================================================== Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>`. -You can now select all PHP supported timezones in the `time_reference` setting, listed here: `Supported timezones `_. You can also -use 'local' if you want to get time(). +You can now select all PHP supported timezones in the `time_reference` setting, listed here: +`Supported timezones `_. You can also use 'local' if you want to get time(). Step 6: Move your errors folder =============================== -- cgit v1.2.3-24-g4f1b From d461934184d95b0cfb2feec93f27b621ef72a5c2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 02:27:25 +0300 Subject: Fix issue #10 + URI class speed improvements --- system/core/URI.php | 20 ++++++++++++-------- user_guide_src/source/changelog.rst | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index a575bc36e..2e661ed4c 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -119,7 +119,7 @@ class CI_URI { } // No PATH_INFO?... What about QUERY_STRING? - $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); + $path = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); if (trim($path, '/') !== '') { $this->_set_uri_string($path); @@ -163,7 +163,7 @@ class CI_URI { * @param string * @return void */ - public function _set_uri_string($str) + protected function _set_uri_string($str) { // Filter out control characters $str = remove_invisible_characters($str, FALSE); @@ -177,8 +177,8 @@ class CI_URI { /** * Detects the URI * - * This function will detect the URI automatically and fix the query string - * if necessary. + * This function will detect the URI automatically + * and fix the query string if necessary. * * @return string */ @@ -189,7 +189,6 @@ class CI_URI { return ''; } - $uri = $_SERVER['REQUEST_URI']; if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); @@ -198,14 +197,19 @@ class CI_URI { { $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } + else + { + $uri = $_SERVER['REQUEST_URI']; + } // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. - if (strncmp($uri, '?/', 2) === 0) + if (strpos($uri, '?/') === 0) { $uri = substr($uri, 2); } - $parts = preg_split('#\?#i', $uri, 2); + + $parts = explode('?', $uri, 2); $uri = $parts[0]; if (isset($parts[1])) { @@ -223,7 +227,7 @@ class CI_URI { return '/'; } - $uri = parse_url($uri, PHP_URL_PATH); + $uri = parse_url('pseudo://hostname/'.$uri, PHP_URL_PATH); // Do some final cleaning of the URI and return it return str_replace(array('//', '../'), '/', trim($uri, '/')); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e955209b1..039e8acf3 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -266,11 +266,12 @@ Bug fixes for 3.0 - Fixed a bug (#1202) - :doc:`Encryption Library ` encode_from_legacy() didn't set back the encrypt mode on failure. - Fixed a bug (#145) - compile_binds() failed when the bind marker was present in a literal string within the query. - Fixed a bug in protect_identifiers() where if passed along with the field names, operators got escaped as well. +- Fixed a bug (#10) - :doc:`URI Library ` internal method _detect_uri() failed with paths containing a colon. Version 2.1.1 ============= -Release Date: Not Released +Release Date: June 13, 2012 - General Changes - Fixed support for docx, xlsx files in mimes.php. @@ -295,7 +296,6 @@ Bug fixes for 2.1.1 - Fixed a bug (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite. - Fixed a bug - CI_DB_pdo_driver::num_rows() was not returning properly value with SELECT queries, cause it was relying on PDOStatement::rowCount(). - Fixed a bug (#1059) - CI_Image_lib::clear() was not correctly clearing all necessary object properties, namely width and height. -- Fixed a bud (#1387) - Active Record's ``from()`` method didn't escape table aliases. Version 2.1.0 ============= -- cgit v1.2.3-24-g4f1b From d163e0b219b8afacea3cd0d1d7c2ce5bb6f8a933 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 03:09:53 +0300 Subject: Polish changes from pull #1233 - Session class already has the time_reference setting - 'GMT' is a valid timezone, so nothing needs to be changed in order to work properly (upgrade notes) - Altered some description text --- application/config/config.php | 6 +++--- system/libraries/Session.php | 12 +++++------- user_guide_src/source/changelog.rst | 3 ++- user_guide_src/source/installation/upgrade_300.rst | 11 ++--------- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 31ff2024d..7da889f81 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -362,9 +362,9 @@ $config['compress_output'] = FALSE; | Master Time Reference |-------------------------------------------------------------------------- | -| Options are 'local' or any PHP supported timezone. This pref tells the -| system whether to use your server's local time as the master 'now' -| reference, or convert it to any PHP supported timezone. See the 'date +| Options are 'local' or any PHP supported timezone. This preference tells +| the system whether to use your server's local time as the master 'now' +| reference, or convert it to the configured one timezone. See the 'date | helper' page of the user guide for information regarding date handling. | */ diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 9fdf744c3..72a942b8a 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -149,11 +149,11 @@ class CI_Session { public $flashdata_key = 'flash'; /** - * Function to use to get the current time + * Timezone to use for the current time * * @var string */ - public $time_reference = 'time'; + public $time_reference = 'local'; /** * Probablity level of garbage collection of old sessions @@ -203,7 +203,7 @@ class CI_Session { // manually via the $params array above or via the config file foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) { - $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); + $this->$key = isset($params[$key]) ? $params[$key] : $this->CI->config->item($key); } if ($this->encryption_key === '') @@ -786,14 +786,12 @@ class CI_Session { */ protected function _get_time() { - $timezone = config_item('time_reference'); - - if ($timezone === 'local' OR $timezone === date_default_timezone_get()) + if ($this->time_reference === 'local' OR $this->time_reference === date_default_timezone_get()) { return time(); } - $datetime = new DateTime('now', new DateTimeZone($timezone)); + $datetime = new DateTime('now', new DateTimeZone($this->time_reference)); sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second); return mktime($hour, $minute, $second, $month, $day, $year); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1f5bcb648..06bfba887 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -48,7 +48,7 @@ Release Date: Not Released - Helpers - - Date helper will now return now() based on the timezone you specify. + - :doc:`Date Helper ` function now() now works with all timezone strings supported by PHP. - ``create_captcha()`` accepts additional colors parameter, allowing for color customization. - ``url_title()`` will now trim extra dashes from beginning and end. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. @@ -173,6 +173,7 @@ Release Date: Not Released - Added get_content_type() method to the :doc:`Output Library `. - Added get_mimes() function to system/core/Commons.php to return the config/mimes.php array. - Added a second argument to set_content_type() in the :doc:`Output Library ` that allows setting the document charset as well. + - $config['time_reference'] now supports all timezone strings supported by PHP. Bug fixes for 3.0 ------------------ diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index d8a3d5bc1..c70737cff 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -42,14 +42,7 @@ need to rename the `$active_record` variable to `$query_builder`. // $active_record = TRUE; $query_builder = TRUE; -Step 5: Change your use of the Date helper's now() function -=========================================================== - -Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>`. -You can now select all PHP supported timezones in the `time_reference` setting, listed here: -`Supported timezones `_. You can also use 'local' if you want to get time(). - -Step 6: Move your errors folder +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 +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 a8262ba2fe0e11302b8d81e1afba71d4f96cd6d7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 03:16:44 +0300 Subject: Fix an issue from d461934184d95b0cfb2feec93f27b621ef72a5c2 --- system/core/URI.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index 2e661ed4c..ef1a12650 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -189,11 +189,11 @@ class CI_URI { return ''; } - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) { - $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + $uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); } - elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0) { $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } -- cgit v1.2.3-24-g4f1b From fb859791182edd2f46479cd69ea4615daebed655 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 03:32:19 +0300 Subject: And yet another missed line from the last one --- system/core/URI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/URI.php b/system/core/URI.php index ef1a12650..a997525ee 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -195,7 +195,7 @@ class CI_URI { } elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0) { - $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + $uri = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME']))); } else { -- cgit v1.2.3-24-g4f1b From 43cfd0c37ca241618f33eae87fec720a5bcf13d6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 11:18:26 +0300 Subject: Comment out _set_uri_string() test as it is no longer callable from outside the class --- tests/codeigniter/core/URI_test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index 0ba694b46..60ed1a4e9 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -9,6 +9,10 @@ class URI_test extends CI_TestCase { // -------------------------------------------------------------------- + /* As of the following commit, _set_uri_string() is a protected method: + + https://github.com/EllisLab/CodeIgniter/commit/d461934184d95b0cfb2feec93f27b621ef72a5c2 + public function test_set_uri_string() { // Slashes get killed @@ -18,6 +22,7 @@ class URI_test extends CI_TestCase { $this->uri->_set_uri_string('nice/uri'); $this->assertEquals('nice/uri', $this->uri->uri_string); } + */ // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From e1c8ee76f4756442094106320d9577c2c7595959 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 11:35:11 +0300 Subject: Alter now() tests --- tests/codeigniter/helpers/date_helper_test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 4b747b864..bcb1477bc 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -13,6 +13,8 @@ class Date_helper_test extends CI_TestCase { public function test_now_local() { + /* + // This stub job, is simply to cater $config['time_reference'] $config = $this->getMock('CI_Config'); $config->expects($this->any()) @@ -22,6 +24,10 @@ class Date_helper_test extends CI_TestCase { // Add the stub to our test instance $this->ci_instance_var('config', $config); + */ + + $this->ci_set_config('time_reference', 'local'); + $this->assertEquals(time(), now()); } @@ -29,6 +35,8 @@ class Date_helper_test extends CI_TestCase { public function test_now_gmt() { + /* + // This stub job, is simply to cater $config['time_reference'] $config = $this->getMock('CI_Config'); $config->expects($this->any()) @@ -38,6 +46,10 @@ class Date_helper_test extends CI_TestCase { // Add the stub to our stdClass $this->ci_instance_var('config', $config); + */ + + $this->ci_set_config('time_reference', 'gmt'); + $t = time(); $this->assertEquals( mktime(gmdate('H', $t), gmdate('i', $t), gmdate('s', $t), gmdate('m', $t), gmdate('d', $t), gmdate('Y', $t)), -- cgit v1.2.3-24-g4f1b From 0ddff314d619e5d24bdf07f3da33c779f5b6e2c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 13:18:07 +0300 Subject: test_now_gmt() -> test_now_utc() --- tests/codeigniter/helpers/date_helper_test.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index bcb1477bc..242935116 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -33,7 +33,7 @@ class Date_helper_test extends CI_TestCase { // ------------------------------------------------------------------------ - public function test_now_gmt() + public function test_now_utc() { /* @@ -41,18 +41,17 @@ class Date_helper_test extends CI_TestCase { $config = $this->getMock('CI_Config'); $config->expects($this->any()) ->method('item') - ->will($this->returnValue('gmt')); + ->will($this->returnValue('UTC')); // Add the stub to our stdClass $this->ci_instance_var('config', $config); */ - $this->ci_set_config('time_reference', 'gmt'); + $this->ci_set_config('time_reference', 'UTC'); - $t = time(); $this->assertEquals( - mktime(gmdate('H', $t), gmdate('i', $t), gmdate('s', $t), gmdate('m', $t), gmdate('d', $t), gmdate('Y', $t)), + gmmktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')), now() ); } -- cgit v1.2.3-24-g4f1b From 3ed533109309326a858c778dfea5cb9186f965b4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 13:21:07 +0300 Subject: Some optimizations to the date helper tests --- tests/codeigniter/helpers/date_helper_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 242935116..1d397ac81 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -51,7 +51,7 @@ class Date_helper_test extends CI_TestCase { $this->ci_set_config('time_reference', 'UTC'); $this->assertEquals( - gmmktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')), + gmmktime(date('G'), date('i'), date('s'), date('n'), date('j'), date('Y')), now() ); } @@ -196,9 +196,9 @@ class Date_helper_test extends CI_TestCase { public function test_local_to_gmt() { $this->assertEquals( - mktime( - gmdate('H', $this->time), gmdate('i', $this->time), gmdate('s', $this->time), - gmdate('m', $this->time), gmdate('d', $this->time), gmdate('Y', $this->time) + gmmktime( + date('G', $this->time), date('i', $this->time), date('s', $this->time), + date('n', $this->time), date('j', $this->time), date('Y', $this->time) ), local_to_gmt($this->time) ); -- cgit v1.2.3-24-g4f1b From 3bbbd26ecb60966b07c597310ae241c432bce198 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 13:35:32 +0300 Subject: Some optimizations to the date helper --- system/helpers/date_helper.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index a5c46e47b..d5036f645 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -314,13 +314,13 @@ if ( ! function_exists('local_to_gmt')) $time = time(); } - return mktime( - gmdate('H', $time), - gmdate('i', $time), - gmdate('s', $time), - gmdate('m', $time), - gmdate('d', $time), - gmdate('Y', $time) + return gmmktime( + date('H', $time), + date('i', $time), + date('s', $time), + date('m', $time), + date('d', $time), + date('Y', $time) ); } } @@ -375,9 +375,7 @@ if ( ! function_exists('mysql_to_unix')) // since the formatting changed with MySQL 4.1 // YYYY-MM-DD HH:MM:SS - $time = str_replace('-', '', $time); - $time = str_replace(':', '', $time); - $time = str_replace(' ', '', $time); + $time = str_replace(array('-', ':', ' '), '', $time); // YYYYMMDDHHMMSS return mktime( -- cgit v1.2.3-24-g4f1b From 19c83f6ec6dd29b2ecbeba87801d275f4e247678 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 14:33:33 +0300 Subject: Add changelog entry for issue #1387 --- 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 06bfba887..7748f9b37 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -269,6 +269,7 @@ Bug fixes for 3.0 - Fixed a bug (#145) - compile_binds() failed when the bind marker was present in a literal string within the query. - Fixed a bug in protect_identifiers() where if passed along with the field names, operators got escaped as well. - Fixed a bug (#10) - :doc:`URI Library ` internal method _detect_uri() failed with paths containing a colon. +- Fixed a bug (#1387) - :doc:`Query Builder `'s from() method didn't escape table aliases. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 3dad2e714189b992248261c78d780b322b3c73da Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 15:10:56 +0300 Subject: Replace strncmp() usage with strpos() --- system/libraries/Email.php | 14 +++++++------- system/libraries/Javascript.php | 2 +- system/libraries/Xmlrpc.php | 2 +- system/libraries/Xmlrpcs.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 09f217530..dd5477e05 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -247,7 +247,7 @@ class CI_Email { $name = $replyto; } - if (strncmp($name, '"', 1) !== 0) + if (strpos($name, '"') !== 0) { $name = '"'.$name.'"'; } @@ -606,7 +606,7 @@ class CI_Email { foreach ($this->_base_charsets as $charset) { - if (strncmp($charset, $this->charset, strlen($charset)) === 0) + if (strpos($charset, $this->charset) === 0) { $this->_encoding = '7bit'; } @@ -651,7 +651,7 @@ class CI_Email { protected function _set_date() { $timezone = date('Z'); - $operator = (strncmp($timezone, '-', 1) === 0) ? '-' : '+'; + $operator = ($timezone[0] === '-') ? '-' : '+'; $timezone = abs($timezone); $timezone = floor($timezone/3600) * 100 + ($timezone % 3600) / 60; @@ -1481,7 +1481,7 @@ class CI_Email { $this->_set_error_message($reply); - if (strncmp($reply, '250', 3) !== 0) + if (strpos($reply, '250') !== 0) { $this->_set_error_message('lang:email_smtp_error', $reply); return FALSE; @@ -1637,7 +1637,7 @@ class CI_Email { $reply = $this->_get_smtp_data(); - if (strncmp($reply, '334', 3) !== 0) + if (strpos($reply, '334') !== 0) { $this->_set_error_message('lang:email_failed_smtp_login', $reply); return FALSE; @@ -1647,7 +1647,7 @@ class CI_Email { $reply = $this->_get_smtp_data(); - if (strncmp($reply, '334', 3) !== 0) + if (strpos($reply, '334') !== 0) { $this->_set_error_message('lang:email_smtp_auth_un', $reply); return FALSE; @@ -1657,7 +1657,7 @@ class CI_Email { $reply = $this->_get_smtp_data(); - if (strncmp($reply, '235', 3) !== 0) + if (strpos($reply, '235') !== 0) { $this->_set_error_message('lang:email_smtp_auth_pw', $reply); return FALSE; diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 98fec61d3..5c8b09217 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -620,7 +620,7 @@ class CI_Javascript { $this->_javascript_location = $this->CI->config->item('javascript_location'); } - if ($relative === TRUE OR strncmp($external_file, 'http://', 7) === 0 OR strncmp($external_file, 'https://', 8) === 0) + if ($relative === TRUE OR strpos($external_file, 'http://') === 0 OR strpos($external_file, 'https://') === 0) { $str = $this->_open_script($external_file); } diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 6f3542333..eac4ac118 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -778,7 +778,7 @@ class XML_RPC_Message extends CI_Xmlrpc } // Check for HTTP 200 Response - if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) + if (strpos($data, 'HTTP') === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr = substr($data, 0, strpos($data, "\n")-1); return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' ('.$errstr.')'); diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index be930b0f9..e81f2ca9a 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -303,7 +303,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $methName = $m->method_name; // Check to see if it is a system call - $system_call = (strncmp($methName, 'system', 5) === 0); + $system_call = (strpos($methName, 'system') === 0); if ($this->xss_clean === FALSE) { -- cgit v1.2.3-24-g4f1b From eef240622a9966fb2c97975e3c651c40fd8590a4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 16:17:48 +0300 Subject: Some date helper improvements --- system/helpers/date_helper.php | 103 +++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 60 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index d5036f645..ae0b7a2b7 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -93,8 +93,10 @@ if ( ! function_exists('mdate')) { return ''; } - - $time = ($time === '') ? now() : $time; + elseif (empty($time)) + { + $time = now(); + } $datestr = str_replace( '%\\', @@ -122,24 +124,19 @@ if ( ! function_exists('standard_date')) function standard_date($fmt = 'DATE_RFC822', $time = '') { $formats = array( - 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O', - 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC', - 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O', - 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', - 'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC', - 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', - 'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O', - 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O', - 'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O', - 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O' - ); - - if ( ! isset($formats[$fmt])) - { - return FALSE; - } - - return mdate($formats[$fmt], $time); + 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O', + 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC', + 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O', + 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', + 'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC', + 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', + 'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O' + ); + + return isset($formats[$fmt]) ? mdate($formats[$fmt], $time) : FALSE; } } @@ -163,20 +160,9 @@ if ( ! function_exists('timespan')) $CI =& get_instance(); $CI->lang->load('date'); - if ( ! is_numeric($seconds)) - { - $seconds = 1; - } - - if ( ! is_numeric($time)) - { - $time = time(); - } - - if ( ! is_numeric($units)) - { - $units = 7; - } + is_numeric($seconds) OR $seconds = 1; + is_numeric($time) OR $time = time(); + is_numeric($units) OR $units = 7; $seconds = ($time <= $seconds) ? 1 : $time - $seconds; @@ -185,7 +171,7 @@ if ( ! function_exists('timespan')) if ($years > 0) { - $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')); + $str[] = $years.' '.$CI->lang->line($years > 1 ? 'date_years' : 'date_year'); } $seconds -= $years * 31557600; @@ -195,7 +181,7 @@ if ( ! function_exists('timespan')) { if ($months > 0) { - $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')); + $str[] = $months.' '.$CI->lang->line($months > 1 ? 'date_months' : 'date_month'); } $seconds -= $months * 2629743; @@ -207,7 +193,7 @@ if ( ! function_exists('timespan')) { if ($weeks > 0) { - $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')); + $str[] = $weeks.' '.$CI->lang->line($weeks > 1 ? 'date_weeks' : 'date_week'); } $seconds -= $weeks * 604800; @@ -219,7 +205,7 @@ if ( ! function_exists('timespan')) { if ($days > 0) { - $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')); + $str[] = $days.' '.$CI->lang->line($days > 1 ? 'date_days' : 'date_day'); } $seconds -= $days * 86400; @@ -231,7 +217,7 @@ if ( ! function_exists('timespan')) { if ($hours > 0) { - $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')); + $str[] = $hours.' '.$CI->lang->line($hours > 1 ? 'date_hours' : 'date_hour'); } $seconds -= $hours * 3600; @@ -243,7 +229,7 @@ if ( ! function_exists('timespan')) { if ($minutes > 0) { - $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')); + $str[] = $minutes.' '.$CI->lang->line($minutes > 1 ? 'date_minutes' : 'date_minute'); } $seconds -= $minutes * 60; @@ -251,7 +237,7 @@ if ( ! function_exists('timespan')) if (count($str) === 0) { - $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')); + $str[] = $seconds.' '.$CI->lang->line($seconds > 1 ? 'date_seconds' : 'date_second'); } return implode(', ', $str); @@ -278,12 +264,16 @@ if ( ! function_exists('days_in_month')) { return 0; } - - if ( ! is_numeric($year) OR strlen($year) !== 4) + elseif ( ! is_numeric($year) OR strlen($year) !== 4) { $year = date('Y'); } + if ($year >= 1970) + { + return (int) date('t', mktime(12, 0, 0, $month, 1, $year)); + } + if ($month == 2) { if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) @@ -315,11 +305,11 @@ if ( ! function_exists('local_to_gmt')) } return gmmktime( - date('H', $time), + date('G', $time), date('i', $time), date('s', $time), - date('m', $time), - date('d', $time), + date('n', $time), + date('j', $time), date('Y', $time) ); } @@ -350,12 +340,7 @@ if ( ! function_exists('gmt_to_local')) $time += timezones($timezone) * 3600; - if ($dst === TRUE) - { - $time += 3600; - } - - return $time; + return ($dst === TRUE) ? $time + 3600 : $time; } } @@ -405,7 +390,7 @@ if ( ! function_exists('unix_to_human')) */ function unix_to_human($time = '', $seconds = FALSE, $fmt = 'us') { - $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; + $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; if ($fmt === 'us') { @@ -423,7 +408,7 @@ if ( ! function_exists('unix_to_human')) if ($fmt === 'us') { - $r .= ' '.date('A', $time); + return $r.' '.date('A', $time); } return $r; @@ -542,15 +527,15 @@ if ( ! function_exists('nice_date')) // Date Like: YYYYMMDD if (preg_match('/^\d{8}$/', $bad_date)) { - $month = substr($bad_date, 0, 2); - $day = substr($bad_date, 2, 2); - $year = substr($bad_date, 4, 4); + $month = substr($bad_date, 0, 2); + $day = substr($bad_date, 2, 2); + $year = substr($bad_date, 4, 4); return date($format, strtotime($month.'/01/'.$year)); } // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) - if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/', $bad_date)) + if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/', $bad_date, $matches)) { list($m, $d, $y) = explode('-', $bad_date); return date($format, strtotime($y.'-'.$m.'-'.$d)); @@ -675,8 +660,6 @@ if ( ! function_exists('timezones')) return $zones; } - $tz = ($tz === 'GMT') ? 'UTC' : $tz; - return isset($zones[$tz]) ? $zones[$tz] : 0; } } -- cgit v1.2.3-24-g4f1b From f11a1939c25de1e327c7c02001c8fbd1ec1fc7b4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 16:35:09 +0300 Subject: Improve date helper functions human_to_unix() and nice_date() --- system/helpers/date_helper.php | 51 ++++++++++++------------------------------ 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index ae0b7a2b7..077a6712c 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -436,51 +436,33 @@ if ( ! function_exists('human_to_unix')) $datestr = preg_replace('/\040+/', ' ', trim($datestr)); - if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr)) + if ( ! preg_match('/^(\d{2}|\d{4})\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr)) { return FALSE; } $split = explode(' ', $datestr); - $ex = explode('-', $split['0']); - - $year = (strlen($ex[0]) === 2) ? '20'.$ex[0] : $ex[0]; - $month = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; - $day = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; + list($year, $month, $day) = explode('-', $split[0]); $ex = explode(':', $split['1']); - $hour = (strlen($ex[0]) === 1) ? '0'.$ex[0] : $ex[0]; - $min = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; - - if (isset($ex[2]) && preg_match('/[0-9]{1,2}/', $ex[2])) - { - $sec = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; - } - else - { - // Unless specified, seconds get set to zero. - $sec = '00'; - } + $hour = (int) $ex[0]; + $min = (int) $ex[1]; + $sec = ( ! empty($ex[2]) && preg_match('/[0-9]{1,2}/', $ex[2])) + ? (int) $ex[2] : 0; if (isset($split[2])) { $ampm = strtolower($split[2]); - if (substr($ampm, 0, 1) === 'p' && $hour < 12) + if ($ampm[0] === 'p' && $hour < 12) { $hour += 12; } - - if (substr($ampm, 0, 1) === 'a' && $hour == 12) - { - $hour = '00'; - } - - if (strlen($hour) === 1) + elseif ($ampm[0] === 'a' && $hour === 12) { - $hour = '0'.$hour; + $hour = 0; } } @@ -508,7 +490,7 @@ if ( ! function_exists('nice_date')) } // Date like: YYYYMM - if (preg_match('/^\d{6}$/', $bad_date)) + if (preg_match('/^\d{6}$/i', $bad_date)) { if (in_array(substr($bad_date, 0, 2), array('19', '20'))) { @@ -525,20 +507,15 @@ if ( ! function_exists('nice_date')) } // Date Like: YYYYMMDD - if (preg_match('/^\d{8}$/', $bad_date)) + if (preg_match('/^(\d{2})\d{2}(\d{4})$/i', $bad_date, $matches)) { - $month = substr($bad_date, 0, 2); - $day = substr($bad_date, 2, 2); - $year = substr($bad_date, 4, 4); - - return date($format, strtotime($month.'/01/'.$year)); + return date($format, strtotime($matches[1].'/01/'.$matches[2])); } // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) - if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/', $bad_date, $matches)) + if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/i', $bad_date, $matches)) { - list($m, $d, $y) = explode('-', $bad_date); - return date($format, strtotime($y.'-'.$m.'-'.$d)); + return date($format, strtotime($matches[3].'-'.$matches[1].'-'.$matches[2])); } // Any other kind of string, when converted into UNIX time, -- cgit v1.2.3-24-g4f1b From ee112692c0e893dbe1d03b7ee62da6860db7310c Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Thu, 14 Jun 2012 15:32:17 -0300 Subject: A TTL of 0 will keep the cache persistant. --- system/libraries/Cache/drivers/Cache_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 08231963e..028875b7d 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -73,7 +73,7 @@ class CI_Cache_file extends CI_Driver { $data = unserialize(file_get_contents($this->_cache_path.$id)); - if (time() > $data['time'] + $data['ttl']) + if ($data['ttl'] > 0 AND time() > $data['time'] + $data['ttl']) { unlink($this->_cache_path.$id); return FALSE; -- cgit v1.2.3-24-g4f1b From eccde13b8ae8be69645cf1abedcdbdc3c278b615 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Thu, 14 Jun 2012 23:22:26 +0200 Subject: exact length passed as string needs to be casted to int --- system/libraries/Form_validation.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 6cbe032c7..069751b45 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1035,7 +1035,7 @@ class CI_Form_validation { * Exact Length * * @param string - * @param int + * @param string * @return bool */ public function exact_length($str, $val) @@ -1045,6 +1045,8 @@ class CI_Form_validation { return FALSE; } + $val = (int) $val; + return (MB_ENABLED === TRUE) ? (mb_strlen($str) === $val) : (strlen($str) === $val); -- cgit v1.2.3-24-g4f1b From a8221ade975111eb55da06b553789ad541bf2bff Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Thu, 14 Jun 2012 23:26:34 +0200 Subject: fix --- system/libraries/Form_validation.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 069751b45..37eb7a9cd 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -993,7 +993,7 @@ class CI_Form_validation { * Minimum Length * * @param string - * @param int + * @param string * @return bool */ public function min_length($str, $val) @@ -1014,7 +1014,7 @@ class CI_Form_validation { * Max Length * * @param string - * @param int + * @param string * @return bool */ public function max_length($str, $val) @@ -1045,11 +1045,9 @@ class CI_Form_validation { return FALSE; } - $val = (int) $val; - return (MB_ENABLED === TRUE) - ? (mb_strlen($str) === $val) - : (strlen($str) === $val); + ? (mb_strlen($str) === intval($val)) + : (strlen($str) === intval($val)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 64cfef0fb8cf6254cb08a0c2e3aef04cd5721942 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Thu, 14 Jun 2012 23:30:44 +0200 Subject: fixed other functions --- system/libraries/Form_validation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 37eb7a9cd..621316c4a 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1004,8 +1004,8 @@ class CI_Form_validation { } return (MB_ENABLED === TRUE) - ? ($val <= mb_strlen($str)) - : ($val <= strlen($str)); + ? (intval($val) <= mb_strlen($str)) + : (intval($val) <= strlen($str)); } // -------------------------------------------------------------------- @@ -1025,8 +1025,8 @@ class CI_Form_validation { } return (MB_ENABLED === TRUE) - ? ($val >= mb_strlen($str)) - : ($val >= strlen($str)); + ? (intval($val) >= mb_strlen($str)) + : (intval($val) >= strlen($str)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From f68db392ea3861de9d80c41e3cd5b857468c53f9 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 14 Jun 2012 17:14:11 -0500 Subject: Somebody double `$$`ed, causing error Severity: 4096 Message: Object of class CI_DB_mysql_forge could not be converted to string Filename: database/DB_forge.php Line Number: 234 --- system/database/DB_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 9b7639289..91f9d560c 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -231,7 +231,7 @@ abstract class CI_DB_forge { if (($result = $this->db->query($sql)) !== FALSE && ! empty($this->db->data_cache['table_names'])) { - $this->db->data_cache['table_names'][] = $$this->db->dbprefix.$table; + $this->db->data_cache['table_names'][] = $this->db->dbprefix.$table; } return $result; -- cgit v1.2.3-24-g4f1b From e389b0eb2f107ee16e5f6ca47833809dffdfc02f Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 14 Jun 2012 17:37:18 -0500 Subject: Fixed ANOTHER DB_Forge bug in the mysql driver. I'm watching you @narfbg. --- system/database/drivers/mysql/mysql_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index d22454d84..2ac75bad2 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -62,7 +62,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { $sql .= "\n\t".$this->db->escape_identifiers($field); - empty($attributes['NAME']) OR ' '.$this->db->escape_identifiers($attributes['NAME']).' '; + empty($attributes['NAME']) OR $sql .= ' '.$this->db->escape_identifiers($attributes['NAME']).' '; if ( ! empty($attributes['TYPE'])) { -- cgit v1.2.3-24-g4f1b From 8295c845a447b973ef27aec6ed41d4325af06a76 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 03:42:25 +0300 Subject: Fix issue #1482 --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 488b294e4..f3e75cbeb 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -381,7 +381,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // Assemble the JOIN statement - $this->qb_join[] = $join = $type.'JOIN '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; + $this->qb_join[] = $join = $type.'JOIN '.$table.' ON '.$cond; if ($this->qb_caching === TRUE) { -- cgit v1.2.3-24-g4f1b From e10fb79a95e2b0594ae68560df8963f92fea86d7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 12:07:04 +0300 Subject: Fix issue #1483 --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index f3e75cbeb..4c70ccc78 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -451,7 +451,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // If the escape value was not set will will base it on the global setting - $escape = $this->_protect_identifiers; + is_bool($escape) OR $escape = $this->_protect_identifiers; foreach ($key as $k => $v) { -- cgit v1.2.3-24-g4f1b From 974c75bc030b4eb0521b66bf85e81a5ab61d14a6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 12:30:02 +0300 Subject: Fix having() --- system/database/DB_query_builder.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 4c70ccc78..486fda963 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -932,10 +932,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $prefix = (count($this->qb_having) === 0) ? '' : $type; - if ($escape === TRUE) - { - $k = $this->protect_identifiers($k); - } + $k = $this->_has_operator($k) + ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') + : $this->protect_identifiers($k, FALSE, $escape); if ( ! $this->_has_operator($k)) { -- cgit v1.2.3-24-g4f1b From ceaf887a7a849eab95b1bed1a837e2e3a1720c99 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Fri, 15 Jun 2012 11:56:24 +0200 Subject: some optimizations --- system/libraries/Form_validation.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 621316c4a..6d4446d0c 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -998,14 +998,18 @@ class CI_Form_validation { */ public function min_length($str, $val) { - if (preg_match('/[^0-9]/', $val)) + if ( ! is_numeric($val)) { return FALSE; } + else + { + $val = (int) $val; + } return (MB_ENABLED === TRUE) - ? (intval($val) <= mb_strlen($str)) - : (intval($val) <= strlen($str)); + ? ($val <= mb_strlen($str)) + : ($val <= strlen($str)); } // -------------------------------------------------------------------- @@ -1019,14 +1023,18 @@ class CI_Form_validation { */ public function max_length($str, $val) { - if (preg_match('/[^0-9]/', $val)) + if ( ! is_numeric($val)) { return FALSE; } + else + { + $val = (int) $val; + } return (MB_ENABLED === TRUE) - ? (intval($val) >= mb_strlen($str)) - : (intval($val) >= strlen($str)); + ? ($val >= mb_strlen($str)) + : ($val >= strlen($str)); } // -------------------------------------------------------------------- @@ -1040,14 +1048,18 @@ class CI_Form_validation { */ public function exact_length($str, $val) { - if (preg_match('/[^0-9]/', $val)) + if ( ! is_numeric($val)) { return FALSE; } + else + { + $val = (int) $val; + } return (MB_ENABLED === TRUE) - ? (mb_strlen($str) === intval($val)) - : (strlen($str) === intval($val)); + ? (mb_strlen($str) === $val) + : (strlen($str) === $val); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 1922a885b40ef63cf0a5141eb8377d04e3bee172 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 15:16:51 +0300 Subject: Update simple_query() documentation (issue #1484) --- user_guide_src/source/database/queries.rst | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index d23efecb3..11dd78392 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -21,11 +21,31 @@ this:: $this->db->simple_query(); =========================== -This is a simplified version of the $this->db->query() function. It ONLY -returns TRUE/FALSE on success or failure. It DOES NOT return a database -result set, nor does it set the query timer, or compile bind data, or -store your query for debugging. It simply lets you submit a query. Most -users will rarely use this function. +This is a simplified version of the $this->db->query() method. It DOES +NOT return a database result set, nor does it set the query timer, or +compile bind data, or store your query for debugging. It simply lets you +submit a query. Most users will rarely use this function. + +It returns whatever the database drivers' "execute" function returns. +That typically is TRUE/FALSE on success or failure for write type queries +such as INSERT, DELETE or UPDATE statements (which is what it really +should be used for) and a resource/object on success for queries with +fetchable results. + +:: + + if ($this->db->simple_query('YOUR QUERY')) + { + echo "Success!"; + } + else + { + echo "Query failed!"; + } + +.. note:: PostgreSQL's pg_exec() function always returns a resource on + success, even for write type queries. So take that in mind if + you're looking for a boolean value. *************************************** Working with Database prefixes manually -- cgit v1.2.3-24-g4f1b From e446ad337945b7839b73f13531b21ed16ece241e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 15:23:41 +0300 Subject: Optimize encode_php_tags() --- system/helpers/security_helper.php | 2 +- system/libraries/Form_validation.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 3e6e91435..7fcb18437 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -123,7 +123,7 @@ if ( ! function_exists('encode_php_tags')) */ function encode_php_tags($str) { - return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); + return str_replace(array(''), array('<?', '?>'), $str); } } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 6d4446d0c..fb1c69caf 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1382,7 +1382,7 @@ class CI_Form_validation { */ public function encode_php_tags($str) { - return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); + return str_replace(array(''), array('<?', '?>'), $str); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From d9b44bef948928739b2b96b43d78b7629c0ccc15 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 16:07:08 +0300 Subject: Fix issue #520 --- system/helpers/date_helper.php | 4 ++++ user_guide_src/source/changelog.rst | 1 + 2 files changed, 5 insertions(+) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 077a6712c..065a223ef 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -488,6 +488,10 @@ if ( ! function_exists('nice_date')) { return 'Unknown'; } + elseif (empty($format)) + { + $format = 'U'; + } // Date like: YYYYMM if (preg_match('/^\d{6}$/i', $bad_date)) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 7748f9b37..ec33414c2 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -270,6 +270,7 @@ Bug fixes for 3.0 - Fixed a bug in protect_identifiers() where if passed along with the field names, operators got escaped as well. - Fixed a bug (#10) - :doc:`URI Library ` internal method _detect_uri() failed with paths containing a colon. - Fixed a bug (#1387) - :doc:`Query Builder `'s from() method didn't escape table aliases. +- Fixed a bug (#520) - :doc:`Date Helper ` function nice_date() failed when the optional second parameter is not passed. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From c275b23b06195e4ea6424d96a0c76b825c71443a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 16:13:17 +0300 Subject: Fix nice_date() documentation --- user_guide_src/source/helpers/date_helper.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index 1b7177fc2..b6dc2e934 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -247,16 +247,18 @@ Example :: - $bad_time = 199605 // Should Produce: 1996-05-01 - $better_time = nice_date($bad_time,'Y-m-d'); - $bad_time = 9-11-2001 // Should Produce: 2001-09-11 - $better_time = nice_date($human,'Y-m-d'); + $bad_date = '199605'; + // Should Produce: 1996-05-01 + $better_date = nice_date($bad_date, 'Y-m-d'); + + $bad_date = '9-11-2001'; + // Should Produce: 2001-09-11 + $better_date = nice_date($bad_date, 'Y-m-d'); timespan() ========== Formats a unix timestamp so that is appears similar to this - :: 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes -- cgit v1.2.3-24-g4f1b From 857b00f4026f149350a6a3447d0c2b0149c1b534 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Fri, 15 Jun 2012 15:26:01 +0200 Subject: more logging --- 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 d056bdb90..28d665fdf 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -352,7 +352,7 @@ abstract class CI_DB_driver { $error = $this->error(); // Log errors - log_message('error', 'Query error: '.$error['message']); + log_message('error', 'Query error: '.$error['message'] . ' - Invalid query: ' . $sql); if ($this->db_debug) { -- cgit v1.2.3-24-g4f1b From 51d6d8406d6493d7e3f8783c5d17a4a1970e9fba Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 16:41:09 +0300 Subject: Add support for HTTP code 303 in set_status_header(), as suggested in pull #341 --- system/core/Common.php | 20 +++++++++++++------- user_guide_src/source/changelog.rst | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 1708653e7..c309d4192 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -431,6 +431,7 @@ if ( ! function_exists('set_status_header')) 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', + 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', @@ -462,18 +463,23 @@ if ( ! function_exists('set_status_header')) 505 => 'HTTP Version Not Supported' ); - if ($code == '' OR ! is_numeric($code)) + if (empty($code) OR ! is_numeric($code)) { show_error('Status codes must be numeric', 500); } - elseif (isset($stati[$code]) && $text === '') - { - $text = $stati[$code]; - } - if ($text === '') + is_int($code) OR $code = (int) $code; + + if (empty($text)) { - show_error('No status text available. Please check your status code number or supply your own message text.', 500); + if (isset($stati[$code])) + { + $text = $stati[$code]; + } + else + { + show_error('No status text available. Please check your status code number or supply your own message text.', 500); + } } $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ec33414c2..aeccea281 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -174,6 +174,7 @@ Release Date: Not Released - Added get_mimes() function to system/core/Commons.php to return the config/mimes.php array. - Added a second argument to set_content_type() in the :doc:`Output Library ` that allows setting the document charset as well. - $config['time_reference'] now supports all timezone strings supported by PHP. + - Added support for HTTP code 303 ("See Other") in set_status_header(). Bug fixes for 3.0 ------------------ -- cgit v1.2.3-24-g4f1b From ac35e5a3fc0987872933131988a99bd21f86a70c Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 15 Jun 2012 22:59:26 +0300 Subject: Fix error in Encryption Class documentation One ANSI character is 8 bits, so 32 characters are not 128 bits but 256 bits. --- user_guide_src/source/libraries/encryption.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst index 28bdca203..a38122203 100644 --- a/user_guide_src/source/libraries/encryption.rst +++ b/user_guide_src/source/libraries/encryption.rst @@ -26,7 +26,7 @@ key security so you may want to think carefully before using it for anything that requires high security, like storing credit card numbers. To take maximum advantage of the encryption algorithm, your key should -be 32 characters in length (128 bits). The key should be as random a +be 32 characters in length (256 bits). The key should be as random a string as you can concoct, with numbers and uppercase and lowercase letters. Your key should **not** be a simple text string. In order to be cryptographically secure it needs to be as random as possible. -- cgit v1.2.3-24-g4f1b From d1a075d7807ad8177ecb4235dfe16ffe2041f860 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 23:28:52 +0300 Subject: mimes.php: zip, rar, php from pull #1472 --- application/config/mimes.php | 5 +++-- user_guide_src/source/changelog.rst | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 15493af43..4b1d6a85d 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -68,7 +68,7 @@ return array( 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'gzip' => 'application/x-gzip', - 'php' => 'application/x-httpd-php', + 'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'), 'php4' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', @@ -80,7 +80,8 @@ return array( 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'), 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', - 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'), + 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'), + 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'), 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index aeccea281..589cd0046 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -30,9 +30,12 @@ Release Date: Not Released - Added support for 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php. - Added support for m4a, aac, m4u, xspf, au, ac3, flac, ogg Audio files to mimes.php. - Added support for kmz and kml (Google Earth) files to mimes.php. - - Added support for ics Calendar files to mimes.php + - Added support for ics Calendar files to mimes.php. + - Added support for rar archives to mimes.php. - Updated support for xml ('application/xml') and xsl ('application/xml', 'text/xsl') files in mimes.php. - Updated support for doc files in mimes.php. + - Updated support for php files in mimes.php. + - Updated support for zip files in mimes.php. - Added some more doctypes. - Added Romanian and Greek characters in foreign_characters.php. - Changed logger to only chmod when file is first created. -- cgit v1.2.3-24-g4f1b From 58ae971ba248cf3e32a139088c3833c9735028de Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Jun 2012 23:44:48 +0300 Subject: Fix issue #167 --- system/core/URI.php | 2 +- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/system/core/URI.php b/system/core/URI.php index a997525ee..208d311a5 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -278,7 +278,7 @@ class CI_URI { { // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern - if ( ! preg_match('|^['.str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-')).']+$|i', $str)) + if ( ! preg_match('|^['.str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-')).']+$|i', urldecode($str))) { show_error('The URI you submitted has disallowed characters.', 400); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 589cd0046..3e5bc8fcb 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -275,6 +275,7 @@ Bug fixes for 3.0 - Fixed a bug (#10) - :doc:`URI Library ` internal method _detect_uri() failed with paths containing a colon. - Fixed a bug (#1387) - :doc:`Query Builder `'s from() method didn't escape table aliases. - Fixed a bug (#520) - :doc:`Date Helper ` function nice_date() failed when the optional second parameter is not passed. +- Fixed a bug (#167) - ``$config['permitted_uri_chars']`` didn't affect URL-encoded characters. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 0140ddd510edffb901b98de6b80676ece183760c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 01:12:56 +0300 Subject: Fix issue #318 + added a default to the switch() in CI_Output::minify() --- system/core/Output.php | 82 +++++++++++++++++++------------------ system/libraries/Profiler.php | 6 +++ user_guide_src/source/changelog.rst | 1 + 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index 8a0f14e02..570d4ebc9 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -72,6 +72,7 @@ class CI_Output { * @var string */ protected $mime_type = 'text/html'; + /** * Determines wether profiler is enabled * @@ -84,7 +85,7 @@ class CI_Output { * * @var bool */ - protected $_zlib_oc = FALSE; + protected $_zlib_oc = FALSE; /** * List of profiler sections @@ -180,7 +181,7 @@ class CI_Output { * how to permit header data to be saved with the cache data... * * @param string - * @param bool + * @param bool * @return void */ public function set_header($header, $replace = TRUE) @@ -223,7 +224,7 @@ class CI_Output { } } } - + $this->mime_type = $mime_type; if (empty($charset)) @@ -300,6 +301,12 @@ class CI_Output { */ public function set_profiler_sections($sections) { + if (isset($sections['query_toggle_count'])) + { + $this->_profiler_sections['query_toggle_count'] = (int) $sections['query_toggle_count']; + unset($sections['query_toggle_count']); + } + foreach ($sections as $section => $enable) { $this->_profiler_sections[$section] = ($enable !== FALSE); @@ -335,7 +342,7 @@ class CI_Output { * with any server headers and profile data. It also stops the * benchmark timer so the page rendering speed and memory usage can be shown. * - * @param string + * @param string * @return mixed */ public function _display($output = '') @@ -358,7 +365,7 @@ class CI_Output { { $output =& $this->final_output; } - + // -------------------------------------------------------------------- // Is minify requested? @@ -467,7 +474,7 @@ class CI_Output { /** * Write a Cache File * - * @param string + * @param string * @return void */ public function _write_cache($output) @@ -510,7 +517,7 @@ class CI_Output { @chmod($cache_path, FILE_WRITE_MODE); log_message('debug', 'Cache file written: '.$cache_path); - + // Send HTTP cache-control headers to browser to match file cache settings. $this->set_cache_header($_SERVER['REQUEST_TIME'], $expire); } @@ -520,8 +527,8 @@ class CI_Output { /** * Update/serve a cached file * - * @param object config class - * @param object uri class + * @param object config class + * @param object uri class * @return bool */ public function _display_cache(&$CFG, &$URI) @@ -562,7 +569,7 @@ class CI_Output { return FALSE; } else - { + { // Or else send the HTTP cache control headers. $this->set_cache_header($last_modified, $expire); } @@ -573,46 +580,44 @@ class CI_Output { return TRUE; } - // -------------------------------------------------------------------- + /** * Set the HTTP headers to match the server-side file cache settings * in order to reduce bandwidth. * - * @param int timestamp of when the page was last modified - * @param int timestamp of when should the requested page expire from cache + * @param int timestamp of when the page was last modified + * @param int timestamp of when should the requested page expire from cache * @return void */ public function set_cache_header($last_modified, $expiration) - { - $max_age = $expiration - $_SERVER['REQUEST_TIME']; + { + $max_age = $expiration - $_SERVER['REQUEST_TIME']; - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']))) + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $this->set_status_header(304); exit; } else { - header('Pragma: public'); + header('Pragma: public'); header('Cache-Control: max-age=' . $max_age . ', public'); header('Expires: '.gmdate('D, d M Y H:i:s', $expiration).' GMT'); header('Last-modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT'); } } - - - // -------------------------------------------------------------------- + /** * Reduce excessive size of HTML content. * - * @param string - * @param string + * @param string + * @param string * @return string */ - public function minify($output, $type='text/html') + public function minify($output, $type = 'text/html') { switch ($type) { @@ -633,7 +638,7 @@ class CI_Output { { $output = str_replace($s, $this->minify($s, 'text/css'), $output); } - + // Minify the javascript in }msU', $output, $javascript_messed); $output = str_replace($javascript_messed[0], $javascript_mini, $output); } - + $size_removed = $size_before - strlen($output); $savings_percent = round(($size_removed / $size_before * 100)); log_message('debug', 'Minifier shaved '.($size_removed / 1000).'KB ('.$savings_percent.'%) off final HTML output.'); break; - - + case 'text/css': - + //Remove CSS comments $output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output); - + // Remove spaces around curly brackets, colons, // semi-colons, parenthesis, commas $output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!', '$1', $output); break; - - + case 'text/javascript': // Currently leaves JavaScript untouched. break; + + default: break; } - + return $output; } - } /* End of file Output.php */ -/* Location: ./system/core/Output.php */ +/* Location: ./system/core/Output.php */ \ No newline at end of file diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index d96088c14..1e961f6df 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -116,6 +116,12 @@ class CI_Profiler { */ public function set_sections($config) { + if (isset($config['query_toggle_count'])) + { + $this->_query_toggle_count = (int) $config['query_toggle_count']; + unset($config['query_toggle_count']); + } + foreach ($config as $method => $enable) { if (in_array($method, $this->_available_sections)) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 3e5bc8fcb..8e0ac10f0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -276,6 +276,7 @@ Bug fixes for 3.0 - Fixed a bug (#1387) - :doc:`Query Builder `'s from() method didn't escape table aliases. - Fixed a bug (#520) - :doc:`Date Helper ` function nice_date() failed when the optional second parameter is not passed. - Fixed a bug (#167) - ``$config['permitted_uri_chars']`` didn't affect URL-encoded characters. +- Fixed a bug (#318) - :doc:`Profiling ` setting *query_toggle_count* was not settable as described in the manual. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From d24160cc4348c32c0c1ec7350e2e2dada2c9291a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 03:21:20 +0300 Subject: Changed order_by() default escaping to _protect_identifiers --- system/database/DB_query_builder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 486fda963..5eb6bbb4e 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -967,7 +967,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool enable field name escaping * @return object */ - public function order_by($orderby, $direction = '', $escape = TRUE) + public function order_by($orderby, $direction = '', $escape = NULL) { if (strtolower($direction) === 'random') { @@ -979,8 +979,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $direction = in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE) ? ' '.$direction : ' ASC'; } + is_bool($escape) OR $escape = $this->_protect_identifiers; - if ((strpos($orderby, ',') !== FALSE) && $escape === TRUE) + if ($escape === TRUE && strpos($orderby, ',') !== FALSE) { $temp = array(); foreach (explode(',', $orderby) as $part) -- cgit v1.2.3-24-g4f1b From 498c1e027e67dfd8108e0e255ff18fb914742b63 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 03:34:10 +0300 Subject: Added an escape parameter to where_in(), or_where_in(), where_not_in(), or_where_not_in() and made where(), or_where() to default the escape setting to the value of _protect_identifiers --- system/database/DB_query_builder.php | 26 ++++++++++++---------- system/database/drivers/postgre/postgre_driver.php | 5 +---- user_guide_src/source/changelog.rst | 3 +-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 5eb6bbb4e..85dd77da9 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -405,7 +405,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - public function where($key, $value = NULL, $escape = TRUE) + public function where($key, $value = NULL, $escape = NULL) { return $this->_where($key, $value, 'AND ', $escape); } @@ -423,7 +423,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - public function or_where($key, $value = NULL, $escape = TRUE) + public function or_where($key, $value = NULL, $escape = NULL) { return $this->_where($key, $value, 'OR ', $escape); } @@ -504,9 +504,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param array The values searched on * @return object */ - public function where_in($key = NULL, $values = NULL) + public function where_in($key = NULL, $values = NULL, $escape = NULL) { - return $this->_where_in($key, $values); + return $this->_where_in($key, $values, FALSE, 'AND ', $escape); } // -------------------------------------------------------------------- @@ -521,9 +521,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param array The values searched on * @return object */ - public function or_where_in($key = NULL, $values = NULL) + public function or_where_in($key = NULL, $values = NULL, $escape = NULL) { - return $this->_where_in($key, $values, FALSE, 'OR '); + return $this->_where_in($key, $values, FALSE, 'OR ', $escape); } // -------------------------------------------------------------------- @@ -538,9 +538,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param array The values searched on * @return object */ - public function where_not_in($key = NULL, $values = NULL) + public function where_not_in($key = NULL, $values = NULL, $escape = NULL) { - return $this->_where_in($key, $values, TRUE); + return $this->_where_in($key, $values, TRUE, 'AND ', $escape); } // -------------------------------------------------------------------- @@ -555,9 +555,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param array The values searched on * @return object */ - public function or_where_not_in($key = NULL, $values = NULL) + public function or_where_not_in($key = NULL, $values = NULL, $escape = NULL) { - return $this->_where_in($key, $values, TRUE, 'OR '); + return $this->_where_in($key, $values, TRUE, 'OR ', $escape); } // -------------------------------------------------------------------- @@ -573,7 +573,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string * @return object */ - protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ') + protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ', $escape = NULL) { if ($key === NULL OR $values === NULL) { @@ -587,6 +587,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $values = array($values); } + is_bool($escape) OR $escape = $this->_protect_identifiers; + $not = ($not) ? ' NOT' : ''; foreach ($values as $value) @@ -595,7 +597,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } $prefix = (count($this->qb_where) === 0) ? '' : $type; - $this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key).$not.' IN ('.implode(', ', $this->qb_wherein).') '; + $this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key, FALSE, $escape).$not.' IN ('.implode(', ', $this->qb_wherein).') '; if ($this->qb_caching === TRUE) { diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index ad9ac9000..3d25b25ee 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -606,10 +606,7 @@ class CI_DB_postgre_driver extends CI_DB { } // If the escape value was not set will will base it on the global setting - if ( ! is_bool($escape)) - { - $escape = $this->_protect_identifiers; - } + is_bool($escape) OR $escape = $this->_protect_identifiers; foreach ($key as $k => $v) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8e0ac10f0..b3c2e7086 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -74,8 +74,7 @@ Release Date: Not Released - Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern. - Added the ability to insert objects with insert_batch(). - Added new methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete(). - - Added an optional order_by() parameter that allows to disable escaping (useful for custom fields). - - Added an optional join() parameter that allows to disable escaping. + - Added an optional parameter that allows to disable escaping (useful for custom fields) for methods join(), order_by(), where_in(), or_where_in(), where_not_in(), or_where_not_in(). - Added support for join() with multiple conditions. - Improved support for the MySQLi driver, including: - OOP style of the PHP extension is now used, instead of the procedural aliases. -- cgit v1.2.3-24-g4f1b From fe642dadd6ba62d597ccf1c7cb91e28059caeebf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 03:47:33 +0300 Subject: All Query Builder methods to respect _protect_identifiers by default --- system/database/DB_query_builder.php | 42 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 85dd77da9..1ac9af901 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -327,7 +327,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string wether not to try to escape identifiers * @return object */ - public function join($table, $cond, $type = '', $escape = TRUE) + public function join($table, $cond, $type = '', $escape = NULL) { if ($type !== '') { @@ -347,6 +347,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // in the protect_identifiers to know whether to add a table prefix $this->_track_aliases($table); + is_bool($escape) OR $escape = $this->_protect_identifiers; + // Split multiple conditions if ($escape === TRUE && preg_match_all('/\sAND\s|\sOR\s/i', $cond, $m, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { @@ -888,7 +890,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - public function having($key, $value = '', $escape = TRUE) + public function having($key, $value = '', $escape = NULL) { return $this->_having($key, $value, 'AND ', $escape); } @@ -905,7 +907,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - public function or_having($key, $value = '', $escape = TRUE) + public function or_having($key, $value = '', $escape = NULL) { return $this->_having($key, $value, 'OR ', $escape); } @@ -923,13 +925,15 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - protected function _having($key, $value = '', $type = 'AND ', $escape = TRUE) + protected function _having($key, $value = '', $type = 'AND ', $escape = NULL) { if ( ! is_array($key)) { $key = array($key => $value); } + is_bool($escape) OR $escape = $this->_protect_identifiers; + foreach ($key as $k => $v) { $prefix = (count($this->qb_having) === 0) ? '' : $type; @@ -1057,14 +1061,16 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // -------------------------------------------------------------------- /** - * The "set" function. Allows key/value pairs to be set for inserting or updating + * The "set" function. + * + * Allows key/value pairs to be set for inserting or updating * * @param mixed * @param string * @param bool * @return object */ - public function set($key, $value = '', $escape = TRUE) + public function set($key, $value = '', $escape = NULL) { $key = $this->_object_to_array($key); @@ -1073,16 +1079,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $key = array($key => $value); } + is_bool($escape) OR $escape = $this->_protect_identifiers; + foreach ($key as $k => $v) { - if ($escape === FALSE) - { - $this->qb_set[$this->protect_identifiers($k)] = $v; - } - else - { - $this->qb_set[$this->protect_identifiers($k, FALSE, TRUE)] = $this->escape($v); - } + $this->qb_set[$this->protect_identifiers($k, FALSE, $escape)] = ($escape) + ? $this->escape($v) : $v; } return $this; @@ -1288,7 +1290,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - public function set_insert_batch($key, $value = '', $escape = TRUE) + public function set_insert_batch($key, $value = '', $escape = NULL) { $key = $this->_object_to_array_batch($key); @@ -1297,6 +1299,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $key = array($key => $value); } + is_bool($escape) OR $escape = $this->_protect_identifiers; + $keys = array_keys($this->_object_to_array(current($key))); sort($keys); @@ -1328,7 +1332,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { foreach ($keys as $k) { - $this->qb_keys[] = $this->protect_identifiers($k); + $this->qb_keys[] = $this->protect_identifiers($k, FALSE, $escape); } return $this; @@ -1727,7 +1731,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param bool * @return object */ - public function set_update_batch($key, $index = '', $escape = TRUE) + public function set_update_batch($key, $index = '', $escape = NULL) { $key = $this->_object_to_array_batch($key); @@ -1736,6 +1740,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // @todo error } + is_bool($escape) OR $escape = $this->_protect_identifiers; + foreach ($key as $k => $v) { $index_set = FALSE; @@ -1747,7 +1753,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $index_set = TRUE; } - $clean[$this->protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2); + $clean[$this->protect_identifiers($k2, FALSE, $escape)] = ($escape === FALSE) ? $v2 : $this->escape($v2); } if ($index_set === FALSE) -- cgit v1.2.3-24-g4f1b From f512b73bc78760198a5409f2c4da71fe749b1301 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 16 Jun 2012 11:15:19 +0100 Subject: Spelling fixes - `wether` to `whether` Interestingly `wether` means a castrated ram in old English --- system/core/Hooks.php | 4 ++-- system/core/Output.php | 2 +- system/database/DB_query_builder.php | 2 +- system/helpers/download_helper.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 29fd88201..afbf4b453 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -39,7 +39,7 @@ class CI_Hooks { /** - * Determines wether hooks are enabled + * Determines whether hooks are enabled * * @var bool */ @@ -53,7 +53,7 @@ class CI_Hooks { public $hooks = array(); /** - * Determines wether hook is in progress, used to prevent infinte loops + * Determines whether hook is in progress, used to prevent infinte loops * * @var bool */ diff --git a/system/core/Output.php b/system/core/Output.php index 570d4ebc9..ed294f116 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -74,7 +74,7 @@ class CI_Output { protected $mime_type = 'text/html'; /** - * Determines wether profiler is enabled + * Determines whether profiler is enabled * * @var book */ diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 1ac9af901..531ca9eb7 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -324,7 +324,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { * @param string * @param string the join condition * @param string the type of join - * @param string wether not to try to escape identifiers + * @param string whether not to try to escape identifiers * @return object */ public function join($table, $cond, $type = '', $escape = NULL) diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 5efbc4930..09c4de578 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -46,7 +46,7 @@ if ( ! function_exists('force_download')) * * @param string filename * @param mixed the data to be downloaded - * @param bool wether to try and send the actual file MIME type + * @param bool whether to try and send the actual file MIME type * @return void */ function force_download($filename = '', $data = '', $set_mime = FALSE) -- cgit v1.2.3-24-g4f1b From ff3f7dea40e8fae81dd586b340d30d24154cf5ab Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 16 Jun 2012 14:21:32 +0200 Subject: Documentation: remaining PHP "var" declarations changed to "public" Since PHP 4 isn't supported anymore, let's clean up these few PHP "var" declarations which were remaining in the documentation. According to my checks, there is no more PHP "var" left. --- user_guide_src/source/database/query_builder.rst | 18 +++++++++--------- user_guide_src/source/general/models.rst | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 54e8df6b5..b86a0c8db 100644 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -603,9 +603,9 @@ Here is an example using an object:: /* class Myclass { - var $title = 'My Title'; - var $content = 'My Content'; - var $date = 'My Date'; + public $title = 'My Title'; + public $content = 'My Content'; + public $date = 'My Date'; } */ @@ -730,9 +730,9 @@ Or an object:: /* class Myclass { - var $title = 'My Title'; - var $content = 'My Content'; - var $date = 'My Date'; + public $title = 'My Title'; + public $content = 'My Content'; + public $date = 'My Date'; } */ @@ -766,9 +766,9 @@ Or you can supply an object:: /* class Myclass { - var $title = 'My Title'; - var $content = 'My Content'; - var $date = 'My Date'; + public $title = 'My Title'; + public $content = 'My Content'; + public $date = 'My Date'; } */ diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst index 87f63e416..2e1e025ee 100644 --- a/user_guide_src/source/general/models.rst +++ b/user_guide_src/source/general/models.rst @@ -18,9 +18,9 @@ model class might look like:: class Blog_model extends CI_Model { - var $title = ''; - var $content = ''; - var $date = ''; + public $title = ''; + public $content = ''; + public $date = ''; function __construct() { -- cgit v1.2.3-24-g4f1b From 3c32a11549d31cac470b92f995add25d7fdeff50 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 18:05:34 +0300 Subject: Small improvements to form_open() --- system/helpers/form_helper.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 984634315..0c5d55037 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -62,9 +62,11 @@ if ( ! function_exists('form_open')) { $action = $CI->config->site_url($action); } - - // If no action is provided then set to the current url - $action OR $action = $CI->config->site_url($CI->uri->uri_string()); + elseif ( ! $action) + { + // If no action is provided then set to the current url + $action = $CI->config->site_url($CI->uri->uri_string()); + } $form = '
    \n"; @@ -76,7 +78,7 @@ if ( ! function_exists('form_open')) if (is_array($hidden) && count($hidden) > 0) { - $form .= sprintf('
    %s
    ', form_hidden($hidden)); + $form .= '
    '.form_hidden($hidden).'
    '; } return $form; -- cgit v1.2.3-24-g4f1b From 1764dd7d4ab6e6e5c799eaa9ce007fce48fa0b63 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 18:48:19 +0300 Subject: Fix issue #938 + some related improvements --- system/core/Config.php | 20 +++++++------------- user_guide_src/source/changelog.rst | 8 +++++--- user_guide_src/source/libraries/config.rst | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index 3de1bcb96..656382716 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -225,12 +225,12 @@ class CI_Config { * Site URL * Returns base_url . index_page [. uri_string] * - * @param string the URI string + * @param mixed the URI string or an array of segments * @return string */ public function site_url($uri = '') { - if ($uri === '') + if (empty($uri)) { return $this->slash_item('base_url').$this->item('index_page'); } @@ -240,10 +240,12 @@ class CI_Config { $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; } - else + elseif (is_array($uri) OR strpos($uri, '?') === FALSE) { - return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri); + $uri = '?'.$this->_uri_string($uri); } + + return $this->slash_item('base_url').$this->item('index_page').$uri; } // ------------------------------------------------------------- @@ -280,15 +282,7 @@ class CI_Config { } elseif (is_array($uri)) { - $i = 0; - $str = ''; - foreach ($uri as $key => $val) - { - $prefix = ($i === 0) ? '' : '&'; - $str .= $prefix.$key.'='.$val; - $i++; - } - return $str; + return http_build_query($uri); } return $uri; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b3c2e7086..b9d72642a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -163,12 +163,12 @@ Release Date: Not Released - Core - - Changed private functions in CI_URI to protected so MY_URI can override them. + - Changed private methods in the :doc:`URI Library ` to protected so MY_URI can override them. - Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions). - - Added method get_vars() to CI_Loader to retrieve all variables loaded with $this->load->vars(). + - Added method get_vars() to the :doc:`Loader Library ` to retrieve all variables loaded with $this->load->vars(). - is_loaded() function from system/core/Commons.php now returns a reference. - $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *` to retrieve $_SERVER['REQUEST_METHOD']. - Modified valid_ip() to use PHP's filter_var() in the :doc:`Input Library `. - Added support for HTTP-Only cookies with new config option ``cookie_httponly`` (default FALSE). - Renamed method _call_hook() to call_hook() in the :doc:`Hooks Library `. @@ -177,6 +177,7 @@ Release Date: Not Released - Added a second argument to set_content_type() in the :doc:`Output Library ` that allows setting the document charset as well. - $config['time_reference'] now supports all timezone strings supported by PHP. - Added support for HTTP code 303 ("See Other") in set_status_header(). + - Changed :doc:`Config Library ` method site_url() to accept an array as well. Bug fixes for 3.0 ------------------ @@ -276,6 +277,7 @@ Bug fixes for 3.0 - Fixed a bug (#520) - :doc:`Date Helper ` function nice_date() failed when the optional second parameter is not passed. - Fixed a bug (#167) - ``$config['permitted_uri_chars']`` didn't affect URL-encoded characters. - Fixed a bug (#318) - :doc:`Profiling ` setting *query_toggle_count* was not settable as described in the manual. +- Fixed a bug (#938) - :doc:`Config Library ` method site_url() added a question mark to the URL string when query strings are enabled even if it already existed. Version 2.1.1 ============= diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 08d9c2905..694896353 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -175,7 +175,7 @@ This function retrieves the URL to your site, plus an optional path such as to a stylesheet or image. The two functions above are normally accessed via the corresponding -functions in the :doc:`URL Helper `. +functions in the :doc:`URL Helper `. $this->config->system_url(); ***************************** -- cgit v1.2.3-24-g4f1b From b089e15b1510de6b6a034631c80d3d5e830ff9f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 19:11:40 +0300 Subject: Fix local_to_gmt() --- system/helpers/date_helper.php | 14 +++++++------- tests/codeigniter/helpers/date_helper_test.php | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 065a223ef..cafb6ba95 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -304,13 +304,13 @@ if ( ! function_exists('local_to_gmt')) $time = time(); } - return gmmktime( - date('G', $time), - date('i', $time), - date('s', $time), - date('n', $time), - date('j', $time), - date('Y', $time) + return mktime( + gmdate('G', $time), + gmdate('i', $time), + gmdate('s', $time), + gmdate('n', $time), + gmdate('j', $time), + gmdate('Y', $time) ); } } diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 1d397ac81..8258c9248 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -196,9 +196,9 @@ class Date_helper_test extends CI_TestCase { public function test_local_to_gmt() { $this->assertEquals( - gmmktime( - date('G', $this->time), date('i', $this->time), date('s', $this->time), - date('n', $this->time), date('j', $this->time), date('Y', $this->time) + mktime( + gmdate('G', $this->time), gmdate('i', $this->time), gmdate('s', $this->time), + gmdate('n', $this->time), gmdate('j', $this->time), gmdate('Y', $this->time) ), local_to_gmt($this->time) ); -- cgit v1.2.3-24-g4f1b From 95d78cf4f78c0fb685a789c280d106ab242318ef Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 19:54:33 +0300 Subject: Fix issue #999 --- system/core/Config.php | 18 +++++++++++++++--- system/core/URI.php | 6 ++++-- user_guide_src/source/changelog.rst | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index 656382716..4b4e5a7ba 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -235,14 +235,26 @@ class CI_Config { return $this->slash_item('base_url').$this->item('index_page'); } + $uri = $this->_uri_string($uri); + if ($this->item('enable_query_strings') === FALSE) { $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); - return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; + + if ($suffix !== '' && ($offset = strpos($uri, '?')) !== FALSE) + { + $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); + } + else + { + $uri .= $suffix; + } + + return $this->slash_item('base_url').$this->slash_item('index_page').$uri; } - elseif (is_array($uri) OR strpos($uri, '?') === FALSE) + elseif (strpos($uri, '?') === FALSE) { - $uri = '?'.$this->_uri_string($uri); + $uri = '?'.$uri; } return $this->slash_item('base_url').$this->item('index_page').$uri; diff --git a/system/core/URI.php b/system/core/URI.php index 208d311a5..6a8b1a5ac 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -302,9 +302,11 @@ class CI_URI { */ public function _remove_url_suffix() { - if ($this->config->item('url_suffix') !== '') + $suffix = (string) $this->config->item('url_suffix'); + + if ($suffix !== '' && ($offset = strrpos($this->uri_string, $suffix)) !== FALSE) { - $this->uri_string = preg_replace('|'.preg_quote($this->config->item('url_suffix')).'$|', '', $this->uri_string); + $this->uri_string = substr_replace($this->uri_string, '', $offset, strlen($suffix)); } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b9d72642a..9ef0ce991 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -278,6 +278,7 @@ Bug fixes for 3.0 - Fixed a bug (#167) - ``$config['permitted_uri_chars']`` didn't affect URL-encoded characters. - Fixed a bug (#318) - :doc:`Profiling ` setting *query_toggle_count* was not settable as described in the manual. - Fixed a bug (#938) - :doc:`Config Library ` method site_url() added a question mark to the URL string when query strings are enabled even if it already existed. +- Fixed a bug (#999) - :doc:`Config Library ` method site_url() always appended ``$config['url_suffix']`` to the end of the URL string, regardless of wether a query string exists in it. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From f51b1fbafcf280d69633a37f4fc87c0ffcef78ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 20:02:23 +0300 Subject: Fix CI_Calendar::generate() not accepting NULLs (introduced in d261b1e89c3d4d5191036d5a5660ef6764e593a0) --- system/libraries/Calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 969a7610a..a49f171b9 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -155,7 +155,7 @@ class CI_Calendar { public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year - if ($year === '') + if (empty($year)) { $year = date('Y', $this->local_time); } @@ -168,7 +168,7 @@ class CI_Calendar { $year = '20'.$year; } - if ($month === '') + if (empty($month)) { $month = date('m', $this->local_time); } -- cgit v1.2.3-24-g4f1b From 95b2f4fa070f34084c78ccc68e67ecca51f40adf Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 16 Jun 2012 20:37:11 +0300 Subject: Really important space fix :) --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index e0dc637ad..5c4c257f8 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -40,7 +40,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/zip.html */ -class CI_Zip { +class CI_Zip { /** * Zip data in string form -- cgit v1.2.3-24-g4f1b From f0a8410a5cbe080b377ec352320872d27ce7d91f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 20:52:20 +0300 Subject: Fix two anchor_popup() issues --- system/helpers/url_helper.php | 7 ++----- user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 2bd41b04d..58bde17b4 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -204,7 +204,7 @@ if ( ! function_exists('anchor_popup')) if ( ! is_array($attributes)) { - $attributes = array(); + $attributes = array($attributes); } foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val) @@ -213,10 +213,7 @@ if ( ! function_exists('anchor_popup')) unset($attributes[$key]); } - if ($attributes !== '') - { - $attributes = _parse_attributes($attributes); - } + $attributes = empty($attributes) ? '' : _parse_attributes($attributes); return ''.$title.''; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 9ef0ce991..542c47396 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -279,6 +279,7 @@ Bug fixes for 3.0 - Fixed a bug (#318) - :doc:`Profiling ` setting *query_toggle_count* was not settable as described in the manual. - Fixed a bug (#938) - :doc:`Config Library ` method site_url() added a question mark to the URL string when query strings are enabled even if it already existed. - Fixed a bug (#999) - :doc:`Config Library ` method site_url() always appended ``$config['url_suffix']`` to the end of the URL string, regardless of wether a query string exists in it. +- Fixed a bug where :doc:`URL Helper ` function anchor_popup() ignored the attributes argument if it is not an array. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 81c3208b79cca353b27ecd4bdf00d4b6e7c91b2c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 21:21:46 +0300 Subject: anchor_popup() improvements --- system/helpers/url_helper.php | 16 +++++++++++++--- user_guide_src/source/changelog.rst | 5 ++++- user_guide_src/source/helpers/url_helper.rst | 26 +++++++++++++++++--------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 58bde17b4..40ce807df 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -199,15 +199,23 @@ if ( ! function_exists('anchor_popup')) if ($attributes === FALSE) { - return '".$title.''; + return '".$title.''; } if ( ! is_array($attributes)) { $attributes = array($attributes); + + // Ref: http://www.w3schools.com/jsref/met_win_open.asp + $window_name = '_blank'; + } + elseif ( ! empty($attributes['window_name'])) + { + $window_name = $attributes['window_name']; + unset($attributes['window_name']); } - foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val) + foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0') as $key => $val) { $atts[$key] = isset($attributes[$key]) ? $attributes[$key] : $val; unset($attributes[$key]); @@ -215,7 +223,9 @@ if ( ! function_exists('anchor_popup')) $attributes = empty($attributes) ? '' : _parse_attributes($attributes); - return ''.$title.''; + return ''.$title.''; } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 542c47396..dd6fa4603 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -53,7 +53,10 @@ Release Date: Not Released - :doc:`Date Helper ` function now() now works with all timezone strings supported by PHP. - ``create_captcha()`` accepts additional colors parameter, allowing for color customization. - - ``url_title()`` will now trim extra dashes from beginning and end. + - :doc:`URL Helper ` changes include: + - ``url_title()`` will now trim extra dashes from beginning and end. + - ``anchor_popup()`` will now fill the "href" attribute with the URL and its JS code will return false instead. + - Added JS window name support to ``anchor_popup()`` function. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. - Changed ``humanize()`` to include a second param for the separator. - Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words. diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index e6d51b22b..3c91fd5dd 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -168,19 +168,20 @@ browser settings. Here is an example with attributes :: - $atts = array(                - 'width'      => '800',                - 'height'     => '600',                - 'scrollbars' => 'yes',                - 'status'     => 'yes',                - 'resizable'  => 'yes',                - 'screenx'    => '0',                - 'screeny'    => '0'              + $atts = array( + 'width' => '800', + 'height' => '600', + 'scrollbars' => 'yes', + 'status'      => 'yes', + 'resizable'   => 'yes', + 'screenx'     => '0', + 'screeny'     => '0', + 'window_name' => '_blank' ); echo anchor_popup('news/local/123', 'Click Me!', $atts); -Note: The above attributes are the function defaults so you only need to +.. note:: The above attributes are the function defaults so you only need to set the ones that are different from what you need. If you want the function to use all of its defaults simply pass an empty array in the third parameter @@ -189,6 +190,13 @@ third parameter echo anchor_popup('news/local/123', 'Click Me!', array()); +.. note:: The 'window_name' is not really an attribute, but an argument to + the JavaScript `window.open() ` + method, which accepts either a window name or a window target. + +.. note:: Any other attribute than the listed above will be parsed as an + HTML attribute to the anchor tag. + mailto() ======== -- cgit v1.2.3-24-g4f1b From d60e700640c2a67f74acff090b94d06117bfc203 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 00:03:03 +0300 Subject: Add an option to disable MIME detection in the Upload library (issue #1494) --- system/libraries/Upload.php | 16 +++++++++++++--- user_guide_src/source/libraries/file_uploading.rst | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index c96daaf15..d381440cd 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -59,6 +59,7 @@ class CI_Upload { public $error_msg = array(); public $mimes = array(); public $remove_spaces = TRUE; + public $detect_mime = TRUE; public $xss_clean = FALSE; public $temp_prefix = 'temp_file_'; public $client_name = ''; @@ -116,6 +117,7 @@ class CI_Upload { 'image_size_str' => '', 'error_msg' => array(), 'remove_spaces' => TRUE, + 'detect_mime' => TRUE, 'xss_clean' => FALSE, 'temp_prefix' => 'temp_file_', 'client_name' => '' @@ -209,7 +211,13 @@ class CI_Upload { // Set the uploaded data as class variables $this->file_temp = $_FILES[$field]['tmp_name']; $this->file_size = $_FILES[$field]['size']; - $this->_file_mime_type($_FILES[$field]); + + // Skip MIME type detection? + if ($this->detect_mime !== FALSE) + { + $this->_file_mime_type($_FILES[$field]); + } + $this->file_type = preg_replace('/^(.+?);.*$/', '\\1', $this->file_type); $this->file_type = strtolower(trim(stripslashes($this->file_type), '"')); $this->file_name = $this->_prep_filename($_FILES[$field]['name']); @@ -990,7 +998,7 @@ class CI_Upload { */ if (function_exists('finfo_file')) { - $finfo = finfo_open(FILEINFO_MIME); + $finfo = @finfo_open(FILEINFO_MIME); if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system { $mime = @finfo_file($finfo, $file['tmp_name']); @@ -1021,7 +1029,9 @@ class CI_Upload { */ if (DIRECTORY_SEPARATOR !== '\\') { - $cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'; + $cmd = function_exists('escapeshellarg') + ? 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1' + : 'file --brief --mime '.$file['tmp_name'].' 2>&1'; if (function_exists('exec')) { diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index 414d84f0b..65cd5c722 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -215,6 +215,9 @@ Preference Default Value Options Descripti that can not be discerned by the person uploading it. **remove_spaces** TRUE TRUE/FALSE (boolean) If set to TRUE, any spaces in the file name will be converted to underscores. This is recommended. +**detect_mime** TRUE TRUE/FALSE (boolean) If set to TRUE, a server side detection of the file type will be + performed to avoid code injection attacks. DO NOT disable this option + unless you have no other option as that would cause a security risk. ============================ ================= ======================= ====================================================================== Setting preferences in a config file -- cgit v1.2.3-24-g4f1b From 88c47278f775413b5a408f48d30bd279e34e601a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 02:32:31 +0300 Subject: Pagination: fixed 'rel' attribute handling, added custom attributes support, deprecated 'anchor_class' setting --- system/libraries/Pagination.php | 86 ++++++++++++++++++-------- user_guide_src/source/changelog.rst | 5 +- user_guide_src/source/libraries/pagination.rst | 40 ++++++------ 3 files changed, 81 insertions(+), 50 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index cdec736ff..9a5a0bf62 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -67,8 +67,8 @@ class CI_Pagination { public $page_query_string = FALSE; public $query_string_segment = 'per_page'; public $display_pages = TRUE; - public $anchor_class = ''; - public $attr_rel = TRUE; + protected $_attributes = ''; + protected $_link_types = array(); /** * Constructor @@ -92,15 +92,29 @@ class CI_Pagination { */ public function initialize($params = array()) { + $attributes = array(); + + if (isset($params['attributes']) && is_array($params['attributes'])) + { + $attributes = $params['attributes']; + unset($params['attributes']); + } + + // Deprecated legacy support for the anchor_class option + // Should be removed in CI 3.1+ + if (isset($params['anchor_class'])) + { + empty($params['anchor_class']) OR $attributes['class'] = $params['anchor_class']; + unset($params['anchor_class']); + } + + $this->_parse_attributes($attributes); + if (count($params) > 0) { foreach ($params as $key => $val) { - if ($key === 'anchor_class') - { - $this->anchor_class = ($val) ? 'class="'.$val.'" ' : ''; - } - elseif (isset($this->$key)) + if (isset($this->$key)) { $this->$key = $val; } @@ -213,7 +227,7 @@ class CI_Pagination { if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1)) { $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url; - $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'"'.$this->_attr_rel('start').'>' + $output .= $this->first_tag_open.'_attributes.$this->_attr_rel('start').'>' .$this->first_link.''.$this->first_tag_close; } @@ -224,13 +238,13 @@ class CI_Pagination { if ($i === $base_page && $this->first_url !== '') { - $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'"'.$this->_attr_rel('prev').'>' + $output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>' .$this->prev_link.''.$this->prev_tag_close; } else { $i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix; - $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'"'.$this->_attr_rel('prev').'>' + $output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>' .$this->prev_link.''.$this->prev_tag_close; } @@ -243,7 +257,6 @@ class CI_Pagination { for ($loop = $start -1; $loop <= $end; $loop++) { $i = ($this->use_page_numbers) ? $loop : ($loop * $this->per_page) - $this->per_page; - if ($i >= $base_page) { if ($this->cur_page === $loop) @@ -253,17 +266,15 @@ class CI_Pagination { else { $n = ($i === $base_page) ? '' : $i; - - if ($n === '' && $this->first_url !== '') + if ($n === '' && ! empty($this->first_url)) { - $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'"'.$this->_attr_rel('start').'>' + $output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>' .$loop.''.$this->num_tag_close; } else { $n = ($n === '') ? '' : $this->prefix.$n.$this->suffix; - - $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'"'.$this->_attr_rel().'>' + $output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>' .$loop.''.$this->num_tag_close; } } @@ -276,8 +287,8 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page; - $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$this->_attr_rel('next').'>' - .$this->next_link.''.$this->next_tag_close; + $output .= $this->next_tag_open.'_attributes + .$this->_attr_rel('next').'>'.$this->next_link.''.$this->next_tag_close; } // Render the "Last" link @@ -285,7 +296,7 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page; - $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$this->_attr_rel().'>' + $output .= $this->last_tag_open.'_attributes.'>' .$this->last_link.''.$this->last_tag_close; } @@ -299,24 +310,45 @@ class CI_Pagination { // -------------------------------------------------------------------- + /** + * Parse attributes + * + * @param array + * @return void + */ + protected function _parse_attributes($attributes) + { + isset($attributes['rel']) OR $attributes['rel'] = TRUE; + $this->_link_types = ($attributes['rel']) + ? array('start' => 'start', 'prev' => 'prev', 'next' => 'next') + : array(); + unset($attributes['rel']); + + $this->_attributes = ''; + foreach ($attributes as $key => $value) + { + $this->_attributes .= ' '.$key.'="'.$value.'"'; + } + } + + // -------------------------------------------------------------------- + /** * Add "rel" attribute * + * @link http://www.w3.org/TR/html5/links.html#linkTypes * @param string * @return string */ - protected function _attr_rel($value = '') + protected function _attr_rel($type) { - if (empty($this->attr_rel) OR ($this->attr_rel === TRUE && empty($value))) - { - return ''; - } - elseif ( ! is_bool($this->attr_rel)) + if (isset($this->_link_types[$type])) { - $value = $this->attr_rel; + unset($this->_link_types[$type]); + return ' rel="'.$type.'"'; } - return ' rel="'.$value.'"'; + return ''; } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index dd6fa4603..4054a04ff 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -162,7 +162,10 @@ Release Date: Not Released - Added dsn (delivery status notification) option to the :doc:`Email Library `. - Renamed method _set_header() to set_header() and made it public to enable adding custom headers in the :doc:`Email Library `. - Added an "index" parameter to the data() method in the :doc:`Upload Library `. - - Added support for the anchor "rel" attribute in the :doc:`Pagination Library `. + - :doc:`Pagination Library ` changes include: + - Added support for the anchor "rel" attribute. + - Added support for setting custom attributes. + - Deprecated usage of the "anchor_class" setting (use the new "attributes" setting instead). - Core diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 560755fb6..c4398d739 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -247,34 +247,30 @@ adding:: $config['display_pages'] = FALSE; -****************************** -Adding a class to every anchor -****************************** +**************************** +Adding attributes to anchors +**************************** -If you want to add a class attribute to every link rendered by the -pagination class, you can set the config "anchor_class" equal to the -classname you want. +If you want to add an extra attribute to be added to every link rendered +by the pagination class, you can set them as key/value pairs in the +"attributes" config :: - $config['anchor_class'] = 'myclass'; // class="myclass" + // Produces: class="myclass" + $config['attributes'] = array('class' => 'myclass'); -********************************** -Changing the "rel" attribute value -********************************** +.. note:: Usage of the old method of setting classes via "anchor_class" + is deprecated. -By default, the rel attribute will be automatically put under the -following conditions: +***************************** +Disabling the "rel" attribute +***************************** -- rel="start" for the "first" link -- rel="prev" for the "previous" link -- rel="next" for the "next" link +By default the rel attribute is dynamically generated and appended to +the appropriate anchors. If for some reason you want to turn it off, +you can pass boolean FALSE as a regular attribute -If you want to disable the rel attribute, or change its value, you -can set the 'attr_rel' config option:: - - // Disable - $config['attr_rel'] = FALSE; +:: - // Use a custom value on all anchors - $config['attr_rel'] = 'custom_value'; // produces: rel="custom_value" \ No newline at end of file + $config['attributes']['rel'] = FALSE; \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0159ae7d492cccca7a30a2f5b5c2b107d399e7ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 02:33:43 +0300 Subject: AND -> && --- system/libraries/Cache/drivers/Cache_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 028875b7d..37d77c268 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -73,7 +73,7 @@ class CI_Cache_file extends CI_Driver { $data = unserialize(file_get_contents($this->_cache_path.$id)); - if ($data['ttl'] > 0 AND time() > $data['time'] + $data['ttl']) + if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl']) { unlink($this->_cache_path.$id); return FALSE; -- cgit v1.2.3-24-g4f1b From d1cace76965f71107aca63df1057b98df8d3b85a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 03:01:00 +0300 Subject: Add deprecated docblock tags for do_hash() and read_file() --- system/helpers/file_helper.php | 1 + system/helpers/security_helper.php | 1 + 2 files changed, 2 insertions(+) diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index be616f62d..7270ee32c 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -47,6 +47,7 @@ if ( ! function_exists('read_file')) * This function is DEPRECATED and should be removed in * CodeIgniter 3.1+. Use file_get_contents() instead. * + * @deprecated * @param string path to file * @return string */ diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 7fcb18437..7968f9e9f 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -80,6 +80,7 @@ if ( ! function_exists('do_hash')) * This function is DEPRECATED and should be removed in * CodeIgniter 3.1+. Use hash() instead. * + * @deprecated * @param string * @param string * @return string -- cgit v1.2.3-24-g4f1b From 929fd2d52beb779e46681d35f8ff138aa65cb8df Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 17:29:57 +0300 Subject: Improve escaping, support for table names with spaces and fix where() for strings with no spaces around operators --- system/database/DB_driver.php | 56 ++++++++++------------ system/database/DB_query_builder.php | 4 +- system/database/drivers/postgre/postgre_driver.php | 4 +- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 28d665fdf..4ec20f45d 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1085,6 +1085,20 @@ abstract class CI_DB_driver { // -------------------------------------------------------------------- + /** + * Returns the SQL string operator + * + * @param string + * @return string + */ + protected function _get_operator($str) + { + return preg_match('/(=|!|<|>| IS NULL| IS NOT NULL| BETWEEN)/i', $str, $match) + ? $match[1] : FALSE; + } + + // -------------------------------------------------------------------- + /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * @@ -1336,39 +1350,21 @@ abstract class CI_DB_driver { // Convert tabs or multiple spaces into single spaces $item = preg_replace('/\s+/', ' ', $item); - static $preg_ec = array(); - - if (empty($preg_ec)) + // If the item has an alias declaration we remove it and set it aside. + // Note: strripos() is used in order to support spaces in table names + if ($offset = strripos($item, ' AS ')) { - if (is_array($this->_escape_char)) - { - $preg_ec = array(preg_quote($this->_escape_char[0]), preg_quote($this->_escape_char[1])); - } - else - { - $preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char); - } + $alias = ($protect_identifiers) + ? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4)) + : substr($item, $offset); + $item = substr($item, 0, $offset); } - - // If the item has an alias declaration we remove it and set it aside. - // Basically we remove everything to the right of the first space - preg_match('/^(('.$preg_ec[0].'[^'.$preg_ec[1].']+'.$preg_ec[1].')|([^'.$preg_ec[0].'][^\s]+))( AS)*(.+)*$/i', $item, $matches); - - if (isset($matches[4])) + elseif ($offset = strrpos($item, ' ')) { - $item = $matches[1]; - - // Escape the alias, if needed - if ($protect_identifiers === TRUE) - { - $alias = empty($matches[5]) - ? ' '.$this->escape_identifiers(ltrim($matches[4])) - : $matches[4].' '.$this->escape_identifiers(ltrim($matches[5])); - } - else - { - $alias = $matches[4].$matches[5]; - } + $alias = ($protect_identifiers) + ? ' '.$this->escape_identifiers(substr($item, $offset + 1)) + : substr($item, $offset); + $item = substr($item, 0, $offset); } else { diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 531ca9eb7..27f9f363b 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -459,8 +459,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; - $k = $this->_has_operator($k) - ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') + $k = (($op = $this->_get_operator($k)) !== FALSE) + ? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op) : $this->protect_identifiers($k, FALSE, $escape); if (is_null($v) && ! $this->_has_operator($k)) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 3d25b25ee..23826a0ae 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -612,8 +612,8 @@ class CI_DB_postgre_driver extends CI_DB { { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; - $k = $this->_has_operator($k) - ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') + $k = (($op = $this->_get_operator($k)) !== FALSE) + ? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op) : $this->protect_identifiers($k, FALSE, $escape); if (is_null($v) && ! $this->_has_operator($k)) -- cgit v1.2.3-24-g4f1b From 3751f9362b731f5f3d2e63176c364d6281fdf415 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 18:07:48 +0300 Subject: Add join() USING support --- system/database/DB_query_builder.php | 14 +++++++++++--- user_guide_src/source/changelog.rst | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 27f9f363b..4c54b1c0a 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -368,12 +368,20 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $newcond .= $m[0][$i][0]; } - $cond = $newcond; + $cond = ' ON '.$newcond; } // Split apart the condition and protect the identifiers elseif ($escape === TRUE && preg_match('/([\[\w\.-]+)([\W\s]+)(.+)/i', $cond, $match)) { - $cond = $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); + $cond = ' ON '.$this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); + } + elseif ( ! $this->_has_operator($cond)) + { + $cond = ' USING ('.($escape ? $this->escape_identifiers($cond) : $cond).')'; + } + else + { + $cond = ' ON '.$cond; } // Do we want to escape the table name? @@ -383,7 +391,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // Assemble the JOIN statement - $this->qb_join[] = $join = $type.'JOIN '.$table.' ON '.$cond; + $this->qb_join[] = $join = $type.'JOIN '.$table.$cond; if ($this->qb_caching === TRUE) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4054a04ff..b39d43b1a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -79,6 +79,7 @@ Release Date: Not Released - Added new methods that return the SQL string of queries without executing them: get_compiled_select(), get_compiled_insert(), get_compiled_update(), get_compiled_delete(). - Added an optional parameter that allows to disable escaping (useful for custom fields) for methods join(), order_by(), where_in(), or_where_in(), where_not_in(), or_where_not_in(). - Added support for join() with multiple conditions. + - Added support for USING in join(). - Improved support for the MySQLi driver, including: - OOP style of the PHP extension is now used, instead of the procedural aliases. - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. -- cgit v1.2.3-24-g4f1b From 6ac514484fffd9700c6ecc57cfa1b1fd105e37f6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Jun 2012 13:05:17 +0300 Subject: Fix issue #1328 --- system/libraries/Form_validation.php | 7 ++++++- user_guide_src/source/changelog.rst | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index fb1c69caf..db773e252 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -649,7 +649,12 @@ class CI_Form_validation { } else { - $postdata = $this->_field_data[$row['field']]['postdata']; + // If we get an array field, but it's not expected - then it is most likely + // somebody messing with the form on the client side, so we'll just consider + // it an empty field + $postdata = is_array($this->_field_data[$row['field']]['postdata']) + ? NULL + : $this->_field_data[$row['field']]['postdata']; } // Is the rule a callback? diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b39d43b1a..67b78bf8b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -287,6 +287,7 @@ Bug fixes for 3.0 - Fixed a bug (#938) - :doc:`Config Library ` method site_url() added a question mark to the URL string when query strings are enabled even if it already existed. - Fixed a bug (#999) - :doc:`Config Library ` method site_url() always appended ``$config['url_suffix']`` to the end of the URL string, regardless of wether a query string exists in it. - Fixed a bug where :doc:`URL Helper ` function anchor_popup() ignored the attributes argument if it is not an array. +- Fixed a bug (#1328) - :doc:`Form Validation Library ` didn't properly check the type of the form fields before processing them. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From fad14b25148ca7202a036dc2b764feb0c8518838 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Jun 2012 13:23:24 +0300 Subject: Fix ODBC _limit() --- system/database/drivers/odbc/odbc_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 222c311c0..5ebba7aeb 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -342,7 +342,7 @@ class CI_DB_odbc_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return $sql.($offset == 0 ? '' : $offset.', ').$limit; + return $sql.' LIMIT '.($offset == 0 ? '' : $offset.', ').$limit; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 777153d8362ed884fc3d47ea4a5e1fa0f1ce8ca9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Jun 2012 13:30:45 +0300 Subject: Changed limit() and offset() to ignore NULL values --- system/database/DB_query_builder.php | 10 +++------- user_guide_src/source/changelog.rst | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 4c54b1c0a..d21f15066 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1042,12 +1042,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function limit($value, $offset = NULL) { - $this->qb_limit = (int) $value; - - if ( ! empty($offset)) - { - $this->qb_offset = (int) $offset; - } + is_null($value) OR $this->qb_limit = (int) $value; + empty($offset) OR $this->qb_offset = (int) $offset; return $this; } @@ -1062,7 +1058,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function offset($offset) { - $this->qb_offset = (int) $offset; + empty($offset) OR $this->qb_offset = (int) $offset; return $this; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 67b78bf8b..da608b162 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -80,6 +80,8 @@ Release Date: Not Released - Added an optional parameter that allows to disable escaping (useful for custom fields) for methods join(), order_by(), where_in(), or_where_in(), where_not_in(), or_where_not_in(). - Added support for join() with multiple conditions. - Added support for USING in join(). + - Changed limit() to ignore NULL values instead of always casting to integer. + - Changed offset() to ignore empty values instead of always casting to integer. - Improved support for the MySQLi driver, including: - OOP style of the PHP extension is now used, instead of the procedural aliases. - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. -- cgit v1.2.3-24-g4f1b From a465fc406010ca3648a7f55a63996569a5f86efb Mon Sep 17 00:00:00 2001 From: Robert Doucette Date: Tue, 19 Jun 2012 01:49:01 +0300 Subject: fixing a typo in the comments of the migration config file --- application/config/migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/migration.php b/application/config/migration.php index 88e398243..7645ade7c 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -44,7 +44,7 @@ $config['migration_enabled'] = FALSE; | | This is the name of the table that will store the current migrations state. | When migrations runs it will store in a database table which migration -| level the system is at. It then compares the migration level in the this +| level the system is at. It then compares the migration level in this | table to the $config['migration_version'] if they are not the same it | will migrate up. This must be set. | -- cgit v1.2.3-24-g4f1b From 9e5a9b55d6bd3588a35f42d62f76934b4a7582f4 Mon Sep 17 00:00:00 2001 From: Dumk0 Date: Tue, 19 Jun 2012 12:02:27 +0300 Subject: Property values aligned into one vertical line --- system/libraries/Pagination.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 9a5a0bf62..5a4ca8f10 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -36,36 +36,36 @@ */ class CI_Pagination { - public $base_url = ''; // The page we are linking to - public $prefix = ''; // A custom prefix added to the path. - public $suffix = ''; // A custom suffix added to the path. - public $total_rows = 0; // Total number of items (database results) - public $per_page = 10; // Max number of items you want shown per page - public $num_links = 2; // Number of "digit" links to show before/after the currently viewed page - public $cur_page = 0; // The current page being viewed - public $use_page_numbers = FALSE; // Use page number for segment instead of offset - public $first_link = '‹ First'; - public $next_link = '>'; - public $prev_link = '<'; - public $last_link = 'Last ›'; - public $uri_segment = 3; + public $base_url = ''; // The page we are linking to + public $prefix = ''; // A custom prefix added to the path. + public $suffix = ''; // A custom suffix added to the path. + public $total_rows = 0; // Total number of items (database results) + public $per_page = 10; // Max number of items you want shown per page + public $num_links = 2; // Number of "digit" links to show before/after the currently viewed page + public $cur_page = 0; // The current page being viewed + public $use_page_numbers = FALSE; // Use page number for segment instead of offset + public $first_link = '‹ First'; + public $next_link = '>'; + public $prev_link = '<'; + public $last_link = 'Last ›'; + public $uri_segment = 3; public $full_tag_open = ''; public $full_tag_close = ''; public $first_tag_open = ''; public $first_tag_close = ' '; public $last_tag_open = ' '; public $last_tag_close = ''; - public $first_url = ''; // Alternative URL for the First Page. - public $cur_tag_open = ' '; + public $first_url = ''; // Alternative URL for the First Page. + public $cur_tag_open = ' '; public $cur_tag_close = ''; public $next_tag_open = ' '; public $next_tag_close = ' '; public $prev_tag_open = ' '; public $prev_tag_close = ''; - public $num_tag_open = ' '; + public $num_tag_open = ' '; public $num_tag_close = ''; public $page_query_string = FALSE; - public $query_string_segment = 'per_page'; + public $query_string_segment = 'per_page'; public $display_pages = TRUE; protected $_attributes = ''; protected $_link_types = array(); -- cgit v1.2.3-24-g4f1b From af6d85088d54ed35f7c36ed010384ff7592f8959 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 19 Jun 2012 15:30:47 -0500 Subject: Fixed Migrations and an incorrect strict comparison. --- system/language/english/migration_lang.php | 2 +- system/libraries/Migration.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php index 9e3e18807..af920660c 100644 --- a/system/language/english/migration_lang.php +++ b/system/language/english/migration_lang.php @@ -26,7 +26,7 @@ */ $lang['migration_none_found'] = "No migrations were found."; -$lang['migration_not_found'] = "This migration could not be found."; +$lang['migration_not_found'] = "No migration could be found with the version number: %d."; $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."; diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 4391b235d..3a1e7a0ad 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -179,7 +179,7 @@ class CI_Migration { // We now prepare to actually DO the migrations // But first let's make sure that everything is the way it should be - for ($i = $start; $i !== $stop; $i += $step) + for ($i = $start; $i != $stop; $i += $step) { $f = glob(sprintf($this->_migration_path.'%03d_*.php', $i)); -- cgit v1.2.3-24-g4f1b From 2f0dce0fa788c442c85318afc30122afb20a880b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jun 2012 11:05:01 +0300 Subject: Small adjustment due to 079fbfcde095230f304e889217f897031a948f61 --- 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 4ec20f45d..a99444167 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1281,7 +1281,7 @@ abstract class CI_DB_driver { if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE) { // Found it - use a relative path for safety - $message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']); + $message[] = 'Filename: '.str_replace(array(APPPATH, BASEPATH), '', $call['file']); $message[] = 'Line Number: '.$call['line']; break; } -- cgit v1.2.3-24-g4f1b From a84055b49539da1faa2893618b2475d1888a9fea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jun 2012 14:37:59 +0300 Subject: Fix issue #1510 --- tests/codeigniter/helpers/date_helper_test.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 8258c9248..4e01b1aa3 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -48,11 +48,9 @@ class Date_helper_test extends CI_TestCase { */ - $this->ci_set_config('time_reference', 'UTC'); - $this->assertEquals( - gmmktime(date('G'), date('i'), date('s'), date('n'), date('j'), date('Y')), - now() + mktime(gmdate('G'), gmdate('i'), gmdate('s'), gmdate('n'), gmdate('j'), gmdate('Y')), + now('UTC') ); } -- cgit v1.2.3-24-g4f1b From 8d3099d4e5261e0f044c7fcd8b3ab7724645aa8d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Jun 2012 16:00:20 +0300 Subject: Fix issue #79 --- system/libraries/Form_validation.php | 3 +-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index db773e252..4bb29e41b 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -571,8 +571,7 @@ class CI_Form_validation { { foreach ($postdata as $key => $val) { - $this->_execute($row, $rules, $val, $cycles); - $cycles++; + $this->_execute($row, $rules, $val, $key); } return; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index da608b162..8a6c922a4 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -290,6 +290,7 @@ Bug fixes for 3.0 - Fixed a bug (#999) - :doc:`Config Library ` method site_url() always appended ``$config['url_suffix']`` to the end of the URL string, regardless of wether a query string exists in it. - Fixed a bug where :doc:`URL Helper ` function anchor_popup() ignored the attributes argument if it is not an array. - Fixed a bug (#1328) - :doc:`Form Validation Library ` didn't properly check the type of the form fields before processing them. +- Fixed a bug (#79) - :doc:`Form Validation Library ` didn't properly validate array fields that use associative keys or have custom indexes. Version 2.1.1 ============= -- cgit v1.2.3-24-g4f1b From 3b6af434b13168828429d06aae7699f6f9537a87 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 21 Jun 2012 09:21:17 -0500 Subject: Replaced block tag minification regex with a less greedy solution. --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Output.php b/system/core/Output.php index ed294f116..4fdf18f14 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -652,7 +652,7 @@ class CI_Output { $output = preg_replace('{\s*\s*}msU', '', $output); // Remove spaces around block-level elements. - $output = preg_replace('{\s*()\s+}msU', '$1', $output); + $output = preg_replace('/\s*(<\/?(html|head|title|meta|script|link|style|body|h[1-6]|div|p|br)[^>]*>)\s*/is', '$1', $output); // Replace mangled
     etc. tags with unprocessed ones.
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From bc69f369eba2f1188be6d89ebd1df8c48e96db5d Mon Sep 17 00:00:00 2001
    From: WanWizard 
    Date: Fri, 22 Jun 2012 00:10:11 +0200
    Subject: fixed query grouping when using where($array) syntax
    
    on request of Phil
    ---
     system/database/DB_query_builder.php | 14 ++++----------
     1 file changed, 4 insertions(+), 10 deletions(-)
    
    diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
    index d21f15066..62e02129b 100644
    --- a/system/database/DB_query_builder.php
    +++ b/system/database/DB_query_builder.php
    @@ -453,8 +453,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     	 */
     	protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
     	{
    -		$type = $this->_group_get_type($type);
    -
     		if ( ! is_array($key))
     		{
     			$key = array($key => $value);
    @@ -465,7 +463,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     
     		foreach ($key as $k => $v)
     		{
    -			$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
    +			$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
     
     			$k = (($op = $this->_get_operator($k)) !== FALSE)
     				? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op)
    @@ -590,8 +588,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     			return $this;
     		}
     
    -		$type = $this->_group_get_type($type);
    -
     		if ( ! is_array($values))
     		{
     			$values = array($values);
    @@ -606,7 +602,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     			$this->qb_wherein[] = $this->escape($value);
     		}
     
    -		$prefix = (count($this->qb_where) === 0) ? '' : $type;
    +		$prefix = (count($this->qb_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
     		$this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key, FALSE, $escape).$not.' IN ('.implode(', ', $this->qb_wherein).') ';
     
     		if ($this->qb_caching === TRUE)
    @@ -702,8 +698,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     	 */
     	protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
     	{
    -		$type = $this->_group_get_type($type);
    -
     		if ( ! is_array($field))
     		{
     			$field = array($field => $match);
    @@ -712,7 +706,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     		foreach ($field as $k => $v)
     		{
     			$k = $this->protect_identifiers($k);
    -			$prefix = (count($this->qb_like) === 0) ? '' : $type;
    +			$prefix = (count($this->qb_like) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
     			$v = $this->escape_like_str($v);
     
     			if ($side === 'none')
    @@ -2393,4 +2387,4 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     }
     
     /* End of file DB_query_builder.php */
    -/* Location: ./system/database/DB_query_builder.php */
    \ No newline at end of file
    +/* Location: ./system/database/DB_query_builder.php */
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7540dede0f01acd7aa1ffd224defc5189305a815 Mon Sep 17 00:00:00 2001
    From: Mat Whitney 
    Date: Fri, 22 Jun 2012 12:02:10 -0700
    Subject: Added optional fourth parameter to timezone_menu
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    allows setting one or more attributes on the generated select tag.
    This allows passing attributes needed for Section 508 compliance §
    1194.22(n), such as an id.
    http://access-board.gov/sec508/guide/1194.22.htm#(n)
    http://www.w3.org/TR/WCAG10-HTML-TECHS/#forms-labels
    ---
     system/helpers/date_helper.php                | 20 ++++++++++++++++++--
     user_guide_src/source/changelog.rst           |  1 +
     user_guide_src/source/helpers/date_helper.rst | 27 +++++++++++++++------------
     3 files changed, 34 insertions(+), 14 deletions(-)
    
    diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
    index cafb6ba95..fc790c585 100644
    --- a/system/helpers/date_helper.php
    +++ b/system/helpers/date_helper.php
    @@ -547,9 +547,10 @@ if ( ! function_exists('timezone_menu'))
     	 * @param	string	timezone
     	 * @param	string	classname
     	 * @param	string	menu name
    +	 * @param	mixed	attributes
     	 * @return	string
     	 */
    -	function timezone_menu($default = 'UTC', $class = '', $name = 'timezones')
    +	function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
     	{
     		$CI =& get_instance();
     		$CI->lang->load('date');
    @@ -563,7 +564,22 @@ if ( ! function_exists('timezone_menu'))
     			$menu .= ' class="'.$class.'"';
     		}
     
    -		$menu .= ">\n";
    +		// Generate a string from the attributes submitted, if any
    +		if (is_array($attributes))
    +		{
    +			$atts = '';
    +			foreach ($attributes as $key => $val)
    +			{
    +				$atts .= ' '.$key.'="'.$val.'"';
    +			}
    +			$attributes = $atts;
    +		}
    +		elseif (is_string($attributes) && strlen($attributes) > 0)
    +		{
    +			$attributes = ' '.$attributes;
    +		}
    +
    +		$menu .= $attributes.">\n";
     
     		foreach (timezones() as $key => $val)
     		{
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 8a6c922a4..c861a1e8d 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -70,6 +70,7 @@ Release Date: Not Released
     	 - ``set_realpath()`` can now also handle file paths as opposed to just directories.
     	 - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html.
     	 - ``read_file()`` is now a deprecated alias of ``file_get_contents()``.
    +   -  :doc:`Date Helper ` Added optional fourth parameter to ``timezone_menu()`` that allows more attributes to be added to the generated select tag
     
     -  Database
     
    diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
    index b6dc2e934..ba079394d 100644
    --- a/user_guide_src/source/helpers/date_helper.rst
    +++ b/user_guide_src/source/helpers/date_helper.rst
    @@ -115,7 +115,7 @@ Supported formats:
     local_to_gmt()
     ==============
     
    -Takes a Unix timestamp as input and returns it as GMT. 
    +Takes a Unix timestamp as input and returns it as GMT.
     
     .. php:method:: local_to_gmt($time = '')
     
    @@ -159,7 +159,7 @@ Example
     mysql_to_unix()
     ===============
     
    -Takes a MySQL Timestamp as input and returns it as Unix. 
    +Takes a MySQL Timestamp as input and returns it as Unix.
     
     .. php:method:: mysql_to_unix($time = '')
     
    @@ -212,7 +212,7 @@ human_to_unix()
     The opposite of the above function. Takes a "human" time as input and
     returns it as Unix. This function is useful if you accept "human"
     formatted dates submitted via a form. Returns FALSE (boolean) if the
    -date string passed to it is not formatted as indicated above. 
    +date string passed to it is not formatted as indicated above.
     
     .. php:method:: human_to_unix($datestr = '')
     
    @@ -235,9 +235,9 @@ them into something useful. It also accepts well-formed dates.
     
     The function will return a Unix timestamp by default. You can,
     optionally, pass a format string (the same type as the PHP date function
    -accepts) as the second parameter. 
    +accepts) as the second parameter.
     
    -.. php:method:: nice_date($bad_date = '', $format = FALSE) 
    +.. php:method:: nice_date($bad_date = '', $format = FALSE)
     
     	:param integer 	$bad_date: The terribly formatted date-like string
     	:param string 	$format: Date format to return (same as php date function)
    @@ -265,10 +265,10 @@ Formats a unix timestamp so that is appears similar to this
     
     The first parameter must contain a Unix timestamp. The second parameter
     must contain a timestamp that is greater that the first timestamp. If
    -the second parameter empty, the current time will be used. The third 
    -parameter is optional and limits the number of time units to display. 
    -The most common purpose for this function is to show how much time has 
    -elapsed from some point in time in the past to now. 
    +the second parameter empty, the current time will be used. The third
    +parameter is optional and limits the number of time units to display.
    +The most common purpose for this function is to show how much time has
    +elapsed from some point in time in the past to now.
     
     .. php:method:: timespan($seconds = 1, $time = '', $units = '')
     
    @@ -293,7 +293,7 @@ days_in_month()
     ===============
     
     Returns the number of days in a given month/year. Takes leap years into
    -account. 
    +account.
     
     .. php:method:: days_in_month($month = 0, $year = '')
     
    @@ -390,14 +390,15 @@ allowed to set their local timezone value.
     The first parameter lets you set the "selected" state of the menu. For
     example, to set Pacific time as the default you will do this
     
    -.. php:method:: timezone_menu($default = 'UTC', $class = "", $name = 'timezones')
    +.. php:method:: timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
     
     	:param string 	$default: timezone
     	:param string	$class: classname
     	:param string	$name: menu name
    +	:param mixed	$attributes: attributes
     	:returns: string
     
    -Example: 
    +Example:
     
     ::
     
    @@ -407,6 +408,8 @@ Please see the timezone reference below to see the values of this menu.
     
     The second parameter lets you set a CSS class name for the menu.
     
    +The fourth parameter lets you set one or more attributes on the generated select tag.
    +
     .. note:: The text contained in the menu is found in the following
     	language file: `language//date_lang.php`
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 282e02c7d66085d3c6d4c85eed4a1581389b5e63 Mon Sep 17 00:00:00 2001
    From: Alex Bilbie 
    Date: Sat, 23 Jun 2012 14:11:58 +0100
    Subject: Clarified support of $config['csrf_exclude_uris'] support in v3.0
     (#236)
    
    ---
     user_guide_src/source/changelog.rst | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 8a6c922a4..f8eb59644 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -148,6 +148,7 @@ Release Date: Not Released
     	 -  If property maintain_ratio is set to TRUE, image_reproportion() now doesn't need both width and height to be specified.
        -  Removed SHA1 function in the :doc:`Encryption Library `.
        -  Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional.
    +   -  Added $config['csrf_exclude_uris'] to the CSRF protection in the :doc:`Security library `, which allows you list URIs which will not have the CSRF validation functions run.
        -  :doc:`Form Validation library ` changes include:
     	 -  Added method error_array() to return all error messages as an array.
     	 -  Added method set_data() to set an alternative data array to be validated instead of the default $_POST.
    @@ -453,7 +454,6 @@ Release Date: August 20, 2011
        -  Added insert_batch() function to the PostgreSQL database driver.
           Thanks to epallerols for the patch.
        -  Added "application/x-csv" to mimes.php.
    -   -  Added CSRF protection URI whitelisting.
        -  Fixed a bug where :doc:`Email library `
           attachments with a "." in the name would using invalid MIME-types.
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From f82b92999e8309155df3e665e25a261c26b0e93d Mon Sep 17 00:00:00 2001
    From: Phil Sturgeon 
    Date: Sat, 23 Jun 2012 15:49:23 +0100
    Subject: Added ['reuse_query_string'] to Pagination. This allows automatic
     repopulation of query string arguments, combined with normal URI segments.
    
    ---
     system/libraries/Pagination.php                | 98 +++++++++++++++-----------
     user_guide_src/source/changelog.rst            |  1 +
     user_guide_src/source/libraries/pagination.rst | 15 ++++
     3 files changed, 74 insertions(+), 40 deletions(-)
    
    diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
    index 5a4ca8f10..75745dd48 100644
    --- a/system/libraries/Pagination.php
    +++ b/system/libraries/Pagination.php
    @@ -36,39 +36,40 @@
      */
     class CI_Pagination {
     
    -	public $base_url		= ''; // The page we are linking to
    -	public $prefix			= ''; // A custom prefix added to the path.
    -	public $suffix			= ''; // A custom suffix added to the path.
    -	public $total_rows		= 0; // Total number of items (database results)
    -	public $per_page		= 10; // Max number of items you want shown per page
    -	public $num_links		= 2; // Number of "digit" links to show before/after the currently viewed page
    -	public $cur_page		= 0; // The current page being viewed
    -	public $use_page_numbers	= FALSE; // Use page number for segment instead of offset
    -	public $first_link		= '‹ First';
    -	public $next_link		= '>';
    -	public $prev_link		= '<';
    -	public $last_link		= 'Last ›';
    -	public $uri_segment		= 3;
    -	public $full_tag_open		= '';
    -	public $full_tag_close		= '';
    -	public $first_tag_open		= '';
    -	public $first_tag_close		= ' ';
    -	public $last_tag_open		= ' ';
    -	public $last_tag_close		= '';
    -	public $first_url		= ''; // Alternative URL for the First Page.
    -	public $cur_tag_open		= ' ';
    -	public $cur_tag_close		= '';
    -	public $next_tag_open		= ' ';
    -	public $next_tag_close		= ' ';
    -	public $prev_tag_open		= ' ';
    -	public $prev_tag_close		= '';
    -	public $num_tag_open		= ' ';
    -	public $num_tag_close		= '';
    -	public $page_query_string	= FALSE;
    -	public $query_string_segment 	= 'per_page';
    -	public $display_pages		= TRUE;
    -	protected $_attributes		= '';
    -	protected $_link_types		= array();
    +	protected $base_url				= ''; // The page we are linking to
    +	protected $prefix				= ''; // A custom prefix added to the path.
    +	protected $suffix				= ''; // A custom suffix added to the path.
    +	protected $total_rows			= 0; // Total number of items (database results)
    +	protected $per_page				= 10; // Max number of items you want shown per page
    +	protected $num_links			= 2; // Number of "digit" links to show before/after the currently viewed page
    +	protected $cur_page				= 0; // The current page being viewed
    +	protected $use_page_numbers		= FALSE; // Use page number for segment instead of offset
    +	protected $first_link			= '‹ First';
    +	protected $next_link			= '>';
    +	protected $prev_link			= '<';
    +	protected $last_link			= 'Last ›';
    +	protected $uri_segment			= 3;
    +	protected $full_tag_open		= '';
    +	protected $full_tag_close		= '';
    +	protected $first_tag_open		= '';
    +	protected $first_tag_close		= ' ';
    +	protected $last_tag_open		= ' ';
    +	protected $last_tag_close		= '';
    +	protected $first_url			= ''; // Alternative URL for the First Page.
    +	protected $cur_tag_open			= ' ';
    +	protected $cur_tag_close		= '';
    +	protected $next_tag_open		= ' ';
    +	protected $next_tag_close		= ' ';
    +	protected $prev_tag_open		= ' ';
    +	protected $prev_tag_close		= '';
    +	protected $num_tag_open			= ' ';
    +	protected $num_tag_close		= '';
    +	protected $page_query_string	= FALSE;
    +	protected $query_string_segment 	= 'per_page';
    +	protected $display_pages		= TRUE;
    +	protected $_attributes			= '';
    +	protected $_link_types			= array();
    +	protected $reuse_query_string   = FALSE;
     
     	/**
     	 * Constructor
    @@ -222,6 +223,23 @@ class CI_Pagination {
     
     		// And here we go...
     		$output = '';
    +		$query_string = '';
    +
    +		// Add anything in the query string back to the links
    +		// Note: Nothing to do with query_string_segment or any other query string options
    +		if ($this->reuse_query_string === TRUE)
    +		{
    +			$get = $CI->input->get();
    +			
    +			// Unset the controll, method, old-school routing options
    +			unset($get['c'], $get['m'], $get[$this->query_string_segment]);
    +
    +			// Put everything else onto the end
    +			$query_string = (strpos($this->base_url, '&') !== FALSE ? '&' : '?') . http_build_query($get, '', '&');
    +
    +			// Add this after the suffix to put it into more links easily
    +			$this->suffix .= $query_string;
    +		}
     
     		// Render the "First" link
     		if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
    @@ -232,19 +250,19 @@ class CI_Pagination {
     		}
     
     		// Render the "previous" link
    -		if  ($this->prev_link !== FALSE && $this->cur_page !== 1)
    +		if ($this->prev_link !== FALSE && $this->cur_page !== 1)
     		{
     			$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
     
     			if ($i === $base_page && $this->first_url !== '')
     			{
    -				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
    +				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
     					.$this->prev_link.''.$this->prev_tag_close;
     			}
     			else
     			{
    -				$i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix;
    -				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
    +				$append = ($i === $base_page) ? $query_string : $this->prefix.$i.$this->suffix;
    +				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
     					.$this->prev_link.''.$this->prev_tag_close;
     			}
     
    @@ -268,13 +286,13 @@ class CI_Pagination {
     						$n = ($i === $base_page) ? '' : $i;
     						if ($n === '' && ! empty($this->first_url))
     						{
    -							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
    +							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
     								.$loop.''.$this->num_tag_close;
     						}
     						else
     						{
    -							$n = ($n === '') ? '' : $this->prefix.$n.$this->suffix;
    -							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
    +							$append = ($n === '') ? $query_string : $this->prefix.$n.$this->suffix;
    +							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
     								.$loop.''.$this->num_tag_close;
     						}
     					}
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index f8eb59644..29084ed9b 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -170,6 +170,7 @@ Release Date: Not Released
     	 -  Added support for the anchor "rel" attribute.
     	 -  Added support for setting custom attributes.
     	 -  Deprecated usage of the "anchor_class" setting (use the new "attributes" setting instead).
    +	 -  Added $config['reuse_query_string'] to allow automatic repopulation of query string arguments, combined with normal URI segments.
     
     -  Core
     
    diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst
    index c4398d739..15b3675df 100644
    --- a/user_guide_src/source/libraries/pagination.rst
    +++ b/user_guide_src/source/libraries/pagination.rst
    @@ -112,6 +112,21 @@ the pagination link will become.
     Note that "per_page" is the default query string passed, however can be
     configured using $config['query_string_segment'] = 'your_string'
     
    +$config['reuse_query_string'] = FALSE;
    +====================================
    +
    +By default your Query String arguments (nothing to do with other 
    +query string options) will be ignored. Setting this config to 
    +TRUE will add existing query string arguments back into the 
    +URL after the URI segment and before the suffix
    +
    +::
    +
    +	http://example.com/index.php/test/page/20?query=search%term
    +
    +This helps you mix together normal :doc:`URI Segments <../general/urls>`
    +as well as query string arguments, which until 3.0 was not possible.
    +
     ***********************
     Adding Enclosing Markup
     ***********************
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7a744a8ba8f07ba1ec3a48f1d5de641b4025ce20 Mon Sep 17 00:00:00 2001
    From: Phil Sturgeon 
    Date: Sat, 23 Jun 2012 17:21:00 +0100
    Subject: If there is no output then no need to try minifying it
    
    ---
     system/core/Output.php | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/system/core/Output.php b/system/core/Output.php
    index 4fdf18f14..5ec8c4bc0 100644
    --- a/system/core/Output.php
    +++ b/system/core/Output.php
    @@ -625,6 +625,11 @@ class CI_Output {
     
     				$size_before = strlen($output);
     
    +				if ($size_before === 0)
    +				{
    +					return '';
    +				}
    +
     				// Find all the 
    ,,\n";
    +		return '\n";
     	}
     }
     
    @@ -600,44 +600,15 @@ if ( ! function_exists('form_prep'))
     	 *
     	 * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
     	 *
    -	 * @param	string
    -	 * @param	string
    +	 * @deprecated	3.0.0	This function has been broken for a long time
    +	 *			and is now just an alias for html_escape(). It's
    +	 *			second argument is ignored.
    +	 * @param	string	$str = ''
    +	 * @param	string	$field_name = ''
     	 * @return	string
     	 */
     	function form_prep($str = '', $field_name = '')
     	{
    -		static $prepped_fields = array();
    -
    -		// if the field name is an array we do this recursively
    -		if (is_array($str))
    -		{
    -			foreach ($str as $key => $val)
    -			{
    -				$str[$key] = form_prep($val);
    -			}
    -
    -			return $str;
    -		}
    -
    -		if ($str === '')
    -		{
    -			return '';
    -		}
    -
    -		// we've already prepped a field with this name
    -		// @todo need to figure out a way to namespace this so
    -		// that we know the *exact* field and not just one with
    -		// the same name
    -		if (isset($prepped_fields[$field_name]))
    -		{
    -			return $str;
    -		}
    -
    -		if ($field_name !== '')
    -		{
    -			$prepped_fields[$field_name] = $field_name;
    -		}
    -
     		return html_escape($str);
     	}
     }
    @@ -663,13 +634,13 @@ if ( ! function_exists('set_value'))
     		{
     			if ( ! isset($_POST[$field]))
     			{
    -				return $default;
    +				return html_escape($default);
     			}
     
    -			return form_prep($_POST[$field], $field);
    +			return html_escape($_POST[$field]);
     		}
     
    -		return form_prep($OBJ->set_value($field, $default), $field);
    +		return html_escape($OBJ->set_value($field, $default));
     	}
     }
     
    @@ -919,7 +890,7 @@ if ( ! function_exists('_parse_form_attributes'))
     		{
     			if ($key === 'value')
     			{
    -				$val = form_prep($val, $default['name']);
    +				$val = html_escape($val);
     			}
     			elseif ($key === 'name' && ! strlen($default['name']))
     			{
    diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
    index 27d48efc2..999b49cb3 100644
    --- a/tests/codeigniter/core/Common_test.php
    +++ b/tests/codeigniter/core/Common_test.php
    @@ -2,8 +2,6 @@
     
     class Common_test extends CI_TestCase {
     
    -	// ------------------------------------------------------------------------
    -
     	public function test_is_php()
     	{
     		$this->assertEquals(TRUE, is_php('1.2.0'));
    @@ -16,12 +14,12 @@ class Common_test extends CI_TestCase {
     	{
     		$this->assertEquals(' class="foo" id="bar"', _stringify_attributes(array('class' => 'foo', 'id' => 'bar')));
     
    -		$atts = new Stdclass;
    +		$atts = new stdClass;
     		$atts->class = 'foo';
     		$atts->id = 'bar';
     		$this->assertEquals(' class="foo" id="bar"', _stringify_attributes($atts));
     
    -		$atts = new Stdclass;
    +		$atts = new stdClass;
     		$this->assertEquals('', _stringify_attributes($atts));
     
     		$this->assertEquals(' class="foo" id="bar"', _stringify_attributes('class="foo" id="bar"'));
    @@ -35,10 +33,20 @@ class Common_test extends CI_TestCase {
     	{
     		$this->assertEquals('width=800,height=600', _stringify_attributes(array('width' => '800', 'height' => '600'), TRUE));
     
    -		$atts = new Stdclass;
    +		$atts = new stdClass;
     		$atts->width = 800;
     		$atts->height = 600;
     		$this->assertEquals('width=800,height=600', _stringify_attributes($atts, TRUE));
     	}
     
    +	// ------------------------------------------------------------------------
    +
    +	public function test_html_escape()
    +	{
    +		$this->assertEquals(
    +			html_escape('Here is a string containing "quoted" text.'),
    +			'Here is a string containing "quoted" text.'
    +		);
    +	}
    +
     }
    \ No newline at end of file
    diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php
    index 48628d2e5..03278581d 100644
    --- a/tests/codeigniter/helpers/form_helper_test.php
    +++ b/tests/codeigniter/helpers/form_helper_test.php
    @@ -7,6 +7,8 @@ class Form_helper_test extends CI_TestCase
     		$this->helper('form');
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_hidden()
     	{
     		$expected = <<assertEquals($expected, form_hidden('username', 'johndoe'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_input()
     	{
     		$expected = <<assertEquals($expected, form_input($data));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_password()
     	{
     		$expected = <<assertEquals($expected, form_password('password'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_upload()
     	{
     		$expected = <<assertEquals($expected, form_upload('attachment'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_textarea()
     	{
     		$expected = <<assertEquals($expected, form_textarea('notes', 'Notes'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_dropdown()
     	{
     		$expected = <<assertEquals($expected, form_dropdown('cars', $options, array('volvo', 'audi')));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_multiselect()
     	{
     		$expected = <<assertEquals($expected, form_multiselect('shirts[]', $options, array('med', 'large')));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_fieldset()
     	{
     		$expected = <<assertEquals($expected, form_fieldset('Address Information'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_fieldset_close()
     	{
     		$expected = <<assertEquals($expected, form_fieldset_close(''));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_checkbox()
     	{
     		$expected = <<assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_radio()
     	{
     		$expected = <<assertEquals($expected, form_radio('newsletter', 'accept', TRUE));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_submit()
     	{
     		$expected = <<assertEquals($expected, form_submit('mysubmit', 'Submit Post!'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_label()
     	{
     		$expected = <<assertEquals($expected, form_label('What is your Name', 'username'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_reset()
     	{
     		$expected = <<assertEquals($expected, form_reset('myreset', 'Reset'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_button()
     	{
     		$expected = <<assertEquals($expected, form_button('name', 'content'));
     	}
     
    +	// ------------------------------------------------------------------------
    +
     	public function test_form_close()
     	{
     		$expected = <<assertEquals($expected, form_close(''));
     	}
     
    -	public function test_form_prep()
    -	{
    -		$expected = 'Here is a string containing "quoted" text.';
    -
    -		$this->assertEquals($expected, form_prep('Here is a string containing "quoted" text.'));
    -	}
    -
     }
     
     /* End of file form_helper_test.php */
    \ No newline at end of file
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 0d832425c..54338f3ee 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -75,7 +75,9 @@ Release Date: Not Released
        -  Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words.
        -  Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default).
        -  Added a work-around in ``force_download()`` for a bug Android <= 2.1, where the filename extension needs to be in uppercase.
    -   -  ``form_dropdown()`` will now also take an array for unity with other form helpers.
    +   -  :doc:`Form Helper ` changes include:
    +	 - ``form_dropdown()`` will now also take an array for unity with other form helpers.
    +	 - ``form_prep()`` is now **DEPRECATED** and only acts as an alias for :doc:`common function ` ``html_escape()``.
        -  ``do_hash()`` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
        -  Removed previously deprecated helper function ``js_insert_smiley()`` from :doc:`Smiley Helper `.
        -  :doc:`File Helper ` changes include:
    @@ -387,6 +389,7 @@ Bug fixes for 3.0
     -  Fixed a bug (#1506) - :doc:`Form Helpers ` set empty *name* attributes.
     -  Fixed a bug (#59) - :doc:`Query Builder ` method ``count_all_results()`` ignored the DISTINCT clause.
     -  Fixed a bug (#1624) - :doc:`Form Validation Library ` rule **matches** didn't property handle array field names.
    +-  Fixed a bug (#1630) - :doc:`Form Helper ` function ``set_value()`` didn't escape HTML entities.
     
     Version 2.1.3
     =============
    diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst
    index fa7b3dbf9..015bf1162 100644
    --- a/user_guide_src/source/helpers/form_helper.rst
    +++ b/user_guide_src/source/helpers/form_helper.rst
    @@ -463,29 +463,6 @@ the tag. For example
     	echo form_close($string);
     	// Would produce:   
     
    -form_prep()
    -===========
    -
    -Allows you to safely use HTML and characters such as quotes within form
    -elements without breaking out of the form. Consider this example
    -
    -::
    -
    -	$string = 'Here is a string containing "quoted" text.';
    -	
    -
    -Since the above string contains a set of quotes it will cause the form
    -to break. The `form_prep()` function converts HTML so that it can be used
    -safely
    -
    -::
    -
    -	
    -
    -.. note:: If you use any of the form helper functions listed in this page the form
    -	values will be prepped automatically, so there is no need to call this
    -	function. Use it only if you are creating your own form elements.
    -
     set_value()
     ===========
     
    @@ -546,4 +523,26 @@ This function is identical to the **set_checkbox()** function above.
     .. note:: If you are using the Form Validation class, you must always specify a rule for your field,
     	even if empty, in order for the set_*() functions to work. This is because if a Form Validation object
     	is defined, the control for set_*() is handed over to a method of the class instead of the generic helper
    -	function.
    \ No newline at end of file
    +	function.
    +
    +Escaping field values
    +=====================
    +
    +You may need to use HTML and characters such as quotes within form
    +elements. In order to do that safely, you'll need to use
    +:doc:`common function <../general/common_functions>` ``html_escape()``.
    +
    +Consider the following example::
    +
    +	$string = 'Here is a string containing "quoted" text.';
    +	
    +
    +Since the above string contains a set of quotes it will cause the form
    +to break. The ``html_escape()`` function converts HTML so that it can be
    +used safely::
    +
    +	
    +
    +.. note:: If you use any of the form helper functions listed in this page, the form
    +	values will be prepped automatically, so there is no need to call this
    +	function. Use it only if you are creating your own form elements.
    \ No newline at end of file
    diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
    index 31a5c0761..952108356 100644
    --- a/user_guide_src/source/installation/upgrade_300.rst
    +++ b/user_guide_src/source/installation/upgrade_300.rst
    @@ -71,8 +71,24 @@ Step 7: Check the calls to Array Helper's element() and elements() functions
     The default return value of these functions, when the required elements
     don't exist, has been changed from FALSE to NULL.
     
    +**********************************************************
    +Step 8: Change usage of Email library with multiple emails
    +**********************************************************
    +
    +The :doc:`Email library <../libraries/email>` will automatically clear the
    +set parameters after successfully sending emails. To override this behaviour,
    +pass FALSE as the first parameter in the ``send()`` method:
    +
    +::
    +
    +	if ($this->email->send(FALSE))
    + 	{
    + 		// Parameters won't be cleared
    + 	}
    +
    +
     ***************************************************************
    -Step 8: Remove usage of (previously) deprecated functionalities
    +Step 9: Remove usage of (previously) deprecated functionalities
     ***************************************************************
     
     In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
    @@ -115,6 +131,16 @@ File helper read_file()
     PHP's native ``file_get_contents()`` function. It is deprecated and scheduled for removal in
     CodeIgniter 3.1+.
     
    +.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
    +	rather than later.
    +
    +Form helper form_prep()
    +=======================
    +
    +:doc:`Form Helper <../helpers/form_helper>` function ``form_prep()`` is now just an alias for
    +:doc:`common function <../general/common_functions>` ``html_escape()`` and it's second argument
    +is ignored. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
    +
     .. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
     	rather than later.
     
    @@ -154,17 +180,4 @@ As a result of that, the 'anchor_class' setting is now deprecated and scheduled
     CodeIgniter 3.1+.
     
     .. note:: This setting is still available, but you're strongly encouraged to remove its' usage sooner
    -	rather than later.
    -
    -Email library
    -=============
    -
    -The :doc:`Email library <../libraries/email>` will automatically clear the set parameters after successfully sending
    -emails. To override this behaviour, pass FALSE as the first parameter in the ``send()`` function:
    -
    -::
    -
    -	if ($this->email->send(FALSE))
    - 	{
    - 		// Parameters won't be cleared
    - 	}
    +	rather than later.
    \ No newline at end of file
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 582ebcb3b7eebd12605804577710cf73f0362001 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 00:52:15 +0300
    Subject: Fix #142
    
    ---
     system/helpers/form_helper.php      | 20 ++++++++++----------
     user_guide_src/source/changelog.rst |  1 +
     2 files changed, 11 insertions(+), 10 deletions(-)
    
    diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
    index d81bb7c08..a09cb36dd 100644
    --- a/system/helpers/form_helper.php
    +++ b/system/helpers/form_helper.php
    @@ -298,10 +298,10 @@ if ( ! function_exists('form_dropdown'))
     	/**
     	 * Drop-down Menu
     	 *
    -	 * @param	string
    -	 * @param	array
    -	 * @param	string
    -	 * @param	string
    +	 * @param	mixed	$name = ''
    +	 * @param	mixed	$options = array()
    +	 * @param	mixed	$selected = array()
    +	 * @param	mixed	$extra = array()
     	 * @return	string
     	 */
     	function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
    @@ -316,10 +316,7 @@ if ( ! function_exists('form_dropdown'))
     			return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']);
     		}
     
    -		if ( ! is_array($selected))
    -		{
    -			$selected = array($selected);
    -		}
    +		is_array($selected) OR $selected = array($selected);
     
     		// If no selected state was submitted we will attempt to set it automatically
     		if (count($selected) === 0 && isset($_POST[$name]))
    @@ -352,14 +349,17 @@ if ( ! function_exists('form_dropdown'))
     				foreach ($val as $optgroup_key => $optgroup_val)
     				{
     					$sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
    -					$form .= '\n";
    +					$form .= '\n";
     				}
     
     				$form .= "\n";
     			}
     			else
     			{
    -				$form .= '\n";
    +				$form .= '\n";
     			}
     		}
     
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 54338f3ee..5b24dc276 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -390,6 +390,7 @@ Bug fixes for 3.0
     -  Fixed a bug (#59) - :doc:`Query Builder ` method ``count_all_results()`` ignored the DISTINCT clause.
     -  Fixed a bug (#1624) - :doc:`Form Validation Library ` rule **matches** didn't property handle array field names.
     -  Fixed a bug (#1630) - :doc:`Form Helper ` function ``set_value()`` didn't escape HTML entities.
    +-  Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values.
     
     Version 2.1.3
     =============
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 29d909d5d1a14efc2e316650946bf43ddf03f1fd Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 01:05:09 +0300
    Subject: [ci skip] Update docblocks for deprecated functions
    
    ---
     system/helpers/date_helper.php     | 17 +++++++----------
     system/helpers/file_helper.php     | 10 ++++------
     system/helpers/form_helper.php     |  1 +
     system/helpers/security_helper.php | 10 ++++------
     4 files changed, 16 insertions(+), 22 deletions(-)
    
    diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
    index 51b2b76db..5d9251526 100644
    --- a/system/helpers/date_helper.php
    +++ b/system/helpers/date_helper.php
    @@ -119,19 +119,16 @@ if ( ! function_exists('standard_date'))
     	 *
     	 * As of PHP 5.2, the DateTime extension provides constants that
     	 * serve for the exact same purpose and are used with date().
    -	 * Due to that, this function is DEPRECATED and should be removed
    -	 * in CodeIgniter 3.1+.
     	 *
    -	 * Here are two examples of how you should replace it:
    +	 * @todo	Remove in version 3.1+.
    +	 * @deprecated	3.0.0	Use PHP's native date() instead.
    +	 * @link	http://www.php.net/manual/en/class.datetime.php#datetime.constants.types
     	 *
    -	 *	date(DATE_RFC822, now()); // default
    -	 *	date(DATE_W3C, $time); // a different format and time
    +	 * @example	date(DATE_RFC822, now()); // default
    +	 * @example	date(DATE_W3C, $time); // a different format and time
     	 *
    -	 * Reference: http://www.php.net/manual/en/class.datetime.php#datetime.constants.types
    -	 *
    -	 * @deprecated
    -	 * @param	string	the chosen format
    -	 * @param	int	Unix timestamp
    +	 * @param	string	$fmt = 'DATE_RFC822'	the chosen format
    +	 * @param	int	$time = NULL		Unix timestamp
     	 * @return	string
     	 */
     	function standard_date($fmt = 'DATE_RFC822', $time = NULL)
    diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
    index 441345b05..8f23a3d54 100644
    --- a/system/helpers/file_helper.php
    +++ b/system/helpers/file_helper.php
    @@ -44,12 +44,10 @@ if ( ! function_exists('read_file'))
     	 *
     	 * Opens the file specfied in the path and returns it as a string.
     	 *
    -	 * This function is DEPRECATED and should be removed in
    -	 * CodeIgniter 3.1+. Use file_get_contents() instead.
    -	 *
    -	 * @deprecated
    -	 * @param	string	path to file
    -	 * @return	string
    +	 * @todo	Remove in version 3.1+.
    +	 * @deprecated	3.0.0	It is now just an alias for PHP's native file_get_contents().
    +	 * @param	string	$file	Path to file
    +	 * @return	string	File contents
     	 */
     	function read_file($file)
     	{
    diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
    index a09cb36dd..622622c0e 100644
    --- a/system/helpers/form_helper.php
    +++ b/system/helpers/form_helper.php
    @@ -600,6 +600,7 @@ if ( ! function_exists('form_prep'))
     	 *
     	 * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
     	 *
    +	 * @todo	Remove in version 3.1+.
     	 * @deprecated	3.0.0	This function has been broken for a long time
     	 *			and is now just an alias for html_escape(). It's
     	 *			second argument is ignored.
    diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
    index 5ecc960bc..8bbd06684 100644
    --- a/system/helpers/security_helper.php
    +++ b/system/helpers/security_helper.php
    @@ -77,12 +77,10 @@ if ( ! function_exists('do_hash'))
     	/**
     	 * Hash encode a string
     	 *
    -	 * This function is DEPRECATED and should be removed in
    -	 * CodeIgniter 3.1+. Use hash() instead.
    -	 *
    -	 * @deprecated
    -	 * @param	string
    -	 * @param	string
    +	 * @todo	Remove in version 3.1+.
    +	 * @deprecated	3.0.0	Use PHP's native hash() instead.
    +	 * @param	string	$str
    +	 * @param	string	$type = 'sha1'
     	 * @return	string
     	 */
     	function do_hash($str, $type = 'sha1')
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From b8f9a15a156a74f788c04b463304cf310ce8ba80 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 01:36:51 +0300
    Subject: Unify Email attachment values into a single array and fix a bug in
     the new buffer attachment feature
    
    ---
     system/libraries/Email.php | 36 ++++++++++++++++++------------------
     1 file changed, 18 insertions(+), 18 deletions(-)
    
    diff --git a/system/libraries/Email.php b/system/libraries/Email.php
    index 83b442f58..9207fc9f0 100644
    --- a/system/libraries/Email.php
    +++ b/system/libraries/Email.php
    @@ -81,9 +81,7 @@ class CI_Email {
     	protected $_cc_array		= array();
     	protected $_bcc_array		= array();
     	protected $_headers		= array();
    -	protected $_attach_name		= array();
    -	protected $_attach_type		= array();
    -	protected $_attach_disp		= array();
    +	protected $_attachments		= array();
     	protected $_protocols		= array('mail', 'sendmail', 'smtp');
     	protected $_base_charsets	= array('us-ascii', 'iso-2022-');	// 7-bit charsets (excluding language suffix)
     	protected $_bit_depths		= array('7bit', '8bit');
    @@ -176,9 +174,7 @@ class CI_Email {
     
     		if ($clear_attachments !== FALSE)
     		{
    -			$this->_attach_name = array();
    -			$this->_attach_type = array();
    -			$this->_attach_disp = array();
    +			$this->_attachments = array();
     		}
     
     		return $this;
    @@ -415,9 +411,12 @@ class CI_Email {
     	 */
     	public function attach($filename, $disposition = '', $newname = NULL, $mime = '')
     	{
    -		$this->_attach_name[] = array($filename, $newname);
    -		$this->_attach_disp[] = empty($disposition) ? 'attachment' : $disposition; // Can also be 'inline'  Not sure if it matters
    -		$this->_attach_type[] = $mime;
    +		$this->_attachments[] = array(
    +			'name'		=> array($filename, $newname),
    +			'disposition'	=> empty($disposition) ? 'attachment' : $disposition,  // Can also be 'inline'  Not sure if it matters
    +			'type' 		=> $mime
    +		);
    +
     		return $this;
     	}
     
    @@ -635,9 +634,9 @@ class CI_Email {
     	{
     		if ($this->mailtype === 'html')
     		{
    -			return (count($this->_attach_name) === 0) ? 'html' : 'html-attach';
    +			return (count($this->_attachments) === 0) ? 'html' : 'html-attach';
     		}
    -		elseif	($this->mailtype === 'text' && count($this->_attach_name) > 0)
    +		elseif	($this->mailtype === 'text' && count($this->_attachments) > 0)
     		{
     			return 'plain-attach';
     		}
    @@ -1045,14 +1044,15 @@ class CI_Email {
     		}
     
     		$attachment = array();
    -		for ($i = 0, $c = count($this->_attach_name), $z = 0; $i < $c; $i++)
    +		for ($i = 0, $c = count($this->_attachments), $z = 0; $i < $c; $i++)
     		{
    -			$filename = $this->_attach_name[$i][0];
    -			$basename = is_null($this->_attach_name[$i][1]) ? basename($filename) : $this->_attach_name[$i][1];
    -			$ctype = $this->_attach_type[$i];
    +			$filename = $this->_attachments[$i]['name'][0];
    +			$basename = is_null($this->_attachments[$i]['name'][1])
    +				? basename($filename) : $this->_attachments[$i]['name'][1];
    +			$ctype = $this->_attachments[$i]['type'];
     			$file_content = '';
     
    -			if ($this->_attach_type[$i] === '')
    +			if ($ctype === '')
     			{
     				if ( ! file_exists($filename))
     				{
    @@ -1074,13 +1074,13 @@ class CI_Email {
     			}
     			else
     			{
    -				$file_content =& $this->_attach_content[$i];
    +				$file_content =& $this->_attachments[$i]['name'][0];
     			}
     
     			$attachment[$z++] = '--'.$this->_atc_boundary.$this->newline
     				.'Content-type: '.$ctype.'; '
     				.'name="'.$basename.'"'.$this->newline
    -				.'Content-Disposition: '.$this->_attach_disp[$i].';'.$this->newline
    +				.'Content-Disposition: '.$this->_attachments[$i]['disposition'].';'.$this->newline
     				.'Content-Transfer-Encoding: base64'.$this->newline;
     
     			$attachment[$z++] = chunk_split(base64_encode($file_content));
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From ca20d8445312e49e1e974c5ed8cf04400929e615 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 03:02:38 +0300
    Subject: Fix #50
    
    ---
     system/libraries/Session/drivers/Session_cookie.php | 5 +----
     user_guide_src/source/changelog.rst                 | 1 +
     2 files changed, 2 insertions(+), 4 deletions(-)
    
    diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
    index 8617aec2d..2f1bf3531 100755
    --- a/system/libraries/Session/drivers/Session_cookie.php
    +++ b/system/libraries/Session/drivers/Session_cookie.php
    @@ -223,9 +223,6 @@ class CI_Session_cookie extends CI_Session_driver {
     			show_error('In order to use the Cookie Session driver you are required to set an encryption key in your config file.');
     		}
     
    -		// Load the string helper so we can use the strip_slashes() function
    -		$this->CI->load->helper('string');
    -
     		// Do we need encryption? If so, load the encryption class
     		if ($this->sess_encrypt_cookie === TRUE)
     		{
    @@ -755,7 +752,7 @@ class CI_Session_cookie extends CI_Session_driver {
     	 */
     	protected function _unserialize($data)
     	{
    -		$data = @unserialize(strip_slashes(trim($data)));
    +		$data = @unserialize(trim($data));
     
     		if (is_array($data))
     		{
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 5b24dc276..59a3a1ff3 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -391,6 +391,7 @@ Bug fixes for 3.0
     -  Fixed a bug (#1624) - :doc:`Form Validation Library ` rule **matches** didn't property handle array field names.
     -  Fixed a bug (#1630) - :doc:`Form Helper ` function ``set_value()`` didn't escape HTML entities.
     -  Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values.
    +-  Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
     
     Version 2.1.3
     =============
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 485a348a7a633d38f69a963e9f77e23077f75d11 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 03:22:43 +0300
    Subject: Add database schema configuration support (used by PostgreSQL, fix
     #158)
    
    ---
     system/database/drivers/odbc/odbc_driver.php                | 13 +++++++++----
     system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php  |  9 +++++++--
     system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php |  9 +++++++--
     system/database/drivers/postgre/postgre_driver.php          |  9 +++++++--
     user_guide_src/source/changelog.rst                         |  3 ++-
     user_guide_src/source/database/configuration.rst            |  1 +
     6 files changed, 33 insertions(+), 11 deletions(-)
    
    diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
    index 063a04b98..37f7a28d3 100644
    --- a/system/database/drivers/odbc/odbc_driver.php
    +++ b/system/database/drivers/odbc/odbc_driver.php
    @@ -49,6 +49,11 @@ class CI_DB_odbc_driver extends CI_DB {
     
     	protected $_random_keyword;
     
    +	/**
    +	 * @var	string Database schema
    +	 */
    +	public $schema = 'public';
    +
     	/**
     	 * Constructor
     	 *
    @@ -234,17 +239,17 @@ class CI_DB_odbc_driver extends CI_DB {
     	 *
     	 * Generates a platform-specific query string so that the table names can be fetched
     	 *
    -	 * @param	bool
    +	 * @param	bool	$prefix_limit = FALSE
     	 * @return	string
     	 */
     	protected function _list_tables($prefix_limit = FALSE)
     	{
    -		$sql = 'SHOW TABLES FROM '.$this->database;
    +		$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'";
     
     		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
     		{
    -			//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
    -			return FALSE; // not currently supported
    +			return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' "
    +				.sprintf($this->_like_escape_str, $this->_like_escape_chr);
     		}
     
     		return $sql;
    diff --git a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
    index 5944d55f4..3be7e3c70 100644
    --- a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
    +++ b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
    @@ -50,6 +50,11 @@ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver {
     
     	protected $_random_keyword = ' RAND()';
     
    +	/**
    +	 * @var	string Database schema
    +	 */
    +	public $schema = 'public';
    +
     	/**
     	 * Constructor
     	 *
    @@ -122,12 +127,12 @@ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver {
     	 *
     	 * Generates a platform-specific query string so that the table names can be fetched
     	 *
    -	 * @param	bool
    +	 * @param	bool	$prefix_limit = FALSE
     	 * @return	string
     	 */
     	protected function _list_tables($prefix_limit = FALSE)
     	{
    -		$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
    +		$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'";
     
     		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
     		{
    diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
    index 74d56e6b8..3efc45a2d 100644
    --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
    +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
    @@ -44,6 +44,11 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
     
     	protected $_random_keyword = ' RANDOM()';
     
    +	/**
    +	 * @var	string Database schema
    +	 */
    +	public $schema = 'public';
    +
     	/**
     	 * Constructor
     	 *
    @@ -92,12 +97,12 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
     	 *
     	 * Generates a platform-specific query string so that the table names can be fetched
     	 *
    -	 * @param	bool
    +	 * @param	bool	$prefix_limit = FALSE
     	 * @return	string
     	 */
     	protected function _list_tables($prefix_limit = FALSE)
     	{
    -		$sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \'public\'';
    +		$sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \''.$this->schema."'";
     
     		if ($prefix_limit === TRUE && $this->dbprefix !== '')
     		{
    diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
    index 1b9474920..91d9a2385 100644
    --- a/system/database/drivers/postgre/postgre_driver.php
    +++ b/system/database/drivers/postgre/postgre_driver.php
    @@ -46,6 +46,11 @@ class CI_DB_postgre_driver extends CI_DB {
     
     	protected $_random_keyword = ' RANDOM()'; // database specific random keyword
     
    +	/**
    +	 * @var	string Database schema
    +	 */
    +	public $schema = 'public';
    +
     	/**
     	 * Constructor
     	 *
    @@ -393,12 +398,12 @@ class CI_DB_postgre_driver extends CI_DB {
     	 *
     	 * Generates a platform-specific query string so that the table names can be fetched
     	 *
    -	 * @param	bool
    +	 * @param	bool	$prefix_limit = FALSE
     	 * @return	string
     	 */
     	protected function _list_tables($prefix_limit = FALSE)
     	{
    -		$sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \'public\'';
    +		$sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \''.$this->schema."'";
     
     		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
     		{
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 59a3a1ff3..c37345933 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -103,7 +103,8 @@ Release Date: Not Released
     	 - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query.
     	 - Added persistent connections support for PHP >= 5.3.
     	 - Added support for ``backup()`` in :doc:`Database Utilities `.
    -   -  Added *dsn* configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
    +   -  Added **dsn** configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
    +   -  Added **schema** configuration setting (defaults to *public*) for drivers that might need it (currently used by PostgreSQL and ODBC).
        -  Improved PDO database support.
        -  Added Interbase/Firebird database support via the *ibase* driver.
        -  Added an optional database name parameter to ``db_select()``.
    diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
    index 668496324..34cefffbd 100644
    --- a/user_guide_src/source/database/configuration.rst
    +++ b/user_guide_src/source/database/configuration.rst
    @@ -182,6 +182,7 @@ Explanation of Values:
     			customizable by the end user.
     **autoinit**		Whether or not to automatically connect to the database when the library loads. If set to false,
     			the connection will take place prior to executing the first query.
    +**schema**		The database schema, defaults to 'public'. Used by PostgreSQL and ODBC drivers.
     **encrypt**		Whether or not to use an encrypted connection.
     **compress**		Whether or not to use client compression (MySQL only).
     **stricton**		TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7d753464d13f3a3326a1679226127570cc0c498f Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 03:37:40 +0300
    Subject: [ci skip] Optimize ascii_to_entities()
    
    ---
     system/helpers/text_helper.php | 11 ++++-------
     1 file changed, 4 insertions(+), 7 deletions(-)
    
    diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
    index 016a36c57..89602fc28 100644
    --- a/system/helpers/text_helper.php
    +++ b/system/helpers/text_helper.php
    @@ -118,18 +118,15 @@ if ( ! function_exists('ascii_to_entities'))
     	/**
     	 * High ASCII to Entities
     	 *
    -	 * Converts High ascii text and MS Word special characters to character entities
    +	 * Converts high ASCII text and MS Word special characters to character entities
     	 *
    -	 * @param	string
    +	 * @param	string	$str
     	 * @return	string
     	 */
     	function ascii_to_entities($str)
     	{
    -		$count	= 1;
    -		$out	= '';
    -		$temp	= array();
    -
    -		for ($i = 0, $s = strlen($str); $i < $s; $i++)
    +		$out = '';
    +		for ($i = 0, $s = strlen($str), $count = 1, $temp = array(); $i < $s; $i++)
     		{
     			$ordinal = ord($str[$i]);
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 3e9d2b8ae82948de3c83bd5a50151949f6e6ca90 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 14:28:51 +0300
    Subject: Docblock improvements
    
    ---
     system/core/Benchmark.php                          | 32 +++++-----
     system/core/Controller.php                         | 11 ++--
     system/core/Exceptions.php                         | 48 +++++++--------
     system/core/Hooks.php                              | 68 ++++++++--------------
     system/core/Lang.php                               | 27 +++++----
     system/core/Model.php                              | 10 ++--
     system/core/Utf8.php                               | 26 +++++----
     system/database/drivers/odbc/odbc_driver.php       |  4 +-
     .../drivers/pdo/subdrivers/pdo_odbc_driver.php     |  4 +-
     .../drivers/pdo/subdrivers/pdo_pgsql_driver.php    |  4 +-
     system/database/drivers/postgre/postgre_driver.php |  4 +-
     system/libraries/Calendar.php                      |  8 ++-
     12 files changed, 125 insertions(+), 121 deletions(-)
    
    diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
    index 2fabdf46e..f94db2721 100644
    --- a/system/core/Benchmark.php
    +++ b/system/core/Benchmark.php
    @@ -26,7 +26,7 @@
      */
     
     /**
    - * CodeIgniter Benchmark Class
    + * Benchmark Class
      *
      * This class enables you to mark points and calculate the time difference
      * between them. Memory consumption can also be displayed.
    @@ -40,21 +40,19 @@
     class CI_Benchmark {
     
     	/**
    -	 * List of all benchmark markers and when they were added
    +	 * List of all benchmark markers
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
    -	public $marker =	array();
    -
    -	// --------------------------------------------------------------------
    +	public $marker = array();
     
     	/**
     	 * Set a benchmark marker
     	 *
     	 * Multiple calls to this function can be made so that several
    -	 * execution points can be timed
    +	 * execution points can be timed.
     	 *
    -	 * @param	string	$name	name of the marker
    +	 * @param	string	$name	Marker name
     	 * @return	void
     	 */
     	public function mark($name)
    @@ -65,6 +63,8 @@ class CI_Benchmark {
     	// --------------------------------------------------------------------
     
     	/**
    +	 * Elapsed time
    +	 *
     	 * Calculates the time difference between two marked points.
     	 *
     	 * If the first parameter is empty this function instead returns the
    @@ -72,10 +72,13 @@ class CI_Benchmark {
     	 * execution time to be shown in a template. The output class will
     	 * swap the real value for this variable.
     	 *
    -	 * @param	string	a particular marked point
    -	 * @param	string	a particular marked point
    -	 * @param	integer	the number of decimal places
    -	 * @return	mixed
    +	 * @param	string	$point1		A particular marked point
    +	 * @param	string	$point2		A particular marked point
    +	 * @param	int	$decimals	Number of decimal places
    +	 *
    +	 * @return	string	Calculated elapsed time on success,
    +	 *			an '{elapsed_string}' if $point1 is empty
    +	 *			or an empty string if $point1 is not found.
     	 */
     	public function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
     	{
    @@ -102,12 +105,13 @@ class CI_Benchmark {
     	/**
     	 * Memory Usage
     	 *
    -	 * This function returns the {memory_usage} pseudo-variable.
    +	 * Simply returns the {memory_usage} marker.
    +	 *
     	 * This permits it to be put it anywhere in a template
     	 * without the memory being calculated until the end.
     	 * The output class will swap the real value for this variable.
     	 *
    -	 * @return	string
    +	 * @return	string	'{memory_usage}'
     	 */
     	public function memory_usage()
     	{
    diff --git a/system/core/Controller.php b/system/core/Controller.php
    index 9196958ae..8c2ba893e 100644
    --- a/system/core/Controller.php
    +++ b/system/core/Controller.php
    @@ -26,7 +26,7 @@
      */
     
     /**
    - * CodeIgniter Application Controller Class
    + * Application Controller Class
      *
      * This class object is the super class that every library in
      * CodeIgniter will be assigned to.
    @@ -40,15 +40,14 @@
     class CI_Controller {
     
     	/**
    -	 * Reference to the global CI instance
    +	 * Reference to the CI singleton
     	 *
    -	 * @static
     	 * @var	object
     	 */
     	private static $instance;
     
     	/**
    -	 * Set up controller properties and methods
    +	 * Class constructor
     	 *
     	 * @return	void
     	 */
    @@ -69,8 +68,10 @@ class CI_Controller {
     		log_message('debug', 'Controller Class Initialized');
     	}
     
    +	// --------------------------------------------------------------------
    +
     	/**
    -	 * Return the CI object
    +	 * Get the CI singleton
     	 *
     	 * @static
     	 * @return	object
    diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
    index bd9178dbd..c0caf2e7d 100644
    --- a/system/core/Exceptions.php
    +++ b/system/core/Exceptions.php
    @@ -64,7 +64,7 @@ class CI_Exceptions {
     	);
     
     	/**
    -	 * Initialize execption class
    +	 * Class constructor
     	 *
     	 * @return	void
     	 */
    @@ -79,12 +79,12 @@ class CI_Exceptions {
     	/**
     	 * Exception Logger
     	 *
    -	 * This function logs PHP generated error messages
    +	 * Logs PHP generated error messages
     	 *
    -	 * @param	string	the error severity
    -	 * @param	string	the error string
    -	 * @param	string	the error filepath
    -	 * @param	string	the error line number
    +	 * @param	int	$severity	Log level
    +	 * @param	string	$message	Error message
    +	 * @param	string	$filepath	File path
    +	 * @param	int	$line		Line number
     	 * @return	void
     	 */
     	public function log_exception($severity, $message, $filepath, $line)
    @@ -96,11 +96,13 @@ class CI_Exceptions {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * 404 Page Not Found Handler
    +	 * 404 Error Handler
     	 *
    -	 * @param	string	the page
    -	 * @param 	bool	log error yes/no
    -	 * @return	string
    +	 * @uses	CI_Exceptions::show_error()
    +	 *
    +	 * @param	string	$page		Page URI
    +	 * @param 	bool	$log_error	Whether to log the error
    +	 * @return	void
     	 */
     	public function show_404($page = '', $log_error = TRUE)
     	{
    @@ -122,15 +124,15 @@ class CI_Exceptions {
     	/**
     	 * General Error Page
     	 *
    -	 * This function takes an error message as input
    -	 * (either as a string or an array) and displays
    -	 * it using the specified template.
    +	 * Takes an error message as input (either as a string or an array)
    +	 * and displays it using the specified template.
    +	 *
    +	 * @param	string		$heading	Page heading
    +	 * @param	string|string[]	$message	Error message
    +	 * @param	string		$template	Template name
    +	 * @param 	int		$statis_code	(default: 500)
     	 *
    -	 * @param	string	the heading
    -	 * @param	string	the message
    -	 * @param	string	the template name
    -	 * @param 	int	the status code
    -	 * @return	string
    +	 * @return	string	Error page output
     	 */
     	public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
     	{
    @@ -154,11 +156,11 @@ class CI_Exceptions {
     	/**
     	 * Native PHP error handler
     	 *
    -	 * @param	string	the error severity
    -	 * @param	string	the error string
    -	 * @param	string	the error filepath
    -	 * @param	string	the error line number
    -	 * @return	string
    +	 * @param	int	$severity	Error level
    +	 * @param	string	$message	Error message
    +	 * @param	string	$filepath	File path
    +	 * @param	int	$line		Line number
    +	 * @return	string	Error page output
     	 */
     	public function show_php_error($severity, $message, $filepath, $line)
     	{
    diff --git a/system/core/Hooks.php b/system/core/Hooks.php
    index afbf4b453..d60e9ac5d 100644
    --- a/system/core/Hooks.php
    +++ b/system/core/Hooks.php
    @@ -26,7 +26,7 @@
      */
     
     /**
    - * CodeIgniter Hooks Class
    + * Hooks Class
      *
      * Provides a mechanism to extend the base system without hacking.
      *
    @@ -41,26 +41,28 @@ class CI_Hooks {
     	/**
     	 * Determines whether hooks are enabled
     	 *
    -	 * @var bool
    +	 * @var	bool
     	 */
    -	public $enabled =	FALSE;
    +	public $enabled = FALSE;
     
     	/**
     	 * List of all hooks set in config/hooks.php
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $hooks =	array();
     
     	/**
    +	 * In progress flag
    +	 *
     	 * Determines whether hook is in progress, used to prevent infinte loops
     	 *
    -	 * @var bool
    +	 * @var	bool
     	 */
    -	public $in_progress	=	FALSE;
    +	protected $_in_progress = FALSE;
     
     	/**
    -	 * Initialize the Hooks Preferences
    +	 * Class constructor
     	 *
     	 * @return	void
     	 */
    @@ -104,8 +106,10 @@ class CI_Hooks {
     	 *
     	 * Calls a particular hook. Called by CodeIgniter.php.
     	 *
    -	 * @param	string	the hook name
    -	 * @return	mixed
    +	 * @uses	CI_Hooks::_run_hook()
    +	 *
    +	 * @param	string	$which	Hook name
    +	 * @return	bool	TRUE on success or FALSE on failure
     	 */
     	public function call_hook($which = '')
     	{
    @@ -136,8 +140,8 @@ class CI_Hooks {
     	 *
     	 * Runs a particular hook
     	 *
    -	 * @param	array	the hook details
    -	 * @return	bool
    +	 * @param	array	$data	Hook details
    +	 * @return	bool	TRUE on success or FALSE on failure
     	 */
     	protected function _run_hook($data)
     	{
    @@ -152,7 +156,7 @@ class CI_Hooks {
     
     		// If the script being called happens to have the same
     		// hook call within it a loop can happen
    -		if ($this->in_progress === TRUE)
    +		if ($this->_in_progress === TRUE)
     		{
     			return;
     		}
    @@ -173,44 +177,20 @@ class CI_Hooks {
     			return FALSE;
     		}
     
    -		// -----------------------------------
    -		// Set class/function name
    -		// -----------------------------------
    -
    -		$class		= FALSE;
    -		$function	= FALSE;
    -		$params		= '';
    -
    -		if ( ! empty($data['class']))
    -		{
    -			$class = $data['class'];
    -		}
    -
    -		if ( ! empty($data['function']))
    -		{
    -			$function = $data['function'];
    -		}
    -
    -		if (isset($data['params']))
    -		{
    -			$params = $data['params'];
    -		}
    +		// Determine and class and/or function names
    +		$class		= empty($data['class']) ? FALSE : $data['class'];
    +		$function	= empty($data['function']) ? FALSE : $data['function'];
    +		$params		= isset($data['params']) ? $data['params'] : '';
     
     		if ($class === FALSE && $function === FALSE)
     		{
     			return FALSE;
     		}
     
    -		// -----------------------------------
    -		// Set the in_progress flag
    -		// -----------------------------------
    -
    -		$this->in_progress = TRUE;
    +		// Set the _in_progress flag
    +		$this->_in_progress = TRUE;
     
    -		// -----------------------------------
     		// Call the requested class and/or function
    -		// -----------------------------------
    -
     		if ($class !== FALSE)
     		{
     			if ( ! class_exists($class))
    @@ -218,7 +198,7 @@ class CI_Hooks {
     				require($filepath);
     			}
     
    -			$HOOK = new $class;
    +			$HOOK = new $class();
     			$HOOK->$function($params);
     		}
     		else
    @@ -231,7 +211,7 @@ class CI_Hooks {
     			$function($params);
     		}
     
    -		$this->in_progress = FALSE;
    +		$this->_in_progress = FALSE;
     		return TRUE;
     	}
     
    diff --git a/system/core/Lang.php b/system/core/Lang.php
    index 601348aa4..e74304dd9 100644
    --- a/system/core/Lang.php
    +++ b/system/core/Lang.php
    @@ -39,19 +39,19 @@ class CI_Lang {
     	/**
     	 * List of translations
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $language =	array();
     
     	/**
     	 * List of loaded language files
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $is_loaded =	array();
     
     	/**
    -	 * Initialize language class
    +	 * Class constructor
     	 *
     	 * @return	void
     	 */
    @@ -65,12 +65,13 @@ class CI_Lang {
     	/**
     	 * Load a language file
     	 *
    -	 * @param	mixed	$langile		the name of the language file to be loaded
    -	 * @param	string	$idiom = ''		the language (english, etc.)
    -	 * @param	bool	$return = FALSE		return loaded array of translations
    -	 * @param 	bool	$add_suffix = TRUE	add suffix to $langfile
    -	 * @param 	string	$alt_path = ''		alternative path to look for language file
    -	 * @return	mixed
    +	 * @param	mixed	$langfile	Language file name
    +	 * @param	string	$idiom		Language name (english, etc.)
    +	 * @param	bool	$return		Whether to return the loaded array of translations
    +	 * @param 	bool	$add_suffix	Whether to add suffix to $langfile
    +	 * @param 	string	$alt_path	Alternative path to look for the language file
    +	 *
    +	 * @return	void|string[]	Array containing translations, if $return is set to TRUE
     	 */
     	public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
     	{
    @@ -146,10 +147,12 @@ class CI_Lang {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a single line of text from the language array
    +	 * Language line
    +	 *
    +	 * Fetches a single line of text from the language array
     	 *
    -	 * @param	string	$line	the language line
    -	 * @return	string
    +	 * @param	string	$line	Language line key
    +	 * @return	string	Translation
     	 */
     	public function line($line = '')
     	{
    diff --git a/system/core/Model.php b/system/core/Model.php
    index 9bc9f879f..5a87ab153 100644
    --- a/system/core/Model.php
    +++ b/system/core/Model.php
    @@ -26,7 +26,7 @@
      */
     
     /**
    - * CodeIgniter Model Class
    + * Model Class
      *
      * @package		CodeIgniter
      * @subpackage	Libraries
    @@ -37,7 +37,7 @@
     class CI_Model {
     
     	/**
    -	 * Initialize CI_Model Class
    +	 * Class constructor
     	 *
     	 * @return	void
     	 */
    @@ -46,13 +46,15 @@ class CI_Model {
     		log_message('debug', 'Model Class Initialized');
     	}
     
    +	// --------------------------------------------------------------------
    +
     	/**
    -	 * __get
    +	 * __get magic
     	 *
     	 * Allows models to access CI's loaded classes using the same
     	 * syntax as controllers.
     	 *
    -	 * @param	string
    +	 * @param	string	$key
     	 */
     	public function __get($key)
     	{
    diff --git a/system/core/Utf8.php b/system/core/Utf8.php
    index 1ff02981b..bc7afed91 100644
    --- a/system/core/Utf8.php
    +++ b/system/core/Utf8.php
    @@ -39,9 +39,9 @@
     class CI_Utf8 {
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
    -	 * Determines if UTF-8 support is to be enabled
    +	 * Determines if UTF-8 support is to be enabled.
     	 *
     	 * @return	void
     	 */
    @@ -87,9 +87,11 @@ class CI_Utf8 {
     	/**
     	 * Clean UTF-8 strings
     	 *
    -	 * Ensures strings are UTF-8
    +	 * Ensures strings contain only valid UTF-8 characters.
     	 *
    -	 * @param	string
    +	 * @uses	CI_Utf8::_is_ascii()	Decide whether a conversion is needed
    +	 *
    +	 * @param	string	$str	String to clean
     	 * @return	string
     	 */
     	public function clean_string($str)
    @@ -109,9 +111,9 @@ class CI_Utf8 {
     	 *
     	 * Removes all ASCII control characters except horizontal tabs,
     	 * line feeds, and carriage returns, as all others can cause
    -	 * problems in XML
    +	 * problems in XML.
     	 *
    -	 * @param	string
    +	 * @param	string	$str	String to clean
     	 * @return	string
     	 */
     	public function safe_ascii_for_xml($str)
    @@ -124,11 +126,11 @@ class CI_Utf8 {
     	/**
     	 * Convert to UTF-8
     	 *
    -	 * Attempts to convert a string to UTF-8
    +	 * Attempts to convert a string to UTF-8.
     	 *
    -	 * @param	string
    -	 * @param	string	input encoding
    -	 * @return	string
    +	 * @param	string	$str		Input string
    +	 * @param	string	$encoding	Input encoding
    +	 * @return	string	$str encoded in UTF-8 or FALSE on failure
     	 */
     	public function convert_to_utf8($str, $encoding)
     	{
    @@ -149,9 +151,9 @@ class CI_Utf8 {
     	/**
     	 * Is ASCII?
     	 *
    -	 * Tests if a string is standard 7-bit ASCII or not
    +	 * Tests if a string is standard 7-bit ASCII or not.
     	 *
    -	 * @param	string
    +	 * @param	string	$str	String to check
     	 * @return	bool
     	 */
     	protected function _is_ascii($str)
    diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
    index 37f7a28d3..f6ea412ad 100644
    --- a/system/database/drivers/odbc/odbc_driver.php
    +++ b/system/database/drivers/odbc/odbc_driver.php
    @@ -50,7 +50,9 @@ class CI_DB_odbc_driver extends CI_DB {
     	protected $_random_keyword;
     
     	/**
    -	 * @var	string Database schema
    +	 * Database schema
    +	 *
    +	 * @var	string
     	 */
     	public $schema = 'public';
     
    diff --git a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
    index 3be7e3c70..d64e9fb36 100644
    --- a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
    +++ b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
    @@ -51,7 +51,9 @@ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver {
     	protected $_random_keyword = ' RAND()';
     
     	/**
    -	 * @var	string Database schema
    +	 * Database schema
    +	 *
    +	 * @var	string
     	 */
     	public $schema = 'public';
     
    diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
    index 3efc45a2d..93674b576 100644
    --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
    +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
    @@ -45,7 +45,9 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
     	protected $_random_keyword = ' RANDOM()';
     
     	/**
    -	 * @var	string Database schema
    +	 * Database schema
    +	 *
    +	 * @var	string
     	 */
     	public $schema = 'public';
     
    diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
    index 91d9a2385..ca231f6f7 100644
    --- a/system/database/drivers/postgre/postgre_driver.php
    +++ b/system/database/drivers/postgre/postgre_driver.php
    @@ -47,7 +47,9 @@ class CI_DB_postgre_driver extends CI_DB {
     	protected $_random_keyword = ' RANDOM()'; // database specific random keyword
     
     	/**
    -	 * @var	string Database schema
    +	 * Database schema
    +	 *
    +	 * @var	string
     	 */
     	public $schema = 'public';
     
    diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
    index a49f171b9..95f537e42 100644
    --- a/system/libraries/Calendar.php
    +++ b/system/libraries/Calendar.php
    @@ -95,11 +95,13 @@ class CI_Calendar {
     	public $next_prev_url		= '';
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
    -	 * Loads the calendar language file and sets the default time reference
    +	 * Loads the calendar language file and sets the default time reference.
     	 *
    -	 * @param	array
    +	 * @uses	CI_Lang::$is_loaded
    +	 *
    +	 * @param	array	$config	Calendar options
     	 * @return	void
     	 */
     	public function __construct($config = array())
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 60826db46d3f9ceabcc280c494a975007423e64a Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 14:45:23 +0300
    Subject: Deprecate string helper repeater() (an alias for str_repeat())
    
    ---
     system/helpers/string_helper.php                   |  7 +++++--
     user_guide_src/source/changelog.rst                |  1 +
     user_guide_src/source/helpers/string_helper.rst    |  3 +++
     user_guide_src/source/installation/upgrade_300.rst | 10 ++++++++++
     4 files changed, 19 insertions(+), 2 deletions(-)
    
    diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
    index 4eee2a262..c5c493452 100644
    --- a/system/helpers/string_helper.php
    +++ b/system/helpers/string_helper.php
    @@ -276,8 +276,11 @@ if ( ! function_exists('repeater'))
     	/**
     	 * Repeater function
     	 *
    -	 * @param	string
    -	 * @param	int	number of repeats
    +	 * @todo	Remove in version 3.1+.
    +	 * @deprecated	3.0.0	This is just an alias for PHP's native str_repeat()
    +	 *
    +	 * @param	string	$data	String to repeat
    +	 * @param	int	$num	Number of repeats
     	 * @return	string
     	 */
     	function repeater($data, $num = 1)
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index c37345933..e91fafccc 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -85,6 +85,7 @@ Release Date: Not Released
     	 - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html.
     	 - ``read_file()`` is now a deprecated alias of ``file_get_contents()``.
        -  :doc:`Security Helper ` function ``strip_image_tags()`` is now an alias for the same method in the :doc:`Security Library `.
    +   -  Deprecated :doc:`String Helper ` function ``repeater()`` - it's just an alias for PHP's native ``str_repeat()``.
     
     -  Database
     
    diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
    index 19500aa0d..530af2f89 100644
    --- a/user_guide_src/source/helpers/string_helper.rst
    +++ b/user_guide_src/source/helpers/string_helper.rst
    @@ -96,6 +96,9 @@ Generates repeating copies of the data you submit. Example
     
     The above would generate 30 newlines.
     
    +.. note:: This function is DEPRECATED. Use the native ``str_repeat()``
    +	instead.
    +
     reduce_double_slashes()
     =======================
     
    diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
    index 952108356..dcdd6e351 100644
    --- a/user_guide_src/source/installation/upgrade_300.rst
    +++ b/user_guide_src/source/installation/upgrade_300.rst
    @@ -131,6 +131,16 @@ File helper read_file()
     PHP's native ``file_get_contents()`` function. It is deprecated and scheduled for removal in
     CodeIgniter 3.1+.
     
    +.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
    +	rather than later.
    +
    +String helper repeater()
    +========================
    +
    +:doc:`String Helper <../helpers/string_helper>` function ``repeater()`` is now just an alias for
    +PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in
    +CodeIgniter 3.1+.
    +
     .. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
     	rather than later.
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 5232ba07752ffa783d03754c3a869d9f73ccae69 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 15:25:05 +0300
    Subject: Docblock improvements to the Config library and remove
     CI_Config::_assign_to_config()
    
    Existance of _assign_to_config() is pointless as this method
    consists just of a foreach calling CI_Config::set_item() and
    is only called by CodeIgniter.php - moved that foreach() in
    there instead.
    ---
     system/core/CodeIgniter.php            |  7 ++-
     system/core/Config.php                 | 80 +++++++++++++++-------------------
     system/core/Exceptions.php             |  2 +-
     tests/codeigniter/core/Config_test.php | 25 +----------
     user_guide_src/source/changelog.rst    |  8 ++--
     5 files changed, 47 insertions(+), 75 deletions(-)
    
    diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
    index f3592eaf9..324b4d849 100644
    --- a/system/core/CodeIgniter.php
    +++ b/system/core/CodeIgniter.php
    @@ -130,9 +130,12 @@
     	$CFG =& load_class('Config', 'core');
     
     	// Do we have any manually set config items in the index.php file?
    -	if (isset($assign_to_config))
    +	if (isset($assign_to_config) && is_array($assign_to_config))
     	{
    -		$CFG->_assign_to_config($assign_to_config);
    +		foreach ($assign_to_config as $key => $value)
    +		{
    +			$CFG->set_item($key, $value);
    +		}
     	}
     
     /*
    diff --git a/system/core/Config.php b/system/core/Config.php
    index e78128c76..152e9af68 100644
    --- a/system/core/Config.php
    +++ b/system/core/Config.php
    @@ -26,7 +26,7 @@
      */
     
     /**
    - * CodeIgniter Config Class
    + * Config Class
      *
      * This class contains functions that enable config files to be managed
      *
    @@ -41,29 +41,31 @@ class CI_Config {
     	/**
     	 * List of all loaded config values
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $config = array();
     
     	/**
     	 * List of all loaded config files
     	 *
    -	 * @var array
    +	 * @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.
     	 *
    -	 * @var array
    +	 * @used-by	CI_Loader	Must be public
    +	 * @var		array
     	 */
     	public $_config_paths =	array(APPPATH);
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
    -	 * Sets the $config data from the primary config.php file as a class variable
    +	 * Sets the $config data from the primary config.php file as a class variable.
    +	 *
    +	 * @return	void
     	 */
     	public function __construct()
     	{
    @@ -93,10 +95,10 @@ class CI_Config {
     	/**
     	 * Load Config File
     	 *
    -	 * @param	string	the config file name
    -	 * @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
    +	 * @param	string	$file			Configuration file name
    +	 * @param	bool	$use_sections		Whether configuration values should be loaded into their own section
    +	 * @param	bool	$fail_gracefully	Whether to just return FALSE or display an error message
    +	 * @return	bool	TRUE if the file was loaded correctly or FALSE on failure
     	 */
     	public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
     	{
    @@ -183,9 +185,9 @@ class CI_Config {
     	/**
     	 * Fetch a config file item
     	 *
    -	 * @param	string	the config item name
    -	 * @param	string	the index name
    -	 * @return	string
    +	 * @param	string	$item	Config item name
    +	 * @param	string	$index	Index name
    +	 * @return	string|bool	The configuration item or FALSE on failure
     	 */
     	public function item($item, $index = '')
     	{
    @@ -200,10 +202,10 @@ class CI_Config {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a config file item - adds slash after item (if item is not empty)
    +	 * Fetch a config file item with slash appended (if not empty)
     	 *
    -	 * @param	string	the config item name
    -	 * @return	string
    +	 * @param	string		$item	Config item name
    +	 * @return	string|bool	The configuration item or FALSE on failure
     	 */
     	public function slash_item($item)
     	{
    @@ -223,9 +225,12 @@ class CI_Config {
     
     	/**
     	 * Site URL
    +	 *
     	 * Returns base_url . index_page [. uri_string]
     	 *
    -	 * @param	mixed	the URI string or an array of segments
    +	 * @uses	CI_Config::_uri_string()
    +	 *
    +	 * @param	string|string[]	$uri	URI string or an array of segments
     	 * @return	string
     	 */
     	public function site_url($uri = '')
    @@ -264,9 +269,12 @@ class CI_Config {
     
     	/**
     	 * Base URL
    +	 *
     	 * Returns base_url [. uri_string]
     	 *
    -	 * @param	string	$uri
    +	 * @uses	CI_Config::_uri_string()
    +	 *
    +	 * @param	string|string[]	$uri	URI string or an array of segments
     	 * @return	string
     	 */
     	public function base_url($uri = '')
    @@ -277,9 +285,12 @@ class CI_Config {
     	// -------------------------------------------------------------
     
     	/**
    -	 * Build URI string for use in Config::site_url() and Config::base_url()
    +	 * Build URI string
    +	 *
    +	 * @used-by	CI_Config::site_url()
    +	 * @used-by	CI_Config::base_url()
     	 *
    -	 * @param	mixed	$uri
    +	 * @param	string|string[]	$uri	URI string or an array of segments
     	 * @return	string
     	 */
     	protected function _uri_string($uri)
    @@ -318,8 +329,8 @@ class CI_Config {
     	/**
     	 * Set a config file item
     	 *
    -	 * @param	string	the config item key
    -	 * @param	string	the config item value
    +	 * @param	string	$item	Config item key
    +	 * @param	string	$value	Config item value
     	 * @return	void
     	 */
     	public function set_item($item, $value)
    @@ -327,29 +338,6 @@ class CI_Config {
     		$this->config[$item] = $value;
     	}
     
    -	// --------------------------------------------------------------------
    -
    -	/**
    -	 * Assign to Config
    -	 *
    -	 * This function is called by the front controller (CodeIgniter.php)
    -	 * after the Config class is instantiated. It permits config items
    -	 * to be assigned or overriden by variables contained in the index.php file
    -	 *
    -	 * @param	array
    -	 * @return	void
    -	 */
    -	public function _assign_to_config($items = array())
    -	{
    -		if (is_array($items))
    -		{
    -			foreach ($items as $key => $val)
    -			{
    -				$this->set_item($key, $val);
    -			}
    -		}
    -	}
    -
     }
     
     /* End of file Config.php */
    diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
    index c0caf2e7d..556257729 100644
    --- a/system/core/Exceptions.php
    +++ b/system/core/Exceptions.php
    @@ -130,7 +130,7 @@ class CI_Exceptions {
     	 * @param	string		$heading	Page heading
     	 * @param	string|string[]	$message	Error message
     	 * @param	string		$template	Template name
    -	 * @param 	int		$statis_code	(default: 500)
    +	 * @param 	int		$status_code	(default: 500)
     	 *
     	 * @return	string	Error page output
     	 */
    diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
    index d652a625e..be426d070 100644
    --- a/tests/codeigniter/core/Config_test.php
    +++ b/tests/codeigniter/core/Config_test.php
    @@ -9,7 +9,7 @@ class Config_test extends CI_TestCase {
     		// set predictable config values
     		$this->cfg = array(
     			'index_page'		=> 'index.php',
    -			'base_url'			=> 'http://example.com/',
    +			'base_url'		=> 'http://example.com/',
     			'subclass_prefix'	=> 'MY_'
     		);
     		$this->ci_set_config($this->cfg);
    @@ -38,7 +38,6 @@ class Config_test extends CI_TestCase {
     		$this->assertFalse($this->config->item('not_yet_set'));
     
     		$this->config->set_item('not_yet_set', 'is set');
    -
     		$this->assertEquals('is set', $this->config->item('not_yet_set'));
     	}
     
    @@ -50,7 +49,6 @@ class Config_test extends CI_TestCase {
     		$this->assertFalse($this->config->slash_item('no_good_item'));
     
     		$this->assertEquals($this->cfg['base_url'], $this->config->slash_item('base_url'));
    -
     		$this->assertEquals($this->cfg['subclass_prefix'].'/', $this->config->slash_item('subclass_prefix'));
     	}
     
    @@ -124,7 +122,7 @@ class Config_test extends CI_TestCase {
     		$q_string = $this->config->item('enable_query_strings');
     		$this->config->set_item('enable_query_strings', FALSE);
     
    -		$uri= 'test';
    +		$uri = 'test';
     		$uri2 = '1';
     		$this->assertEquals($index_page.'/'.$uri, $this->config->site_url($uri));
     		$this->assertEquals($index_page.'/'.$uri.'/'.$uri2, $this->config->site_url(array($uri, $uri2)));
    @@ -137,7 +135,6 @@ class Config_test extends CI_TestCase {
     		$this->assertEquals($index_page.'/'.$uri.$suffix.'?'.$arg, $this->config->site_url($uri.'?'.$arg));
     
     		$this->config->set_item('url_suffix', FALSE);
    -
     		$this->config->set_item('enable_query_strings', TRUE);
     
     		$this->assertEquals($index_page.'?'.$uri, $this->config->site_url($uri));
    @@ -233,22 +230,4 @@ class Config_test extends CI_TestCase {
     		$this->assertNull($this->config->load($file));
     	}
     
    -	// --------------------------------------------------------------------
    -
    -	public function test_assign_to_config()
    -	{
    -		$key1 = 'test';
    -		$key2 = '1';
    -		$val1 = 'foo';
    -		$val2 = 'bar';
    -		$cfg = array(
    -			$key1 => $val1,
    -			$key2 => $val2
    -		);
    -
    -		$this->assertNull($this->config->_assign_to_config($cfg));
    -		$this->assertEquals($val1, $this->config->item($key1));
    -		$this->assertEquals($val2, $this->config->item($key2));
    -	}
    -
     }
    \ No newline at end of file
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index e91fafccc..a1cdcd475 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -236,8 +236,8 @@ Release Date: Not Released
     	 -  Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
     	 -  ``CI_Loader::_ci_autoloader()`` is now a protected method.
     	 -  Added autoloading of drivers with ``$autoload['drivers']``.
    -	 -  ``CI_Loader::library()`` will now load drivers as well, for backward compatibility of converted libraries (like Session).
    -   -  ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as *`).
    +	 -  ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``` changes include:
     	 -  Added ``method()`` to retrieve ``$_SERVER['REQUEST_METHOD']``.
     	 -  Modified ``valid_ip()`` to use PHP's ``filter_var()``.
    @@ -254,7 +254,9 @@ Release Date: Not Released
     	 -  Added method ``get_content_type()``.
     	 -  Added a second argument to method ``set_content_type()`` that allows setting the document charset as well.
        -  ``$config['time_reference']`` now supports all timezone strings supported by PHP.
    -   -  Changed :doc:`Config Library ` method ``site_url()`` to accept an array as well.
    +   -  :doc:`Config Library ` changes include:
    +	 -  Changed ``site_url()`` method  to accept an array as well.
    +	 -  Removed internal method ``_assign_to_config()`` and moved it's implementation in *CodeIgniter.php* instead.
        -  :doc:`Security Library ` changes include:
     	 -  Added method ``strip_image_tags()``.
     	 -  Added ``$config['csrf_regeneration']``, which makes token regeneration optional.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 1887ec69c9230ff3fbde63f209b50ce69b28fc62 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 16:22:07 +0300
    Subject: Input class improvements
    
    - Disable register_globals replication on PHP 5.4+ (no longer exists).
    - DocBlock improvements.
    - Add missing changelog entry.
    - Change user_agent() to return NULL when no value is found (for consistency with other fetcher methods).
    ---
     system/core/Config.php              |   2 +-
     system/core/Input.php               | 228 +++++++++++++++++++-----------------
     user_guide_src/source/changelog.rst |   4 +-
     3 files changed, 125 insertions(+), 109 deletions(-)
    
    diff --git a/system/core/Config.php b/system/core/Config.php
    index 152e9af68..642cee798 100644
    --- a/system/core/Config.php
    +++ b/system/core/Config.php
    @@ -55,7 +55,7 @@ class CI_Config {
     	/**
     	 * List of paths to search when trying to load a config file.
     	 *
    -	 * @used-by	CI_Loader	Must be public
    +	 * @used-by	CI_Loader
     	 * @var		array
     	 */
     	public $_config_paths =	array(APPPATH);
    diff --git a/system/core/Input.php b/system/core/Input.php
    index ec935d531..18406fe43 100644
    --- a/system/core/Input.php
    +++ b/system/core/Input.php
    @@ -41,59 +41,68 @@ class CI_Input {
     	/**
     	 * IP address of the current user
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
    -	public $ip_address =	FALSE;
    +	public $ip_address = FALSE;
     
     	/**
    -	 * user agent (web browser) being used by the current user
    +	 * User agent strin
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
    -	public $user_agent =	FALSE;
    +	public $user_agent = FALSE;
     
     	/**
    -	 * If FALSE, then $_GET will be set to an empty array
    +	 * Allow GET array flag
     	 *
    -	 * @var bool
    +	 * If set to FALSE, then $_GET will be set to an empty array.
    +	 *
    +	 * @var	bool
     	 */
    -	protected $_allow_get_array =	TRUE;
    +	protected $_allow_get_array = TRUE;
     
     	/**
    -	 * If TRUE, then newlines are standardized
    +	 * Standartize new lines flag
    +	 *
    +	 * If set to TRUE, then newlines are standardized.
     	 *
    -	 * @var bool
    +	 * @var	bool
     	 */
    -	protected $_standardize_newlines =	TRUE;
    +	protected $_standardize_newlines = TRUE;
     
     	/**
    -	 * Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
    -	 * Set automatically based on config setting
    +	 * Enable XSS flag
    +	 *
    +	 * Determines whether the XSS filter is always active when
    +	 * GET, POST or COOKIE data is encountered.
    +	 * Set automatically based on config setting.
     	 *
    -	 * @var bool
    +	 * @var	bool
     	 */
    -	protected $_enable_xss =	FALSE;
    +	protected $_enable_xss = FALSE;
     
     	/**
    +	 * Enable CSRF flag
    +	 *
     	 * Enables a CSRF cookie token to be set.
    -	 * Set automatically based on config setting
    +	 * Set automatically based on config setting.
     	 *
    -	 * @var bool
    +	 * @var	bool
     	 */
    -	protected $_enable_csrf =	FALSE;
    +	protected $_enable_csrf = FALSE;
     
     	/**
     	 * List of all HTTP request headers
     	 *
     	 * @var array
     	 */
    -	protected $headers =	array();
    +	protected $headers = array();
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
    -	 * Sets whether to globally enable the XSS processing
    -	 * and whether to allow the $_GET array
    +	 * Determines whether to globally enable the XSS processing
    +	 * and whether to allow the $_GET array.
     	 *
     	 * @return	void
     	 */
    @@ -124,12 +133,12 @@ class CI_Input {
     	/**
     	 * Fetch from array
     	 *
    -	 * This is a helper function to retrieve values from global arrays
    +	 * Internal method used to retrieve values from global arrays.
     	 *
    -	 * @param	array
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	string
    +	 * @param	array	&$array		$_GET, $_POST, $_COOKIE, $_SERVER, etc.
    +	 * @param	string	$index		Index for item to be fetched from $array
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
    +	 * @return	mixed
     	 */
     	protected function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
     	{
    @@ -151,9 +160,9 @@ class CI_Input {
     	/**
     	 * Fetch an item from the GET array
     	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	string
    +	 * @param	string	$index		Index for item to be fetched from $_GET
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
    +	 * @return	mixed
     	 */
     	public function get($index = NULL, $xss_clean = FALSE)
     	{
    @@ -178,9 +187,9 @@ class CI_Input {
     	/**
     	 * Fetch an item from the POST array
     	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	string
    +	 * @param	string	$index		Index for item to be fetched from $_POST
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
    +	 * @return	mixed
     	 */
     	public function post($index = NULL, $xss_clean = FALSE)
     	{
    @@ -204,11 +213,11 @@ class CI_Input {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch an item from either the GET array or the POST
    +	 * Fetch an item from POST data with fallback to GET
     	 *
    -	 * @param	string	The index key
    -	 * @param	bool	XSS cleaning
    -	 * @return	string
    +	 * @param	string	$index		Index for item to be fetched from $_POST or $_GET
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
    +	 * @return	mixed
     	 */
     	public function get_post($index = '', $xss_clean = FALSE)
     	{
    @@ -222,31 +231,45 @@ class CI_Input {
     	/**
     	 * Fetch an item from the COOKIE array
     	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	string
    +	 * @param	string	$index		Index for item to be fetched from $_COOKIE
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
    +	 * @return	mixed
     	 */
     	public function cookie($index = '', $xss_clean = FALSE)
     	{
     		return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
     	}
     
    +	// --------------------------------------------------------------------
    +
    +	/**
    +	 * Fetch an item from the SERVER array
    +	 *
    +	 * @param	string	$index		Index for item to be fetched from $_SERVER
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
    +	 * @return	mixed
    +	 */
    +	public function server($index = '', $xss_clean = FALSE)
    +	{
    +		return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
    +	}
    +
     	// ------------------------------------------------------------------------
     
     	/**
     	 * Set cookie
     	 *
    -	 * Accepts seven parameters, or you can submit an associative
    +	 * Accepts an arbitrary number of parameters (up to 7) or an associative
     	 * array in the first parameter containing all the values.
     	 *
    -	 * @param	mixed
    -	 * @param	string	the value of the cookie
    -	 * @param	string	the number of seconds until expiration
    -	 * @param	string	the cookie domain.  Usually:  .yourdomain.com
    -	 * @param	string	the cookie path
    -	 * @param	string	the cookie prefix
    -	 * @param	bool	true makes the cookie secure
    -	 * @param	bool	true makes the cookie accessible via http(s) only (no javascript)
    +	 * @param	string|mixed[]	$name		Cookie name or an array containing parameters
    +	 * @param	string		$value		Cookie value
    +	 * @param	int		$expire		Cookie expiration time in seconds
    +	 * @param	string		$domain		Cookie domain (e.g.: '.yourdomain.com')
    +	 * @param	string		$path		Cookie path (default: '/')
    +	 * @param	string		$prefix		Cookie name prefix
    +	 * @param	bool		$secure		Whether to only transfer cookies via SSL
    +	 * @param	bool		$httponly	Whether to only makes the cookie accessible via HTTP (no javascript)
     	 * @return	void
     	 */
     	public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
    @@ -302,24 +325,12 @@ class CI_Input {
     
     	// --------------------------------------------------------------------
     
    -	/**
    -	 * Fetch an item from the SERVER array
    -	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	string
    -	 */
    -	public function server($index = '', $xss_clean = FALSE)
    -	{
    -		return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
    -	}
    -
    -	// --------------------------------------------------------------------
    -
     	/**
     	 * Fetch the IP Address
     	 *
    -	 * @return	string
    +	 * Determines and validates the visitor's IP address.
    +	 *
    +	 * @return	string	IP address
     	 */
     	public function ip_address()
     	{
    @@ -458,8 +469,8 @@ class CI_Input {
     	/**
     	 * Validate IP Address
     	 *
    -	 * @param	string
    -	 * @param	string	'ipv4' or 'ipv6'
    +	 * @param	string	$ip	IP address
    +	 * @param	string	$which	IP protocol: 'ipv4' or 'ipv6'
     	 * @return	bool
     	 */
     	public function valid_ip($ip, $which = '')
    @@ -483,9 +494,9 @@ class CI_Input {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * User Agent
    +	 * Fetch User Agent string
     	 *
    -	 * @return	string
    +	 * @return	string|null	User Agent string or NULL if it doesn't exist
     	 */
     	public function user_agent()
     	{
    @@ -494,7 +505,7 @@ class CI_Input {
     			return $this->user_agent;
     		}
     
    -		return $this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : FALSE;
    +		return $this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
     	}
     
     	// --------------------------------------------------------------------
    @@ -502,11 +513,12 @@ class CI_Input {
     	/**
     	 * Sanitize Globals
     	 *
    -	 * This function does the following:
    +	 * Internal method serving for the following purposes:
     	 *
    -	 * - Unsets $_GET data (if query strings are not enabled)
    -	 * - Unsets all globals if register_globals is enabled
    -	 * - Standardizes newline characters to \n
    +	 *	- Unsets $_GET data (if query strings are not enabled)
    +	 *	- Unsets all globals if register_globals is enabled
    +	 *	- Cleans POST, COOKIE and SERVER data
    +	 * 	- Standardizes newline characters to PHP_EOL
     	 *
     	 * @return	void
     	 */
    @@ -534,25 +546,29 @@ class CI_Input {
     			'IN'
     		);
     
    -		// Unset globals for securiy.
    +		// Unset globals for security.
     		// This is effectively the same as register_globals = off
    -		foreach (array($_GET, $_POST, $_COOKIE) as $global)
    +		// PHP 5.4 no longer has the register_globals functionality.
    +		if ( ! is_php('5.4'))
     		{
    -			if (is_array($global))
    +			foreach (array($_GET, $_POST, $_COOKIE) as $global)
     			{
    -				foreach ($global as $key => $val)
    +				if (is_array($global))
     				{
    -					if ( ! in_array($key, $protected))
    +					foreach ($global as $key => $val)
     					{
    -						global $$key;
    -						$$key = NULL;
    +						if ( ! in_array($key, $protected))
    +						{
    +							global $$key;
    +							$$key = NULL;
    +						}
     					}
     				}
    -			}
    -			elseif ( ! in_array($global, $protected))
    -			{
    -				global $$global;
    -				$$global = NULL;
    +				elseif ( ! in_array($global, $protected))
    +				{
    +					global $$global;
    +					$$global = NULL;
    +				}
     			}
     		}
     
    @@ -613,10 +629,10 @@ class CI_Input {
     	/**
     	 * Clean Input Data
     	 *
    -	 * This is a helper function. It escapes data and
    -	 * standardizes newline characters to \n
    +	 * Internal method that aids in escaping data and
    +	 * standardizing newline characters to PHP_EOL.
     	 *
    -	 * @param	string
    +	 * @param	string|string[]	$str	Input string(s)
     	 * @return	string
     	 */
     	protected function _clean_input_data($str)
    @@ -624,9 +640,9 @@ class CI_Input {
     		if (is_array($str))
     		{
     			$new_array = array();
    -			foreach ($str as $key => $val)
    +			foreach (array_keys($str) as $key)
     			{
    -				$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
    +				$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($str[$key]);
     			}
     			return $new_array;
     		}
    @@ -670,11 +686,11 @@ class CI_Input {
     	/**
     	 * Clean Keys
     	 *
    -	 * This is a helper function. To prevent malicious users
    +	 * Internal method that helps to prevent malicious users
     	 * from trying to exploit keys we make sure that keys are
     	 * only named with alpha-numeric text and a few other items.
     	 *
    -	 * @param	string
    +	 * @param	string	$str	Input string
     	 * @return	string
     	 */
     	protected function _clean_input_keys($str)
    @@ -699,15 +715,12 @@ class CI_Input {
     	/**
     	 * Request Headers
     	 *
    -	 * In Apache, you can simply call apache_request_headers(), however for
    -	 * people running other webservers the function is undefined.
    -	 *
    -	 * @param	bool	XSS cleaning
    +	 * @param	bool	$xss_clean	Whether to apply XSS filtering
     	 * @return	array
     	 */
     	public function request_headers($xss_clean = FALSE)
     	{
    -		// Look at Apache go!
    +		// In Apache, you can simply call apache_request_headers()
     		if (function_exists('apache_request_headers'))
     		{
     			$headers = apache_request_headers();
    @@ -744,9 +757,9 @@ class CI_Input {
     	 *
     	 * Returns the value of a single member of the headers class member
     	 *
    -	 * @param	string	array key for $this->headers
    -	 * @param	bool	XSS Clean or not
    -	 * @return	mixed	FALSE on failure, string on success
    +	 * @param	string		$index		Header name
    +	 * @param	bool		$xss_clean	Whether to apply XSS filtering
    +	 * @return	string|bool	The requested header on success or FALSE on failure
     	 */
     	public function get_request_header($index, $xss_clean = FALSE)
     	{
    @@ -768,9 +781,9 @@ class CI_Input {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Is ajax Request?
    +	 * Is AJAX request?
     	 *
    -	 * Test to see if a request contains the HTTP_X_REQUESTED_WITH header
    +	 * Test to see if a request contains the HTTP_X_REQUESTED_WITH header.
     	 *
     	 * @return 	bool
     	 */
    @@ -782,9 +795,9 @@ class CI_Input {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Is cli Request?
    +	 * Is CLI request?
     	 *
    -	 * Test to see if a request was made from the command line
    +	 * Test to see if a request was made from the command line.
     	 *
     	 * @return 	bool
     	 */
    @@ -798,10 +811,11 @@ class CI_Input {
     	/**
     	 * Get Request Method
     	 *
    -	 * Return the Request Method
    +	 * Return the request method
     	 *
    -	 * @param	bool	uppercase or lowercase
    -	 * @return 	bool
    +	 * @param	bool	$upper	Whether to return in upper or lower case
    +	 *				(default: FALSE)
    +	 * @return 	string
     	 */
     	public function method($upper = FALSE)
     	{
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index a1cdcd475..c98ac7295 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -240,8 +240,10 @@ Release Date: Not Released
     	 -  ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``` changes include:
     	 -  Added ``method()`` to retrieve ``$_SERVER['REQUEST_METHOD']``.
    -	 -  Modified ``valid_ip()`` to use PHP's ``filter_var()``.
     	 -  Added support for arrays and network addresses (e.g. 192.168.1.1/24) for use with the *proxy_ips* setting.
    +	 -  Changed method ``valid_ip()`` to use PHP's native ``filter_var()`` function.
    +	 -  Changed internal method ``_sanitize_globals()`` to skip enforcing reversal of *register_globals* in PHP 5.4+, where this functionality no longer exists.
    +	 -  Changed methods ``get()``, ``post()``, ``get_post()``, ``cookie()``, ``server()``, ``user_agent()`` to return NULL instead of FALSE when no value is found.
        -  :doc:`Common functions ` changes include:
     	 -  Added function ``get_mimes()`` to return the *config/mimes.php* array.
     	 -  Added support for HTTP code 303 ("See Other") in ``set_status_header()``.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From ed4b258a204319c5a3a7c242c1cc7dfbfe14ad4e Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 17:46:52 +0300
    Subject: Make CI_Loader::config() a proper alias for CI_Config::load() and
     improve the Loader class DocBlocks
    
    ---
     system/core/Loader.php              | 286 +++++++++++++++++++-----------------
     user_guide_src/source/changelog.rst |   5 +-
     2 files changed, 155 insertions(+), 136 deletions(-)
    
    diff --git a/system/core/Loader.php b/system/core/Loader.php
    index b316c8e1b..db56ab3ae 100644
    --- a/system/core/Loader.php
    +++ b/system/core/Loader.php
    @@ -28,7 +28,7 @@
     /**
      * Loader Class
      *
    - * Loads views and files
    + * Loads framework components.
      *
      * @package		CodeIgniter
      * @subpackage	Libraries
    @@ -42,84 +42,84 @@ class CI_Loader {
     	/**
     	 * Nesting level of the output buffering mechanism
     	 *
    -	 * @var int
    +	 * @var	int
     	 */
     	protected $_ci_ob_level;
     
     	/**
     	 * List of paths to load views from
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_view_paths =	array();
     
     	/**
     	 * List of paths to load libraries from
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_library_paths =	array();
     
     	/**
     	 * List of paths to load models from
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_model_paths =	array();
     
     	/**
     	 * List of paths to load helpers from
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_helper_paths =	array();
     
     	/**
     	 * List of loaded base classes
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_base_classes =	array(); // Set by the controller class
     
     	/**
     	 * List of cached variables
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_cached_vars =	array();
     
     	/**
     	 * List of loaded classes
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_classes =	array();
     
     	/**
     	 * List of loaded files
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_loaded_files =	array();
     
     	/**
     	 * List of loaded models
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_models =	array();
     
     	/**
     	 * List of loaded helpers
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_helpers =	array();
     
     	/**
     	 * List of class name mappings
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_ci_varmap =	array(
     		'unit_test' => 'unit',
    @@ -127,9 +127,9 @@ class CI_Loader {
     	);
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
    -	 * Sets the path to the view files and gets the initial output buffering level
    +	 * Sets component load paths gets the initial output buffering level.
     	 *
     	 * @return	void
     	 */
    @@ -149,9 +149,9 @@ class CI_Loader {
     	/**
     	 * Initialize the Loader
     	 *
    -	 * This method is called once in CI_Controller.
    -	 *
    -	 * @return 	object
    +	 * @used-by	CI_Controller
    +	 * @uses	CI_Loader::_ci_autoloader()
    +	 * @return 	object	$this
     	 */
     	public function initialize()
     	{
    @@ -169,14 +169,12 @@ class CI_Loader {
     	/**
     	 * Is Loaded
     	 *
    -	 * A utility function to test if a class is in the self::$_ci_classes array.
    -	 * This function returns the object name if the class tested for is loaded,
    -	 * and returns FALSE if it isn't.
    +	 * A utility method to test if a class is in the self::$_ci_classes array.
     	 *
    -	 * It is mainly used in the form_helper -> _get_validation_object()
    +	 * @used-by	Mainly used by Form Helper function _get_validation_object().
     	 *
    -	 * @param 	string	class being checked for
    -	 * @return 	mixed	class object name on the CI SuperObject or FALSE
    +	 * @param 	string		$class	Class name to check for
    +	 * @return 	string|bool	Class object name if loaded or FALSE
     	 */
     	public function is_loaded($class)
     	{
    @@ -186,14 +184,14 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Class Loader
    +	 * Library Loader
     	 *
    -	 * This function lets users load and instantiate classes.
    -	 * It is designed to be called from a user's app controllers.
    +	 * Loads and instantiates libraries.
    +	 * Designed to be called from application controllers.
     	 *
    -	 * @param	string	the name of the class
    -	 * @param	mixed	the optional parameters
    -	 * @param	string	an optional object name
    +	 * @param	string	$library	Library name
    +	 * @param	array	$params		Optional parameters to pass to the library class constructor
    +	 * @param	string	$object_name	An optional object name to assign to
     	 * @return	void
     	 */
     	public function library($library = '', $params = NULL, $object_name = NULL)
    @@ -210,7 +208,7 @@ class CI_Loader {
     
     		if ($library === '' OR isset($this->_base_classes[$library]))
     		{
    -			return FALSE;
    +			return;
     		}
     
     		if ( ! is_null($params) && ! is_array($params))
    @@ -226,16 +224,20 @@ class CI_Loader {
     	/**
     	 * Model Loader
     	 *
    -	 * This function lets users load and instantiate models.
    +	 * Loads and instantiates libraries.
     	 *
    -	 * @param	string	the name of the class
    -	 * @param	string	name for the model
    -	 * @param	bool	database connection
    +	 * @param	string	$model		Model name
    +	 * @param	string	$name		An optional object name to assign to
    +	 * @param	bool	$db_conn	An optional database connection configuration to initialize
     	 * @return	void
     	 */
     	public function model($model, $name = '', $db_conn = FALSE)
     	{
    -		if (is_array($model))
    +		if (empty($model))
    +		{
    +			return;
    +		}
    +		elseif (is_array($model))
     		{
     			foreach ($model as $class)
     			{
    @@ -244,11 +246,6 @@ class CI_Loader {
     			return;
     		}
     
    -		if ($model === '')
    -		{
    -			return;
    -		}
    -
     		$path = '';
     
     		// Is the model in a sub-folder? If so, parse out the filename and path.
    @@ -318,10 +315,13 @@ class CI_Loader {
     	/**
     	 * Database Loader
     	 *
    -	 * @param	mixed	$params = ''		the DB settings
    -	 * @param	bool	$return = FALSE		whether to return the DB object
    -	 * @param	bool	$query_builder = NULL	whether to enable query builder (overrides the config setting)
    -	 * @return	object
    +	 * @param	mixed	$params		Database configuration options
    +	 * @param	bool	$return 	Whether to return the database object
    +	 * @param	bool	$query_builder	Whether to enable Query Builder
    +	 *					(overrides the configuration setting)
    +	 *
    +	 * @return	void|object|bool	Database object if $return is set to TRUE,
    +	 *					FALSE on failure, void in any other case
     	 */
     	public function database($params = '', $return = FALSE, $query_builder = NULL)
     	{
    @@ -352,9 +352,9 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Load the Utilities Class
    +	 * Load the Database Utilities Class
     	 *
    -	 * @return	string
    +	 * @return	void
     	 */
     	public function dbutil()
     	{
    @@ -381,7 +381,7 @@ class CI_Loader {
     	/**
     	 * Load the Database Forge Class
     	 *
    -	 * @return	string
    +	 * @return	void
     	 */
     	public function dbforge()
     	{
    @@ -402,19 +402,15 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Load View
    -	 *
    -	 * This function is used to load a "view" file. It has three parameters:
    +	 * View Loader
     	 *
    -	 * 1. The name of the "view" file to be included.
    -	 * 2. An associative array of data to be extracted for use in the view.
    -	 * 3. TRUE/FALSE - whether to return the data or load it. In
    -	 *	some cases it's advantageous to be able to return data so that
    -	 *	a developer can process it in some way.
    +	 * Loads "view" files.
     	 *
    -	 * @param	string
    -	 * @param	array
    -	 * @param	bool
    +	 * @param	string	$view	View name
    +	 * @param	array	$vars	An associative array of data
    +	 *				to be extracted for use in the view
    +	 * @param	bool	$return	Whether to return the view output
    +	 *				or leave it to the Output class
     	 * @return	void
     	 */
     	public function view($view, $vars = array(), $return = FALSE)
    @@ -425,13 +421,11 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Load File
    -	 *
    -	 * This is a generic file loader
    +	 * Generic File Loader
     	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	string
    +	 * @param	string	$path	File path
    +	 * @param	bool	$return	Whether to return the file output
    +	 * @return	void|string
     	 */
     	public function file($path, $return = FALSE)
     	{
    @@ -446,8 +440,10 @@ class CI_Loader {
     	 * Once variables are set they become available within
     	 * the controller class and its "view" files.
     	 *
    -	 * @param	array
    -	 * @param 	string
    +	 * @param	array|object|string	$vars
    +	 *					An associative array or object containing values
    +	 *					to be set, or a value's name if string
    +	 * @param 	string	$val	Value to set, only used if $vars is a string
     	 * @return	void
     	 */
     	public function vars($vars = array(), $val = '')
    @@ -475,8 +471,8 @@ class CI_Loader {
     	 *
     	 * Check if a variable is set and retrieve it.
     	 *
    -	 * @param	array
    -	 * @return	void
    +	 * @param	string	$key	Variable name
    +	 * @return	mixed	The variable or NULL if not found
     	 */
     	public function get_var($key)
     	{
    @@ -488,7 +484,7 @@ class CI_Loader {
     	/**
     	 * Get Variables
     	 *
    -	 * Retrieve all loaded variables
    +	 * Retrieves all loaded variables.
     	 *
     	 * @return	array
     	 */
    @@ -500,11 +496,9 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Load Helper
    -	 *
    -	 * This function loads the specified helper file.
    +	 * Helper Loader
     	 *
    -	 * @param	mixed
    +	 * @param	string|string[]	$helpers	Helper name(s)
     	 * @return	void
     	 */
     	public function helper($helpers = array())
    @@ -562,10 +556,11 @@ class CI_Loader {
     	/**
     	 * Load Helpers
     	 *
    -	 * This is simply an alias to the above function in case the
    -	 * user has written the plural form of this function.
    +	 * An alias for the helper() method in case the developer has
    +	 * written the plural form of it.
     	 *
    -	 * @param	array
    +	 * @uses	CI_Loader::helper()
    +	 * @param	string|string[]	$helpers	Helper name(s)
     	 * @return	void
     	 */
     	public function helpers($helpers = array())
    @@ -576,22 +571,21 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Loads a language file
    +	 * Language Loader
     	 *
    -	 * @param	array
    -	 * @param	string
    +	 * Loads language files.
    +	 *
    +	 * @param	string|string[]	$files	List of language file names to load
    +	 * @param	string		Language name
     	 * @return	void
     	 */
    -	public function language($file = array(), $lang = '')
    +	public function language($files = array(), $lang = '')
     	{
     		$CI =& get_instance();
     
    -		if ( ! is_array($file))
    -		{
    -			$file = array($file);
    -		}
    +		is_array($files) OR $files = array($files);
     
    -		foreach ($file as $langfile)
    +		foreach ($files as $langfile)
     		{
     			$CI->lang->load($langfile, $lang);
     		}
    @@ -600,30 +594,35 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Loads a config file
    +	 * Config Loader
     	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @param 	bool
    -	 * @return	void
    +	 * Loads a config file (an alias for CI_Config::load()).
    +	 *
    +	 * @uses	CI_Config::load()
    +	 * @param	string	$file			Configuration file name
    +	 * @param	bool	$use_sections		Whether configuration values should be loaded into their own section
    +	 * @param	bool	$fail_gracefully	Whether to just return FALSE or display an error message
    +	 * @return	bool	TRUE if the file was loaded correctly or FALSE on failure
     	 */
     	public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
     	{
     		$CI =& get_instance();
    -		$CI->config->load($file, $use_sections, $fail_gracefully);
    +		return $CI->config->load($file, $use_sections, $fail_gracefully);
     	}
     
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Driver
    +	 * Driver Loader
     	 *
    -	 * Loads a driver library
    +	 * Loads a driver library.
     	 *
    -	 * @param	mixed	the name of the class or array of classes
    -	 * @param	mixed	the optional parameters
    -	 * @param	string	an optional object name
    -	 * @return	void
    +	 * @param	string|string[]	$library	Driver name(s)
    +	 * @param	array		$params		Optional parameters to pass to the driver
    +	 * @param	string		$object_name	An optional object name to assign to
    +	 *
    +	 * @return	void|object|bool	Object or FALSE on failure if $library is a string
    +	 *					and $object_name is set. void otherwise.
     	 */
     	public function driver($library = '', $params = NULL, $object_name = NULL)
     	{
    @@ -656,10 +655,16 @@ class CI_Loader {
     	/**
     	 * Add Package Path
     	 *
    -	 * Prepends a parent path to the library, model, helper, and config path arrays
    +	 * Prepends a parent path to the library, model, helper and config
    +	 * path arrays.
    +	 *
    +	 * @see	CI_Loader::$_ci_library_paths
    +	 * @see	CI_Loader::$_ci_model_paths
    +	 * @see CI_Loader::$_ci_helper_paths
    +	 * @see CI_Config::$_config_paths
     	 *
    -	 * @param	string
    -	 * @param 	bool
    +	 * @param	string	$path		Path to add
    +	 * @param 	bool	$view_cascade	(default: TRUE)
     	 * @return	void
     	 */
     	public function add_package_path($path, $view_cascade = TRUE)
    @@ -682,10 +687,10 @@ class CI_Loader {
     	/**
     	 * Get Package Paths
     	 *
    -	 * Return a list of all package paths, by default it will ignore BASEPATH.
    +	 * Return a list of all package paths.
     	 *
    -	 * @param	string
    -	 * @return	void
    +	 * @param	bool	$include_base	Whether to include BASEPATH (default: TRUE)
    +	 * @return	array
     	 */
     	public function get_package_paths($include_base = FALSE)
     	{
    @@ -697,14 +702,14 @@ class CI_Loader {
     	/**
     	 * Remove Package Path
     	 *
    -	 * Remove a path from the library, model, and helper path arrays if it exists
    -	 * If no path is provided, the most recently added path is removed.
    +	 * Remove a path from the library, model, helper and/or config
    +	 * path arrays if it exists. If no path is provided, the most recently
    +	 * added path will be removed removed.
     	 *
    -	 * @param	string
    -	 * @param 	bool
    +	 * @param	string	$path	Path to remove
     	 * @return	void
     	 */
    -	public function remove_package_path($path = '', $remove_config_path = TRUE)
    +	public function remove_package_path($path = '')
     	{
     		$config =& $this->_ci_get_component('config');
     
    @@ -749,13 +754,16 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Loader
    +	 * Internal CI Data Loader
    +	 *
    +	 * Used to load views and files.
     	 *
    -	 * This function is used to load views and files.
     	 * Variables are prefixed with _ci_ to avoid symbol collision with
    -	 * variables made available to view files
    +	 * variables made available to view files.
     	 *
    -	 * @param	array
    +	 * @used-by	CI_Loader::view()
    +	 * @used-by	CI_Loader::file()
    +	 * @param	array	$_ci_data	Data to load
     	 * @return	void
     	 */
     	protected function _ci_load($_ci_data)
    @@ -883,13 +891,14 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Load class
    +	 * Internal CI Class Loader
     	 *
    -	 * This function loads the requested class.
    +	 * @used-by	CI_Loader::library()
    +	 * @uses	CI_Loader::_ci_init_class()
     	 *
    -	 * @param	string	the item that is being loaded
    -	 * @param	mixed	any additional parameters
    -	 * @param	string	an optional object name
    +	 * @param	string	$class		Class name to load
    +	 * @param	mixed	$params		Optional parameters to pass to the class constructor
    +	 * @param	string	$object_name	Optional object name to assign to
     	 * @return	void
     	 */
     	protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
    @@ -1024,12 +1033,17 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Instantiates a class
    +	 * Internal CI Class Instantiator
    +	 *
    +	 * @used-by	CI_Loader::_ci_load_class()
     	 *
    -	 * @param	string
    -	 * @param	string
    -	 * @param	bool
    -	 * @param	string	an optional object name
    +	 * @param	string		$class		Class name
    +	 * @param	string		$prefix		Class name prefix
    +	 * @param	array|null|bool	$config		Optional configuration to pass to the class constructor:
    +	 *						FALSE to skip;
    +	 *						NULL to search in config paths;
    +	 *						array containing configuration data
    +	 * @param	string		$object_name	Optional object name to assign to
     	 * @return	void
     	 */
     	protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
    @@ -1131,11 +1145,11 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Autoloader
    +	 * CI Autoloader
     	 *
    -	 * The config/autoload.php file contains an array that permits sub-systems,
    -	 * libraries, and helpers to be loaded automatically.
    +	 * Loads component listed in the config/autoload.php file.
     	 *
    +	 * @used-by	CI_Loader::initialize()
     	 * @return	void
     	 */
     	protected function _ci_autoloader()
    @@ -1218,11 +1232,12 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Object to Array
    +	 * CI Object to Array translator
     	 *
    -	 * Takes an object as input and converts the class variables to array key/vals
    +	 * Takes an object as input and converts the class variables to
    +	 * an associative array with key/value pairs.
     	 *
    -	 * @param	object
    +	 * @param	object	$object	Object data to translate
     	 * @return	array
     	 */
     	protected function _ci_object_to_array($object)
    @@ -1233,9 +1248,11 @@ class CI_Loader {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Get a reference to a specific library or model
    +	 * CI Component getter
    +	 *
    +	 * Get a reference to a specific library or model.
     	 *
    -	 * @param 	string
    +	 * @param 	string	$component	Component name
     	 * @return	bool
     	 */
     	protected function &_ci_get_component($component)
    @@ -1249,10 +1266,11 @@ class CI_Loader {
     	/**
     	 * Prep filename
     	 *
    -	 * This function preps the name of various items to make loading them more reliable.
    +	 * This function prepares filenames of various items to
    +	 * make their loading more reliable.
     	 *
    -	 * @param	mixed
    -	 * @param 	string
    +	 * @param	string|string[]	$filename	Filename(s)
    +	 * @param 	string		$extension	Filename extension
     	 * @return	array
     	 */
     	protected function _ci_prep_filename($filename, $extension)
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index c98ac7295..4b161dc2d 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -234,10 +234,11 @@ Release Date: Not Released
        -  Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
        -  :doc:`Loader Library ` changes include:
     	 -  Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
    -	 -  ``CI_Loader::_ci_autoloader()`` is now a protected method.
    +	 -  ``_ci_autoloader()`` is now a protected method.
     	 -  Added autoloading of drivers with ``$autoload['drivers']``.
    -	 -  ``CI_Loader::library()`` will now load drivers as well, for backward compatibility of converted libraries (like :doc:`Session `).
    +	 -  ``library()`` method will now load drivers as well, for backward compatibility of converted libraries (like :doc:`Session `).
     	 -  ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``` changes include:
     	 -  Added ``method()`` to retrieve ``$_SERVER['REQUEST_METHOD']``.
     	 -  Added support for arrays and network addresses (e.g. 192.168.1.1/24) for use with the *proxy_ips* setting.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From bb82969e52ca3fe67dfbb88deccf636d08e8d693 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:00:35 +0300
    Subject: Remove extra new lines
    
    ---
     system/core/Lang.php | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/system/core/Lang.php b/system/core/Lang.php
    index e74304dd9..251cf6ef1 100644
    --- a/system/core/Lang.php
    +++ b/system/core/Lang.php
    @@ -120,7 +120,6 @@ class CI_Lang {
     			}
     		}
     
    -
     		if ( ! isset($lang) OR ! is_array($lang))
     		{
     			log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 2b5b92e6535fb328bf4fbe75396c80e352b7c3a2 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:01:47 +0300
    Subject: Remove extra space...
    
    ---
     system/libraries/Session/drivers/Session_native.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/system/libraries/Session/drivers/Session_native.php b/system/libraries/Session/drivers/Session_native.php
    index da744f39b..a837b89f6 100755
    --- a/system/libraries/Session/drivers/Session_native.php
    +++ b/system/libraries/Session/drivers/Session_native.php
    @@ -1,4 +1,4 @@
    -
    Date: Sat, 27 Oct 2012 18:04:40 +0300
    Subject: Fix Loader tests
    
    ---
     tests/codeigniter/core/Loader_test.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
    index f7c338a20..816587a49 100644
    --- a/tests/codeigniter/core/Loader_test.php
    +++ b/tests/codeigniter/core/Loader_test.php
    @@ -36,7 +36,7 @@ class Loader_test extends CI_TestCase {
     		$this->assertAttributeInstanceOf($class, $lib, $this->ci_obj);
     
     		// Test no lib given
    -		$this->assertFalse($this->load->library());
    +		$this->assertNull($this->load->library());
     
     		// Test a string given to params
     		$this->assertNull($this->load->library($lib, ' '));
    @@ -450,7 +450,7 @@ class Loader_test extends CI_TestCase {
     	public function test_load_config()
     	{
     		$cfg = 'someconfig';
    -		$this->assertNull($this->load->config($cfg, FALSE));
    +		$this->assertTrue($this->load->config($cfg, FALSE));
     		$this->assertContains($cfg, $this->ci_obj->config->loaded);
     	}
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From a5779d0a9ad598da8647e033ef8d88c3ac81fa02 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:04:54 +0300
    Subject: Remove extra new lines
    
    ---
     system/core/CodeIgniter.php | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
    index 324b4d849..f27086386 100644
    --- a/system/core/CodeIgniter.php
    +++ b/system/core/CodeIgniter.php
    @@ -232,7 +232,6 @@
     		return CI_Controller::get_instance();
     	}
     
    -
     	if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
     	{
     		require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 8b9aa179047643668446ca454461a3ef34b3d228 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:06:09 +0300
    Subject: Remove extra new lines
    
    ---
     system/core/Input.php | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/system/core/Input.php b/system/core/Input.php
    index 18406fe43..f6213c34e 100644
    --- a/system/core/Input.php
    +++ b/system/core/Input.php
    @@ -209,7 +209,6 @@ class CI_Input {
     		return $this->_fetch_from_array($_POST, $index, $xss_clean);
     	}
     
    -
     	// --------------------------------------------------------------------
     
     	/**
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From a8349bc4809e5a5a6bbc2c1a6566a01f4f8f16c7 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:07:59 +0300
    Subject: Remove extra new lines
    
    ---
     system/core/Output.php | 3 +--
     1 file changed, 1 insertion(+), 2 deletions(-)
    
    diff --git a/system/core/Output.php b/system/core/Output.php
    index aa0e05dc4..2da1b3e25 100644
    --- a/system/core/Output.php
    +++ b/system/core/Output.php
    @@ -375,10 +375,9 @@ class CI_Output {
     			$output = $this->minify($output, $this->mime_type);
     		}
     
    -
     		// --------------------------------------------------------------------
     
    -		// Do we need to write a cache file?  Only if the controller does not have its
    +		// Do we need to write a cache file? Only if the controller does not have its
     		// own _output() method and we are not dealing with a cache file, which we
     		// can determine by the existence of the $CI object above
     		if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 31b7c339a1ffda23d9ad288e294fbde5e7e22f70 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:09:46 +0300
    Subject: Remove extra new lines
    
    ---
     system/core/Utf8.php | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/system/core/Utf8.php b/system/core/Utf8.php
    index bc7afed91..efe3c10dc 100644
    --- a/system/core/Utf8.php
    +++ b/system/core/Utf8.php
    @@ -64,7 +64,6 @@ class CI_Utf8 {
     			define('MB_ENABLED', FALSE);
     		}
     
    -
     		if (
     			@preg_match('/./u', 'é') === 1	// PCRE must support UTF-8
     			&& function_exists('iconv')	// iconv must be installed
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 2b6b4300b36365bc060b1697e3f3c7088e6856e6 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:12:24 +0300
    Subject: Update system/core/URI.php
    
    ---
     system/core/URI.php | 3 +--
     1 file changed, 1 insertion(+), 2 deletions(-)
    
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 13530bd63..33f7d21fa 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -473,7 +473,7 @@ class CI_URI {
     		$segments = array_slice($this->$segment_array(), ($n - 1));
     		$i = 0;
     		$lastval = '';
    -		$retval  = array();
    +		$retval = array();
     		foreach ($segments as $seg)
     		{
     			if ($i % 2)
    @@ -640,7 +640,6 @@ class CI_URI {
     		return $this->uri_string;
     	}
     
    -
     	// --------------------------------------------------------------------
     
     	/**
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 94b1f76780e4dbc67ff4b43a98f2cb4e23c01a29 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:19:59 +0300
    Subject: Style guide...
    
    ---
     system/libraries/Cache/Cache.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
    index ce71445df..7ec2380a5 100644
    --- a/system/libraries/Cache/Cache.php
    +++ b/system/libraries/Cache/Cache.php
    @@ -103,7 +103,7 @@ class CI_Cache extends CI_Driver_Library {
     			}
     		}
     
    -		isset($config['key_prefix']) AND $this->key_prefix = $config['key_prefix'];
    +		isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix'];
     
     		if (isset($config['backup']) && in_array('cache_'.$config['backup'], $this->valid_drivers))
     		{
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From bfbe8b2ca47a854686d0ca498686ef1e68124fd8 Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:25:08 +0300
    Subject: Remove extra new lines
    
    ---
     system/libraries/javascript/Jquery.php | 3 +--
     1 file changed, 1 insertion(+), 2 deletions(-)
    
    diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
    index 8739d141f..ed02fadb7 100644
    --- a/system/libraries/javascript/Jquery.php
    +++ b/system/libraries/javascript/Jquery.php
    @@ -700,7 +700,6 @@ class CI_Jquery extends CI_Javascript {
     		return $updater."\t\t$($container).load('$controller'$request_options);";
     	}
     
    -
     	// --------------------------------------------------------------------
     	// Pre-written handy stuff
     	// --------------------------------------------------------------------
    @@ -716,7 +715,7 @@ class CI_Jquery extends CI_Javascript {
     	protected function _zebraTables($class = '', $odd = 'odd', $hover = '')
     	{
     		$class = ($class !== '') ? '.'.$class : '';
    -		$zebra  = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
    +		$zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");";
     
     		$this->jquery_code_for_compile[] = $zebra;
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7e4356b399c2ada34879c6d27edf87e1375029cf Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:41:00 +0300
    Subject: Remove extra new lines
    
    ---
     system/libraries/Email.php | 13 ++++++-------
     1 file changed, 6 insertions(+), 7 deletions(-)
    
    diff --git a/system/libraries/Email.php b/system/libraries/Email.php
    index 9207fc9f0..edca303ff 100644
    --- a/system/libraries/Email.php
    +++ b/system/libraries/Email.php
    @@ -47,20 +47,20 @@ class CI_Email {
     	public $smtp_port	= 25;			// SMTP Port
     	public $smtp_timeout	= 5;			// SMTP Timeout in seconds
     	public $smtp_crypto	= '';			// SMTP Encryption. Can be null, tls or ssl.
    -	public $wordwrap	= TRUE;			// TRUE/FALSE  Turns word-wrap on/off
    +	public $wordwrap	= TRUE;			// TRUE/FALSE - Turns word-wrap on/off
     	public $wrapchars	= 76;			// Number of characters to wrap at.
    -	public $mailtype	= 'text';		// text/html  Defines email formatting
    +	public $mailtype	= 'text';		// text/html - Defines email formatting
     	public $charset		= 'utf-8';		// Default char set: iso-8859-1 or us-ascii
     	public $multipart	= 'mixed';		// "mixed" (in the body) or "related" (separate)
     	public $alt_message	= '';			// Alternative message for HTML emails
    -	public $validate	= FALSE;		// TRUE/FALSE.  Enables email validation
    +	public $validate	= FALSE;		// TRUE/FALSE - Enables email validation
     	public $priority	= 3;			// Default priority (1 - 5)
     	public $newline		= "\n";			// Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
    -	public $crlf		= "\n";			// The RFC 2045 compliant CRLF for quoted-printable is "\r\n".  Apparently some servers,
    +	public $crlf		= "\n";			// The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
     									// even on the receiving end think they need to muck with CRLFs, so using "\n", while
     									// distasteful, is the only thing that seems to work for all environments.
     	public $dsn		= FALSE;		// Delivery Status Notification
    -	public $send_multipart	= TRUE;		// TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override.  Set to FALSE for Yahoo.
    +	public $send_multipart	= TRUE;		// TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
     	public $bcc_batch_mode	= FALSE;	// TRUE/FALSE - Turns on/off Bcc batch feature
     	public $bcc_batch_size	= 200;		// If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
     
    @@ -989,7 +989,6 @@ class CI_Email {
     					$this->_finalbody = $hdr.$this->_finalbody;
     				}
     
    -
     				if ($this->send_multipart !== FALSE)
     				{
     					$this->_finalbody .= '--'.$this->_alt_boundary.'--';
    @@ -1661,7 +1660,7 @@ class CI_Email {
     	// --------------------------------------------------------------------
     
     	/**
    -	 *  SMTP Authenticate
    +	 * SMTP Authenticate
     	 *
     	 * @return	bool
     	 */
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From b9fe7e9be099f450747de6ed28d400764ffc58b3 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sat, 27 Oct 2012 18:45:59 +0300
    Subject: [ci skip] Router class DocBlock improvements
    
    ---
     system/core/Output.php | 156 +++++++++++++++++++++++++++----------------------
     system/core/Router.php |  67 +++++++++++----------
     2 files changed, 120 insertions(+), 103 deletions(-)
    
    diff --git a/system/core/Output.php b/system/core/Output.php
    index aa0e05dc4..3f2f84fa1 100644
    --- a/system/core/Output.php
    +++ b/system/core/Output.php
    @@ -28,7 +28,7 @@
     /**
      * Output Class
      *
    - * Responsible for sending final output to browser
    + * Responsible for sending final output to the browser.
      *
      * @package		CodeIgniter
      * @subpackage	Libraries
    @@ -39,70 +39,74 @@
     class CI_Output {
     
     	/**
    -	 * Current output string
    +	 * Final output string
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	public $final_output;
     
     	/**
     	 * Cache expiration time
     	 *
    -	 * @var int
    +	 * @var	int
     	 */
    -	public $cache_expiration =	0;
    +	public $cache_expiration = 0;
     
     	/**
     	 * List of server headers
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $headers =	array();
     
     	/**
     	 * List of mime types
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $mimes =		array();
     
     	/**
     	 * Mime-type for the current page
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
    -	protected $mime_type		= 'text/html';
    +	protected $mime_type	= 'text/html';
     
     	/**
    -	 * Determines whether profiler is enabled
    +	 * Enable Profiler flag
     	 *
    -	 * @var book
    +	 * @var	bool
     	 */
    -	public $enable_profiler =	FALSE;
    +	public $enable_profiler = FALSE;
     
     	/**
    -	 * Determines if output compression is enabled
    +	 * zLib output compression flag
     	 *
    -	 * @var bool
    +	 * @var	bool
     	 */
     	protected $_zlib_oc =		FALSE;
     
     	/**
     	 * List of profiler sections
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_profiler_sections =	array();
     
     	/**
    -	 * Whether or not to parse variables like {elapsed_time} and {memory_usage}
    +	 * Parse markers flag
     	 *
    -	 * @var bool
    +	 * Whether or not to parse variables like {elapsed_time} and {memory_usage}.
    +	 *
    +	 * @var	bool
     	 */
     	public $parse_exec_vars =	TRUE;
     
     	/**
    -	 * Set up Output class
    +	 * Class constructor
    +	 *
    +	 * Determines whether zLib output compression will be used.
     	 *
     	 * @return	void
     	 */
    @@ -121,7 +125,7 @@ class CI_Output {
     	/**
     	 * Get Output
     	 *
    -	 * Returns the current output string
    +	 * Returns the current output string.
     	 *
     	 * @return	string
     	 */
    @@ -135,10 +139,10 @@ class CI_Output {
     	/**
     	 * Set Output
     	 *
    -	 * Sets the output string
    +	 * Sets the output string.
     	 *
    -	 * @param	string
    -	 * @return	void
    +	 * @param	string	$output	Output data
    +	 * @return	object	$this
     	 */
     	public function set_output($output)
     	{
    @@ -151,14 +155,14 @@ class CI_Output {
     	/**
     	 * Append Output
     	 *
    -	 * Appends data onto the output string
    +	 * Appends data onto the output string.
     	 *
    -	 * @param	string
    -	 * @return	void
    +	 * @param	string	$output	Data to append
    +	 * @return	object	$this
     	 */
     	public function append_output($output)
     	{
    -		if ($this->final_output == '')
    +		if (empty($this->final_output))
     		{
     			$this->final_output = $output;
     		}
    @@ -175,16 +179,16 @@ class CI_Output {
     	/**
     	 * Set Header
     	 *
    -	 * Lets you set a server header which will be outputted with the final display.
    +	 * Lets you set a server header which will be sent with the final output.
     	 *
    -	 * Note: If a file is cached, headers will not be sent. We need to figure out
    -	 * how to permit header data to be saved with the cache data...
    +	 * Note: If a file is cached, headers will not be sent.
    +	 * @todo	We need to figure out how to permit headers to be cached.
     	 *
    -	 * @param	string
    -	 * @param	bool
    -	 * @return	void
    +	 * @param	string	$header		Header
    +	 * @param	bool	$replace	Whether to replace the old header value, if already set
    +	 * @return	object	$this
     	 */
    -	public function set_header($header, $replace = TRUE)
    +	public function set_header($header, $replace)
     	{
     		// If zlib.output_compression is enabled it will compress the output,
     		// but it will not modify the content-length header to compensate for
    @@ -192,7 +196,7 @@ class CI_Output {
     		// We'll just skip content-length in those cases.
     		if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0)
     		{
    -			return;
    +			return $this;
     		}
     
     		$this->headers[] = array($header, $replace);
    @@ -202,11 +206,11 @@ class CI_Output {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set Content Type Header
    +	 * Set Content-Type Header
     	 *
    -	 * @param	string	$mime_type	extension of the file we're outputting
    -	 * @param	string	$charset = NULL
    -	 * @return	void
    +	 * @param	string	$mime_type	Extension of the file we're outputting
    +	 * @param	string	$charset	Character set (default: NULL)
    +	 * @return	object	$this
     	 */
     	public function set_content_type($mime_type, $charset = NULL)
     	{
    @@ -243,7 +247,7 @@ class CI_Output {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Get Current Content Type Header
    +	 * Get Current Content-Type Header
     	 *
     	 * @return	string	'text/html', if not already set
     	 */
    @@ -264,11 +268,13 @@ class CI_Output {
     
     	/**
     	 * Set HTTP Status Header
    -	 * moved to Common procedural functions in 1.7.2
     	 *
    -	 * @param	int	the status code
    -	 * @param	string
    -	 * @return	void
    +	 * As of version 1.7.2, this is an alias for common function
    +	 * set_status_header().
    +	 *
    +	 * @param	int	$code	Status code (default: 200)
    +	 * @param	string	$text	Optional message
    +	 * @return	object	$this
     	 */
     	public function set_status_header($code = 200, $text = '')
     	{
    @@ -281,8 +287,8 @@ class CI_Output {
     	/**
     	 * Enable/disable Profiler
     	 *
    -	 * @param	bool
    -	 * @return	void
    +	 * @param	bool	$val	TRUE to enable or FALSE to disable
    +	 * @return	object	$this
     	 */
     	public function enable_profiler($val = TRUE)
     	{
    @@ -295,10 +301,11 @@ class CI_Output {
     	/**
     	 * Set Profiler Sections
     	 *
    -	 * Allows override of default / config settings for Profiler section display
    +	 * Allows override of default/config settings for
    +	 * Profiler section display.
     	 *
    -	 * @param	array
    -	 * @return	void
    +	 * @param	array	$sections	Profiler sections
    +	 * @return	object	$this
     	 */
     	public function set_profiler_sections($sections)
     	{
    @@ -321,8 +328,8 @@ class CI_Output {
     	/**
     	 * Set Cache
     	 *
    -	 * @param	int
    -	 * @return	void
    +	 * @param	int	$time	Cache expiration time in seconds
    +	 * @return	object	$this
     	 */
     	public function cache($time)
     	{
    @@ -335,16 +342,16 @@ class CI_Output {
     	/**
     	 * Display Output
     	 *
    -	 * All "view" data is automatically put into this variable by the controller class:
    -	 *
    -	 * $this->final_output
    +	 * Processes sends the sends finalized output data to the browser along
    +	 * with any server headers and profile data. It also stops benchmark
    +	 * timers so the page rendering speed and memory usage can be shown.
     	 *
    -	 * This function sends the finalized output data to the browser along
    -	 * with any server headers and profile data. It also stops the
    -	 * benchmark timer so the page rendering speed and memory usage can be shown.
    +	 * Note: All "view" data is automatically put into $this->final_output
    +	 *	 by controller class.
     	 *
    -	 * @param	string
    -	 * @return	mixed
    +	 * @uses	CI_Output::$final_output
    +	 * @param	string	$output	Output data override
    +	 * @return	void
     	 */
     	public function _display($output = '')
     	{
    @@ -431,7 +438,7 @@ class CI_Output {
     			echo $output;
     			log_message('debug', 'Final output sent to browser');
     			log_message('debug', 'Total execution time: '.$elapsed);
    -			return TRUE;
    +			return;
     		}
     
     		// --------------------------------------------------------------------
    @@ -473,9 +480,9 @@ class CI_Output {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Write a Cache File
    +	 * Write Cache
     	 *
    -	 * @param	string
    +	 * @param	string	$output	Output data to cache
     	 * @return	void
     	 */
     	public function _write_cache($output)
    @@ -526,11 +533,14 @@ class CI_Output {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Update/serve a cached file
    +	 * Update/serve cached output
     	 *
    -	 * @param	object	config class
    -	 * @param	object	uri class
    -	 * @return	bool
    +	 * @uses	CI_Config
    +	 * @uses	CI_URI
    +	 *
    +	 * @param	object	&$CFG	CI_Config class instance
    +	 * @param	object	&$URI	CI_URI class instance
    +	 * @return	bool	TRUE on success or FALSE on failure
     	 */
     	public function _display_cache(&$CFG, &$URI)
     	{
    @@ -584,11 +594,13 @@ class CI_Output {
     	// --------------------------------------------------------------------
     
     	/**
    +	 * Set Cache Header
    +	 *
     	 * Set the HTTP headers to match the server-side file cache settings
     	 * in order to reduce bandwidth.
     	 *
    -	 * @param	int	timestamp of when the page was last modified
    -	 * @param	int	timestamp of when should the requested page expire from cache
    +	 * @param	int	$last_modified	Timestamp of when the page was last modified
    +	 * @param	int	$expiration	Timestamp of when should the requested page expire from cache
     	 * @return	void
     	 */
     	public function set_cache_header($last_modified, $expiration)
    @@ -612,11 +624,13 @@ class CI_Output {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Reduce excessive size of HTML content.
    +	 * Minify
     	 *
    -	 * @param	string
    -	 * @param	string
    -	 * @return	string
    +	 * Reduce excessive size of HTML/CSS/JavaScript content.
    +	 *
    +	 * @param	string	$output	Output to minify
    +	 * @param	string	$type	Output content MIME type
    +	 * @return	string	Minified output
     	 */
     	public function minify($output, $type = 'text/html')
     	{
    diff --git a/system/core/Router.php b/system/core/Router.php
    index 5bc053045..efee2439f 100644
    --- a/system/core/Router.php
    +++ b/system/core/Router.php
    @@ -39,56 +39,56 @@
     class CI_Router {
     
     	/**
    -	 * Config class
    +	 * CI_Config class object
     	 *
    -	 * @var object
    +	 * @var	object
     	 */
     	public $config;
     
     	/**
     	 * List of routes
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $routes =	array();
     
     	/**
     	 * List of error routes
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $error_routes =	array();
     
     	/**
     	 * Current class name
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	public $class =		'';
     
     	/**
     	 * Current method name
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	public $method =	'index';
     
     	/**
     	 * Sub-directory that contains the requested controller class
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	public $directory =	'';
     
     	/**
     	 * Default controller (and method if specific)
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	public $default_controller;
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
     	 * Runs the route mapping function.
     	 *
    @@ -104,9 +104,9 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the route mapping
    +	 * Set route mapping
     	 *
    -	 * This function determines what should be served based on the URI request,
    +	 * Determines what should be served based on the URI request,
     	 * as well as any "routes" that have been set in the routing config file.
     	 *
     	 * @return	void
    @@ -179,7 +179,7 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the default controller
    +	 * Set default controller
     	 *
     	 * @return	void
     	 */
    @@ -213,12 +213,12 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the Route
    +	 * Set request route
     	 *
    -	 * This function takes an array of URI segments as
    -	 * input, and sets the current class/method
    +	 * Takes an array of URI segments as input and sets the class/method
    +	 * to be called.
     	 *
    -	 * @param	array
    +	 * @param	array	$segments	URI segments
     	 * @return	void
     	 */
     	protected function _set_request($segments = array())
    @@ -253,11 +253,12 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Validates the supplied segments.
    -	 * Attempts to determine the path to the controller.
    +	 * Validate request
     	 *
    -	 * @param	array
    -	 * @return	array
    +	 * Attempts validate the URI request and determine the controller path.
    +	 *
    +	 * @param	array	$segments	URI segments
    +	 * @return	array	URI segments
     	 */
     	protected function _validate_request($segments)
     	{
    @@ -347,9 +348,8 @@ class CI_Router {
     	/**
     	 * Parse Routes
     	 *
    -	 * This function matches any routes that may exist in
    -	 * the config/routes.php file against the URI to
    -	 * determine if the class/method need to be remapped.
    +	 * Matches any routes that may exist in the config/routes.php file
    +	 * against the URI to determine if the class/method need to be remapped.
     	 *
     	 * @return	void
     	 */
    @@ -391,9 +391,9 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the class name
    +	 * Set class name
     	 *
    -	 * @param	string
    +	 * @param	string	$class	Class name
     	 * @return	void
     	 */
     	public function set_class($class)
    @@ -416,9 +416,9 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the method name
    +	 * Set method name
     	 *
    -	 * @param	string
    +	 * @param	string	$method	Method name
     	 * @return	void
     	 */
     	public function set_method($method)
    @@ -441,9 +441,9 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the directory name
    +	 * Set directory name
     	 *
    -	 * @param	string
    +	 * @param	string	$dir	Directory name
     	 * @return	void
     	 */
     	public function set_directory($dir)
    @@ -454,7 +454,10 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch the sub-directory (if any) that contains the requested controller class
    +	 * Fetch directory
    +	 *
    +	 * Feches the sub-directory (if any) that contains the requested
    +	 * controller class.
     	 *
     	 * @return	string
     	 */
    @@ -466,9 +469,9 @@ class CI_Router {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the controller overrides
    +	 * Set controller overrides
     	 *
    -	 * @param	array
    +	 * @param	array	$routing	Route overrides
     	 * @return	void
     	 */
     	public function _set_overrides($routing)
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 3bb4029bbe0db9625be21e2dad82ef18286560ca Mon Sep 17 00:00:00 2001
    From: vkeranov 
    Date: Sat, 27 Oct 2012 18:47:26 +0300
    Subject: Remove extra spaces...
    
    ---
     system/libraries/Session/Session.php | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
    index 978506062..fec9b5b31 100755
    --- a/system/libraries/Session/Session.php
    +++ b/system/libraries/Session/Session.php
    @@ -1,4 +1,4 @@
    -valid_drivers = array(
     			'Session_native',
    -		   	'Session_cookie'
    +			'Session_cookie'
     		);
     		$key = 'sess_valid_drivers';
     		$drivers = isset($params[$key]) ? $params[$key] : $CI->config->item($key);
    @@ -243,7 +243,7 @@ class CI_Session extends CI_Driver_Library {
     	/**
     	 * Fetch all flashdata
     	 *
    -	 * @return	array   Flash data array
    +	 * @return	array	Flash data array
     	 */
     	public function all_flashdata()
     	{
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 44dc50e41b9eab2ad62f5abe09641247733c836d Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sun, 28 Oct 2012 13:30:21 +0200
    Subject: Fix #1937
    
    ---
     system/core/Output.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/system/core/Output.php b/system/core/Output.php
    index e969ba899..3bb8f8dc0 100644
    --- a/system/core/Output.php
    +++ b/system/core/Output.php
    @@ -188,7 +188,7 @@ class CI_Output {
     	 * @param	bool	$replace	Whether to replace the old header value, if already set
     	 * @return	object	$this
     	 */
    -	public function set_header($header, $replace)
    +	public function set_header($header, $replace = TRUE)
     	{
     		// If zlib.output_compression is enabled it will compress the output,
     		// but it will not modify the content-length header to compensate for
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 64354104d69425848e477b322ebf0604e2593326 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sun, 28 Oct 2012 14:16:02 +0200
    Subject: [ci skip] DocBlock improvements for Security library
    
    ---
     system/core/Security.php | 177 ++++++++++++++++++++++++++---------------------
     1 file changed, 100 insertions(+), 77 deletions(-)
    
    diff --git a/system/core/Security.php b/system/core/Security.php
    index d7c82712d..50d0ce052 100644
    --- a/system/core/Security.php
    +++ b/system/core/Security.php
    @@ -37,45 +37,55 @@
     class CI_Security {
     
     	/**
    -	 * Random Hash for protecting URLs
    +	 * XSS Hash
     	 *
    -	 * @var string
    +	 * Random Hash for protecting URLs.
    +	 *
    +	 * @var	string
     	 */
     	protected $_xss_hash =	'';
     
     	/**
    -	 * Random Hash for Cross Site Request Forgery Protection Cookie
    +	 * CSRF Hash
    +	 *
    +	 * Random hash for Cross Site Request Forgery protection cookie
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	protected $_csrf_hash =	'';
     
     	/**
    -	 * Expiration time for Cross Site Request Forgery Protection Cookie
    -	 * Defaults to two hours (in seconds)
    +	 * CSRF Expire time
    +	 *
    +	 * Expiration time for Cross Site Request Forgery protection cookie.
    +	 * Defaults to two hours (in seconds).
     	 *
    -	 * @var int
    +	 * @var	int
     	 */
     	protected $_csrf_expire =	7200;
     
     	/**
    -	 * Token name for Cross Site Request Forgery Protection Cookie
    +	 * CSRF Token name
     	 *
    -	 * @var string
    +	 * Token name for Cross Site Request Forgery protection cookie.
    +	 *
    +	 * @var	string
     	 */
     	protected $_csrf_token_name =	'ci_csrf_token';
     
     	/**
    -	 * Cookie name for Cross Site Request Forgery Protection Cookie
    +	 * CSRF Cookie name
    +	 *
    +	 * Cookie name for Cross Site Request Forgery protection cookie.
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	protected $_csrf_cookie_name =	'ci_csrf_token';
     
     	/**
     	 * List of never allowed strings
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_never_allowed_str =	array(
     		'document.cookie'	=> '[removed]',
    @@ -91,9 +101,9 @@ class CI_Security {
     	);
     
     	/**
    -	 * List of never allowed regex replacement
    +	 * List of never allowed regex replacements
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	protected $_never_allowed_regex = array(
     		'javascript\s*:',
    @@ -104,7 +114,7 @@ class CI_Security {
     	);
     
     	/**
    -	 * Initialize security class
    +	 * Class constructor
     	 *
     	 * @return	void
     	 */
    @@ -138,7 +148,7 @@ class CI_Security {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Verify Cross Site Request Forgery Protection
    +	 * CSRF Verify
     	 *
     	 * @return	object
     	 */
    @@ -188,10 +198,10 @@ class CI_Security {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set Cross Site Request Forgery Protection Cookie
    +	 * CSRF Set Cookie
     	 *
    -	 * @return	object
     	 * @codeCoverageIgnore
    +	 * @return	object
     	 */
     	public function csrf_set_cookie()
     	{
    @@ -234,9 +244,8 @@ class CI_Security {
     	/**
     	 * Get CSRF Hash
     	 *
    -	 * Getter Method
    -	 *
    -	 * @return 	string 	self::_csrf_hash
    +	 * @see		CI_Security::$_csrf_hash
    +	 * @return 	string	CSRF hash
     	 */
     	public function get_csrf_hash()
     	{
    @@ -248,9 +257,8 @@ class CI_Security {
     	/**
     	 * Get CSRF Token Name
     	 *
    -	 * Getter Method
    -	 *
    -	 * @return 	string 	self::_csrf_token_name
    +	 * @see		CI_Security::$_csrf_token_name
    +	 * @return	string	CSRF token name
     	 */
     	public function get_csrf_token_name()
     	{
    @@ -263,26 +271,26 @@ class CI_Security {
     	 * XSS Clean
     	 *
     	 * Sanitizes data so that Cross Site Scripting Hacks can be
    -	 * prevented.  This function does a fair amount of work but
    +	 * prevented.  This method does a fair amount of work but
     	 * it is extremely thorough, designed to prevent even the
     	 * most obscure XSS attempts.  Nothing is ever 100% foolproof,
     	 * of course, but I haven't been able to get anything passed
     	 * the filter.
     	 *
    -	 * Note: This function should only be used to deal with data
    -	 * upon submission. It's not something that should
    -	 * be used for general runtime processing.
    +	 * Note: Should only be used to deal with data upon submission.
    +	 *	 It's not something that should be used for general
    +	 *	 runtime processing.
     	 *
    -	 * This function was based in part on some code and ideas I
    -	 * got from Bitflux: http://channel.bitflux.ch/wiki/XSS_Prevention
    +	 * @link	http://channel.bitflux.ch/wiki/XSS_Prevention
    +	 * 		Based in part on some code and ideas from Bitflux.
     	 *
    -	 * To help develop this script I used this great list of
    -	 * vulnerabilities along with a few other hacks I've
    -	 * harvested from examining vulnerabilities in other programs:
    -	 * http://ha.ckers.org/xss.html
    +	 * @link	http://ha.ckers.org/xss.html
    +	 * 		To help develop this script I used this great list of
    +	 *		vulnerabilities along with a few other hacks I've
    +	 *		harvested from examining vulnerabilities in other programs.
     	 *
    -	 * @param	mixed	string or array
    -	 * @param 	bool
    +	 * @param	string|string[]	$str		Input data
    +	 * @param 	bool		$is_image	Whether the input is an image
     	 * @return	string
     	 */
     	public function xss_clean($str, $is_image = FALSE)
    @@ -469,9 +477,12 @@ class CI_Security {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Random Hash for protecting URLs
    +	 * XSS Hash
     	 *
    -	 * @return	string
    +	 * Generates the XSS hash if needed and returns it.
    +	 *
    +	 * @see		CI_Security::$_xss_hash
    +	 * @return	string	XSS hash
     	 */
     	public function xss_hash()
     	{
    @@ -489,7 +500,7 @@ class CI_Security {
     	/**
     	 * HTML Entities Decode
     	 *
    -	 * This function is a replacement for html_entity_decode()
    +	 * A replacement for html_entity_decode()
     	 *
     	 * The reason we are not using html_entity_decode() by itself is because
     	 * while it is not technically correct to leave out the semicolon
    @@ -497,8 +508,10 @@ class CI_Security {
     	 * correctly. html_entity_decode() does not convert entities without
     	 * semicolons, so we are left with our own little solution here. Bummer.
     	 *
    -	 * @param	string
    -	 * @param	string
    +	 * @link	http://php.net/html-entity-decode
    +	 *
    +	 * @param	string	$str		Input
    +	 * @param	string	$charset	Character set
     	 * @return	string
     	 */
     	public function entity_decode($str, $charset = NULL)
    @@ -521,10 +534,10 @@ class CI_Security {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Filename Security
    +	 * Sanitize Filename
     	 *
    -	 * @param	string
    -	 * @param 	bool
    +	 * @param	string	$str		Input file name
    +	 * @param 	bool	$relative_path	Whether to preserve paths
     	 * @return	string
     	 */
     	public function sanitize_filename($str, $relative_path = FALSE)
    @@ -563,7 +576,7 @@ class CI_Security {
     	/**
     	 * Strip Image Tags
     	 *
    -	 * @param	string
    +	 * @param	string	$str
     	 * @return	string
     	 */
     	public function strip_image_tags($str)
    @@ -576,10 +589,11 @@ class CI_Security {
     	/**
     	 * Compact Exploded Words
     	 *
    -	 * Callback function for xss_clean() to remove whitespace from
    -	 * things like j a v a s c r i p t
    +	 * Callback method for xss_clean() to remove whitespace from
    +	 * things like 'j a v a s c r i p t'.
     	 *
    -	 * @param	array
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param	array	$matches
     	 * @return	string
     	 */
     	protected function _compact_exploded_words($matches)
    @@ -593,16 +607,22 @@ class CI_Security {
     	 * Remove Evil HTML Attributes (like event handlers and style)
     	 *
     	 * It removes the evil attribute and either:
    -	 * 	- Everything up until a space
    -	 *		For example, everything between the pipes:
    +	 *
    +	 *  - Everything up until a space. For example, everything between the pipes:
    +	 *
    +	 *	
     	 *		
    -	 * 	- Everything inside the quotes
    -	 *		For example, everything between the pipes:
    +	 *	
    +	 *
    +	 *  - Everything inside the quotes. For example, everything between the pipes:
    +	 *
    +	 *	
     	 *		
    +	 *	
     	 *
    -	 * @param string $str The string to check
    -	 * @param boolean $is_image TRUE if this is an image
    -	 * @return string The string with the evil attributes removed
    +	 * @param	string	$str		The string to check
    +	 * @param	bool	$is_image	Whether the input is an image
    +	 * @return	string	The string with the evil attributes removed
     	 */
     	protected function _remove_evil_attributes($str, $is_image)
     	{
    @@ -655,9 +675,10 @@ class CI_Security {
     	/**
     	 * Sanitize Naughty HTML
     	 *
    -	 * Callback function for xss_clean() to remove naughty HTML elements
    +	 * Callback method for xss_clean() to remove naughty HTML elements.
     	 *
    -	 * @param	array
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param	array	$matches
     	 * @return	string
     	 */
     	protected function _sanitize_naughty_html($matches)
    @@ -672,12 +693,14 @@ class CI_Security {
     	/**
     	 * JS Link Removal
     	 *
    -	 * Callback function for xss_clean() to sanitize links
    +	 * Callback method for xss_clean() to sanitize links.
    +	 *
     	 * This limits the PCRE backtracks, making it more performance friendly
     	 * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
    -	 * PHP 5.2+ on link-heavy strings
    +	 * PHP 5.2+ on link-heavy strings.
     	 *
    -	 * @param	array
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param	array	$match
     	 * @return	string
     	 */
     	protected function _js_link_removal($match)
    @@ -695,12 +718,14 @@ class CI_Security {
     	/**
     	 * JS Image Removal
     	 *
    -	 * Callback function for xss_clean() to sanitize image tags
    +	 * Callback method for xss_clean() to sanitize image tags.
    +	 *
     	 * This limits the PCRE backtracks, making it more performance friendly
     	 * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
    -	 * PHP 5.2+ on image tag heavy strings
    +	 * PHP 5.2+ on image tag heavy strings.
     	 *
    -	 * @param	array
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param	array	$match
     	 * @return	string
     	 */
     	protected function _js_img_removal($match)
    @@ -718,9 +743,8 @@ class CI_Security {
     	/**
     	 * Attribute Conversion
     	 *
    -	 * Used as a callback for XSS Clean
    -	 *
    -	 * @param	array
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param	array	$match
     	 * @return	string
     	 */
     	protected function _convert_attribute($match)
    @@ -733,9 +757,11 @@ class CI_Security {
     	/**
     	 * Filter Attributes
     	 *
    -	 * Filters tag attributes for consistency and safety
    +	 * Filters tag attributes for consistency and safety.
     	 *
    -	 * @param	string
    +	 * @used-by	CI_Security::_js_img_removal()
    +	 * @used-by	CI_Security::_js_link_removal()
    +	 * @param	string	$str
     	 * @return	string
     	 */
     	protected function _filter_attributes($str)
    @@ -757,9 +783,8 @@ class CI_Security {
     	/**
     	 * HTML Entity Decode Callback
     	 *
    -	 * Used as a callback for XSS Clean
    -	 *
    -	 * @param	array
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param	array	$match
     	 * @return	string
     	 */
     	protected function _decode_entity($match)
    @@ -772,9 +797,8 @@ class CI_Security {
     	/**
     	 * Validate URL entities
     	 *
    -	 * Called by xss_clean()
    -	 *
    -	 * @param 	string
    +	 * @used-by	CI_Security::xss_clean()
    +	 * @param 	string	$str
     	 * @return 	string
     	 */
     	protected function _validate_entities($str)
    @@ -812,8 +836,7 @@ class CI_Security {
     	/**
     	 * Do Never Allowed
     	 *
    -	 * A utility function for xss_clean()
    -	 *
    +	 * @used-by	CI_Security::xss_clean()
     	 * @param 	string
     	 * @return 	string
     	 */
    @@ -832,7 +855,7 @@ class CI_Security {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set Cross Site Request Forgery Protection Cookie
    +	 * Set CSRF Hash and Cookie
     	 *
     	 * @return	string
     	 */
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From cca742750745de665d8071b38d6e368bf54cd985 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Sun, 28 Oct 2012 14:43:36 +0200
    Subject: [ci skip] URI Library DocBlock improvements
    
    ---
     system/core/URI.php | 192 +++++++++++++++++++++++++++++-----------------------
     1 file changed, 108 insertions(+), 84 deletions(-)
    
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 33f7d21fa..d67a35d4b 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -39,36 +39,37 @@
     class CI_URI {
     
     	/**
    -	 * List of cached uri segments
    +	 * List of cached URI segments
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $keyval =	array();
     
     	/**
    -	 * Current uri string
    +	 * Current URI string
     	 *
    -	 * @var string
    +	 * @var	string
     	 */
     	public $uri_string;
     
     	/**
    -	 * List of uri segments
    +	 * List of URI segments
     	 *
    -	 * @var array
    +	 * @var	array
     	 */
     	public $segments =	array();
     
     	/**
    -	 * Re-indexed list of uri segments
    -	 * Starts at 1 instead of 0
    +	 * Re-indexed list of URI segments
     	 *
    -	 * @var array
    +	 * Starts at 1 instead of 0.
    +	 *
    +	 * @var	array
     	 */
     	public $rsegments =	array();
     
     	/**
    -	 * Constructor
    +	 * Class constructor
     	 *
     	 * Simply globalizes the $RTR object. The front
     	 * loads the Router class early on so it's not available
    @@ -85,10 +86,9 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Get the URI String
    -	 *
    -	 * Called by CI_Router
    +	 * Fetch URI String
     	 *
    +	 * @used-by	CI_Router
     	 * @return	void
     	 */
     	public function _fetch_uri_string()
    @@ -158,9 +158,9 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Set the URI String
    +	 * Set URI String
     	 *
    -	 * @param 	string
    +	 * @param 	string	$str
     	 * @return	void
     	 */
     	protected function _set_uri_string($str)
    @@ -172,10 +172,9 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Detects the URI
    +	 * Detects URI
     	 *
    -	 * This function will detect the URI automatically
    -	 * and fix the query string if necessary.
    +	 * Will detect the URI automatically and fix the query string if necessary.
     	 *
     	 * @return	string
     	 */
    @@ -233,10 +232,13 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Is cli Request?
    +	 * Is CLI Request?
     	 *
    -	 * Duplicate of function from the Input class to test to see if a request was made from the command line
    +	 * Duplicate of method from the Input class to test to see if
    +	 * a request was made from the command line.
     	 *
    +	 * @see		CI_Input::is_cli_request()
    +	 * @used-by	CI_URI::_fetch_uri_string()
     	 * @return 	bool
     	 */
     	protected function _is_cli_request()
    @@ -247,7 +249,7 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Parse cli arguments
    +	 * Parse CLI arguments
     	 *
     	 * Take each command line argument and assume it is a URI segment.
     	 *
    @@ -262,11 +264,12 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Filter segments for malicious characters
    +	 * Filter URI
     	 *
    -	 * Called by CI_Router
    +	 * Filters segments for malicious characters.
     	 *
    -	 * @param	string
    +	 * @used-by	CI_Router
    +	 * @param	string	$str
     	 * @return	string
     	 */
     	public function _filter_uri($str)
    @@ -291,10 +294,11 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Remove the suffix from the URL if needed
    +	 * Remove URL suffix
     	 *
    -	 * Called by CI_Router
    +	 * Removes the suffix from the URL if needed.
     	 *
    +	 * @used-by	CI_Router
     	 * @return	void
     	 */
     	public function _remove_url_suffix()
    @@ -310,11 +314,12 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Explode the URI Segments. The individual segments will
    -	 * be stored in the $this->segments array.
    +	 * Explode URI segments
     	 *
    -	 * Called by CI_Router
    +	 * The individual segments will be stored in the $this->segments array.
     	 *
    +	 * @see		CI_URI::$segments
    +	 * @used-by	CI_Router
     	 * @return	void
     	 */
     	public function _explode_segments()
    @@ -336,13 +341,12 @@ class CI_URI {
     	/**
     	 * Re-index Segments
     	 *
    -	 * This function re-indexes the $this->segment array so that it
    -	 * starts at 1 rather than 0. Doing so makes it simpler to
    -	 * use functions like $this->uri->segment(n) since there is
    -	 * a 1:1 relationship between the segment array and the actual segments.
    -	 *
    -	 * Called by CI_Router
    +	 * Re-indexes the CI_URI::$segment array so that it starts at 1 rather
    +	 * than 0. Doing so makes it simpler to use methods like
    +	 * CI_URI::segment(n) since there is a 1:1 relationship between the
    +	 * segment array and the actual segments.
     	 *
    +	 * @used-by	CI_Router
     	 * @return	void
     	 */
     	public function _reindex_segments()
    @@ -356,13 +360,12 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a URI Segment
    +	 * Fetch URI Segment
     	 *
    -	 * This function returns the URI segment based on the number provided.
    -	 *
    -	 * @param	int
    -	 * @param	mixed
    -	 * @return	string
    +	 * @see		CI_URI::$segments
    +	 * @param	int		$n		Index
    +	 * @param	mixed		$no_result	What to return if the segment index is not found
    +	 * @return	mixed
     	 */
     	public function segment($n, $no_result = NULL)
     	{
    @@ -372,15 +375,17 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a URI "routed" Segment
    +	 * Fetch URI "routed" Segment
     	 *
    -	 * This function returns the re-routed URI segment (assuming routing rules are used)
    -	 * based on the number provided. If there is no routing this function returns the
    -	 * same result as $this->segment()
    +	 * Returns the re-routed URI segment (assuming routing rules are used)
    +	 * based on the index provided. If there is no routing, will return
    +	 * the same result as CI_URI::segment().
     	 *
    -	 * @param	int
    -	 * @param	mixed
    -	 * @return	string
    +	 * @see		CI_URI::$rsegments
    +	 * @see		CI_URI::segment()
    +	 * @param	int		$n		Index
    +	 * @param	mixed		$no_result	What to return if the segment index is not found
    +	 * @return	mixed
     	 */
     	public function rsegment($n, $no_result = NULL)
     	{
    @@ -390,23 +395,23 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Generate a key value pair from the URI string
    +	 * URI to assoc
     	 *
    -	 * This function generates and associative array of URI data starting
    -	 * at the supplied segment. For example, if this is your URI:
    +	 * Generates an associative array of URI data starting at the supplied
    +	 * segment index. For example, if this is your URI:
     	 *
     	 *	example.com/user/search/name/joe/location/UK/gender/male
     	 *
    -	 * You can use this function to generate an array with this prototype:
    +	 * You can use this method to generate an array with this prototype:
     	 *
    -	 * array (
    -	 *			name => joe
    -	 *			location => UK
    -	 *			gender => male
    -	 *		 )
    +	 *	array (
    +	 *		name => joe
    +	 *		location => UK
    +	 *		gender => male
    +	 *	 )
     	 *
    -	 * @param	int	the starting segment number
    -	 * @param	array	an array of default values
    +	 * @param	int	$n		Index (default: 3)
    +	 * @param	array	$default	Default values
     	 * @return	array
     	 */
     	public function uri_to_assoc($n = 3, $default = array())
    @@ -417,10 +422,14 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Identical to above only it uses the re-routed segment array
    +	 * Routed URI to assoc
    +	 *
    +	 * Identical to CI_URI::uri_to_assoc(), only it uses the re-routed
    +	 * segment array.
     	 *
    -	 * @param 	int	the starting segment number
    -	 * @param 	array	an array of default values
    +	 * @see		CI_URI::uri_to_assoc()
    +	 * @param 	int	$n		Index (default: 3)
    +	 * @param 	array	$default	Default values
     	 * @return 	array
     	 */
     	public function ruri_to_assoc($n = 3, $default = array())
    @@ -431,11 +440,15 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Generate a key value pair from the URI string or Re-routed URI string
    +	 * Internal URI-to-assoc
     	 *
    -	 * @param	int	$n = 3			the starting segment number
    -	 * @param	array	$default = array()	an array of default values
    -	 * @param	string	$which = 'segment'	which array we should use
    +	 * Generates a key/value pair from the URI string or re-routed URI string.
    +	 *
    +	 * @used-by	CI_URI::uri_to_assoc()
    +	 * @used-by	CI_URI::ruri_to_assoc()
    +	 * @param	int	$n		Index (default: 3)
    +	 * @param	array	$default	Default values
    +	 * @param	string	$which		Array name ('segment' or 'rsegment')
     	 * @return	array
     	 */
     	protected function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
    @@ -509,10 +522,12 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Generate a URI string from an associative array
    +	 * Assoc to URI
     	 *
    -	 * @param	array	an associative array of key/values
    -	 * @return	array
    +	 * Generates a URI string from an associative array.
    +	 *
    +	 * @param	array	$array	Input array of key/value pairs
    +	 * @return	string	URI string
     	 */
     	public function assoc_to_uri($array)
     	{
    @@ -529,10 +544,12 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a URI Segment and add a trailing slash
    +	 * Slash segment
    +	 *
    +	 * Fetches an URI segment with a slash.
     	 *
    -	 * @param	int
    -	 * @param	string
    +	 * @param	int	$n	Index
    +	 * @param	string	$where	Where to add the slash ('trailing' or 'leading')
     	 * @return	string
     	 */
     	public function slash_segment($n, $where = 'trailing')
    @@ -543,10 +560,12 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a URI Segment and add a trailing slash
    +	 * Slash routed segment
     	 *
    -	 * @param	int
    -	 * @param	string
    +	 * Fetches an URI routed segment with a slash.
    +	 *
    +	 * @param	int	$n	Index
    +	 * @param	string	$where	Where to add the slash ('trailing' or 'leading')
     	 * @return	string
     	 */
     	public function slash_rsegment($n, $where = 'trailing')
    @@ -557,11 +576,16 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch a URI Segment and add a trailing slash - helper function
    +	 * Internal Slash segment
    +	 *
    +	 * Fetches an URI Segment and adds a slash to it.
     	 *
    -	 * @param	int
    -	 * @param	string
    -	 * @param	string
    +	 * @used-by	CI_URI::slash_segment()
    +	 * @used-by	CI_URI::slash_rsegment()
    +	 *
    +	 * @param	int	$n	Index
    +	 * @param	string	$where	Where to add the slash ('trailing' or 'leading')
    +	 * @param	string	$which	Array name ('segment' or 'rsegment')
     	 * @return	string
     	 */
     	protected function _slash_segment($n, $where = 'trailing', $which = 'segment')
    @@ -585,7 +609,7 @@ class CI_URI {
     	/**
     	 * Segment Array
     	 *
    -	 * @return	array
    +	 * @return	array	CI_URI::$segments
     	 */
     	public function segment_array()
     	{
    @@ -597,7 +621,7 @@ class CI_URI {
     	/**
     	 * Routed Segment Array
     	 *
    -	 * @return	array
    +	 * @return	array	CI_URI::$rsegments
     	 */
     	public function rsegment_array()
     	{
    @@ -631,9 +655,9 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch the entire URI string
    +	 * Fetch URI string
     	 *
    -	 * @return	string
    +	 * @return	string	CI_URI::$uri_string
     	 */
     	public function uri_string()
     	{
    @@ -643,7 +667,7 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Fetch the entire Re-routed URI string
    +	 * Fetch Re-routed URI string
     	 *
     	 * @return	string
     	 */
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 51b7acda68a144d4e6d917f467a53d0299b326dd Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Mon, 29 Oct 2012 16:23:13 +0200
    Subject: [ci skip] Clarify explanation of the 404_override setting in
     application/config/routes.php
    
    ---
     application/config/routes.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/application/config/routes.php b/application/config/routes.php
    index 001198615..d1a4419b7 100644
    --- a/application/config/routes.php
    +++ b/application/config/routes.php
    @@ -59,8 +59,8 @@
     |
     |	$route['404_override'] = 'errors/page_missing';
     |
    -| This route will tell the Router what URI segments to use if those provided
    -| in the URL cannot be matched to a valid route.
    +| This route will tell the Router which controller/method to use if those
    +| provided in the URL cannot be matched to a valid route.
     |
     */
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 9bea4be2efa74b963d3cd0bbaa4635deffc2f109 Mon Sep 17 00:00:00 2001
    From: GDmac 
    Date: Tue, 30 Oct 2012 06:14:19 +0100
    Subject: Fix #1938
    
    Where the email library removed multiple spaces inside a plain text message.
    
    Signed-off-by: GDmac 
    ---
     system/libraries/Email.php | 9 ++++++---
     1 file changed, 6 insertions(+), 3 deletions(-)
    
    diff --git a/system/libraries/Email.php b/system/libraries/Email.php
    index edca303ff..7280466a5 100644
    --- a/system/libraries/Email.php
    +++ b/system/libraries/Email.php
    @@ -770,6 +770,9 @@ class CI_Email {
     			$body = str_replace(str_repeat("\n", $i), "\n\n", $body);
     		}
     
    +		// Reduce multiple spaces
    +		$str = preg_replace('| +|', ' ', $str);
    +
     		return ($this->wordwrap)
     			? $this->word_wrap($body, 76)
     			: $body;
    @@ -792,15 +795,15 @@ class CI_Email {
     			$charlim = empty($this->wrapchars) ? 76 : $this->wrapchars;
     		}
     
    -		// Reduce multiple spaces
    -		$str = preg_replace('| +|', ' ', $str);
    -
     		// Standardize newlines
     		if (strpos($str, "\r") !== FALSE)
     		{
     			$str = str_replace(array("\r\n", "\r"), "\n", $str);
     		}
     
    +		// Reduce multiple spaces at end of line
    +		$str = preg_replace('| +\n|', "\n", $str);
    +
     		// If the current word is surrounded by {unwrap} tags we'll
     		// strip the entire chunk and replace it with a marker.
     		$unwrap = array();
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 9d82e8212d9b63a6d4de0b7858257c50a96f6b8a Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Tue, 30 Oct 2012 11:30:47 +0200
    Subject: [ci skip] Alter a changelog entry for 2.1.3
    
    ---
     user_guide_src/source/changelog.rst | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 4b161dc2d..c7f72f609 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -413,7 +413,7 @@ Bug fixes for 2.1.3
     
     -  Fixed a bug (#1543) - File-based :doc:`Caching ` method ``get_metadata()`` used a non-existent array key to look for the TTL value.
     -  Fixed a bug (#1314) - :doc:`Session Library ` method ``sess_destroy()`` didn't destroy the userdata array.
    --  Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``.
    +-  Fixed a bug (#804) - :doc:`Profiler library ` was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``.
     -  Fixed a bug (#1699) - :doc:`Migration Library ` ignored the ``$config['migration_path']`` setting.
     -  Fixed a bug (#227) - :doc:`Input Library ` allowed unconditional spoofing of HTTP clients' IP addresses through the *HTTP_CLIENT_IP* header.
     -  Fixed a bug (#907) - :doc:`Input Library ` ignored *HTTP_X_CLUSTER_CLIENT_IP* and *HTTP_X_CLIENT_IP* headers when checking for proxies.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 0dfb62ff0ab1d184e20819a066139fea28d68da4 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Tue, 30 Oct 2012 11:37:15 +0200
    Subject: [ci skip] Fix a note in the QB documentation
    
    ---
     user_guide_src/source/database/query_builder.rst | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
    index 5380d0998..61cd7dfed 100644
    --- a/user_guide_src/source/database/query_builder.rst
    +++ b/user_guide_src/source/database/query_builder.rst
    @@ -492,8 +492,8 @@ Or multiple function calls can be made if you need multiple fields.
     .. note:: order_by() was formerly known as orderby(), which has been
     	removed.
     
    -.. note:: random ordering is not currently supported in Oracle or MSSQL
    -	drivers. These will default to 'ASC'.
    +.. note:: Random ordering is not currently supported in Oracle and
    +	will default to ASC instead.
     
     $this->db->limit()
     ==================
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7676c2d6761cb3cdeccf005c2a30140f0ba3ced5 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Tue, 30 Oct 2012 13:42:01 +0200
    Subject: Fix issue #658 (:any wildcard matching slashes)
    
    ---
     system/core/Router.php                             |  2 +-
     user_guide_src/source/changelog.rst                |  1 +
     user_guide_src/source/general/routing.rst          | 30 +++++++++++++---
     user_guide_src/source/installation/upgrade_300.rst | 40 +++++++++++++++++-----
     4 files changed, 58 insertions(+), 15 deletions(-)
    
    diff --git a/system/core/Router.php b/system/core/Router.php
    index efee2439f..a5e29f1a3 100644
    --- a/system/core/Router.php
    +++ b/system/core/Router.php
    @@ -368,7 +368,7 @@ class CI_Router {
     		foreach ($this->routes as $key => $val)
     		{
     			// Convert wild-cards to RegEx
    -			$key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key);
    +			$key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);
     
     			// Does the RegEx match?
     			if (preg_match('#^'.$key.'$#', $uri))
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index c7f72f609..5b3ca3e9f 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -399,6 +399,7 @@ Bug fixes for 3.0
     -  Fixed a bug (#1630) - :doc:`Form Helper ` function ``set_value()`` didn't escape HTML entities.
     -  Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values.
     -  Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
    +-  Fixed a bug (#658) - :doc:`Routing ` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment.
     
     Version 2.1.3
     =============
    diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
    index c03937070..a6332c90c 100644
    --- a/user_guide_src/source/general/routing.rst
    +++ b/user_guide_src/source/general/routing.rst
    @@ -29,7 +29,7 @@ Setting your own routing rules
     Routing rules are defined in your application/config/routes.php file. In
     it you'll see an array called $route that permits you to specify your
     own routing criteria. Routes can either be specified using wildcards or
    -Regular Expressions
    +Regular Expressions.
     
     Wildcards
     =========
    @@ -47,7 +47,11 @@ segment of the URL, and a number is found in the second segment, the
     You can match literal values or you can use two wildcard types:
     
     **(:num)** will match a segment containing only numbers.
    -**(:any)** will match a segment containing any character.
    +**(:any)** will match a segment containing any character (except for '/', which is the segment delimiter).
    +
    +.. note:: Wildcards are actually aliases for regular expressions, with
    +	**:any** being translated to **[^/]+** and **:num** to **[0-9]+**,
    +	respectively.
     
     .. note:: Routes will run in the order they are defined. Higher routes
     	will always take precedence over lower ones.
    @@ -104,12 +108,28 @@ rules. Any valid regular expression is allowed, as are back-references.
     
     A typical RegEx route might look something like this::
     
    -	$route['products/([a-z]+)/(\d+)'] = "$1/id_$2";
    +	$route['products/([a-z]+)/(\d+)'] = '$1/id_$2';
     
     In the above example, a URI similar to products/shirts/123 would instead
    -call the shirts controller class and the id_123 function.
    +call the shirts controller class and the id_123 method.
    +
    +With regular expressions, you can also catch a segment containing a
    +forward slash ('/'), which would usually represent the delimiter between
    +multiple segments.
    +For example, if a user accesses a password protected area of your web
    +application and you wish to be able to redirect them back to the same
    +page after they log in, you may find this example useful::
    +
    +	$route['login/(.+)'] = 'auth/login/$1';
    +
    +That will call the auth controller class and its ``login()`` method,
    +passing everything contained in the URI after *login/* as a parameter.
    +
    +For those of you who don't know regular expressions and want to learn
    +more about them, `regular-expressions.info `
    +might be a good starting point.
     
    -You can also mix and match wildcards with regular expressions.
    +..note:: You can also mix and match wildcards with regular expressions.
     
     Reserved Routes
     ===============
    diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
    index dcdd6e351..6d99f4655 100644
    --- a/user_guide_src/source/installation/upgrade_300.rst
    +++ b/user_guide_src/source/installation/upgrade_300.rst
    @@ -52,11 +52,12 @@ Step 5: Update your config/database.php
     ***************************************
     
     Due to 3.0.0's renaming of Active Record to Query Builder, inside your `config/database.php`, you will
    -need to rename the `$active_record` variable to `$query_builder`.
    +need to rename the `$active_record` variable to `$query_builder`
    +::
     
    -    $active_group = 'default';
    -    // $active_record = TRUE;
    -    $query_builder = TRUE;
    +	$active_group = 'default';
    +	// $active_record = TRUE;
    +	$query_builder = TRUE;
     
     *******************************
     Step 6: Move your errors folder
    @@ -64,15 +65,36 @@ Step 6: Move your errors folder
     
     In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*.
     
    +*******************************************************
    +Step 7: Update your config/routes.php containing (:any)
    +*******************************************************
    +
    +Historically, CodeIgniter has always provided the **:any** wildcard in routing,
    +with the intention of providing a way to match any character **within** an URI segment.
    +
    +However, the **:any** wildcard is actually just an alias for a regular expression
    +and used to be executed in that manner as **.+**. This is considered a bug, as it
    +also matches the / (forward slash) character, which is the URI segment delimiter
    +and that was never the intention. In CodeIgniter 3, the **:any** wildcard will now
    +represent **[^/]+**, so that it will not match a forward slash.
    +
    +There are certainly many developers that have utilized this bug as an actual feature.
    +If you're one of them and want to match a forward slash, please use the **.+**
    +regular expression::
    +
    +	(.+)	// matches ANYTHING
    +	(:any)	// matches any character, except for '/'
    +
    +
     ****************************************************************************
    -Step 7: Check the calls to Array Helper's element() and elements() functions
    +Step 8: Check the calls to Array Helper's element() and elements() functions
     ****************************************************************************
     
     The default return value of these functions, when the required elements
     don't exist, has been changed from FALSE to NULL.
     
     **********************************************************
    -Step 8: Change usage of Email library with multiple emails
    +Step 9: Change usage of Email library with multiple emails
     **********************************************************
     
     The :doc:`Email library <../libraries/email>` will automatically clear the
    @@ -87,9 +109,9 @@ pass FALSE as the first parameter in the ``send()`` method:
      	}
     
     
    -***************************************************************
    -Step 9: Remove usage of (previously) deprecated functionalities
    -***************************************************************
    +****************************************************************
    +Step 10: Remove usage of (previously) deprecated functionalities
    +****************************************************************
     
     In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
     that have been removed in CodeIgniter 3.0.0:
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 759d322a2e7d16278dede0eeafb86f5e5ea1ddc0 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Tue, 30 Oct 2012 11:30:47 +0200
    Subject: [ci skip] Alter a changelog entry for 2.1.3
    
    ---
     user_guide_src/source/changelog.rst | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 4b161dc2d..c7f72f609 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -413,7 +413,7 @@ Bug fixes for 2.1.3
     
     -  Fixed a bug (#1543) - File-based :doc:`Caching ` method ``get_metadata()`` used a non-existent array key to look for the TTL value.
     -  Fixed a bug (#1314) - :doc:`Session Library ` method ``sess_destroy()`` didn't destroy the userdata array.
    --  Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``.
    +-  Fixed a bug (#804) - :doc:`Profiler library ` was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``.
     -  Fixed a bug (#1699) - :doc:`Migration Library ` ignored the ``$config['migration_path']`` setting.
     -  Fixed a bug (#227) - :doc:`Input Library ` allowed unconditional spoofing of HTTP clients' IP addresses through the *HTTP_CLIENT_IP* header.
     -  Fixed a bug (#907) - :doc:`Input Library ` ignored *HTTP_X_CLUSTER_CLIENT_IP* and *HTTP_X_CLIENT_IP* headers when checking for proxies.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From afca803c1a9212575c9a6454d5a648d1170da91d Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Tue, 30 Oct 2012 11:37:15 +0200
    Subject: [ci skip] Fix a note in the QB documentation
    
    ---
     user_guide_src/source/database/query_builder.rst | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
    index 5380d0998..61cd7dfed 100644
    --- a/user_guide_src/source/database/query_builder.rst
    +++ b/user_guide_src/source/database/query_builder.rst
    @@ -492,8 +492,8 @@ Or multiple function calls can be made if you need multiple fields.
     .. note:: order_by() was formerly known as orderby(), which has been
     	removed.
     
    -.. note:: random ordering is not currently supported in Oracle or MSSQL
    -	drivers. These will default to 'ASC'.
    +.. note:: Random ordering is not currently supported in Oracle and
    +	will default to ASC instead.
     
     $this->db->limit()
     ==================
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From ed1741125d638cfaa1bb2918b7f140f282a107de Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Tue, 30 Oct 2012 13:42:01 +0200
    Subject: Fix issue #658 (:any wildcard matching slashes)
    
    ---
     system/core/Router.php                             |  2 +-
     user_guide_src/source/changelog.rst                |  1 +
     user_guide_src/source/general/routing.rst          | 30 +++++++++++++---
     user_guide_src/source/installation/upgrade_300.rst | 40 +++++++++++++++++-----
     4 files changed, 58 insertions(+), 15 deletions(-)
    
    diff --git a/system/core/Router.php b/system/core/Router.php
    index efee2439f..a5e29f1a3 100644
    --- a/system/core/Router.php
    +++ b/system/core/Router.php
    @@ -368,7 +368,7 @@ class CI_Router {
     		foreach ($this->routes as $key => $val)
     		{
     			// Convert wild-cards to RegEx
    -			$key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key);
    +			$key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);
     
     			// Does the RegEx match?
     			if (preg_match('#^'.$key.'$#', $uri))
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index c7f72f609..5b3ca3e9f 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -399,6 +399,7 @@ Bug fixes for 3.0
     -  Fixed a bug (#1630) - :doc:`Form Helper ` function ``set_value()`` didn't escape HTML entities.
     -  Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values.
     -  Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
    +-  Fixed a bug (#658) - :doc:`Routing ` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment.
     
     Version 2.1.3
     =============
    diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
    index c03937070..a6332c90c 100644
    --- a/user_guide_src/source/general/routing.rst
    +++ b/user_guide_src/source/general/routing.rst
    @@ -29,7 +29,7 @@ Setting your own routing rules
     Routing rules are defined in your application/config/routes.php file. In
     it you'll see an array called $route that permits you to specify your
     own routing criteria. Routes can either be specified using wildcards or
    -Regular Expressions
    +Regular Expressions.
     
     Wildcards
     =========
    @@ -47,7 +47,11 @@ segment of the URL, and a number is found in the second segment, the
     You can match literal values or you can use two wildcard types:
     
     **(:num)** will match a segment containing only numbers.
    -**(:any)** will match a segment containing any character.
    +**(:any)** will match a segment containing any character (except for '/', which is the segment delimiter).
    +
    +.. note:: Wildcards are actually aliases for regular expressions, with
    +	**:any** being translated to **[^/]+** and **:num** to **[0-9]+**,
    +	respectively.
     
     .. note:: Routes will run in the order they are defined. Higher routes
     	will always take precedence over lower ones.
    @@ -104,12 +108,28 @@ rules. Any valid regular expression is allowed, as are back-references.
     
     A typical RegEx route might look something like this::
     
    -	$route['products/([a-z]+)/(\d+)'] = "$1/id_$2";
    +	$route['products/([a-z]+)/(\d+)'] = '$1/id_$2';
     
     In the above example, a URI similar to products/shirts/123 would instead
    -call the shirts controller class and the id_123 function.
    +call the shirts controller class and the id_123 method.
    +
    +With regular expressions, you can also catch a segment containing a
    +forward slash ('/'), which would usually represent the delimiter between
    +multiple segments.
    +For example, if a user accesses a password protected area of your web
    +application and you wish to be able to redirect them back to the same
    +page after they log in, you may find this example useful::
    +
    +	$route['login/(.+)'] = 'auth/login/$1';
    +
    +That will call the auth controller class and its ``login()`` method,
    +passing everything contained in the URI after *login/* as a parameter.
    +
    +For those of you who don't know regular expressions and want to learn
    +more about them, `regular-expressions.info `
    +might be a good starting point.
     
    -You can also mix and match wildcards with regular expressions.
    +..note:: You can also mix and match wildcards with regular expressions.
     
     Reserved Routes
     ===============
    diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
    index dcdd6e351..6d99f4655 100644
    --- a/user_guide_src/source/installation/upgrade_300.rst
    +++ b/user_guide_src/source/installation/upgrade_300.rst
    @@ -52,11 +52,12 @@ Step 5: Update your config/database.php
     ***************************************
     
     Due to 3.0.0's renaming of Active Record to Query Builder, inside your `config/database.php`, you will
    -need to rename the `$active_record` variable to `$query_builder`.
    +need to rename the `$active_record` variable to `$query_builder`
    +::
     
    -    $active_group = 'default';
    -    // $active_record = TRUE;
    -    $query_builder = TRUE;
    +	$active_group = 'default';
    +	// $active_record = TRUE;
    +	$query_builder = TRUE;
     
     *******************************
     Step 6: Move your errors folder
    @@ -64,15 +65,36 @@ Step 6: Move your errors folder
     
     In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*.
     
    +*******************************************************
    +Step 7: Update your config/routes.php containing (:any)
    +*******************************************************
    +
    +Historically, CodeIgniter has always provided the **:any** wildcard in routing,
    +with the intention of providing a way to match any character **within** an URI segment.
    +
    +However, the **:any** wildcard is actually just an alias for a regular expression
    +and used to be executed in that manner as **.+**. This is considered a bug, as it
    +also matches the / (forward slash) character, which is the URI segment delimiter
    +and that was never the intention. In CodeIgniter 3, the **:any** wildcard will now
    +represent **[^/]+**, so that it will not match a forward slash.
    +
    +There are certainly many developers that have utilized this bug as an actual feature.
    +If you're one of them and want to match a forward slash, please use the **.+**
    +regular expression::
    +
    +	(.+)	// matches ANYTHING
    +	(:any)	// matches any character, except for '/'
    +
    +
     ****************************************************************************
    -Step 7: Check the calls to Array Helper's element() and elements() functions
    +Step 8: Check the calls to Array Helper's element() and elements() functions
     ****************************************************************************
     
     The default return value of these functions, when the required elements
     don't exist, has been changed from FALSE to NULL.
     
     **********************************************************
    -Step 8: Change usage of Email library with multiple emails
    +Step 9: Change usage of Email library with multiple emails
     **********************************************************
     
     The :doc:`Email library <../libraries/email>` will automatically clear the
    @@ -87,9 +109,9 @@ pass FALSE as the first parameter in the ``send()`` method:
      	}
     
     
    -***************************************************************
    -Step 9: Remove usage of (previously) deprecated functionalities
    -***************************************************************
    +****************************************************************
    +Step 10: Remove usage of (previously) deprecated functionalities
    +****************************************************************
     
     In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
     that have been removed in CodeIgniter 3.0.0:
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7330384763d39d4b6066e036def51996a82103b4 Mon Sep 17 00:00:00 2001
    From: GDmac 
    Date: Tue, 30 Oct 2012 13:05:05 +0100
    Subject: Description for Fix #1938 added to changelog
    
    Signed-off-by: GDmac 
    ---
     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 5b3ca3e9f..065daf54b 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -400,6 +400,7 @@ Bug fixes for 3.0
     -  Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values.
     -  Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
     -  Fixed a bug (#658) - :doc:`Routing ` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment.
    +-  Fixed a bug (#1938) - :doc:`Email ` where the email library removed multiple spaces inside a pre-formatted plain text message.
     
     Version 2.1.3
     =============
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From d4516e3562b1c412d7c3edea874eaa6e6922ad0e Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Wed, 31 Oct 2012 14:44:38 +0200
    Subject: CI_URI::_detect_uri() to accept absolute URIs
    
    (thanks to @sourcejedi, PR #1326)
    
    For HTTP/1.1 compliance, RFC2616 specifies that both relative
    and absolute URI formats must be accepted:
    
    - http://localhost/path/ (absolute)
    - /path/ (relative)
    ---
     system/core/URI.php                 | 40 ++++++++++++++++++-------------------
     user_guide_src/source/changelog.rst |  4 +++-
     2 files changed, 23 insertions(+), 21 deletions(-)
    
    diff --git a/system/core/URI.php b/system/core/URI.php
    index d67a35d4b..3d942eda7 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -185,37 +185,39 @@ class CI_URI {
     			return '';
     		}
     
    -		if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0)
    -		{
    -			$uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
    -		}
    -		elseif (strpos($_SERVER['REQUEST_URI'], dirname($_SERVER['SCRIPT_NAME'])) === 0)
    +		$uri = parse_url($_SERVER['REQUEST_URI']);
    +		$query = isset($uri['query']) ? $uri['query'] : '';
    +		$uri = isset($uri['path']) ? $uri['path'] : '';
    +
    +		if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
     		{
    -			$uri = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])));
    +			$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
     		}
    -		else
    +		elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
     		{
    -			$uri = $_SERVER['REQUEST_URI'];
    +			$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
     		}
    -
     		// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
     		// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
    -		if (strpos($uri, '?/') === 0)
    +
    +		if ($uri === '' && strncmp($query, '/', 1) === 0)
    +		{
    +			$query = explode('?', $query, 2);
    +			$uri = $query[0];
    +			$_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
    +		}
    +		else
     		{
    -			$uri = substr($uri, 2);
    +			$_SERVER['QUERY_STRING'] = $query;
     		}
     
    -		$parts = explode('?', $uri, 2);
    -		$uri = $parts[0];
    -		if (isset($parts[1]))
    +		if ($_SERVER['QUERY_STRING'] === '')
     		{
    -			$_SERVER['QUERY_STRING'] = $parts[1];
    -			parse_str($_SERVER['QUERY_STRING'], $_GET);
    +			$_GET = array();
     		}
     		else
     		{
    -			$_SERVER['QUERY_STRING'] = '';
    -			$_GET = array();
    +			parse_str($_SERVER['QUERY_STRING'], $_GET);
     		}
     
     		if ($uri === '/' OR $uri === '')
    @@ -223,8 +225,6 @@ class CI_URI {
     			return '/';
     		}
     
    -		$uri = parse_url('pseudo://hostname/'.$uri, PHP_URL_PATH);
    -
     		// Do some final cleaning of the URI and return it
     		return str_replace(array('//', '../'), '/', trim($uri, '/'));
     	}
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 065daf54b..8e823d08d 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -230,7 +230,9 @@ Release Date: Not Released
     
     -  Core
     
    -   -  Changed private methods in the :doc:`URI Library ` to protected so MY_URI can override them.
    +   -  :doc:`URI Library ` changes include:
    +	 -  Changed private methods to protected so that MY_URI can override them.
    +	 -  Changed ``_detect_uri()`` to accept absolute URIs for compatibility with HTTP/1.1 as per `RFC2616 `.
        -  Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
        -  :doc:`Loader Library ` changes include:
     	 -  Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From f2b19fee7876708c7a7bb5cba6b7df682a9d2a53 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Wed, 31 Oct 2012 16:16:24 +0200
    Subject: Multiple improvements to the URI class
    
    (thanks to @sourcejedi, PR #1326 for most of the ideas)
    
     - Renamed _detect_uri() and _parse_cli_args() to _parse_request_uri() and _parse_argv() respectively.
     - Added _parse_query_string() which allows us to detect the URI path from QUERY_STRING much like it is done in _parse_request_uri().
    
    (the above changes also allow for a simpler logic in the case where the *uri_protocol* setting is not set to 'AUTO')
    
     - Updated application/config/config.php with a better list of the *uri_protocol* options.
     - Added _reset_query_string() to aid in re-processing  from the QUERY_STRING (utilized in _parse_request_uri() and _parse_query_string()).
    ---
     application/config/config.php       |  11 ++--
     system/core/URI.php                 | 103 ++++++++++++++++++++++++++----------
     user_guide_src/source/changelog.rst |   5 +-
     3 files changed, 85 insertions(+), 34 deletions(-)
    
    diff --git a/application/config/config.php b/application/config/config.php
    index ab1508e7b..6867cee88 100644
    --- a/application/config/config.php
    +++ b/application/config/config.php
    @@ -62,11 +62,12 @@ $config['index_page'] = 'index.php';
     | URI string.  The default setting of 'AUTO' works for most servers.
     | If your links do not seem to work, try one of the other delicious flavors:
     |
    -| 'AUTO'			Default - auto detects
    -| 'PATH_INFO'		Uses the PATH_INFO
    -| 'QUERY_STRING'	Uses the QUERY_STRING
    -| 'REQUEST_URI'		Uses the REQUEST_URI
    -| 'ORIG_PATH_INFO'	Uses the ORIG_PATH_INFO
    +| 'AUTO'		Default - auto detects
    +| 'CLI' or 'argv'	Uses $_SERVER['argv'] (for php-cli only)
    +| 'REQUEST_URI'		Uses $_SERVER['REQUEST_URI']
    +| 'PATH_INFO'		Uses $_SERVER['PATH_INFO']
    +| 'QUERY_STRING'	Uses $_SERVER['QUERY_STRING']
    +| 'ORIG_PATH_INFO'	Uses $_SERVER['ORIG_PATH_INFO']
     |
     */
     $config['uri_protocol']	= 'AUTO';
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 3d942eda7..6692d07a6 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -98,12 +98,12 @@ class CI_URI {
     			// Is the request coming from the command line?
     			if ($this->_is_cli_request())
     			{
    -				$this->_set_uri_string($this->_parse_cli_args());
    +				$this->_set_uri_string($this->_parse_argv());
     				return;
     			}
     
     			// Let's try the REQUEST_URI first, this will work in most situations
    -			if ($uri = $this->_detect_uri())
    +			if (($uri = $this->_parse_request_uri()) !== '')
     			{
     				$this->_set_uri_string($uri);
     				return;
    @@ -111,18 +111,17 @@ class CI_URI {
     
     			// Is there a PATH_INFO variable?
     			// Note: some servers seem to have trouble with getenv() so we'll test it two ways
    -			$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
    -			if (trim($path, '/') !== '' && $path !== '/'.SELF)
    +			$uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
    +			if (trim($uri, '/') !== '' && $uri !== '/'.SELF)
     			{
     				$this->_set_uri_string($path);
     				return;
     			}
     
     			// No PATH_INFO?... What about QUERY_STRING?
    -			$path = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
    -			if (trim($path, '/') !== '')
    +			if (($uri = $this->_parse_query_string()) !== '')
     			{
    -				$this->_set_uri_string($path);
    +				$this->_set_uri_string($uri);
     				return;
     			}
     
    @@ -140,19 +139,19 @@ class CI_URI {
     
     		$uri = strtoupper($this->config->item('uri_protocol'));
     
    -		if ($uri === 'REQUEST_URI')
    +		if ($uri === 'CLI')
     		{
    -			$this->_set_uri_string($this->_detect_uri());
    +			$this->_set_uri_string($this->_parse_argv());
     			return;
     		}
    -		elseif ($uri === 'CLI')
    +		elseif (method_exists($this, ($method = '_parse_'.strtolower($uri))))
     		{
    -			$this->_set_uri_string($this->_parse_cli_args());
    +			$this->_set_uri_string($this->$method());
     			return;
     		}
     
    -		$path = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri);
    -		$this->_set_uri_string($path);
    +		$uri = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri);
    +		$this->_set_uri_string($uri);
     	}
     
     	// --------------------------------------------------------------------
    @@ -172,13 +171,15 @@ class CI_URI {
     	// --------------------------------------------------------------------
     
     	/**
    -	 * Detects URI
    +	 * Parse REQUEST_URI
     	 *
    -	 * Will detect the URI automatically and fix the query string if necessary.
    +	 * Will parse REQUEST_URI and automatically detect the URI from it,
    +	 * while fixing the query string if necessary.
     	 *
    +	 * @used-by	CI_URI::_fetch_uri_string()
     	 * @return	string
     	 */
    -	protected function _detect_uri()
    +	protected function _parse_request_uri()
     	{
     		if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']))
     		{
    @@ -197,10 +198,10 @@ class CI_URI {
     		{
     			$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
     		}
    +
     		// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
     		// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
    -
    -		if ($uri === '' && strncmp($query, '/', 1) === 0)
    +		if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0)
     		{
     			$query = explode('?', $query, 2);
     			$uri = $query[0];
    @@ -211,14 +212,7 @@ class CI_URI {
     			$_SERVER['QUERY_STRING'] = $query;
     		}
     
    -		if ($_SERVER['QUERY_STRING'] === '')
    -		{
    -			$_GET = array();
    -		}
    -		else
    -		{
    -			parse_str($_SERVER['QUERY_STRING'], $_GET);
    -		}
    +		$this->_reset_query_string();
     
     		if ($uri === '/' OR $uri === '')
     		{
    @@ -231,6 +225,59 @@ class CI_URI {
     
     	// --------------------------------------------------------------------
     
    +	/**
    +	 * Parse QUERY_STRING
    +	 *
    +	 * Will parse QUERY_STRING and automatically detect the URI from it.
    +	 *
    +	 * @used-by	CI_URI::_fetch_uri_string()
    +	 * @return	string
    +	 */
    +	protected function _parse_query_string()
    +	{
    +		$uri = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
    +
    +		if (trim($uri, '/') === '')
    +		{
    +			return '';
    +		}
    +		elseif (strncmp($uri, '/', 1) === 0)
    +		{
    +			$uri = explode('?', $uri, 2);
    +			$_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
    +			$uri = $uri[0];
    +		}
    +		$this->_reset_query_string();
    +
    +		return str_replace(array('//', '../'), '/', trim($uri, '/'));
    +	}
    +
    +	// --------------------------------------------------------------------
    +
    +	/**
    +	 * Reset QUERY_STRING
    +	 *
    +	 * Re-processes QUERY_STRING to and fetches the real GET values from it.
    +	 * Useful for cases where we got the URI path from it's query string.
    +	 *
    +	 * @used-by	CI_URI::_parse_request_uri()
    +	 * @used-by	CI_URI::_parse_query_string()
    +	 * @return	void
    +	 */
    +	protected function _reset_query_string()
    +	{
    +		if ($_SERVER['QUERY_STRING'] === '')
    +		{
    +			$_GET = array();
    +		}
    +		else
    +		{
    +			parse_str($_SERVER['QUERY_STRING']);
    +		}
    +	}
    +
    +	// --------------------------------------------------------------------
    +
     	/**
     	 * Is CLI Request?
     	 *
    @@ -255,10 +302,10 @@ class CI_URI {
     	 *
     	 * @return	string
     	 */
    -	protected function _parse_cli_args()
    +	protected function _parse_argv()
     	{
     		$args = array_slice($_SERVER['argv'], 1);
    -		return $args ? '/'.implode('/', $args) : '';
    +		return $args ? implode('/', $args) : '';
     	}
     
     	// --------------------------------------------------------------------
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 8e823d08d..4fda2903a 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -232,7 +232,10 @@ Release Date: Not Released
     
        -  :doc:`URI Library ` changes include:
     	 -  Changed private methods to protected so that MY_URI can override them.
    -	 -  Changed ``_detect_uri()`` to accept absolute URIs for compatibility with HTTP/1.1 as per `RFC2616 `.
    +	 -  Renamed internal method ``_parse_cli_args()`` to ``_parse_argv()``.
    +	 -  Renamed internal method ``_detect_uri()`` to ``_parse_request_uri()``.
    +	 -  Changed ``_parse_request_uri()`` to accept absolute URIs for compatibility with HTTP/1.1 as per `RFC2616 `.
    +	 -  Added protected method ``_parse_query_string()`` to URI paths in the the **QUERY_STRING** value, like ``_parse_request_uri()`` does.
        -  Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
        -  :doc:`Loader Library ` changes include:
     	 -  Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From a9a1d2520493211ca35f7ab56866d0e154afc1c3 Mon Sep 17 00:00:00 2001
    From: Jonatas Miguel 
    Date: Wed, 31 Oct 2012 14:26:26 +0000
    Subject: removed conflict markers
    
    ---
     user_guide_src/source/changelog.rst | 24 ------------------------
     1 file changed, 24 deletions(-)
    
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index c87aebd57..990ba1386 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -145,11 +145,7 @@ Release Date: Not Released
        -  Added PDO support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge `.
        -  Added ``unbuffered_row()`` method for getting a row without prefetching whole result (consume less memory).
        -  Added PDO support for ``list_fields()`` in :doc:`Database Results `.
    -<<<<<<< HEAD
    -   -  Added capability for packages to hold database.php config files
    -=======
        -  Added capability for packages to hold *database.php* config files
    ->>>>>>> a7001e968a4791312391eb245ad84888893cda8f
        -  Added subdrivers support (currently only used by PDO).
        -  Added MySQL client compression support.
        -  Added encrypted connections support (for *mysql*, *sqlsrv* and PDO with *sqlsrv*).
    @@ -228,25 +224,6 @@ Release Date: Not Released
     -  Core
     
        -  Changed private methods in the :doc:`URI Library ` to protected so MY_URI can override them.
    -<<<<<<< HEAD
    -   -  Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions).
    -   -  Added method get_vars() to the :doc:`Loader Library ` to retrieve all variables loaded with $this->load->vars().
    -   -  is_loaded() function from system/core/Commons.php now returns a reference.
    -   -  $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *` to retrieve $_SERVER['REQUEST_METHOD'].
    -   -  Modified valid_ip() to use PHP's filter_var() in the :doc:`Input Library `.
    -   -  Added support for HTTP-Only cookies with new config option ``cookie_httponly`` (default FALSE).
    -   -  Renamed method _call_hook() to call_hook() in the :doc:`Hooks Library `.
    -   -  Added get_content_type() method to the :doc:`Output Library `.
    -   -  Added get_mimes() function to system/core/Commons.php to return the config/mimes.php array.
    -   -  Added a second argument to set_content_type() in the :doc:`Output Library ` that allows setting the document charset as well.
    -   -  $config['time_reference'] now supports all timezone strings supported by PHP.
    -   -  Added support for HTTP code 303 ("See Other") in set_status_header().
    -   -  Changed :doc:`Config Library ` method site_url() to accept an array as well.
    -   -  Added method ``strip_image_tags()`` to the :doc:`Security Library `.
    -   -  Changed ``_exception_handler()`` to respect php.ini 'display_errors' setting.
    -   -  Added possibility to route requests using callback methods.
    -=======
        -  Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
        -  :doc:`Loader Library ` changes include:
     	 -  Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
    @@ -275,7 +252,6 @@ Release Date: Not Released
     	 -  Added method ``strip_image_tags()``.
     	 -  Added ``$config['csrf_regeneration']``, which makes token regeneration optional.
     	 -  Added ``$config['csrf_exclude_uris']``, which allows you list URIs which will not have the CSRF validation methods run.
    ->>>>>>> a7001e968a4791312391eb245ad84888893cda8f
        -  Added possibility to route requests using callbacks.
     
     Bug fixes for 3.0
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 704f3f5223637dd6008106b1d04a68668458590e Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Wed, 31 Oct 2012 16:50:13 +0200
    Subject: Fix an erroneous variable name
    
    ---
     system/core/URI.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 6692d07a6..407a6ce88 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -114,7 +114,7 @@ class CI_URI {
     			$uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
     			if (trim($uri, '/') !== '' && $uri !== '/'.SELF)
     			{
    -				$this->_set_uri_string($path);
    +				$this->_set_uri_string($uri);
     				return;
     			}
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 9dd2dbb8b9a3edecddcb3907b65a402fd1ae71b4 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Wed, 31 Oct 2012 17:54:56 +0200
    Subject: Fix issues #388 & #705
    
    (thanks to @sourcejedi, PR #1326 for pointing inconsistencies with RFC2616
    ---
     system/core/URI.php                 | 9 +++++----
     user_guide_src/source/changelog.rst | 3 ++-
     2 files changed, 7 insertions(+), 5 deletions(-)
    
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 407a6ce88..4a8d33e88 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -188,7 +188,7 @@ class CI_URI {
     
     		$uri = parse_url($_SERVER['REQUEST_URI']);
     		$query = isset($uri['query']) ? $uri['query'] : '';
    -		$uri = isset($uri['path']) ? $uri['path'] : '';
    +		$uri = isset($uri['path']) ? rawurldecode($uri['path']) : '';
     
     		if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
     		{
    @@ -204,7 +204,7 @@ class CI_URI {
     		if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0)
     		{
     			$query = explode('?', $query, 2);
    -			$uri = $query[0];
    +			$uri = rawurldecode($query[0]);
     			$_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
     		}
     		else
    @@ -245,8 +245,9 @@ class CI_URI {
     		{
     			$uri = explode('?', $uri, 2);
     			$_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
    -			$uri = $uri[0];
    +			$uri = rawurldecode($uri[0]);
     		}
    +
     		$this->_reset_query_string();
     
     		return str_replace(array('//', '../'), '/', trim($uri, '/'));
    @@ -325,7 +326,7 @@ class CI_URI {
     		{
     			// preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
     			// compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
    -			if ( ! preg_match('|^['.str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-')).']+$|i', urldecode($str)))
    +			if ( ! preg_match('|^['.str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '|')).']+$|i', $str))
     			{
     				show_error('The URI you submitted has disallowed characters.', 400);
     			}
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 2df8ca7c1..e0b8c75e0 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -406,7 +406,8 @@ Bug fixes for 3.0
     -  Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values.
     -  Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
     -  Fixed a bug (#658) - :doc:`Routing ` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment.
    --  Fixed a bug (#1938) - :doc:`Email ` where the email library removed multiple spaces inside a pre-formatted plain text message.
    +-  Fixed a bug (#1938) - :doc:`Email Library ` removed multiple spaces inside a pre-formatted plain text message.
    +-  Fixed a bug (#388, #705) - :doc:`URI Library ` didn't apply URL-decoding to URI segments that it got from **REQUEST_URI** and/or **QUERY_STRING**.
     
     Version 2.1.3
     =============
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 34c8b9c45fdcd2eb0eee5e2275a52e4c2faed5dc Mon Sep 17 00:00:00 2001
    From: Jonathon Hill 
    Date: Wed, 31 Oct 2012 14:02:35 -0400
    Subject: Added support for timestamp-based migrations
    
    Signed-off-by: Jonathon Hill 
    ---
     application/config/migration.php              |  18 ++
     system/language/english/migration_lang.php    |   1 +
     system/libraries/Migration.php                | 230 +++++++++++++++-----------
     user_guide_src/source/changelog.rst           |   3 +
     user_guide_src/source/libraries/migration.rst |  84 ++++++----
     5 files changed, 207 insertions(+), 129 deletions(-)
    
    diff --git a/application/config/migration.php b/application/config/migration.php
    index 7645ade7c..476da1b8e 100644
    --- a/application/config/migration.php
    +++ b/application/config/migration.php
    @@ -37,6 +37,24 @@
     */
     $config['migration_enabled'] = FALSE;
     
    +/*
    +|--------------------------------------------------------------------------
    +| Migration Style
    +|--------------------------------------------------------------------------
    +|
    +| Migration file names may be based on a sequential identifier or on
    +| a timestamp. Options are:
    +|
    +|   'sequential' = Default migration naming (001_add_blog.php)
    +|   'timestamp'  = Timestamp migration naming (20121031104401_add_blog.php)
    +|                  Use timestamp format YYYYMMDDHHIISS.
    +|
    +| If this configuration value is missing the Migration library defaults
    +| to 'sequential' for backward compatibility.
    +|
    +*/
    +$config['migration_style'] = 'timestamp';
    +
     /*
     |--------------------------------------------------------------------------
     | Migrations table
    diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php
    index 5753c00bf..a262d3018 100644
    --- a/system/language/english/migration_lang.php
    +++ b/system/language/english/migration_lang.php
    @@ -27,6 +27,7 @@
     
     $lang['migration_none_found']			= 'No migrations were found.';
     $lang['migration_not_found']			= 'No migration could be found with the version number: %d.';
    +$lang['migration_sequence_gap']         = 'There is a gap in the migration sequence near version number: %d.';
     $lang['migration_multiple_version']		= 'There 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.';
    diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
    index 5d637d44a..2a06aa011 100644
    --- a/system/libraries/Migration.php
    +++ b/system/libraries/Migration.php
    @@ -45,6 +45,13 @@ class CI_Migration {
     	 * @var bool
     	 */
     	protected $_migration_enabled = FALSE;
    +	
    +	/**
    +	 * Migration numbering style
    +	 *
    +	 * @var bool
    +	 */
    +	protected $_migration_style = 'sequential';
     
     	/**
     	 * Path to migration classes
    @@ -73,6 +80,13 @@ class CI_Migration {
     	 * @var bool
     	 */
     	protected $_migration_auto_latest = FALSE;
    +	
    +	/**
    +	 * Migration basename regex
    +	 *
    +	 * @var bool
    +	 */
    +	protected $_migration_regex = NULL;
     
     	/**
     	 * Error message
    @@ -125,12 +139,21 @@ class CI_Migration {
     		{
     			show_error('Migrations configuration file (migration.php) must have "migration_table" set.');
     		}
    +		
    +		// Migration basename regex
    +		$this->_migration_regex = $this->_migration_style === 'timestamp' ? '/^\d{14}_(\w+)$/' : '/^\d{3}_(\w+)$/';
    +		
    +		// Make sure a valid migration numbering style was set.
    +		if ( ! in_array($this->_migration_style, array('sequential', 'timestamp')))
    +		{
    +			show_error('An invalid migration numbering style was specified: '.$this->_migration_style);
    +		}
     
     		// If the migrations table is missing, make it
     		if ( ! $this->db->table_exists($this->_migration_table))
     		{
     			$this->dbforge->add_field(array(
    -				'version' => array('type' => 'INT', 'constraint' => 3),
    +				'version' => array('type' => 'BIGINT', 'constraint' => 3),
     			));
     
     			$this->dbforge->create_table($this->_migration_table, TRUE);
    @@ -158,113 +181,80 @@ class CI_Migration {
     	 */
     	public function version($target_version)
     	{
    -		$start = $current_version = $this->_get_version();
    -		$stop = $target_version;
    -
    +		$current_version = (int) $this->_get_version();
    +		$target_version = (int) $target_version;
    +		
    +		$migrations = $this->find_migrations();
    +		
    +		if ($target_version > 0 AND ! isset($migrations[$target_version]))
    +		{
    +			$this->_error_string = sprintf($this->lang->line('migration_not_found'), $target_version);
    +			return FALSE;
    +		}
    +		
     		if ($target_version > $current_version)
     		{
     			// Moving Up
    -			++$start;
    -			++$stop;
    -			$step = 1;
    +			$method = 'up';
     		}
     		else
     		{
    -			// Moving Down
    -			$step = -1;
    +			// Moving Down, apply in reverse order
    +			$method = 'down';
    +			krsort($migrations);
     		}
     
    -		$method = $step === 1 ? 'up' : 'down';
    -		$migrations = array();
    -
    -		// We now prepare to actually DO the migrations
    -		// But first let's make sure that everything is the way it should be
    -		for ($i = $start; $i != $stop; $i += $step)
    +		if (empty($migrations))
     		{
    -			$f = glob(sprintf($this->_migration_path.'%03d_*.php', $i));
    +			return TRUE;
    +		}
    +		
    +		$previous = FALSE;
     
    -			// Only one migration per step is permitted
    -			if (count($f) > 1)
    +		// Validate all available migrations, and run the ones within our target range
    +		foreach ($migrations as $number => $file)
    +		{
    +			// Check for sequence gaps
    +			if ($this->_migration_style === 'sequential' AND $previous !== FALSE AND abs($number - $previous) > 1)
     			{
    -				$this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $i);
    +				$this->_error_string = sprintf($this->lang->line('migration_sequence_gap'), $number);
     				return FALSE;
     			}
    +		
    +			include $file;
    +			$class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php'))));
     
    -			// Migration step not found
    -			if (count($f) === 0)
    +			// Validate the migration file structure
    +			if ( ! class_exists($class))
     			{
    -				// If trying to migrate up to a version greater than the last
    -				// existing one, migrate to the last one.
    -				if ($step === 1)
    -				{
    -					break;
    -				}
    -
    -				// If trying to migrate down but we're missing a step,
    -				// something must definitely be wrong.
    -				$this->_error_string = sprintf($this->lang->line('migration_not_found'), $i);
    +				$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
     				return FALSE;
     			}
    -
    -			$file = basename($f[0]);
    -			$name = basename($f[0], '.php');
    -
    -			// Filename validations
    -			if (preg_match('/^\d{3}_(\w+)$/', $name, $match))
    -			{
    -				$match[1] = strtolower($match[1]);
    -
    -				// Cannot repeat a migration at different steps
    -				if (in_array($match[1], $migrations))
    -				{
    -					$this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $match[1]);
    -					return FALSE;
    -				}
    -
    -				include $f[0];
    -				$class = 'Migration_'.ucfirst($match[1]);
    -
    -				if ( ! class_exists($class))
    -				{
    -					$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
    -					return FALSE;
    -				}
    -
    -				if ( ! is_callable(array($class, $method)))
    -				{
    -					$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
    -					return FALSE;
    -				}
    -
    -				$migrations[] = $match[1];
    -			}
    -			else
    +			elseif ( ! is_callable(array($class, $method)))
     			{
    -				$this->_error_string = sprintf($this->lang->line('migration_invalid_filename'), $file);
    +				$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
     				return FALSE;
     			}
    +			
    +			$previous = $number;
    +
    +			// Run migrations that are inside the target range
    +			if (
    +				($method === 'up'   AND $number > $current_version AND $number <= $target_version) OR
    +				($method === 'down' AND $number <= $current_version AND $number > $target_version)
    +			) {
    +				log_message('debug', 'Migrating '.$method.' from version '.$current_version.' to version '.$number);
    +				call_user_func(array(new $class, $method));
    +				$current_version = $number;
    +				$this->_update_version($current_version);
    +			}
     		}
    -
    -		log_message('debug', 'Current migration: '.$current_version);
    -
    -		$version = $i + ($step === 1 ? -1 : 0);
    -
    -		// If there is nothing to do so quit
    -		if ($migrations === array())
    -		{
    -			return TRUE;
    -		}
    -
    -		log_message('debug', 'Migrating from '.$method.' to version '.$version);
    -
    -		// Loop through the migrations
    -		foreach ($migrations AS $migration)
    +		
    +		// This is necessary when moving down, since the the last migration applied
    +		// will be the down() method for the next migration up from the target
    +		if ($current_version <> $target_version)
     		{
    -			// Run the migration class
    -			$class = 'Migration_'.ucfirst(strtolower($migration));
    -			call_user_func(array(new $class, $method));
    -
    -			$current_version += $step;
    +			$current_version = $target_version;
     			$this->_update_version($current_version);
     		}
     
    @@ -282,17 +272,19 @@ class CI_Migration {
     	 */
     	public function latest()
     	{
    -		if ( ! $migrations = $this->find_migrations())
    +		$migrations = $this->find_migrations();
    +		
    +		if (empty($migrations))
     		{
     			$this->_error_string = $this->lang->line('migration_none_found');
     			return FALSE;
     		}
     
     		$last_migration = basename(end($migrations));
    -
    +		
     		// Calculate the last migration step from existing migration
     		// filenames and procceed to the standard version migration
    -		return $this->version((int) $last_migration);
    +		return $this->version($this->_get_migration_number($last_migration));
     	}
     
     	// --------------------------------------------------------------------
    @@ -326,22 +318,60 @@ class CI_Migration {
     	 *
     	 * @return	array	list of migration file paths sorted by version
     	 */
    -	protected function find_migrations()
    +	public function find_migrations()
     	{
    +		$migrations = array();
    +	
     		// Load all *_*.php files in the migrations path
    -		$files = glob($this->_migration_path.'*_*.php');
    -
    -		for ($i = 0, $c = count($files); $i < $c; $i++)
    +		foreach (glob($this->_migration_path.'*_*.php') as $file)
     		{
    -			// Mark wrongly formatted files as false for later filtering
    -			if ( ! preg_match('/^\d{3}_(\w+)$/', basename($files[$i], '.php')))
    +			$name = basename($file, '.php');
    +		
    +			// Filter out non-migration files
    +			if (preg_match($this->_migration_regex, $name))
     			{
    -				$files[$i] = FALSE;
    +				$number = $this->_get_migration_number($name);
    +				
    +				// There cannot be duplicate migration numbers
    +				if (isset($migrations[$number]))
    +				{
    +					$this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $number);
    +					show_error($this->_error_string);
    +				}
    +				
    +				$migrations[$number] = $file;
     			}
     		}
     
    -		sort($files);
    -		return $files;
    +		ksort($migrations);
    +		return $migrations;
    +	}
    +
    +	// --------------------------------------------------------------------
    +
    +	/**
    +	 * Extracts the migration number from a filename
    +	 *
    +	 * @return	int Numeric portion of a migration filename
    +	 */
    +	protected function _get_migration_number($migration)
    +	{
    +		$parts = explode('_', $migration);
    +		return (int) $parts[0];
    +	}
    +
    +	// --------------------------------------------------------------------
    +
    +	/**
    +	 * Extracts the migration class name from a filename
    +	 *
    +	 * @return	string text portion of a migration filename
    +	 */
    +	protected function _get_migration_name($migration)
    +	{
    +		$parts = explode('_', $migration);
    +		array_shift($parts);
    +		return implode('_', $parts);
     	}
     
     	// --------------------------------------------------------------------
    @@ -365,10 +395,10 @@ class CI_Migration {
     	 * @param	int	Migration reached
     	 * @return	void	Outputs a report of the migration
     	 */
    -	protected function _update_version($migrations)
    +	protected function _update_version($migration)
     	{
     		return $this->db->update($this->_migration_table, array(
    -			'version' => $migrations
    +			'version' => $migration
     		));
     	}
     
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 065daf54b..f45cc5cd7 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -227,6 +227,9 @@ Release Date: Not Released
     	 -  Added support for hashing algorithms other than SHA1 and MD5.
     	 -  Removed previously deprecated ``sha1()`` method.
        -  Changed :doc:`Language Library ` method ``load()`` to filter the language name with ``ctype_digit()``.
    +   -  :doc:`Migration Library ` changes include:
    +     -  Added support for timestamp-based migrations (enabled by default)
    +     -  Added ``$config['migration_style']`` to allow switching between sequential migrations and timestamp migrations
     
     -  Core
     
    diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst
    index cb7d96a6d..246396171 100644
    --- a/user_guide_src/source/libraries/migration.rst
    +++ b/user_guide_src/source/libraries/migration.rst
    @@ -13,17 +13,40 @@ run so all you have to do is update your application files and
     call **$this->migrate->current()** to work out which migrations should be run. 
     The current version is found in **config/migration.php**.
     
    +********************
    +Migration file names
    +********************
    +
    +Each Migration is run in numeric order forward or backwards depending on the
    +method taken. Two numbering styles are available:
    +
    +* **Sequential:** each migration is numbered in sequence, starting with **001**.
    +  Each number must be three digits, and there must not be any gaps in the
    +  sequence. (This was the numbering scheme prior to CodeIgniter 3.0.)
    +* **Timestamp:** each migration is numbered using the timestamp when the migration
    +  was created, in **YYYYMMDDHHIISS** format (e.g. **20121031100537**). This
    +  helps prevent numbering conflicts when working in a team environment, and is
    +  the preferred scheme in CodeIgniter 3.0 and later.
    +
    +The desired style may be selected using the **$config['migration_style']**
    +setting in your **migration.php** config file.
    +
    +Regardless of which numbering style you choose to use, prefix your migration
    +files with the migration number followed by an underscore and a descriptive
    +name for the migration. For example:
    +
    +* **001_add_blog.php** (sequential numbering)
    +* **20121031100537_add_blog.php** (timestamp numbering)
    +
     ******************
     Create a Migration
     ******************
    -
    -.. note:: Each Migration is run in numerical order forward or backwards 
    -	depending on the method taken. Use a prefix of 3 numbers followed by an 
    -	underscore for the filename of your migration.
     	
     This will be the first migration for a new site which has a blog. All 
     migrations go in the folder **application/migrations/** and have names such 
    -as: **001_add_blog.php**.::
    +as **20121031100537_add_blog.php**.::
    +
    +	 TRUE,
     				),
     			));
    -			
    +			$this->dbforge->add_key('blog_id', TRUE);
     			$this->dbforge->create_table('blog');
     		}
     
    @@ -55,6 +78,7 @@ as: **001_add_blog.php**.::
     		{
     			$this->dbforge->drop_table('blog');
     		}
    +	}
     
     Then in **application/config/migration.php** set **$config['migration_version'] = 1;**.
     
    @@ -65,25 +89,25 @@ Usage Example
     In this example some simple code is placed in **application/controllers/migrate.php** 
     to update the schema.::
     
    -	$this->load->library('migration');
    -
    -	if ( ! $this->migration->current())
    +	migration->error_string());
    +	    public function index()
    +	    {
    +	    	$this->load->library('migration');
    +	    	
    +	    	if ($this->migration->current() === FALSE)
    +	    	{
    +	    		show_error($this->migration->error_string());
    +	    	}
    +	    }
     	}
     
     ******************
     Function Reference
     ******************
     
    -There are five available methods for the Migration class:
    -
    --  $this->migration->current();
    --  $this->migration->error_string();
    --  $this->migration->find_migrations();
    --  $this->migration->latest();
    --  $this->migration->version();
    -
     $this->migration->current()
     ============================
     
    @@ -124,14 +148,16 @@ Migration Preferences
     
     The following is a table of all the config options for migrations.
     
    -========================== ====================== ============= =============================================
    -Preference                 Default                Options       Description
    -========================== ====================== ============= =============================================
    -**migration_enabled**      FALSE                  TRUE / FALSE  Enable or disable migrations.
    -**migration_path**         APPPATH.'migrations/'  None          The path to your migrations folder.
    -**migration_version**      0                      None          The current version your database should use.
    -**migration_table**        migrations             None          The table name for storing the shema
    -                                                                version number.
    -**migration_auto_latest**  FALSE                  TRUE / FALSE  Enable or disable automatically 
    -                                                                running migrations.
    -========================== ====================== ============= =============================================
    +========================== ====================== ========================== =============================================
    +Preference                 Default                Options                    Description
    +========================== ====================== ========================== =============================================
    +**migration_enabled**      FALSE                  TRUE / FALSE               Enable or disable migrations.
    +**migration_path**         APPPATH.'migrations/'  None                       The path to your migrations folder.
    +**migration_version**      0                      None                       The current version your database should use.
    +**migration_table**        migrations             None                       The table name for storing the schema
    +                                                                             version number.
    +**migration_auto_latest**  FALSE                  TRUE / FALSE               Enable or disable automatically 
    +                                                                             running migrations.
    +**migration_style**        'timestamp'            'timestamp' / 'sequential' The type of numeric identifier used to name
    +                                                                             migration files.
    +========================== ====================== ========================== =============================================
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From ea6688b3b9a7a208d1c44439c4f01801fd3b8c65 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Wed, 31 Oct 2012 21:52:11 +0200
    Subject: Fix issue in resetting QUERY_STRING, GET vars introduced in
     f2b19fee7876708c7a7bb5cba6b7df682a9d2a53
    
    ---
     system/core/URI.php | 28 ++--------------------------
     1 file changed, 2 insertions(+), 26 deletions(-)
    
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 4a8d33e88..3b7718fff 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -212,7 +212,7 @@ class CI_URI {
     			$_SERVER['QUERY_STRING'] = $query;
     		}
     
    -		$this->_reset_query_string();
    +		parse_str($_SERVER['QUERY_STRING'], $_GET);
     
     		if ($uri === '/' OR $uri === '')
     		{
    @@ -248,37 +248,13 @@ class CI_URI {
     			$uri = rawurldecode($uri[0]);
     		}
     
    -		$this->_reset_query_string();
    +		parse_str($_SERVER['QUERY_STRING'], $_GET);
     
     		return str_replace(array('//', '../'), '/', trim($uri, '/'));
     	}
     
     	// --------------------------------------------------------------------
     
    -	/**
    -	 * Reset QUERY_STRING
    -	 *
    -	 * Re-processes QUERY_STRING to and fetches the real GET values from it.
    -	 * Useful for cases where we got the URI path from it's query string.
    -	 *
    -	 * @used-by	CI_URI::_parse_request_uri()
    -	 * @used-by	CI_URI::_parse_query_string()
    -	 * @return	void
    -	 */
    -	protected function _reset_query_string()
    -	{
    -		if ($_SERVER['QUERY_STRING'] === '')
    -		{
    -			$_GET = array();
    -		}
    -		else
    -		{
    -			parse_str($_SERVER['QUERY_STRING']);
    -		}
    -	}
    -
    -	// --------------------------------------------------------------------
    -
     	/**
     	 * Is CLI Request?
     	 *
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 30563ff7fd210f86103a5691f001441e76cfb646 Mon Sep 17 00:00:00 2001
    From: Andrey 
    Date: Thu, 1 Nov 2012 01:49:39 +0400
    Subject: add russian in foreign_chars.php
    
    ---
     application/config/foreign_chars.php | 80 ++++++++++++++++++++++++------------
     1 file changed, 54 insertions(+), 26 deletions(-)
    
    diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
    index 6614caa31..1127c7cc8 100644
    --- a/application/config/foreign_chars.php
    +++ b/application/config/foreign_chars.php
    @@ -40,44 +40,56 @@ $foreign_characters = array(
     	'/Ä/' => 'Ae',
     	'/Ü/' => 'Ue',
     	'/Ö/' => 'Oe',
    -	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ/' => 'A',
    -	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ/' => 'a',
    +	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
    +	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
    +	'/Б/' => 'B',
    +	'/б/' => 'b',
     	'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
     	'/ç|ć|ĉ|ċ|č/' => 'c',
    +	'/Д/' => 'D',
    +	'/д/' => 'd',
     	'/Ð|Ď|Đ|Δ/' => 'Dj',
     	'/ð|ď|đ|δ/' => 'dj',
    -	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ/' => 'E',
    -	'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ/' => 'e',
    -	'/Ĝ|Ğ|Ġ|Ģ|Γ/' => 'G',
    -	'/ĝ|ğ|ġ|ģ|γ/' => 'g',
    +	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Ё|Э/' => 'E',
    +	'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|ё|э/' => 'e',
    +	'/Ф/' => 'F',
    +	'/ф/' => 'f',
    +	'/Ĝ|Ğ|Ġ|Ģ|Γ|Г/' => 'G',
    +	'/ĝ|ğ|ġ|ģ|γ|г/' => 'g',
     	'/Ĥ|Ħ/' => 'H',
     	'/ĥ|ħ/' => 'h',
    -	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị/' => 'I',
    -	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị/' => 'i',
    +	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Й/' => 'I',
    +	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|й/' => 'i',
     	'/Ĵ/' => 'J',
     	'/ĵ/' => 'j',
    -	'/Ķ|Κ/' => 'K',
    -	'/ķ|κ/' => 'k',
    -	'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ/' => 'L',
    -	'/ĺ|ļ|ľ|ŀ|ł|λ/' => 'l',
    -	'/Ñ|Ń|Ņ|Ň|Ν/' => 'N',
    -	'/ñ|ń|ņ|ň|ʼn|ν/' => 'n',
    -	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ/' => 'O',
    -	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ/' => 'o',
    -	'/Ŕ|Ŗ|Ř|Ρ/' => 'R',
    -	'/ŕ|ŗ|ř|ρ/' => 'r',
    -	'/Ś|Ŝ|Ş|Ș|Š|Σ/' => 'S',
    -	'/ś|ŝ|ş|ș|š|ſ|σ|ς/' => 's',
    -	'/Ț|Ţ|Ť|Ŧ|τ/' => 'T',
    -	'/ț|ţ|ť|ŧ/' => 't',
    -	'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự/' => 'U',
    -	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự/' => 'u',
    +	'/Ķ|Κ|К/' => 'K',
    +	'/ķ|κ|к/' => 'k',
    +	'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
    +	'/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
    +	'/М/' => 'M',
    +	'/м/' => 'm',
    +	'/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
    +	'/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
    +	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
    +	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
    +	'/П/' => 'P',
    +	'/п/' => 'p',
    +	'/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
    +	'/ŕ|ŗ|ř|ρ|р/' => 'r',
    +	'/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
    +	'/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
    +	'/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
    +	'/ț|ţ|ť|ŧ|т/' => 't',
    +	'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
    +	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
     	'/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ/' => 'Y',
     	'/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ/' => 'y',
    +	'/В/' => 'V',
    +	'/в/' => 'v',
     	'/Ŵ/' => 'W',
     	'/ŵ/' => 'w',
    -	'/Ź|Ż|Ž|Ζ/' => 'Z',
    -	'/ź|ż|ž|ζ/' => 'z',
    +	'/Ź|Ż|Ž|Ζ|З/' => 'Z',
    +	'/ź|ż|ž|ζ|з/' => 'z',
     	'/Æ|Ǽ/' => 'AE',
     	'/ß/'=> 'ss',
     	'/IJ/' => 'IJ',
    @@ -89,6 +101,22 @@ $foreign_characters = array(
     	'/β/' => 'v',
     	'/μ/' => 'm',
     	'/ψ/' => 'ps',
    +	'/Ж/'=>'ZH',
    +	'/ж/'=>'zh',
    +	'/Х/'=>'KH',
    +	'/х/'=>'kh',
    +	'/Ц/'=>'TC',
    +	'/ц/'=>'tc',
    +	'/Ч/'=>'CH',
    +	'/ч/'=>'ch',
    +	'/Ш/'=>'SH',
    +	'/ш/'=>'sh',
    +	'/Щ/'=>'SHCH',
    +	'/щ/'=>'shch',
    +	'/Ю/'=>'IU',
    +	'/ю/'=>'iu',
    +	'/Я/'=>'IA',
    +	'/я/'=>'ia'
     );
     
     /* End of file foreign_chars.php */
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From dc6fba5492a215b40c254ed6f704c580427cdfea Mon Sep 17 00:00:00 2001
    From: GDmac 
    Date: Wed, 31 Oct 2012 16:53:15 +0100
    Subject: Fix #1946 dbforge add_key
    
    add_key not setting multiple-column keys when given array
    
    Signed-off-by: GDmac 
    ---
     system/database/DB_forge.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
    index 119d78d38..2be2790dd 100644
    --- a/system/database/DB_forge.php
    +++ b/system/database/DB_forge.php
    @@ -132,7 +132,7 @@ abstract class CI_DB_forge {
     	 */
     	public function add_key($key = '', $primary = FALSE)
     	{
    -		if (is_array($key))
    +		if ($primary && is_array($key))
     		{
     			foreach ($key as $one)
     			{
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 3b72eb58e61581b7e92012a322be48e216491d7c Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 00:45:26 +0200
    Subject: Changed URI auto-detection to try PATH_INFO first
    
    (thanks to @sourcejedi, PR #1326)
    
    Up until PHP 5.2.4 (which is our new lowest requirement),
    there was a bug related to PATH_INFO which made REQUEST_URI
    a more reliable choice. This is now no longer the case,
    see https://bugs.php.net/bug.php?id=31892 for more details.
    
    Also removed ORIG_PATH_INFO from the suggested alternatives
    for uri_protocol in application/config/config.php as it will
    not exist in most of PHP's recent versions and is pointless
    when you can use PATH_INFO anyway.
    ---
     application/config/config.php       |  3 +--
     system/core/URI.php                 | 14 ++++++--------
     user_guide_src/source/changelog.rst |  1 +
     3 files changed, 8 insertions(+), 10 deletions(-)
    
    diff --git a/application/config/config.php b/application/config/config.php
    index 6867cee88..0562953b0 100644
    --- a/application/config/config.php
    +++ b/application/config/config.php
    @@ -64,10 +64,9 @@ $config['index_page'] = 'index.php';
     |
     | 'AUTO'		Default - auto detects
     | 'CLI' or 'argv'	Uses $_SERVER['argv'] (for php-cli only)
    -| 'REQUEST_URI'		Uses $_SERVER['REQUEST_URI']
     | 'PATH_INFO'		Uses $_SERVER['PATH_INFO']
    +| 'REQUEST_URI'		Uses $_SERVER['REQUEST_URI']
     | 'QUERY_STRING'	Uses $_SERVER['QUERY_STRING']
    -| 'ORIG_PATH_INFO'	Uses $_SERVER['ORIG_PATH_INFO']
     |
     */
     $config['uri_protocol']	= 'AUTO';
    diff --git a/system/core/URI.php b/system/core/URI.php
    index 3b7718fff..309c77630 100644
    --- a/system/core/URI.php
    +++ b/system/core/URI.php
    @@ -102,23 +102,21 @@ class CI_URI {
     				return;
     			}
     
    -			// Let's try the REQUEST_URI first, this will work in most situations
    -			if (($uri = $this->_parse_request_uri()) !== '')
    +			// Is there a PATH_INFO variable? This should be the easiest solution.
    +			if (isset($_SERVER['PATH_INFO']))
     			{
    -				$this->_set_uri_string($uri);
    +				$this->_set_uri_string($_SERVER['PATH_INFO']);
     				return;
     			}
     
    -			// Is there a PATH_INFO variable?
    -			// Note: some servers seem to have trouble with getenv() so we'll test it two ways
    -			$uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
    -			if (trim($uri, '/') !== '' && $uri !== '/'.SELF)
    +			// Let's try REQUEST_URI then, this will work in most situations
    +			if (($uri = $this->_parse_request_uri()) !== '')
     			{
     				$this->_set_uri_string($uri);
     				return;
     			}
     
    -			// No PATH_INFO?... What about QUERY_STRING?
    +			// No REQUEST_URI either?... What about QUERY_STRING?
     			if (($uri = $this->_parse_query_string()) !== '')
     			{
     				$this->_set_uri_string($uri);
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index e0b8c75e0..a6494e361 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -236,6 +236,7 @@ Release Date: Not Released
     	 -  Renamed internal method ``_detect_uri()`` to ``_parse_request_uri()``.
     	 -  Changed ``_parse_request_uri()`` to accept absolute URIs for compatibility with HTTP/1.1 as per `RFC2616 `.
     	 -  Added protected method ``_parse_query_string()`` to URI paths in the the **QUERY_STRING** value, like ``_parse_request_uri()`` does.
    +	 -  Changed ``_fetch_uri_string()`` to try the **PATH_INFO** variable first when auto-detecting.
        -  Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
        -  :doc:`Loader Library ` changes include:
     	 -  Added method ``get_vars()`` to the Loader to retrieve all variables loaded with ``$this->load->vars()``.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 87f4dc27230debc0af281c9780f2ba939fe07608 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 01:11:22 +0200
    Subject: Fix an update_string() bug
    
    ---
     system/database/DB_driver.php        | 30 +++---------------------------
     system/database/DB_query_builder.php |  2 +-
     2 files changed, 4 insertions(+), 28 deletions(-)
    
    diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
    index e8286aaa1..795ed6711 100644
    --- a/system/database/DB_driver.php
    +++ b/system/database/DB_driver.php
    @@ -1080,43 +1080,19 @@ abstract class CI_DB_driver {
     	 */
     	public function update_string($table, $data, $where)
     	{
    -		if ($where === '')
    +		if (empty($where))
     		{
     			return FALSE;
     		}
     
    +		$this->where($where);
    +
     		$fields = array();
     		foreach ($data as $key => $val)
     		{
     			$fields[$this->protect_identifiers($key)] = $this->escape($val);
     		}
     
    -		if ( ! is_array($where))
    -		{
    -			$dest = array($where);
    -		}
    -		else
    -		{
    -			$dest = array();
    -			foreach ($where as $key => $val)
    -			{
    -				$prefix = (count($dest) === 0) ? '' : ' AND ';
    -				$key = $this->protect_identifiers($key);
    -
    -				if ($val !== '')
    -				{
    -					if ( ! $this->_has_operator($key))
    -					{
    -						$key .= ' =';
    -					}
    -
    -					$val = ' '.$this->escape($val);
    -				}
    -
    -				$dest[] = $prefix.$key.$val;
    -			}
    -		}
    -
     		return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest);
     	}
     
    diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
    index a3585586e..cc43d834c 100644
    --- a/system/database/DB_query_builder.php
    +++ b/system/database/DB_query_builder.php
    @@ -1575,7 +1575,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     		}
     
     		$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set);
    -
    +var_dump($sql);
     		$this->_reset_write();
     		return $this->query($sql);
     	}
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From e2afc886d5e7fe1d55a467c9bc46fe40c1a2bbf6 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 01:35:34 +0200
    Subject: Session cookie driver changes
    
     - Changed docs CREATE TABLE ci_sessions example to have the PRIMARY KEY of session_id, ip_address and user_agent combined.
     - Changed DB updates to add WHERE clauses for the ip_address and/or user_agent strings if sess_match_ip and/or sess_match_useragent are set to TRUE.
    ---
     .../libraries/Session/drivers/Session_cookie.php   | 36 +++++++++++++++++++---
     user_guide_src/source/libraries/sessions.rst       |  2 +-
     2 files changed, 32 insertions(+), 6 deletions(-)
    
    diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
    index 2f1bf3531..8f527ace7 100755
    --- a/system/libraries/Session/drivers/Session_cookie.php
    +++ b/system/libraries/Session/drivers/Session_cookie.php
    @@ -540,11 +540,25 @@ class CI_Session_cookie extends CI_Session_driver {
     		// Check for database
     		if ($this->sess_use_database === TRUE)
     		{
    +			$this->CI->db->where('session_id', $old_sessid);
    +
    +			if ($this->sess_match_ip === TRUE)
    +			{
    +				$this->CI->db->where('ip_address', $this->CI->input->ip_address());
    +			}
    +
    +			if ($this->sess_match_useragent === TRUE)
    +			{
    +				$this->CI->db->where('user_agent', trim(substr($this->CI->input->user_agent(), 0, 120)));
    +			}
    +
     			// Update the session ID and last_activity field in the DB
    -			$this->CI->db->update($this->sess_table_name, array(
    -					 'last_activity' => $this->now,
    -					 'session_id' => $this->userdata['session_id']
    -			), array('session_id' => $old_sessid));
    +			$this->CI->db->update($this->sess_table_name,
    +				array(
    +					'last_activity' => $this->now,
    +					'session_id' => $this->userdata['session_id']
    +				)
    +			);
     		}
     
     		// Write the cookie
    @@ -590,7 +604,19 @@ class CI_Session_cookie extends CI_Session_driver {
     			// Run the update query
     			// Any time we change the session id, it gets updated immediately,
     			// so our where clause below is always safe
    -			$this->CI->db->update($this->sess_table_name, $set, array('session_id' => $this->userdata['session_id']));
    +			$this->CI->db->where('session_id', $this->userdata['session_id']);
    +
    +			if ($this->sess_match_ip === TRUE)
    +			{
    +				$this->CI->db->where('ip_address', $this->CI->input->ip_address());
    +			}
    +
    +			if ($this->sess_match_useragent === TRUE)
    +			{
    +				$this->CI->db->where('user_agent', trim(substr($this->CI->input->user_agent(), 0, 120)));
    +			}
    +
    +			$this->CI->db->update($this->sess_table_name, $set);
     
     			// Clear dirty flag to prevent double updates
     			$this->data_dirty = FALSE;
    diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst
    index dd9e8cbb4..ee7fb0b1c 100644
    --- a/user_guide_src/source/libraries/sessions.rst
    +++ b/user_guide_src/source/libraries/sessions.rst
    @@ -388,7 +388,7 @@ session class::
     		user_agent varchar(120) NOT NULL,
     		last_activity int(10) unsigned DEFAULT 0 NOT NULL,
     		user_data text NOT NULL,
    -		PRIMARY KEY (session_id),
    +		PRIMARY KEY (session_id, ip_address, user_agent),
     		KEY `last_activity_idx` (`last_activity`)
     	);
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From b107e5728ad867e860d2d4469c1ec523bd3ffac1 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 11:50:21 +0200
    Subject: Remove var_dump() missed in a previous commit
    
    ---
     system/database/DB_query_builder.php | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
    index cc43d834c..8a3d3b198 100644
    --- a/system/database/DB_query_builder.php
    +++ b/system/database/DB_query_builder.php
    @@ -1575,7 +1575,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
     		}
     
     		$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set);
    -var_dump($sql);
     		$this->_reset_write();
     		return $this->query($sql);
     	}
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 948f0218b845e68ea162322dae3a2f5fe7e4a913 Mon Sep 17 00:00:00 2001
    From: sa 
    Date: Thu, 1 Nov 2012 16:27:02 +0400
    Subject: russian second letter in lowercase, foreign_chars.php
    
    ---
     application/config/foreign_chars.php | 16 ++++++++--------
     1 file changed, 8 insertions(+), 8 deletions(-)
    
    diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
    index 1127c7cc8..5a2bb0cf7 100644
    --- a/application/config/foreign_chars.php
    +++ b/application/config/foreign_chars.php
    @@ -101,21 +101,21 @@ $foreign_characters = array(
     	'/β/' => 'v',
     	'/μ/' => 'm',
     	'/ψ/' => 'ps',
    -	'/Ж/'=>'ZH',
    +	'/Ж/'=>'Zh',
     	'/ж/'=>'zh',
    -	'/Х/'=>'KH',
    +	'/Х/'=>'Kh',
     	'/х/'=>'kh',
    -	'/Ц/'=>'TC',
    +	'/Ц/'=>'Tc',
     	'/ц/'=>'tc',
    -	'/Ч/'=>'CH',
    +	'/Ч/'=>'Ch',
     	'/ч/'=>'ch',
    -	'/Ш/'=>'SH',
    +	'/Ш/'=>'Sh',
     	'/ш/'=>'sh',
    -	'/Щ/'=>'SHCH',
    +	'/Щ/'=>'Shch',
     	'/щ/'=>'shch',
    -	'/Ю/'=>'IU',
    +	'/Ю/'=>'Iu',
     	'/ю/'=>'iu',
    -	'/Я/'=>'IA',
    +	'/Я/'=>'Ia',
     	'/я/'=>'ia'
     );
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From ce1b02a0fa8e07f769c41634e19c15482244e687 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 14:40:52 +0200
    Subject: [ci skip] Add changelog entry for PR #1951
    
    ---
     user_guide_src/source/changelog.rst | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index a6494e361..4aef2a174 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -39,10 +39,10 @@ Release Date: Not Released
        -  Updated support for zip files in mimes.php.
        -  Updated support for csv files in mimes.php.
        -  Added some more doctypes.
    -   -  Added Romanian, Greek and Vietnamese characters in *foreign_characters.php*.
    +   -  Added Romanian, Greek, Vietnamese and Cyrilic characters in *application/config/foreign_characters.php*.
        -  Changed logger to only chmod when file is first created.
        -  Removed previously deprecated SHA1 Library.
    -   -  Removed previously deprecated use of ``$autoload['core']`` in application/config/autoload.php.
    +   -  Removed previously deprecated use of ``$autoload['core']`` in *application/config/autoload.php*.
           Only entries in ``$autoload['libraries']`` are auto-loaded now.
        -  Removed previously deprecated EXT constant.
        -  Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties.
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 7c4d10660a0a47446474bf97e3cb65f80693f1ee Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 15:14:34 +0200
    Subject: Fix issue #1953 (form values being escaped twice)
    
    Re-instaing an improved form_prep() function, reverting most of the changes from 74ffd17ab06327ca62ddfe28a186cae7ba6bd459.
    ---
     system/helpers/form_helper.php                     | 83 ++++++++++++----------
     system/libraries/Form_validation.php               | 10 +--
     tests/codeigniter/helpers/form_helper_test.php     | 15 ++++
     user_guide_src/source/changelog.rst                |  2 +-
     user_guide_src/source/helpers/form_helper.rst      | 44 ++++++------
     user_guide_src/source/installation/upgrade_300.rst | 10 ---
     6 files changed, 88 insertions(+), 76 deletions(-)
    
    diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
    index 622622c0e..9c4c4dae6 100644
    --- a/system/helpers/form_helper.php
    +++ b/system/helpers/form_helper.php
    @@ -124,9 +124,9 @@ if ( ! function_exists('form_hidden'))
     	 * Generates hidden fields. You can pass a simple key/value string or
     	 * an associative array with multiple values.
     	 *
    -	 * @param	mixed
    -	 * @param	string
    -	 * @param	bool
    +	 * @param	mixed	$name		Field name
    +	 * @param	string	$value		Field value
    +	 * @param	bool	$recursing
     	 * @return	string
     	 */
     	function form_hidden($name, $value = '', $recursing = FALSE)
    @@ -149,7 +149,7 @@ if ( ! function_exists('form_hidden'))
     
     		if ( ! is_array($value))
     		{
    -			$form .= '\n";
    +			$form .= '\n";
     		}
     		else
     		{
    @@ -243,9 +243,9 @@ if ( ! function_exists('form_textarea'))
     	/**
     	 * Textarea field
     	 *
    -	 * @param	mixed
    -	 * @param	string
    -	 * @param	string
    +	 * @param	mixed	$data
    +	 * @param	string	$value
    +	 * @param	string	$extra
     	 * @return	string
     	 */
     	function form_textarea($data = '', $value = '', $extra = '')
    @@ -263,7 +263,7 @@ if ( ! function_exists('form_textarea'))
     		}
     
     		$name = is_array($data) ? $data['name'] : $data;
    -		return '\n";
    +		return '\n";
     	}
     }
     
    @@ -298,10 +298,10 @@ if ( ! function_exists('form_dropdown'))
     	/**
     	 * Drop-down Menu
     	 *
    -	 * @param	mixed	$name = ''
    -	 * @param	mixed	$options = array()
    -	 * @param	mixed	$selected = array()
    -	 * @param	mixed	$extra = array()
    +	 * @param	mixed	$name
    +	 * @param	mixed	$options
    +	 * @param	mixed	$selected
    +	 * @param	mixed	$extra
     	 * @return	string
     	 */
     	function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
    @@ -349,7 +349,7 @@ if ( ! function_exists('form_dropdown'))
     				foreach ($val as $optgroup_key => $optgroup_val)
     				{
     					$sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
    -					$form .= '\n";
     				}
     
    @@ -357,7 +357,7 @@ if ( ! function_exists('form_dropdown'))
     			}
     			else
     			{
    -				$form .= '\n";
     			}
    @@ -600,17 +600,28 @@ if ( ! function_exists('form_prep'))
     	 *
     	 * Formats text so that it can be safely placed in a form field in the event it has HTML tags.
     	 *
    -	 * @todo	Remove in version 3.1+.
    -	 * @deprecated	3.0.0	This function has been broken for a long time
    -	 *			and is now just an alias for html_escape(). It's
    -	 *			second argument is ignored.
    -	 * @param	string	$str = ''
    -	 * @param	string	$field_name = ''
    -	 * @return	string
    +	 * @param	string|string[]	$str		Value to escape
    +	 * @param	bool		$is_textarea	Whether we're escaping for a textarea element
    +	 * @return	string|string[]	Escaped values
     	 */
    -	function form_prep($str = '', $field_name = '')
    +	function form_prep($str = '', $is_textarea = FALSE)
     	{
    -		return html_escape($str);
    +		if (is_array($str))
    +		{
    +			foreach (array_keys($str) as $key)
    +			{
    +				$str[$key] = form_prep($str[$key], $is_textarea);
    +			}
    +
    +			return $str;
    +		}
    +
    +		if ($is_textarea === TRUE)
    +		{
    +			return str_replace(array('<', '>'), array('<', '>'), stripslashes($str));
    +		}
    +
    +		return str_replace(array("'", '"'), array(''', '"'), stripslashes($data));
     	}
     }
     
    @@ -625,23 +636,21 @@ if ( ! function_exists('set_value'))
     	 * re-populate an input field or textarea. If Form Validation
     	 * is active it retrieves the info from the validation class
     	 *
    -	 * @param	string
    -	 * @param	string
    -	 * @return	mixed
    +	 * @param	string	$field		Field name
    +	 * @param	string	$default	Default value
    +	 * @param	bool	$is_textarea	Whether the field is a textarea element
    +	 * @return	string
     	 */
    -	function set_value($field = '', $default = '')
    +	function set_value($field = '', $default = '', $is_textarea = FALSE)
     	{
     		if (FALSE === ($OBJ =& _get_validation_object()))
     		{
    -			if ( ! isset($_POST[$field]))
    -			{
    -				return html_escape($default);
    -			}
    -
    -			return html_escape($_POST[$field]);
    +			return isset($_POST[$field])
    +				? form_prep($_POST[$field], $is_textarea)
    +				: form_prep($default, $is_textarea);
     		}
     
    -		return html_escape($OBJ->set_value($field, $default));
    +		return form_prep($OBJ->set_value($field, $default), $is_textarea);
     	}
     }
     
    @@ -862,8 +871,8 @@ if ( ! function_exists('_parse_form_attributes'))
     	 *
     	 * Helper function used by some of the form helpers
     	 *
    -	 * @param	array
    -	 * @param	array
    +	 * @param	array	$attributes	List of attributes
    +	 * @param	array	$default	Default values
     	 * @return	string
     	 */
     	function _parse_form_attributes($attributes, $default)
    @@ -891,7 +900,7 @@ if ( ! function_exists('_parse_form_attributes'))
     		{
     			if ($key === 'value')
     			{
    -				$val = html_escape($val);
    +				$val = form_prep($val);
     			}
     			elseif ($key === 'name' && ! strlen($default['name']))
     			{
    diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
    index c1bf51935..74dac7d29 100644
    --- a/system/libraries/Form_validation.php
    +++ b/system/libraries/Form_validation.php
    @@ -1323,6 +1323,11 @@ class CI_Form_validation {
     	 */
     	public function prep_for_form($data = '')
     	{
    +		if ($this->_safe_form_data === FALSE OR empty($data))
    +		{
    +			return $data;
    +		}
    +
     		if (is_array($data))
     		{
     			foreach ($data as $key => $val)
    @@ -1333,11 +1338,6 @@ class CI_Form_validation {
     			return $data;
     		}
     
    -		if ($this->_safe_form_data === FALSE OR $data === '')
    -		{
    -			return $data;
    -		}
    -
     		return str_replace(array("'", '"', '<', '>'), array(''', '"', '<', '>'), stripslashes($data));
     	}
     
    diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php
    index 03278581d..89165271e 100644
    --- a/tests/codeigniter/helpers/form_helper_test.php
    +++ b/tests/codeigniter/helpers/form_helper_test.php
    @@ -272,6 +272,21 @@ EOH;
     		$this->assertEquals($expected, form_close(''));
     	}
     
    +	// ------------------------------------------------------------------------
    +
    +	public function test_form_prep()
    +	{
    +		$this->assertEquals(
    +			'Here is a string containing "quoted" text.',
    +			form_prep('Here is a string containing "quoted" text.')
    +		);
    +
    +		$this->assertEquals(
    +			'Here is a string containing a <tag>.',
    +			form_prep('Here is a string containing a .', TRUE)
    +		);
    +	}
    +
     }
     
     /* End of file form_helper_test.php */
    \ No newline at end of file
    diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
    index 4aef2a174..511ee00f6 100644
    --- a/user_guide_src/source/changelog.rst
    +++ b/user_guide_src/source/changelog.rst
    @@ -77,7 +77,7 @@ Release Date: Not Released
        -  Added a work-around in ``force_download()`` for a bug Android <= 2.1, where the filename extension needs to be in uppercase.
        -  :doc:`Form Helper ` changes include:
     	 - ``form_dropdown()`` will now also take an array for unity with other form helpers.
    -	 - ``form_prep()`` is now **DEPRECATED** and only acts as an alias for :doc:`common function ` ``html_escape()``.
    +	 - ``form_prep()``'s second argument now only accepts a boolean value, which determines whether the value is escaped for a *textarea* or a regular *input* element.
        -  ``do_hash()`` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
        -  Removed previously deprecated helper function ``js_insert_smiley()`` from :doc:`Smiley Helper `.
        -  :doc:`File Helper ` changes include:
    diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst
    index 015bf1162..02a758694 100644
    --- a/user_guide_src/source/helpers/form_helper.rst
    +++ b/user_guide_src/source/helpers/form_helper.rst
    @@ -463,6 +463,26 @@ the tag. For example
     	echo form_close($string);
     	// Would produce:   
     
    +form_prep()
    +===========
    +
    +Allows you to safely use HTML and characters such as quotes within form
    +elements without breaking out of the form. Consider this example
    +::
    +
    +	$string = 'Here is a string containing "quoted" text.';
    +	
    +
    +Since the above string contains a set of quotes it will cause the form
    +to break. The ``form_prep()`` function converts HTML so that it can be used
    +safely::
    +
    +	
    +
    +.. note:: If you use any of the form helper functions listed in this page the form
    +	values will be prepped automatically, so there is no need to call this
    +	function. Use it only if you are creating your own form elements.
    +
     set_value()
     ===========
     
    @@ -523,26 +543,4 @@ This function is identical to the **set_checkbox()** function above.
     .. note:: If you are using the Form Validation class, you must always specify a rule for your field,
     	even if empty, in order for the set_*() functions to work. This is because if a Form Validation object
     	is defined, the control for set_*() is handed over to a method of the class instead of the generic helper
    -	function.
    -
    -Escaping field values
    -=====================
    -
    -You may need to use HTML and characters such as quotes within form
    -elements. In order to do that safely, you'll need to use
    -:doc:`common function <../general/common_functions>` ``html_escape()``.
    -
    -Consider the following example::
    -
    -	$string = 'Here is a string containing "quoted" text.';
    -	
    -
    -Since the above string contains a set of quotes it will cause the form
    -to break. The ``html_escape()`` function converts HTML so that it can be
    -used safely::
    -
    -	
    -
    -.. note:: If you use any of the form helper functions listed in this page, the form
    -	values will be prepped automatically, so there is no need to call this
    -	function. Use it only if you are creating your own form elements.
    \ No newline at end of file
    +	function.
    \ No newline at end of file
    diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
    index 6d99f4655..fd5eea478 100644
    --- a/user_guide_src/source/installation/upgrade_300.rst
    +++ b/user_guide_src/source/installation/upgrade_300.rst
    @@ -163,16 +163,6 @@ String helper repeater()
     PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in
     CodeIgniter 3.1+.
     
    -.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
    -	rather than later.
    -
    -Form helper form_prep()
    -=======================
    -
    -:doc:`Form Helper <../helpers/form_helper>` function ``form_prep()`` is now just an alias for
    -:doc:`common function <../general/common_functions>` ``html_escape()`` and it's second argument
    -is ignored. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
    -
     .. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner
     	rather than later.
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 075f6fa31aab069aaa21a4d6f13e3ca850012d05 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 15:18:44 +0200
    Subject: Fix an erroneous variable name
    
    ---
     system/helpers/form_helper.php | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
    index 9c4c4dae6..2f451b402 100644
    --- a/system/helpers/form_helper.php
    +++ b/system/helpers/form_helper.php
    @@ -621,7 +621,7 @@ if ( ! function_exists('form_prep'))
     			return str_replace(array('<', '>'), array('<', '>'), stripslashes($str));
     		}
     
    -		return str_replace(array("'", '"'), array(''', '"'), stripslashes($data));
    +		return str_replace(array("'", '"'), array(''', '"'), stripslashes($str));
     	}
     }
     
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From 1a9b7e0d1f96b3cee5692f582d860dca4978dee5 Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 16:23:47 +0200
    Subject: Remove is_numeric() checks from Cart library (superseded by casts to
     float)
    
    ---
     system/libraries/Cart.php | 17 +----------------
     1 file changed, 1 insertion(+), 16 deletions(-)
    
    diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
    index d4b17fa36..6cc7ee230 100644
    --- a/system/libraries/Cart.php
    +++ b/system/libraries/Cart.php
    @@ -193,7 +193,7 @@ class CI_Cart {
     		$items['qty'] = (float) $items['qty'];
     
     		// If the quantity is zero or blank there's nothing for us to do
    -		if ( ! is_numeric($items['qty']) OR $items['qty'] == 0)
    +		if ($items['qty'] == 0)
     		{
     			return FALSE;
     		}
    @@ -224,15 +224,6 @@ class CI_Cart {
     		// Prep the price. Remove leading zeros and anything that isn't a number or decimal point.
     		$items['price'] = (float) $items['price'];
     
    -		// Is the price a valid number?
    -		if ( ! is_numeric($items['price']))
    -		{
    -			log_message('error', 'An invalid price was submitted for product ID: '.$items['id']);
    -			return FALSE;
    -		}
    -
    -		// --------------------------------------------------------------------
    -
     		// We now need to create a unique identifier for the item being inserted into the cart.
     		// Every time something is added to the cart it is stored in the master cart array.
     		// Each row in the cart array, however, must have a unique index that identifies not only
    @@ -350,12 +341,6 @@ class CI_Cart {
     		// Prep the quantity
     		$items['qty'] = (float) $items['qty'];
     
    -		// Is the quantity a number?
    -		if ( ! is_numeric($items['qty']))
    -		{
    -			return FALSE;
    -		}
    -
     		// Is the quantity zero?  If so we will remove the item from the cart.
     		// If the quantity is greater than zero we are updating
     		if ($items['qty'] == 0)
    -- 
    cgit v1.2.3-24-g4f1b
    
    
    From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001
    From: Andrey Andreev 
    Date: Thu, 1 Nov 2012 17:33:58 +0200
    Subject: Manually apply PR #1594 (fixing phpdoc page-level
     generation/warnings)
    
    Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files.
    ---
     application/controllers/welcome.php                            | 3 ++-
     application/views/errors/error_404.php                         | 3 ++-
     application/views/errors/error_db.php                          | 3 ++-
     application/views/errors/error_general.php                     | 3 ++-
     application/views/errors/error_php.php                         | 3 ++-
     application/views/welcome_message.php                          | 3 ++-
     system/core/Benchmark.php                                      | 3 ++-
     system/core/CodeIgniter.php                                    | 3 ++-
     system/core/Common.php                                         | 3 ++-
     system/core/Config.php                                         | 3 ++-
     system/core/Controller.php                                     | 3 ++-
     system/core/Exceptions.php                                     | 3 ++-
     system/core/Hooks.php                                          | 3 ++-
     system/core/Input.php                                          | 3 ++-
     system/core/Lang.php                                           | 3 ++-
     system/core/Loader.php                                         | 3 ++-
     system/core/Model.php                                          | 3 ++-
     system/core/Output.php                                         | 3 ++-
     system/core/Router.php                                         | 3 ++-
     system/core/Security.php                                       | 3 ++-
     system/core/URI.php                                            | 3 ++-
     system/core/Utf8.php                                           | 3 ++-
     system/database/DB.php                                         | 3 ++-
     system/database/DB_cache.php                                   | 3 ++-
     system/database/DB_driver.php                                  | 3 ++-
     system/database/DB_forge.php                                   | 3 ++-
     system/database/DB_query_builder.php                           | 3 ++-
     system/database/DB_result.php                                  | 3 ++-
     system/database/DB_utility.php                                 | 3 ++-
     system/database/drivers/cubrid/cubrid_driver.php               | 3 ++-
     system/database/drivers/cubrid/cubrid_forge.php                | 3 ++-
     system/database/drivers/cubrid/cubrid_result.php               | 3 ++-
     system/database/drivers/cubrid/cubrid_utility.php              | 3 ++-
     system/database/drivers/ibase/ibase_driver.php                 | 3 ++-
     system/database/drivers/ibase/ibase_forge.php                  | 3 ++-
     system/database/drivers/ibase/ibase_result.php                 | 3 ++-
     system/database/drivers/ibase/ibase_utility.php                | 3 ++-
     system/database/drivers/mssql/mssql_driver.php                 | 3 ++-
     system/database/drivers/mssql/mssql_forge.php                  | 3 ++-
     system/database/drivers/mssql/mssql_result.php                 | 3 ++-
     system/database/drivers/mssql/mssql_utility.php                | 3 ++-
     system/database/drivers/mysql/mysql_driver.php                 | 3 ++-
     system/database/drivers/mysql/mysql_forge.php                  | 3 ++-
     system/database/drivers/mysql/mysql_result.php                 | 3 ++-
     system/database/drivers/mysql/mysql_utility.php                | 3 ++-
     system/database/drivers/mysqli/mysqli_driver.php               | 3 ++-
     system/database/drivers/mysqli/mysqli_forge.php                | 3 ++-
     system/database/drivers/mysqli/mysqli_result.php               | 3 ++-
     system/database/drivers/mysqli/mysqli_utility.php              | 3 ++-
     system/database/drivers/oci8/oci8_driver.php                   | 3 ++-
     system/database/drivers/oci8/oci8_forge.php                    | 3 ++-
     system/database/drivers/oci8/oci8_result.php                   | 3 ++-
     system/database/drivers/oci8/oci8_utility.php                  | 3 ++-
     system/database/drivers/odbc/odbc_driver.php                   | 3 ++-
     system/database/drivers/odbc/odbc_forge.php                    | 3 ++-
     system/database/drivers/odbc/odbc_result.php                   | 3 ++-
     system/database/drivers/odbc/odbc_utility.php                  | 3 ++-
     system/database/drivers/pdo/pdo_driver.php                     | 3 ++-
     system/database/drivers/pdo/pdo_forge.php                      | 3 ++-
     system/database/drivers/pdo/pdo_result.php                     | 3 ++-
     system/database/drivers/pdo/pdo_utility.php                    | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_4d_driver.php       | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php   | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php    | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php      | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_informix_driver.php | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php    | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_oci_driver.php      | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php     | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php    | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php   | 3 ++-
     system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php   | 3 ++-
     system/database/drivers/postgre/postgre_driver.php             | 3 ++-
     system/database/drivers/postgre/postgre_forge.php              | 3 ++-
     system/database/drivers/postgre/postgre_result.php             | 3 ++-
     system/database/drivers/postgre/postgre_utility.php            | 3 ++-
     system/database/drivers/sqlite/sqlite_driver.php               | 3 ++-
     system/database/drivers/sqlite/sqlite_forge.php                | 3 ++-
     system/database/drivers/sqlite/sqlite_result.php               | 3 ++-
     system/database/drivers/sqlite/sqlite_utility.php              | 3 ++-
     system/database/drivers/sqlite3/sqlite3_driver.php             | 3 ++-
     system/database/drivers/sqlite3/sqlite3_forge.php              | 3 ++-
     system/database/drivers/sqlite3/sqlite3_result.php             | 3 ++-
     system/database/drivers/sqlite3/sqlite3_utility.php            | 3 ++-
     system/database/drivers/sqlsrv/sqlsrv_driver.php               | 3 ++-
     system/database/drivers/sqlsrv/sqlsrv_forge.php                | 3 ++-
     system/database/drivers/sqlsrv/sqlsrv_result.php               | 3 ++-
     system/database/drivers/sqlsrv/sqlsrv_utility.php              | 3 ++-
     system/helpers/array_helper.php                                | 3 ++-
     system/helpers/captcha_helper.php                              | 3 ++-
     system/helpers/cookie_helper.php                               | 3 ++-
     system/helpers/date_helper.php                                 | 3 ++-
     system/helpers/directory_helper.php                            | 3 ++-
     system/helpers/download_helper.php                             | 3 ++-
     system/helpers/email_helper.php                                | 3 ++-
     system/helpers/file_helper.php                                 | 3 ++-
     system/helpers/form_helper.php                                 | 4 +++-
     system/helpers/html_helper.php                                 | 3 ++-
     system/helpers/inflector_helper.php                            | 3 ++-
     system/helpers/language_helper.php                             | 3 ++-
     system/helpers/number_helper.php                               | 3 ++-
     system/helpers/path_helper.php                                 | 3 ++-
     system/helpers/security_helper.php                             | 3 ++-
     system/helpers/smiley_helper.php                               | 3 ++-
     system/helpers/string_helper.php                               | 3 ++-
     system/helpers/text_helper.php                                 | 3 ++-
     system/helpers/typography_helper.php                           | 3 ++-
     system/helpers/url_helper.php                                  | 3 ++-
     system/helpers/xml_helper.php                                  | 3 ++-
     system/language/english/calendar_lang.php                      | 1 +
     system/language/english/date_lang.php                          | 1 +
     system/language/english/db_lang.php                            | 1 +
     system/language/english/email_lang.php                         | 1 +
     system/language/english/form_validation_lang.php               | 1 +
     system/language/english/ftp_lang.php                           | 1 +
     system/language/english/imglib_lang.php                        | 1 +
     system/language/english/migration_lang.php                     | 2 +-
     system/language/english/number_lang.php                        | 1 +
     system/language/english/profiler_lang.php                      | 1 +
     system/language/english/unit_test_lang.php                     | 1 +
     system/language/english/upload_lang.php                        | 1 +
     system/libraries/Cache/Cache.php                               | 5 +++--
     system/libraries/Cache/drivers/Cache_apc.php                   | 5 +++--
     system/libraries/Cache/drivers/Cache_dummy.php                 | 5 +++--
     system/libraries/Cache/drivers/Cache_file.php                  | 5 +++--
     system/libraries/Cache/drivers/Cache_memcached.php             | 5 +++--
     system/libraries/Cache/drivers/Cache_redis.php                 | 5 +++--
     system/libraries/Cache/drivers/Cache_wincache.php              | 5 +++--
     system/libraries/Calendar.php                                  | 3 ++-
     system/libraries/Cart.php                                      | 3 ++-
     system/libraries/Driver.php                                    | 3 ++-
     system/libraries/Email.php                                     | 3 ++-
     system/libraries/Encrypt.php                                   | 3 ++-
     system/libraries/Form_validation.php                           | 3 ++-
     system/libraries/Ftp.php                                       | 3 ++-
     system/libraries/Image_lib.php                                 | 3 ++-
     system/libraries/Javascript.php                                | 3 ++-
     system/libraries/Log.php                                       | 5 +++--
     system/libraries/Migration.php                                 | 3 ++-
     system/libraries/Pagination.php                                | 3 ++-
     system/libraries/Parser.php                                    | 3 ++-
     system/libraries/Profiler.php                                  | 3 ++-
     system/libraries/Session/Session.php                           | 5 +++--
     system/libraries/Session/drivers/Session_cookie.php            | 5 +++--
     system/libraries/Session/drivers/Session_native.php            | 5 +++--
     system/libraries/Table.php                                     | 3 ++-
     system/libraries/Trackback.php                                 | 3 ++-
     system/libraries/Typography.php                                | 3 ++-
     system/libraries/Unit_test.php                                 | 3 ++-
     system/libraries/Upload.php                                    | 3 ++-
     system/libraries/User_agent.php                                | 3 ++-
     system/libraries/Xmlrpc.php                                    | 3 ++-
     system/libraries/Xmlrpcs.php                                   | 3 ++-
     system/libraries/Zip.php                                       | 3 ++-
     system/libraries/javascript/Jquery.php                         | 3 ++-
     156 files changed, 312 insertions(+), 156 deletions(-)
    
    diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php
    index 1ed82d2a7..f70dd78ad 100644
    --- a/application/controllers/welcome.php
    +++ b/application/controllers/welcome.php
    @@ -1,4 +1,4 @@
    -
     
     
    diff --git a/application/views/errors/error_db.php b/application/views/errors/error_db.php
    index 76ca6df7a..21d5d86ef 100644
    --- a/application/views/errors/error_db.php
    +++ b/application/views/errors/error_db.php
    @@ -1,4 +1,4 @@
    -
     
     
    diff --git a/application/views/errors/error_general.php b/application/views/errors/error_general.php
    index e9baf1665..5bf361113 100644
    --- a/application/views/errors/error_general.php
    +++ b/application/views/errors/error_general.php
    @@ -1,4 +1,4 @@
    -
     
     
    diff --git a/application/views/errors/error_php.php b/application/views/errors/error_php.php
    index b76dc8a9e..c0c4bd622 100644
    --- a/application/views/errors/error_php.php
    +++ b/application/views/errors/error_php.php
    @@ -1,4 +1,4 @@
    -
     
     
    diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php index d227f82d1..27332f456 100644 --- a/application/views/welcome_message.php +++ b/application/views/welcome_message.php @@ -1,4 +1,4 @@ - diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index f94db2721..e80ee54dd 100644 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -1,4 +1,4 @@ -\n\n"; + $message .= '<'."?php if defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 5d637d44a..06f2f562c 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -1,4 +1,4 @@ - Date: Thu, 1 Nov 2012 18:50:43 +0200 Subject: [ci skip] Alter form validation examples including the *matches* rule --- user_guide_src/source/libraries/form_validation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 4d1940212..c010eb578 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -288,8 +288,8 @@ CodeIgniter lets you pipe multiple rules together. Let's try it. Change your rules in the third parameter of rule setting function, like this:: $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]'); - $this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]'); - $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); + $this->form_validation->set_rules('password', 'Password', 'required'); + $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]'); The above code sets the following rules: @@ -315,8 +315,8 @@ can also prep your data in various ways. For example, you can set up rules like this:: $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean'); - $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5'); - $this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required'); + $this->form_validation->set_rules('password', 'Password', 'trim|required|md5'); + $this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required|matches[password]'); $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email'); In the above example, we are "trimming" the fields, converting the -- cgit v1.2.3-24-g4f1b From d1097a1dc30f40c68bc4a5c89d3fadb295c55e56 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 19:55:42 +0200 Subject: Allow use of dashes in controller/method URI segments Supersedes PR #642 --- system/core/Router.php | 10 +++++++++- user_guide_src/source/changelog.rst | 6 ++++-- user_guide_src/source/general/routing.rst | 6 +++--- user_guide_src/source/general/urls.rst | 27 +++++++++++++++++++++++---- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/system/core/Router.php b/system/core/Router.php index 87f3e9e63..89fb74f2f 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -190,6 +190,7 @@ class CI_Router { { show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.'); } + // Is the method being specified? if (strpos($this->default_controller, '/') !== FALSE) { @@ -268,9 +269,13 @@ class CI_Router { return $segments; } + $temp = str_replace('-', '_', $segments[0]); + // Does the requested controller exist in the root folder? - if (file_exists(APPPATH.'controllers/'.$segments[0].'.php')) + if (file_exists(APPPATH.'controllers/'.$temp.'.php')) { + $segments[0] = $temp; + empty($segments[1]) OR $segments[1] = str_replace('-', '_', $segments[1]); return $segments; } @@ -283,6 +288,9 @@ class CI_Router { if (count($segments) > 0) { + $segments[0] = str_replace('-', '_', $segments[0]); + empty($segments[1]) OR $segments[1] = str_replace('-', '_', $segments[1]); + // Does the requested controller exist in the sub-folder? if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php')) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 511ee00f6..8363d2797 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -46,7 +46,7 @@ Release Date: Not Released Only entries in ``$autoload['libraries']`` are auto-loaded now. - Removed previously deprecated EXT constant. - Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties. - - Moved error templates to "application/views/errors" + - Moved error templates to *application/views/errors*. - Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per environment. - Changed detection of ``$view_folder`` so that if it's not found in the current path, it will now also be searched for under the application folder. - Path constants BASEPATH, APPPATH and VIEWPATH are now (internally) defined as absolute paths. @@ -270,7 +270,9 @@ Release Date: Not Released - Added method ``strip_image_tags()``. - Added ``$config['csrf_regeneration']``, which makes token regeneration optional. - Added ``$config['csrf_exclude_uris']``, which allows you list URIs which will not have the CSRF validation methods run. - - Added possibility to route requests using callbacks. + - :doc:`URI Routing ` changes include: + - Added possibility to route requests using callbacks. + - Added possibility to use dashes in the controller and method URI segments (translated to underscores). Bug fixes for 3.0 ------------------ diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 43c181669..e6174cc0d 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -162,8 +162,8 @@ appear by default. This route indicates which controller class should be loaded if the requested controller is not found. It will override the default 404 error page. It won't affect to the show_404() function, which will -continue loading the default error_404.php file at -application/errors/error_404.php. +continue loading the default *error_404.php* file at +*application/errors/error_404.php*. .. important:: The reserved routes must come before any wildcard or - regular expression routes. + regular expression routes. \ No newline at end of file diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst index 6b390b559..20f80632a 100644 --- a/user_guide_src/source/general/urls.rst +++ b/user_guide_src/source/general/urls.rst @@ -28,9 +28,28 @@ approach, usually represent:: #. The third, and any additional segments, represent the ID and any variables that will be passed to the controller. -The :doc:`URI Class <../libraries/uri>` and the :doc:`URL Helper <../helpers/url_helper>` contain functions that make it -easy to work with your URI data. In addition, your URLs can be remapped -using the :doc:`URI Routing ` feature for more flexibility. +The :doc:`URI Class <../libraries/uri>` and the :doc:`URL Helper <../helpers/url_helper>` +contain functions that make it easy to work with your URI data. In addition, +your URLs can be remapped using the :doc:`URI Routing ` feature for +more flexibility. + +Friendly URLs +============= + +As you might guess, since there's a straight relationship between +URI segments and the controller/method pair that's being called, +those two determining segments must represent a valid class and +method name. +You may however also use dashes in the class/method-representing +segments, and they will automatically be translated to underscores +in order to be valid routed segments. + +For example:: + + example.com/my-settings/change-password/ + +The above example will route to the ``My_settings`` controller and +its method ``change_password()``. Removing the index.php file =========================== @@ -94,4 +113,4 @@ active. Your controllers and functions will then be accessible using the .. note:: If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed - to work with segment based URLs. + to work with segment based URLs. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 254735ee011d99f5c7fe3825849d7ec0b54bd4e1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 21:21:20 +0200 Subject: Fix issue #122 --- system/core/URI.php | 9 ++++++++- user_guide_src/source/changelog.rst | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/system/core/URI.php b/system/core/URI.php index 2f6cade34..e2cac8d89 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -696,7 +696,14 @@ class CI_URI { */ public function ruri_string() { - return implode('/', $this->rsegment_array()); + global $RTR; + + if (($dir = $RTR->fetch_directory()) === '/') + { + $dir = ''; + } + + return $dir.implode('/', $this->rsegment_array()); } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8363d2797..a4af27254 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -411,6 +411,7 @@ Bug fixes for 3.0 - Fixed a bug (#658) - :doc:`Routing ` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment. - Fixed a bug (#1938) - :doc:`Email Library ` removed multiple spaces inside a pre-formatted plain text message. - Fixed a bug (#388, #705) - :doc:`URI Library ` didn't apply URL-decoding to URI segments that it got from **REQUEST_URI** and/or **QUERY_STRING**. +- Fixed a bug (#122) - :doc:`URI Library ` method ``ruri_string()`` didn't include a directory if one is used. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From 597ea27a0660bdf72f84d74566cc842e4da37efd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 22:56:26 +0200 Subject: [ci skip] DocBlocks for Email, Ftp, Unit_test and Javascript libraries Partially fixes issue #1295 --- system/libraries/Email.php | 327 +++++++++++++++++++++++++++++++++++++--- system/libraries/Ftp.php | 103 +++++++++---- system/libraries/Javascript.php | 17 ++- system/libraries/Unit_test.php | 51 ++++++- 4 files changed, 437 insertions(+), 61 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 0109e2890..62f196c05 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -39,55 +39,340 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_Email { + /** + * Used as the User-Agent and X-Mailer headers' value. + * + * @var string + */ public $useragent = 'CodeIgniter'; + + /** + * Path to the Sendmail binary. + * + * @var string + */ public $mailpath = '/usr/sbin/sendmail'; // Sendmail path + + /** + * Which method to use for sending e-mails. + * + * @var string 'mail', 'sendmail' or 'smtp' + */ public $protocol = 'mail'; // mail/sendmail/smtp - public $smtp_host = ''; // SMTP Server. Example: mail.earthlink.net - public $smtp_user = ''; // SMTP Username - public $smtp_pass = ''; // SMTP Password - public $smtp_port = 25; // SMTP Port - public $smtp_timeout = 5; // SMTP Timeout in seconds - public $smtp_crypto = ''; // SMTP Encryption. Can be null, tls or ssl. - public $wordwrap = TRUE; // TRUE/FALSE - Turns word-wrap on/off - public $wrapchars = 76; // Number of characters to wrap at. - public $mailtype = 'text'; // text/html - Defines email formatting - public $charset = 'utf-8'; // Default char set: iso-8859-1 or us-ascii + + /** + * STMP Server host + * + * @var string + */ + public $smtp_host = ''; + + /** + * SMTP Username + * + * @var string + */ + public $smtp_user = ''; + + /** + * SMTP Password + * + * @var string + */ + public $smtp_pass = ''; + + /** + * SMTP Server port + * + * @var int + */ + public $smtp_port = 25; + + /** + * SMTP connection timeout in seconds + * + * @var int + */ + public $smtp_timeout = 5; + + /** + * SMTP Encryption + * + * @var string NULL, 'tls' or 'ssl' + */ + public $smtp_crypto = NULL; + + /** + * Whether to apply word-wrapping to the message body. + * + * @var bool + */ + public $wordwrap = TRUE; + + /** + * Number of characters to wrap at. + * + * @see CI_Email::$wordwrap + * @var int + */ + public $wrapchars = 76; + + /** + * Message format. + * + * @var string 'text' or 'html' + */ + public $mailtype = 'text'; + + /** + * Character set (default: utf-8) + * + * @var string + */ + public $charset = 'utf-8'; + + /** + * Multipart message + * + * @var string 'mixed' (in the body) or 'related' (separate) + */ public $multipart = 'mixed'; // "mixed" (in the body) or "related" (separate) - public $alt_message = ''; // Alternative message for HTML emails - public $validate = FALSE; // TRUE/FALSE - Enables email validation + + /** + * Alternative message (for HTML messages only) + * + * @var string + */ + public $alt_message = ''; + + /** + * Whether to validate e-mail addresses. + * + * @var bool + */ + public $validate = FALSE; + + /** + * X-Priority header value. + * + * @var int 1-5 + */ public $priority = 3; // Default priority (1 - 5) + + /** + * Newline character sequence. + * Use "\r\n" to comply with RFC 822. + * + * @link http://www.ietf.org/rfc/rfc822.txt + * @var string "\r\n" or "\n" + */ public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) - public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers, - // even on the receiving end think they need to muck with CRLFs, so using "\n", while - // distasteful, is the only thing that seems to work for all environments. - public $dsn = FALSE; // Delivery Status Notification - public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo. - public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature - public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch + /** + * CRLF character sequence + * + * RFC 2045 specifies that for 'quoted-printable' encoding, + * "\r\n" must be used. However, it appears that some servers + * (even on the receiving end) don't handle it properly and + * switching to "\n", while improper, is the only solution + * that seems to work for all environments. + * + * @link http://www.ietf.org/rfc/rfc822.txt + * @var string + */ + public $crlf = "\n"; + + /** + * Whether to use Delivery Status Notification. + * + * @var bool + */ + public $dsn = FALSE; + + /** + * Whether to send multipart alternatives. + * Yahoo! doesn't seem to like these. + * + * @var bool + */ + public $send_multipart = TRUE; + + /** + * Whether to send messages to BCC recipients in batches. + * + * @var bool + */ + public $bcc_batch_mode = FALSE; + + /** + * BCC Batch max number size. + * + * @see CI_Email::$bcc_batch_mode + * @var int + */ + public $bcc_batch_size = 200; + + // -------------------------------------------------------------------- + + /** + * Whether PHP is running in safe mode. Initialized by the class constructor. + * + * @var bool + */ protected $_safe_mode = FALSE; + + /** + * Subject header + * + * @var string + */ protected $_subject = ''; + + /** + * Message body + * + * @var string + */ protected $_body = ''; + + /** + * Final message body to be sent. + * + * @var string + */ protected $_finalbody = ''; + + /** + * multipart/alternative boundary + * + * @var string + */ protected $_alt_boundary = ''; + + /** + * Attachment boundary + * + * @var string + */ protected $_atc_boundary = ''; + + /** + * Final headers to send + * + * @var string + */ protected $_header_str = ''; + + /** + * SMTP Connection socket placeholder + * + * @var resource + */ protected $_smtp_connect = ''; + + /** + * Mail encoding + * + * @var string '8bit' or '7bit' + */ protected $_encoding = '8bit'; - protected $_IP = FALSE; + + /** + * Whether to perform SMTP authentication + * + * @var bool + */ protected $_smtp_auth = FALSE; + + /** + * Whether to send a Reply-To header + * + * @var bool + */ protected $_replyto_flag = FALSE; + + /** + * Debug messages + * + * @see CI_Email::print_debugger() + * @var string + */ protected $_debug_msg = array(); + + /** + * Recipients + * + * @var string[] + */ protected $_recipients = array(); + + /** + * CC Recipients + * + * @var string[] + */ protected $_cc_array = array(); + + /** + * BCC Recipients + * + * @var string[] + */ protected $_bcc_array = array(); + + /** + * Message headers + * + * @var string[] + */ protected $_headers = array(); + + /** + * Attachment data + * + * @var array + */ protected $_attachments = array(); + + /** + * Valid $protocol values + * + * @see CI_Email::$protocol + * @var string[] + */ protected $_protocols = array('mail', 'sendmail', 'smtp'); - protected $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix) + + /** + * Base charsets + * + * Character sets valid for 7-bit encoding, + * excluding language suffix. + * + * @var string[] + */ + protected $_base_charsets = array('us-ascii', 'iso-2022-'); + + /** + * Bit depths + * + * Valid mail encodings + * + * @see CI_Email::$_encoding + * @var string[] + */ protected $_bit_depths = array('7bit', '8bit'); + + /** + * $priority translations + * + * Actual values to send with the X-Priority header + * + * @var string[] + */ protected $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)'); + // -------------------------------------------------------------------- + /** * Constructor - Sets Email Preferences * diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index b9954c7f2..60c03b5ad 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -37,18 +37,63 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_FTP { + /** + * FTP Server hostname + * + * @var string + */ public $hostname = ''; + + /** + * FTP Username + * + * @var string + */ public $username = ''; + + /** + * FTP Password + * + * @var string + */ public $password = ''; + + /** + * FTP Server port + * + * @var int + */ public $port = 21; + + /** + * Passive mode flag + * + * @var bool + */ public $passive = TRUE; + + /** + * Debug flag + * + * Specifies whether to display error messages. + * + * @var bool + */ public $debug = FALSE; + + /** + * Connection + * + * @var resource + */ public $conn_id = FALSE; + // -------------------------------------------------------------------- + /** * Constructor * - * @param array $config = array() + * @param array $config * @return void */ public function __construct($config = array()) @@ -66,7 +111,7 @@ class CI_FTP { /** * Initialize preferences * - * @param array + * @param array $config * @return void */ public function initialize($config = array()) @@ -88,7 +133,7 @@ class CI_FTP { /** * FTP Connect * - * @param array the connection values + * @param array $config Connection values * @return bool */ public function connect($config = array()) @@ -168,8 +213,8 @@ class CI_FTP { * so we do it by trying to change to a particular directory. * Internally, this parameter is only used by the "mirror" function below. * - * @param string - * @param bool + * @param string $path + * @param bool $supress_debug * @return bool */ public function changedir($path = '', $supress_debug = FALSE) @@ -198,8 +243,8 @@ class CI_FTP { /** * Create a directory * - * @param string - * @param int + * @param string $path + * @param int $permissions * @return bool */ public function mkdir($path = '', $permissions = NULL) @@ -234,10 +279,10 @@ class CI_FTP { /** * Upload a file to the server * - * @param string - * @param string - * @param string - * @param int + * @param string $locpath + * @param string $rempath + * @param string $mode + * @param int $permissions * @return bool */ public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL) @@ -288,9 +333,9 @@ class CI_FTP { /** * Download a file from a remote server to the local server * - * @param string - * @param string - * @param string + * @param string $rempath + * @param string $locpath + * @param string $mode * @return bool */ public function download($rempath, $locpath, $mode = 'auto') @@ -329,9 +374,9 @@ class CI_FTP { /** * Rename (or move) a file * - * @param string - * @param string - * @param bool + * @param string $old_file + * @param string $new_file + * @param bool $move * @return bool */ public function rename($old_file, $new_file, $move = FALSE) @@ -360,8 +405,8 @@ class CI_FTP { /** * Move a file * - * @param string - * @param string + * @param string $old_file + * @param string $new_file * @return bool */ public function move($old_file, $new_file) @@ -374,7 +419,7 @@ class CI_FTP { /** * Rename (or move) a file * - * @param string + * @param string $filepath * @return bool */ public function delete_file($filepath) @@ -404,7 +449,7 @@ class CI_FTP { * Delete a folder and recursively delete everything (including sub-folders) * containted within it. * - * @param string + * @param string $filepath * @return bool */ public function delete_dir($filepath) @@ -451,8 +496,8 @@ class CI_FTP { /** * Set file permissions * - * @param string the file path - * @param int the permissions + * @param string $path File path + * @param int $perm Permissions * @return bool */ public function chmod($path, $perm) @@ -481,7 +526,7 @@ class CI_FTP { /** * FTP List files in the specified directory * - * @param string $path = '.' + * @param string $path * @return array */ public function list_files($path = '.') @@ -504,8 +549,8 @@ class CI_FTP { * Whatever the directory structure of the original file path will be * recreated on the server. * - * @param string path to source with trailing slash - * @param string path to destination - include the base folder with trailing slash + * @param string $locpath Path to source with trailing slash + * @param string $rempath Path to destination - include the base folder with trailing slash * @return bool */ public function mirror($locpath, $rempath) @@ -551,7 +596,7 @@ class CI_FTP { /** * Extract the file extension * - * @param string + * @param string $filename * @return string */ protected function _getext($filename) @@ -570,7 +615,7 @@ class CI_FTP { /** * Set the upload type * - * @param string + * @param string $ext Filename extension * @return string */ protected function _settype($ext) @@ -617,7 +662,7 @@ class CI_FTP { /** * Display error message * - * @param string + * @param string $line * @return void */ protected function _error($line) diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index c2f458de8..9a15cddaa 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -37,12 +37,19 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_Javascript { + /** + * JavaScript location + * + * @var string + */ protected $_javascript_location = 'js'; + // -------------------------------------------------------------------- + /** * Constructor * - * @param array $params = array() + * @param array $params * @return void */ public function __construct($params = array()) @@ -587,8 +594,8 @@ class CI_Javascript { * * gather together all script needing to be output * - * @param string $view_var = 'script_foot' - * @param bool $script_tags = TRUE + * @param string $view_var + * @param bool $script_tags * @return string */ public function compile($view_var = 'script_foot', $script_tags = TRUE) @@ -617,8 +624,8 @@ class CI_Javascript { * * Outputs a