summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-07 13:57:04 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-07 13:57:04 +0200
commit0f0b76980cb07f39b20c8591882aeae3854f016c (patch)
tree28ee4a2375e1d2b7fe28f5826015686ace374981
parentc839d28f4230dce0c658338f267b821cc16490a2 (diff)
Deprecated do_hash() and read_file() in favor of hash() and file_get_contents() respectively
-rw-r--r--system/database/DB_cache.php2
-rw-r--r--system/helpers/file_helper.php31
-rw-r--r--system/helpers/security_helper.php3
-rw-r--r--system/libraries/Cache/drivers/Cache_file.php4
-rw-r--r--user_guide_src/source/changelog.rst20
-rw-r--r--user_guide_src/source/helpers/file_helper.rst3
-rw-r--r--user_guide_src/source/helpers/security_helper.rst6
-rw-r--r--user_guide_src/source/helpers/string_helper.rst3
8 files changed, 29 insertions, 43 deletions
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 14f3c21bc..ba9110382 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -99,7 +99,7 @@ class CI_DB_Cache {
$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)))
+ if (FALSE === ($cachedata = file_get_contents($filepath)))
{
return FALSE;
}
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index d53d986f9..b717aaa0d 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -44,38 +44,15 @@ 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.
+ *
* @param string path to file
* @return string
*/
function read_file($file)
{
- if ( ! file_exists($file))
- {
- return FALSE;
- }
-
- if (function_exists('file_get_contents'))
- {
- return file_get_contents($file);
- }
-
- if ( ! $fp = @fopen($file, FOPEN_READ))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_SH);
-
- $data = '';
- if (filesize($file) > 0)
- {
- $data =& fread($fp, filesize($file));
- }
-
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return $data;
+ return file_get_contents($file);
}
}
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 6187a4a7a..3e6e91435 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -77,6 +77,9 @@ if ( ! function_exists('do_hash'))
/**
* Hash encode a string
*
+ * This function is DEPRECATED and should be removed in
+ * CodeIgniter 3.1+. Use hash() instead.
+ *
* @param string
* @param string
* @return string
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index ce2c2b13a..5170de821 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -71,7 +71,7 @@ class CI_Cache_file extends CI_Driver {
return FALSE;
}
- $data = unserialize(read_file($this->_cache_path.$id));
+ $data = unserialize(file_get_contents($this->_cache_path.$id));
if (time() > $data['time'] + $data['ttl'])
{
@@ -165,7 +165,7 @@ class CI_Cache_file extends CI_Driver {
return FALSE;
}
- $data = unserialize(read_file($this->_cache_path.$id));
+ $data = unserialize(file_get_contents($this->_cache_path.$id));
if (is_array($data))
{
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 211e9acc9..7180c2d07 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -44,19 +44,21 @@ Release Date: Not Released
- Helpers
- - create_captcha() accepts additional colors parameter, allowing for color customization
- - url_title() will now trim extra dashes from beginning and end.
+ - ``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 <helpers/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.
- - 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.
- - 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.
+ - 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.
+ - ``do_hash()`` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
+ - Removed previously deprecated helper function ``js_insert_smiley()`` from smiley helper.
+ - :doc:`File Helper <helpers/file_helper>` changes include:
+ - ``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()``.
- Database
diff --git a/user_guide_src/source/helpers/file_helper.rst b/user_guide_src/source/helpers/file_helper.rst
index bfc271eb3..60c5aa98c 100644
--- a/user_guide_src/source/helpers/file_helper.rst
+++ b/user_guide_src/source/helpers/file_helper.rst
@@ -32,6 +32,9 @@ The path can be a relative or full server path. Returns FALSE (boolean) on failu
controller or view files. CodeIgniter uses a front controller so paths
are always relative to the main site index.
+.. note:: This function is DEPRECATED. Use the native ``file_get_contents()``
+ instead.
+
If your server is running an `open_basedir` restriction this function might not work if you are trying to access a file above the calling script.
write_file('path', $data)
diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst
index b1bcf2b4a..ec0be28b3 100644
--- a/user_guide_src/source/helpers/security_helper.rst
+++ b/user_guide_src/source/helpers/security_helper.rst
@@ -43,8 +43,10 @@ for a full list of supported algorithms.
$str = do_hash($str); // SHA1
$str = do_hash($str, 'md5'); // MD5
-.. note:: This function was formerly named dohash(), which has been
- removed in favor of `do_hash()`.
+.. note:: This function was formerly named ``dohash()``, which has been
+ removed in favor of ``do_hash()``.
+
+.. note:: This function is DEPRECATED. Use the native ``hash()`` instead.
strip_image_tags()
==================
diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
index 2d23fb00c..19500aa0d 100644
--- a/user_guide_src/source/helpers/string_helper.rst
+++ b/user_guide_src/source/helpers/string_helper.rst
@@ -36,8 +36,7 @@ alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- **unique**: Encrypted with MD5 and uniqid(). Note: The length
parameter is not available for this type. Returns a fixed length 32
character string.
-- **sha1**: An encrypted random number based on do_hash() from the
- :doc:`security helper <security_helper>`.
+- **sha1**: An encrypted random number based on ``sha1()``.
Usage example