From e837d3589ba5c5da5daa58f69bdc14447c90bc51 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 5 Jan 2022 23:44:53 +0200 Subject: Drop some previously deprecated functionality --- system/database/DB_forge.php | 10 +--------- system/helpers/string_helper.php | 4 +--- system/helpers/url_helper.php | 15 ++------------- system/libraries/Pagination.php | 8 -------- tests/codeigniter/helpers/string_helper_test.php | 2 +- tests/codeigniter/helpers/url_helper_test.php | 4 ++-- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes user_guide_src/source/changelog.rst | 4 ++++ user_guide_src/source/database/forge.rst | 3 +-- user_guide_src/source/helpers/string_helper.rst | 3 --- user_guide_src/source/helpers/url_helper.rst | 3 --- user_guide_src/source/installation/upgrade_320.rst | 5 +++++ user_guide_src/source/libraries/pagination.rst | 3 --- 13 files changed, 17 insertions(+), 47 deletions(-) diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index ce9b30d82..f31823536 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -556,25 +556,17 @@ abstract class CI_DB_forge { /** * Column Add * - * @todo Remove deprecated $_after option in 3.1+ * @param string $table Table name * @param array $field Column definition - * @param string $_after Column for AFTER clause (deprecated) * @return bool */ - public function add_column($table, $field, $_after = NULL) + public function add_column($table, $field) { // Work-around for literal column definitions is_array($field) OR $field = array($field); foreach (array_keys($field) as $k) { - // Backwards-compatibility work-around for MySQL/CUBRID AFTER clause (remove in 3.1+) - if ($_after !== NULL && is_array($field[$k]) && ! isset($field[$k]['after'])) - { - $field[$k]['after'] = $_after; - } - $this->add_field(array($k => $field[$k])); } diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 3a05525db..5b359f730 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -170,7 +170,7 @@ if ( ! function_exists('random_string')) /** * Create a "Random" String * - * @param string type of random string. basic, alpha, alnum, numeric, nozero, unique, md5, encrypt and sha1 + * @param string type of random string. basic, alpha, alnum, numeric, nozero, md5 and sha1 * @param int number of characters * @return string */ @@ -200,10 +200,8 @@ if ( ! function_exists('random_string')) break; } return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len); - case 'unique': // todo: remove in 3.1+ case 'md5': return md5(uniqid(mt_rand())); - case 'encrypt': // todo: remove in 3.1+ case 'sha1': return sha1(uniqid(mt_rand(), TRUE)); } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 4c060a203..17601c40c 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -470,31 +470,20 @@ if ( ! function_exists('url_title')) * human-friendly URL string with a "separator" string * as the word separator. * - * @todo Remove old 'dash' and 'underscore' usage in 3.1+. * @param string $str Input string - * @param string $separator Word separator - * (usually '-' or '_') + * @param string $separator Word separator (usually '-' or '_') * @param bool $lowercase Whether to transform the output string to lowercase * @return string */ function url_title($str, $separator = '-', $lowercase = FALSE) { - if ($separator === 'dash') - { - $separator = '-'; - } - elseif ($separator === 'underscore') - { - $separator = '_'; - } - $q_separator = preg_quote($separator, '#'); $trans = array( '&.+?;' => '', '[^\w\d _-]' => '', '\s+' => $separator, - '('.$q_separator.')+' => $separator + '('.$q_separator.')+' => $separator, ); $str = strip_tags($str); diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 20418c00a..837ac4b32 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -363,14 +363,6 @@ class CI_Pagination { 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']); - } - foreach ($params as $key => $val) { if (property_exists($this, $key)) diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php index 4f15909ff..f6d473a41 100644 --- a/tests/codeigniter/helpers/string_helper_test.php +++ b/tests/codeigniter/helpers/string_helper_test.php @@ -98,7 +98,7 @@ class String_helper_test extends CI_TestCase { public function test_random_string() { $this->assertEquals(16, strlen(random_string('alnum', 16))); - $this->assertEquals(32, strlen(random_string('unique', 16))); + $this->assertEquals(32, strlen(random_string('md5', 16))); $this->assertEquals('string', gettype(random_string('numeric', 16))); } diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index 5f936568b..1b295511e 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -21,7 +21,7 @@ class Url_helper_test extends CI_TestCase { foreach ($words as $in => $out) { - $this->assertEquals($out, url_title($in, 'dash', TRUE)); + $this->assertEquals($out, url_title($in, '-', TRUE)); } } @@ -41,7 +41,7 @@ class Url_helper_test extends CI_TestCase { foreach ($words as $in => $out) { - $this->assertEquals($out, url_title($in, 'underscore')); + $this->assertEquals($out, url_title($in, '_')); } } diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index db14455eb..36e4ae5de 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2a729264e..80a5ca0e9 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -39,6 +39,7 @@ Release Date: Not Released - Removed previously deprecated *Cart Library*. - Removed previously deprecated *Javascript Library* (it was always experimental in the first place). + - Removed previously deprecated ``anchor_class`` option from :doc:`Pagination Library `. - Added TLS and UNIX socket connection support to :doc:`Session Library ` 'redis' driver. - Updated :doc:`ZIP Library ` method ``read_dir()`` to include hidden (dot-prefixed) files. @@ -88,6 +89,7 @@ Release Date: Not Released - :doc:`Database Forge `: - Added support for declaring date/time type fields default values as ``CURRENT_TIMESTAMP`` and similar. + - Removed previously deprecated ``$_after`` parameter for ``add_column()``. - :doc:`Query Builder `: @@ -103,6 +105,7 @@ Release Date: Not Released - Removed previously deprecated :doc:`Date Helper ` function ``standard_date()`` (use PHP's native ``date()`` instead). - Removed previously deprecated :doc:`Security Helper ` function ``do_hash()`` (use PHP's native ``hash()`` instead). - Removed previously deprecated :doc:`File Helper ` function ``read_file()`` (use PHP's native ``file_get_contents()`` instead). + - Removed previously deprecated options ``'dash'`` and ``'underscore'`` from :doc:`URL Helper ` function :php:func:`url_title()`. - Added new function :php:func:`ordinal_format()` to :doc:`Inflector Helper `. - :doc:`Download Helper ` changes include: @@ -115,6 +118,7 @@ Release Date: Not Released - Removed previously deprecated function ``trim_slashes()`` (use PHP's native ``trim()`` with ``'/'`` instead). - Removed previously deprecated function ``repeater()`` (use PHP's native ``str_repeat()`` instead). + - Removed previously deprecated ``'unique'`` and ``'encrypt'`` options from ``random_string()``. - :doc:`HTML Helper ` changes include: diff --git a/user_guide_src/source/database/forge.rst b/user_guide_src/source/database/forge.rst index c6cacb1b0..1562a1a2d 100644 --- a/user_guide_src/source/database/forge.rst +++ b/user_guide_src/source/database/forge.rst @@ -322,11 +322,10 @@ Class Reference .. php:class:: CI_DB_forge - .. php:method:: add_column($table[, $field = array()[, $_after = NULL]]) + .. php:method:: add_column($table[, $field = array()]) :param string $table: Table name to add the column to :param array $field: Column definition(s) - :param string $_after: Column for AFTER clause (deprecated) :returns: TRUE on success, FALSE on failure :rtype: bool diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst index 4663bb08b..c9b5e278c 100644 --- a/user_guide_src/source/helpers/string_helper.rst +++ b/user_guide_src/source/helpers/string_helper.rst @@ -52,9 +52,6 @@ The following functions are available: echo random_string('alnum', 16); - .. note:: Usage of the *unique* and *encrypt* types is DEPRECATED. They - are just aliases for *md5* and *sha1* respectively. - .. php:function:: increment_string($str[, $separator = '_'[, $first = 1]]) :param string $str: Input string diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index adeab8c58..037e613ea 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -298,9 +298,6 @@ The following functions are available: $url_title = url_title($title, 'underscore'); // Produces: Whats_wrong_with_CSS - .. note:: Old usage of 'dash' and 'underscore' as the second parameter - is DEPRECATED. - The third parameter determines whether or not lowercase characters are forced. By default they are not. Options are boolean TRUE/FALSE. diff --git a/user_guide_src/source/installation/upgrade_320.rst b/user_guide_src/source/installation/upgrade_320.rst index 48914c414..715e8858d 100644 --- a/user_guide_src/source/installation/upgrade_320.rst +++ b/user_guide_src/source/installation/upgrade_320.rst @@ -231,6 +231,11 @@ CodeIgniter versions that have been removed in 3.2.0: - The entire *Smiley Helper* (an archived version is available on GitHub: `bcit-ci/ci3-smiley-helper `_) +- The ``$_after`` parameter from :doc:`Database Forge <../database/forge>` method ``add_column()``. +- The ``anchor_class`` option from :doc:`Pagination Library <../libraries/pagination>` (use ``class`` instead). +- The ``unique`` and ``encrypt`` options from :doc:`String Helper <../helpers/string_helper>` function ``random_string()``. +- The ``underscore`` and ``dash`` options from :doc:`URL Helper <../helpers/url_helper>`` function :php:func:`url_title()`. + Step 11: Make sure you're validating all user inputs ==================================================== diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index fbc75ea56..760f50c94 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -277,9 +277,6 @@ by the pagination class, you can set them as key/value pairs in the // Produces: class="myclass" $config['attributes'] = array('class' => 'myclass'); -.. note:: Usage of the old method of setting classes via "anchor_class" - is deprecated. - ***************************** Disabling the "rel" attribute ***************************** -- cgit v1.2.3-24-g4f1b