summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php2
-rwxr-xr-xsystem/core/CodeIgniter.php2
-rw-r--r--system/core/Common.php5
-rwxr-xr-xsystem/core/Config.php2
-rwxr-xr-xsystem/core/Input.php8
-rw-r--r--system/core/Loader.php2
-rwxr-xr-xsystem/core/Output.php6
-rwxr-xr-xsystem/core/Router.php6
-rwxr-xr-xsystem/core/Security.php2
-rwxr-xr-xsystem/core/URI.php2
-rw-r--r--system/core/Utf8.php2
-rwxr-xr-xsystem/database/DB.php4
-rw-r--r--system/database/DB_cache.php12
-rw-r--r--system/database/DB_query_builder.php12
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php4
-rw-r--r--system/database/drivers/mssql/mssql_driver.php4
-rw-r--r--system/database/drivers/mysql/mysql_driver.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php12
-rw-r--r--system/database/drivers/odbc/odbc_driver.php6
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php8
-rw-r--r--system/database/drivers/sqlite3/sqlite3_driver.php4
-rw-r--r--system/helpers/date_helper.php10
-rw-r--r--system/libraries/Calendar.php12
-rw-r--r--system/libraries/Cart.php4
-rw-r--r--system/libraries/Encrypt.php4
-rw-r--r--system/libraries/Image_lib.php6
-rw-r--r--system/libraries/Session.php2
-rw-r--r--system/libraries/Trackback.php2
-rw-r--r--system/libraries/Upload.php4
-rw-r--r--tests/codeigniter/database/query_builder/insert_test.php8
-rw-r--r--tests/mocks/autoloader.php8
-rw-r--r--tests/mocks/database/drivers/sqlite.php2
-rw-r--r--tests/phpunit.xml25
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/general/environments.rst10
35 files changed, 120 insertions, 85 deletions
diff --git a/index.php b/index.php
index 5a1190112..3b00dd360 100644
--- a/index.php
+++ b/index.php
@@ -42,7 +42,7 @@
*
* NOTE: If you change these, also change the error_reporting() code below
*/
- define('ENVIRONMENT', 'development');
+ define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 182f17ab3..b3e984d4d 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 ( ! empty($assign_to_config['subclass_prefix']))
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
diff --git a/system/core/Common.php b/system/core/Common.php
index a773c4f20..8af7d6323 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -436,12 +436,11 @@ 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 === '')
+ elseif (isset($stati[$code]) && $text === '')
{
$text = $stati[$code];
}
diff --git a/system/core/Config.php b/system/core/Config.php
index 0e5fa5265..3de1bcb96 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -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;
}
diff --git a/system/core/Input.php b/system/core/Input.php
index 284b15697..73f46ba6a 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -267,18 +267,22 @@ class CI_Input {
{
$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') !== '/')
{
$path = config_item('cookie_path');
}
+
if ($secure === FALSE && config_item('cookie_secure') !== FALSE)
{
$secure = config_item('cookie_secure');
}
+
if ($httponly === FALSE && config_item('cookie_httponly') !== FALSE)
{
$httponly = config_item('cookie_httponly');
@@ -324,7 +328,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);
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 66a9e7faa..09e948714 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -261,7 +261,7 @@ class CI_Loader {
$model = substr($model, $last_slash);
}
- if ($name === '')
+ if (empty($name))
{
$name = $model;
}
diff --git a/system/core/Output.php b/system/core/Output.php
index 496948ab7..9b85b3ec4 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -101,7 +101,7 @@ class CI_Output {
*/
public function __construct()
{
- $this->_zlib_oc = @ini_get('zlib.output_compression');
+ $this->_zlib_oc = (bool) @ini_get('zlib.output_compression');
// Get mime types for later
if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.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;
}
@@ -505,7 +505,7 @@ class CI_Output {
*
* @param object config class
* @param object uri class
- * @return void
+ * @return bool
*/
public function _display_cache(&$CFG, &$URI)
{
diff --git a/system/core/Router.php b/system/core/Router.php
index 93875bdd9..5bc053045 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();
}
@@ -483,14 +483,14 @@ class CI_Router {
$this->set_directory($routing['directory']);
}
- if (isset($routing['controller']) && $routing['controller'] !== '')
+ if ( ! empty($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 9cbcd9248..4593a1090 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -847,4 +847,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 0afb374c2..a575bc36e 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -111,7 +111,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');
+ $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
if (trim($path, '/') !== '' && $path !== '/'.SELF)
{
$this->_set_uri_string($path);
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 2b5a1f5eb..0a7ec501c 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
+ && (bool) @ini_get('mbstring.func_overload') !== TRUE // Multibyte string function overloading cannot be enabled
&& $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8
)
{
diff --git a/system/database/DB.php b/system/database/DB.php
index b0113b6f4..00d14b43e 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -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 (empty($params['dbdriver']))
{
show_error('You have not selected a database type to connect to.');
}
@@ -157,7 +157,7 @@ function &DB($params = '', $query_builder_override = NULL)
$DB->initialize();
}
- if (isset($params['stricton']) && $params['stricton'] === TRUE)
+ if ( ! empty($params['stricton']))
{
$DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
}
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 443bbce5f..14f3c21bc 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -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);
@@ -156,12 +156,12 @@ class CI_DB_Cache {
{
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 === '')
{
- $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_query_builder.php b/system/database/DB_query_builder.php
index 45d68cd39..7a0ea0c30 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -675,19 +675,19 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
if ($side === 'none')
{
- $like_statement = $prefix." $k $not LIKE '{$v}'";
+ $like_statement = "{$prefix} $k $not LIKE '{$v}'";
}
elseif ($side === 'before')
{
- $like_statement = $prefix." $k $not LIKE '%{$v}'";
+ $like_statement = "{$prefix} $k $not LIKE '%{$v}'";
}
elseif ($side === 'after')
{
- $like_statement = $prefix." $k $not LIKE '{$v}%'";
+ $like_statement = "{$prefix} $k $not LIKE '{$v}%'";
}
else
{
- $like_statement = $prefix." $k $not LIKE '%{$v}%'";
+ $like_statement = "{$prefix} $k $not LIKE '%{$v}%'";
}
// some platforms require an escape sequence definition for LIKE wildcards
@@ -1535,7 +1535,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->where($where);
}
- if ($limit !== NULL)
+ if ($limit != NULL)
{
$this->limit($limit);
}
@@ -1856,7 +1856,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->where($where);
}
- if ($limit !== NULL)
+ if ($limit != NULL)
{
$this->limit($limit);
}
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index b7763d90f..6b9286fa0 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;
+ empty($this->port) OR $this->port = 33000;
}
}
@@ -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/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 5bd666960..697b2fd28 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 ( ! empty($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 ( ! empty($this->port))
{
$this->hostname .= ','.$this->port;
}
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index fc9bbdc4e..5937b223b 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 ( ! empty($this->port))
{
$this->hostname .= ':'.$this->port;
}
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 5814aceb9..02f893755 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -71,9 +71,9 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
public function db_connect()
{
- 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);
+ return empty($this->port)
+ ? @new mysqli($this->hostname, $this->username, $this->password, $this->database)
+ : @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port);
}
// --------------------------------------------------------------------
@@ -91,9 +91,9 @@ class CI_DB_mysqli_driver extends CI_DB {
return $this->db_connect();
}
- 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);
+ return empty($this->port)
+ ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database)
+ : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index b493e9335..c3735da05 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 (empty($this->dsn))
{
$this->dsn = $this->hostname;
}
@@ -254,9 +254,9 @@ class CI_DB_odbc_driver extends CI_DB {
*/
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
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index c87a16ba8..f52b1ba1b 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 && $this->dbprefix != '')
{
$sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
@@ -404,16 +404,16 @@ class CI_DB_sqlite_driver extends CI_DB {
*/
protected function _limit($sql, $limit, $offset)
{
- if ($offset === 0)
+ if ($offset == 0)
{
$offset = '';
}
else
{
- $offset .= ", ";
+ $offset .= ', ';
}
- return $sql."LIMIT ".$offset.$limit;
+ return $sql.'LIMIT '.$offset.$limit;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index ea4cf2d4f..2acefbcf4 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -87,7 +87,7 @@ class CI_DB_sqlite3_driver extends CI_DB {
public function db_pconnect()
{
log_message('debug', 'SQLite3 doesn\'t support persistent connections');
- return $this->db_pconnect();
+ return $this->db_connect();
}
// --------------------------------------------------------------------
@@ -104,7 +104,7 @@ class CI_DB_sqlite3_driver extends CI_DB {
return $this->data_cache['version'];
}
- $version = $this->conn_id->version();
+ $version = SQLite3::version();
return $this->data_cache['version'] = $version['versionString'];
}
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 0bda33378..c601dc9e5 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -285,7 +285,7 @@ if ( ! function_exists('days_in_month'))
$year = date('Y');
}
- if ($month === 2)
+ if ($month == 2)
{
if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0))
{
@@ -472,9 +472,9 @@ if ( ! function_exists('human_to_unix'))
$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
{
@@ -482,7 +482,7 @@ if ( ! function_exists('human_to_unix'))
$sec = '00';
}
- if (isset($split['2']))
+ if (isset($split[2]))
{
$ampm = strtolower($split[2]);
@@ -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';
}
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 753033a34..969a7610a 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -205,7 +205,7 @@ class CI_Calendar {
$cur_month = date('m', $this->local_time);
$cur_day = date('j', $this->local_time);
- $is_current_month = ($cur_year === $year && $cur_month === $month);
+ $is_current_month = ($cur_year == $year && $cur_month == $month);
// Generate the template data array
$this->parse_template();
@@ -258,21 +258,21 @@ class CI_Calendar {
for ($i = 0; $i < 7; $i++)
{
- $out .= ($is_current_month === TRUE && $day === $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
if ($day > 0 && $day <= $total_days)
{
if (isset($data[$day]))
{
// Cells with content
- $temp = ($is_current_month === TRUE && $day === $cur_day) ?
+ $temp = ($is_current_month === TRUE && $day == $cur_day) ?
$this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
$out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp);
}
else
{
// Cells with no content
- $temp = ($is_current_month === TRUE && $day === $cur_day) ?
+ $temp = ($is_current_month === TRUE && $day == $cur_day) ?
$this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
@@ -283,7 +283,7 @@ class CI_Calendar {
$out .= $this->temp['cal_cell_blank'];
}
- $out .= ($is_current_month === TRUE && $day === $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
$day++;
}
@@ -419,7 +419,7 @@ class CI_Calendar {
}
// Is the year a leap year?
- if ($month === 2)
+ if ($month == 2)
{
if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0))
{
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 87b1877c3..c442f88da 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 ( ! is_numeric($items['qty']) OR $items['qty'] == 0)
{
return FALSE;
}
@@ -358,7 +358,7 @@ class CI_Cart {
// 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)
+ if ($items['qty'] == 0)
{
unset($this->_cart_contents[$items['rowid']]);
}
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 102b1dfdd..959e2eea8 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -449,7 +449,7 @@ class CI_Encrypt {
*/
protected function _get_cipher()
{
- if ($this->_mcrypt_cipher === '')
+ if ($this->_mcrypt_cipher === NULL)
{
return $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
}
@@ -466,7 +466,7 @@ class CI_Encrypt {
*/
protected function _get_mode()
{
- if ($this->_mcrypt_mode === '')
+ if ($this->_mcrypt_mode === NULL)
{
return $this->_mcrypt_mode = MCRYPT_MODE_CBC;
}
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index c3973a02f..4735dfd08 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -610,8 +610,8 @@ class CI_Image_lib {
}
// Set the x/y coordinates
- $this->x_axis = ($this->x_axis === '' OR ! preg_match('/^[0-9]+$/', $this->x_axis)) ? 0 : $this->x_axis;
- $this->y_axis = ($this->y_axis === '' OR ! preg_match('/^[0-9]+$/', $this->y_axis)) ? 0 : $this->y_axis;
+ is_numeric($this->x_axis) OR $this->x_axis = 0;
+ is_numeric($this->y_axis) OR $this->y_axis = 0;
// Watermark-related Stuff...
if ($this->wm_overlay_path !== '')
@@ -750,7 +750,7 @@ class CI_Image_lib {
if ($this->gd_version() !== FALSE)
{
$gd_version = str_replace('0', '', $this->gd_version());
- $v2_override = ($gd_version === 2) ? TRUE : FALSE;
+ $v2_override = ($gd_version === 2);
}
}
else
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index cc992a5b8..7beedd96b 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -359,7 +359,7 @@ class CI_Session {
// Is there custom data? If so, add it to the main session array
$row = $query->row();
- if (isset($row->user_data) && $row->user_data !== '')
+ if ( ! empty($row->user_data))
{
$custom_data = $this->_unserialize($row->user_data);
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 0da85a022..9a680dc2a 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -132,7 +132,7 @@ class CI_Trackback {
{
foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
{
- if ( ! isset($_POST[$val]) OR $_POST[$val] === '')
+ if (empty($_POST[$val]))
{
$this->set_error('The following required POST variable is missing: '.$val);
return FALSE;
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index e4cc54b21..bd97a611b 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -809,12 +809,12 @@ class CI_Upload {
{
$file = $this->file_temp;
- if (filesize($file) === 0)
+ if (filesize($file) == 0)
{
return FALSE;
}
- if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') !== '')
+ if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit'))
{
$current = ini_get('memory_limit') * 1024 * 1024;
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
index 8ba60e242..a9aafb66e 100644
--- a/tests/codeigniter/database/query_builder/insert_test.php
+++ b/tests/codeigniter/database/query_builder/insert_test.php
@@ -26,7 +26,7 @@ class Insert_test extends CI_TestCase {
public function test_insert()
{
$job_data = array('id' => 1, 'name' => 'Grocery Sales', 'description' => 'Discount!');
-
+
// Do normal insert
$this->assertTrue($this->db->insert('job', $job_data));
@@ -45,10 +45,10 @@ class Insert_test extends CI_TestCase {
public function test_insert_batch()
{
$job_datas = array(
- array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'),
+ array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'),
array('id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'),
);
-
+
// Do insert batch except for sqlite driver
if (strpos(DB_DRIVER, 'sqlite') === FALSE)
{
@@ -62,5 +62,5 @@ class Insert_test extends CI_TestCase {
$this->assertEquals('Cab Driver', $job_3->name);
}
}
-
+
} \ No newline at end of file
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index ff2196d4e..90aabcbe6 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -7,9 +7,9 @@
// Prototype :
//
// $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
+// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php
// and so on...
-function autoload($class)
+function autoload($class)
{
$dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR;
@@ -75,13 +75,13 @@ function autoload($class)
{
$trace = debug_backtrace();
- // If the autoload call came from `class_exists` or `file_exists`,
+ // If the autoload call came from `class_exists` or `file_exists`,
// we skipped and return FALSE
if ($trace[2]['function'] === 'class_exists' OR $trace[2]['function'] === 'file_exists')
{
return FALSE;
}
-
+
throw new InvalidArgumentException("Unable to load $class.");
}
diff --git a/tests/mocks/database/drivers/sqlite.php b/tests/mocks/database/drivers/sqlite.php
index 76a182cbf..15cefbf53 100644
--- a/tests/mocks/database/drivers/sqlite.php
+++ b/tests/mocks/database/drivers/sqlite.php
@@ -1,7 +1,7 @@
<?php
class Mock_Database_Drivers_Sqlite extends Mock_Database_DB_Driver {
-
+
/**
* Instantiate the database driver
*
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
new file mode 100644
index 000000000..56cb8841c
--- /dev/null
+++ b/tests/phpunit.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ bootstrap="./Bootstrap.php"
+ colors="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false">
+ <testsuites>
+ <testsuite name="CodeIgniter Core Test Suite">
+ <directory suffix="test.php">./codeigniter/core</directory>
+ <directory suffix="test.php">./codeigniter/helpers</directory>
+ <directory suffix="test.php">./codeigniter/libraries</directory>
+ </testsuite>
+ </testsuites>
+ <filters>
+ <blacklist>
+ <directory suffix=".php">PEAR_INSTALL_DIR</directory>
+ <directory suffix=".php">PHP_LIBDIR</directory>
+ </blacklist>
+ </filters>
+</phpunit> \ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index c8c2ef010..587e56ea7 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -19,6 +19,7 @@ Release Date: Not Released
- General Changes
- PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4.
+ - ``$_SERVER['CI_ENV']`` can now be set to control the ``ENVIRONMENT`` constant.
- Added an optional backtrace to php-error template.
- Added Android to the list of user agents.
- Added Windows 7, Android, Blackberry and iOS to the list of user platforms.
diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst
index 40725feba..fa1b096e2 100644
--- a/user_guide_src/source/general/environments.rst
+++ b/user_guide_src/source/general/environments.rst
@@ -11,10 +11,16 @@ when "live".
The ENVIRONMENT Constant
========================
-By default, CodeIgniter comes with the environment constant set to
+By default, CodeIgniter comes with the environment constant set to use
+the value provided in ``$_SERVER['CI_ENV']``, otherwise defaults to
'development'. At the top of index.php, you will see::
- define('ENVIRONMENT', 'development');
+ define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
+
+This server variable can be set in your .htaccess file, or Apache
+config using `SetEnv <https://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv>`_.
+Alternative methods are available for nginx and other servers, or you can
+remove this logic entirely and set the constant based on the HTTP_HOST or IP.
In addition to affecting some basic framework behavior (see the next
section), you may use this constant in your own development to