From 172f949370bb1498789c7d897fdaa4073388ebd5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Dec 2016 15:28:41 +0200 Subject: Remove previously deprecated File Helper function read_file() --- system/helpers/file_helper.php | 20 ---------------- tests/codeigniter/helpers/file_helper_test.php | 15 +----------- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/helpers/file_helper.rst | 28 +--------------------- user_guide_src/source/installation/upgrade_320.rst | 1 + 5 files changed, 4 insertions(+), 61 deletions(-) diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 3cb36a551..484bf3228 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -49,26 +49,6 @@ defined('BASEPATH') OR exit('No direct script access allowed'); // ------------------------------------------------------------------------ -if ( ! function_exists('read_file')) -{ - /** - * Read File - * - * Opens the file specified in the path and returns it as a 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) - { - return @file_get_contents($file); - } -} - -// ------------------------------------------------------------------------ - if ( ! function_exists('write_file')) { /** diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php index c31817595..5ed8cb5c0 100644 --- a/tests/codeigniter/helpers/file_helper_test.php +++ b/tests/codeigniter/helpers/file_helper_test.php @@ -14,19 +14,6 @@ class File_helper_Test extends CI_TestCase { // -------------------------------------------------------------------- - public function test_read_file() - { - $this->assertFalse(read_file('does_not_exist')); - - $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - - $file = vfsStream::newFile('my_file.txt')->withContent($content)->at($this->_test_dir); - - $this->assertEquals($content, read_file(vfsStream::url('my_file.txt'))); - } - - // -------------------------------------------------------------------- - public function test_octal_permissions() { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; @@ -144,4 +131,4 @@ class File_helper_Test extends CI_TestCase { $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); } -} \ No newline at end of file +} diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8be737b6f..b6ef1db95 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -17,6 +17,7 @@ Release Date: Not Released - Removed previously deprecated :doc:`Security Helper ` function ``do_hash()`` (use PHP's native ``hash()`` instead). - Removed previously deprecated :doc:`HTML Helper ` functions ``br()`` and ``nbs()`` (use PHP's native ``str_repeat()`` with ``'
'`` and ``' '`` respectively). - Removed previously deprecated :doc:`String Helper ` functions ``trim_slashes()`` and ``repeater()`` (use PHP's native ``trim()`` with ``'/'`` and ``str_repeat()`` respectively). + - Removed previously deprecated :doc:`File Helper ` function ``read_file()`` (use PHP's native ``file_get_contents()`` instead). - Removed previously deprecated *Email Helper* (had only two functions, aliases for PHP's native ``filter_var()`` and ``mail()``). - Libraries diff --git a/user_guide_src/source/helpers/file_helper.rst b/user_guide_src/source/helpers/file_helper.rst index 833cddea4..dcf3a2340 100644 --- a/user_guide_src/source/helpers/file_helper.rst +++ b/user_guide_src/source/helpers/file_helper.rst @@ -23,32 +23,6 @@ Available Functions The following functions are available: - -.. php:function:: read_file($file) - - :param string $file: File path - :returns: File contents or FALSE on failure - :rtype: string - - Returns the data contained in the file specified in the path. - - Example:: - - $string = read_file('./path/to/file.php'); - - The path can be a relative or full server path. Returns FALSE (boolean) on failure. - - .. note:: The path is relative to your main site index.php file, NOT your - 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. - - .. important:: 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. - .. php:function:: write_file($path, $data[, $mode = 'wb']) :param string $path: File path @@ -199,4 +173,4 @@ The following functions are available: :: - echo octal_permissions(fileperms('./index.php')); // 644 \ No newline at end of file + echo octal_permissions(fileperms('./index.php')); // 644 diff --git a/user_guide_src/source/installation/upgrade_320.rst b/user_guide_src/source/installation/upgrade_320.rst index 8a559c268..5cf2acd3b 100644 --- a/user_guide_src/source/installation/upgrade_320.rst +++ b/user_guide_src/source/installation/upgrade_320.rst @@ -143,6 +143,7 @@ version 3.0.0, that have been removed in 3.2.0: - ``nbs()`` :doc:`HTML Helper <../helpers/html_helper>` function (use ``str_repeat()`` with ``' '`` instead) - ``trim_slashes()`` :doc:`String Helper <../helpers/string_helper>` function (use ``trim()`` with ``'/'`` instead) - ``repeater()`` :doc:`String Helper <../helpers/string_helper>` function (use ``str_repeat()`` instead) +- ``read_file()`` :doc:`File Helper <../helpers/file_helper>` function (use ``file_get_contents()`` instead) - The entire *Email Helper*, which only had two functions: -- cgit v1.2.3-24-g4f1b