Merge pull request #3835 from ftwbzhao/feature/userguide
[ci skip] Update APC section link
diff --git a/.gitignore b/.gitignore
index 9edcfca..5982f9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,4 +13,15 @@
user_guide_src/cilexer/dist/*
user_guide_src/cilexer/pycilexer.egg-info/*
/vendor/
-/nbproject/
\ No newline at end of file
+
+# IDE Files
+#-------------------------
+/nbproject/
+.idea/*
+
+## Sublime Text cache files
+*.tmlanguage.cache
+*.tmPreferences.cache
+*.stTheme.cache
+*.sublime-workspace
+*.sublime-project
diff --git a/application/config/config.php b/application/config/config.php
index f78371f..94e5d28 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -192,8 +192,6 @@
| Error Logging Threshold
|--------------------------------------------------------------------------
|
-| If you have enabled error logging, you can set an error threshold to
-| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
index d02dea9..ac406e3 100644
--- a/application/config/foreign_chars.php
+++ b/application/config/foreign_chars.php
@@ -56,6 +56,7 @@
'/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
'/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
'/ț|ţ|ť|ŧ|т/' => 't',
+ '/Þ|þ/' => 'th',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
'/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
diff --git a/application/config/mimes.php b/application/config/mimes.php
index 8eff4d2..98a6fde 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -127,7 +127,7 @@
'rsa' => 'application/x-pkcs7',
'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
'3g2' => 'video/3gpp2',
- '3gp' => 'video/3gp',
+ '3gp' => array('video/3gp', 'video/3gpp'),
'mp4' => 'video/mp4',
'm4a' => 'audio/x-m4a',
'f4v' => 'video/mp4',
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 6f3295a..2fd9554 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -62,6 +62,7 @@
$browsers = array(
'OPR' => 'Opera',
'Flock' => 'Flock',
+ 'Edge' => 'Spartan',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
diff --git a/composer.json b/composer.json
index 4ff60c5..0653a78 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,15 @@
{
- "description" : "The CodeIgniter framework",
- "name" : "codeigniter/framework",
+ "description": "The CodeIgniter framework",
+ "name": "codeigniter/framework",
+ "type": "project",
+ "homepage": "http://codeigniter.com",
"license": "MIT",
+ "support": {
+ "forum": "http://forum.codeigniter.com/",
+ "wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
+ "irc": "irc://irc.freenode.net/codeigniter",
+ "source": "https://github.com/bcit-ci/CodeIgniter"
+ },
"require": {
"php": ">=5.2.4"
},
diff --git a/system/core/Common.php b/system/core/Common.php
index a96828e..b850fd3 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -506,6 +506,9 @@
{
is_int($code) OR $code = (int) $code;
$stati = array(
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
@@ -524,6 +527,7 @@
400 => 'Bad Request',
401 => 'Unauthorized',
+ 402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
@@ -745,7 +749,7 @@
{
return $var;
}
-
+
if (is_array($var))
{
return array_map('html_escape', $var, array_fill(0, count($var), $double_encode));
diff --git a/system/core/Output.php b/system/core/Output.php
index 02f6693..e7d559a 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -674,7 +674,7 @@
$cache_info = unserialize($match[1]);
$expire = $cache_info['expire'];
- $last_modified = filemtime($cache_path);
+ $last_modified = filemtime($filepath);
// Has the file expired?
if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path))
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 3d35c2d..64ee880 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1218,7 +1218,7 @@
/**
* Fetch Field Names
*
- * @param string the table name
+ * @param string $table Table name
* @return array
*/
public function list_fields($table)
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
index 67dc5f5..206d835 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
@@ -157,6 +157,30 @@
// --------------------------------------------------------------------
/**
+ * Select the database
+ *
+ * @param string $database
+ * @return bool
+ */
+ public function db_select($database = '')
+ {
+ if ($database === '')
+ {
+ $database = $this->database;
+ }
+
+ if (FALSE !== $this->simple_query('USE '.$this->escape_identifiers($database)))
+ {
+ $this->database = $database;
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php
index f07f49f..d5ca741 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php
@@ -121,17 +121,31 @@
// --------------------------------------------------------------------
/**
- * Show column query
+ * Fetch Field Names
*
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @param string $table
- * @return string
+ * @param string $table Table name
+ * @return array
*/
- protected function _list_columns($table = '')
+ public function list_fields($table)
{
- // Not supported
- return FALSE;
+ // Is there a cached result?
+ if (isset($this->data_cache['field_names'][$table]))
+ {
+ return $this->data_cache['field_names'][$table];
+ }
+
+ if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $this->data_cache['field_names'][$table] = array();
+ foreach ($result as $row)
+ {
+ $this->data_cache['field_names'][$table][] = $row['name'];
+ }
+
+ return $this->data_cache['field_names'][$table];
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index fdbe949..a7c6420 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -247,17 +247,31 @@
// --------------------------------------------------------------------
/**
- * Show column query
+ * Fetch Field Names
*
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @param string $table
- * @return string
+ * @param string $table Table name
+ * @return array
*/
- protected function _list_columns($table = '')
+ public function list_fields($table)
{
- // Not supported
- return FALSE;
+ // Is there a cached result?
+ if (isset($this->data_cache['field_names'][$table]))
+ {
+ return $this->data_cache['field_names'][$table];
+ }
+
+ if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ $this->data_cache['field_names'][$table] = array();
+ foreach ($result as $row)
+ {
+ $this->data_cache['field_names'][$table][] = $row['name'];
+ }
+
+ return $this->data_cache['field_names'][$table];
}
// --------------------------------------------------------------------
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index e07b52b..2ce55b9 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -62,7 +62,7 @@
* @param mixed
* @return mixed depends on what the array contains
*/
- function element($item, $array, $default = NULL)
+ function element($item, array $array, $default = NULL)
{
return array_key_exists($item, $array) ? $array[$item] : $default;
}
@@ -99,7 +99,7 @@
* @param mixed
* @return mixed depends on what the array contains
*/
- function elements($items, $array, $default = NULL)
+ function elements($items, array $array, $default = NULL)
{
$return = array();
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index d8ed45d..f289005 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -133,6 +133,7 @@
}
$plural_rules = array(
+ '/(quiz)$/' => '\1zes', // quizzes
'/^(ox)$/' => '\1\2en', // ox
'/([m|l])ouse$/' => '\1ice', // mouse, louse
'/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index bf623b0..5f8c6ce 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -161,7 +161,7 @@
$site_url = is_array($uri)
? site_url($uri)
- : preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
+ : (preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri));
if ($title === '')
{
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 40ac701..215a7c5 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -100,28 +100,10 @@
*/
public function __construct($config = array())
{
- $default_config = array(
- 'adapter',
- 'memcached'
- );
-
- foreach ($default_config as $key)
- {
- if (isset($config[$key]))
- {
- $param = '_'.$key;
-
- $this->{$param} = $config[$key];
- }
- }
-
+ isset($config['adapter']) && $this->_adapter = $config['adapter'];
+ isset($config['backup']) && $this->_backup_driver = $config['backup'];
isset($config['key_prefix']) && $this->key_prefix = $config['key_prefix'];
- if (isset($config['backup']) && in_array($config['backup'], $this->valid_drivers))
- {
- $this->_backup_driver = $config['backup'];
- }
-
// If the specified adapter isn't available, check the backup.
if ( ! $this->is_supported($this->_adapter))
{
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 522eba7..7599602 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -461,7 +461,7 @@
{
$this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']);
}
- elseif (isset($validation_array[$field]) && $validation_array[$field] !== '')
+ elseif (isset($validation_array[$field]))
{
$this->_field_data[$field]['postdata'] = $validation_array[$field];
}
@@ -870,17 +870,11 @@
*/
protected function _translate_fieldname($fieldname)
{
- // Do we need to translate the field name?
- // We look for the prefix lang: to determine this
- if (sscanf($fieldname, 'lang:%s', $line) === 1)
+ // Do we need to translate the field name? We look for the prefix 'lang:' to determine this
+ // If we find one, but there's no translation for the string - just return it
+ if (sscanf($fieldname, 'lang:%s', $line) === 1 && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE)))
{
- // Were we able to translate the field name? If not we use $line
- if (FALSE === ($fieldname = $this->CI->lang->line('form_validation_'.$line))
- // DEPRECATED support for non-prefixed keys
- && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE)))
- {
- return $line;
- }
+ return $line;
}
return $fieldname;
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index af45bb5..b532075 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -490,7 +490,7 @@
// so we'll recursively call delete_dir()
if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->conn_id, $list[$i]))
{
- $this->delete_dir($list[$i]);
+ $this->delete_dir($filepath.$list[$i]);
}
}
}
diff --git a/system/libraries/Session/drivers/Session_memcached_driver.php b/system/libraries/Session/drivers/Session_memcached_driver.php
index c7185ee..97b8605 100644
--- a/system/libraries/Session/drivers/Session_memcached_driver.php
+++ b/system/libraries/Session/drivers/Session_memcached_driver.php
@@ -322,7 +322,7 @@
$this->_lock_key = $lock_key;
break;
}
- while ($attempt++ < 30);
+ while (++$attempt < 30);
if ($attempt === 30)
{
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 1ce101d..b098cc4 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -336,7 +336,7 @@
$this->_lock_key = $lock_key;
break;
}
- while ($attempt++ < 30);
+ while (++$attempt < 30);
if ($attempt === 30)
{
diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php
index 53a2068..529e969 100644
--- a/tests/codeigniter/helpers/email_helper_test.php
+++ b/tests/codeigniter/helpers/email_helper_test.php
@@ -13,6 +13,7 @@
$this->assertEquals(FALSE, valid_email('test@test@test.com'));
$this->assertEquals(TRUE, valid_email('test@test.com'));
$this->assertEquals(TRUE, valid_email('my.test@test.com'));
+ $this->assertEquals(TRUE, valid_email('my.test@subdomain.test.com'));
}
public function test_send_mail()
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 8fa4d1e..2d10f8f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -11,10 +11,22 @@
- Added DoS mitigation to :php:func:`hash_pbkdf2()` :doc:`compatibility function <general/compatibility_functions>`.
+- Database
+
+ - Added ``list_fields()`` support for SQLite ('sqlite3' and 'pdo_sqlite' drivers).
+
Bug fixes for 3.0.1
-------------------
- Fixed a bug (#3733) - Autoloading of libraries with aliases didn't work, although it was advertised to.
+- Fixed a bug (#3744) - Redis :doc:`Caching <libraries/caching>` driver didn't handle authentication failures properly.
+- Fixed a bug (#3761) - :doc:`URL Helper <helpers/url_helper>` function :php:func:`anchor()` didn't work with array inputs.
+- Fixed a bug (#3773) - ``db_select()`` didn't work for MySQL with the PDO :doc:`Database <database/index>` driver.
+- Fixed a bug (#3771) - :doc:`Form Validation Library <libraries/form_validation>` was looking for a 'form_validation_' prefix when trying to translate field name labels.
+- Fixed a bug (#3787) - :doc:`FTP Library <libraries/ftp>` method ``delete_dir()`` failed when the target has subdirectories.
+- Fixed a bug (#3801) - :doc:`Output Library <libraries/output>` method ``_display_cache()`` incorrectly looked for the last modified time of a directory instead of the cache file.
+- Fixed a bug (#3816) - :doc:`Form Validation Library <libraries/form_validation>` treated empty string values as non-existing ones.
+- Fixed a bug (#3823) - :doc:`Session Library <libraries/sessions>` drivers Redis and Memcached didn't properly handle locks that are blocking the request for more than 30 seconds.
Version 3.0.0
=============
diff --git a/user_guide_src/source/general/controllers.rst b/user_guide_src/source/general/controllers.rst
index bc8319d..7ab5a7f 100644
--- a/user_guide_src/source/general/controllers.rst
+++ b/user_guide_src/source/general/controllers.rst
@@ -138,7 +138,7 @@
To specify a default controller, open your **application/config/routes.php**
file and set this variable::
- $route['default_controller'] = 'Blog';
+ $route['default_controller'] = 'blog';
Where Blog is the name of the controller class you want used. If you now
load your main index.php file without specifying any URI segments you'll
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index e0f9f00..a85da26 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -400,7 +400,7 @@
UM95 (UTC - 09:30) Marquesas Islands
UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands
UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island
-UM7 (UTC - 11:00) Mountain Standard Time
+UM7 (UTC - 07:00) Mountain Standard Time
UM6 (UTC - 06:00) Central Standard Time
UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean
UM45 (UTC - 04:30) Venezuelan Standard Time
diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst
index 25be0c9..9eb9b78 100644
--- a/user_guide_src/source/libraries/migration.rst
+++ b/user_guide_src/source/libraries/migration.rst
@@ -88,7 +88,7 @@
}
}
-Then in **application/config/migration.php** set ``$config['migration_version'] = 1;``.
+Then in **application/config/migration.php** set ``$config['migration_version'] = 20121031100537;``.
*************
Usage Example
@@ -181,4 +181,4 @@
specific versions. It works just like ``current()`` but ignores ``$config['migration_version']``.
::
- $this->migration->version(5);
\ No newline at end of file
+ $this->migration->version(5);
diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst
index ac56fc5..16b3979 100644
--- a/user_guide_src/source/libraries/security.rst
+++ b/user_guide_src/source/libraries/security.rst
@@ -88,7 +88,7 @@
::
- $config['csrf_regeneration'] = TRUE;
+ $config['csrf_regenerate'] = TRUE;
Select URIs can be whitelisted from csrf protection (for example API
endpoints expecting externally POSTed content). You can add these URIs
diff --git a/user_guide_src/source/overview/features.rst b/user_guide_src/source/overview/features.rst
index b230be9..f62546b 100644
--- a/user_guide_src/source/overview/features.rst
+++ b/user_guide_src/source/overview/features.rst
@@ -8,8 +8,8 @@
anything about the quality of the code, or the performance, or the
attention to detail, or security practices. The only way to really judge
an app is to try it and get to know the code.
-:doc:`Installing <../installation/>`_ CodeIgniter is child's play so we
-encourage you to do just that. In the mean time here's a list of
+:doc:`Installing <../installation/index>` CodeIgniter is child's play so
+we encourage you to do just that. In the mean time here's a list of
CodeIgniter's main features.
- Model-View-Controller Based System