From 6f30b1ad3f51470cd2ffe95447806dbf527f6938 Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Fri, 27 Mar 2015 09:38:23 -0700 Subject: Fix an example in the tutorial. Signed-off-by:Master Yoda --- user_guide_src/source/tutorial/static_pages.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst index 210d9f8d6..0c75d5a34 100644 --- a/user_guide_src/source/tutorial/static_pages.rst +++ b/user_guide_src/source/tutorial/static_pages.rst @@ -64,7 +64,7 @@ following code. -

CodeIgniter Tutorial

+

The header contains the basic HTML code that you'll want to display before loading the main view, together with a heading. It will also -- cgit v1.2.3-24-g4f1b From 32e7ba3560a2c2c3a72236463091049c51a518ec Mon Sep 17 00:00:00 2001 From: Cyrille TOULET Date: Fri, 27 Mar 2015 19:28:10 +0100 Subject: Fix an "strpos(): Empty needle" warning Signed-off-by: Cyrille TOULET --- system/core/URI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index e96749456..43a0a9caa 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -205,11 +205,11 @@ class CI_URI { $query = isset($uri['query']) ? $uri['query'] : ''; $uri = isset($uri['path']) ? $uri['path'] : ''; - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + if (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); } - elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + elseif (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) { $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } -- cgit v1.2.3-24-g4f1b From 5bc1dc5257577f2afd562f5b039ad95d57befdb1 Mon Sep 17 00:00:00 2001 From: David Woods Date: Fri, 27 Mar 2015 22:41:58 -0700 Subject: Added more units tests for Form_validation Up to 65% coverage Signed-off-by: David Woods --- .../codeigniter/libraries/Form_validation_test.php | 110 ++++++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 1bbd1758b..19e7beeee 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -248,7 +248,7 @@ class Form_validation_test extends CI_TestCase { $this->assertTrue($this->form_validation->valid_emails('1@sample.com,2@sample.com')); $this->assertTrue($this->form_validation->valid_emails('email@sample.com')); - $this->assertFalse($this->form_validation->valid_emails('valid_email', '@sample.com')); + $this->assertFalse($this->form_validation->valid_emails('valid_email', '@sample.com')); $this->assertFalse($this->form_validation->valid_emails('@sample.com,2@sample.com,validemail@email.ca')); } @@ -313,7 +313,7 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_data($erroneous_data); $this->form_validation->set_rules($rules); $this->form_validation->run(); - $this->assertEquals('

'.$err_message.'

', $this->form_validation->error('req_field')); + $this->assertEquals('

' . $err_message . '

', $this->form_validation->error('req_field')); $this->form_validation->reset_validation(); $this->form_validation->set_message('required', $err_message); @@ -323,6 +323,111 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('', $this->form_validation->error('req_field')); } + public function test_set_error_delimiters() + { + $this->form_validation->reset_validation(); + $prefix = '
'; + $suffix = '
'; + $this->form_validation->set_error_delimiters($prefix, $suffix); + $this->form_validation->set_rules('foo', 'label', 'required'); + $_POST = array('foo' => ''); + $this->form_validation->run(); + $error_msg = $this->form_validation->error('foo'); + + $this->assertTrue(strrpos($error_msg, $prefix) === 0); + $this->assertTrue(strrpos($error_msg, $suffix, -strlen($suffix)) === (strlen($error_msg) - strlen($suffix))); + } + + public function test_error_array() + { + $this->form_validation->reset_validation(); + $error_message = 'What a terrible error!'; + $this->form_validation->set_message('required', $error_message); + $this->form_validation->set_rules('foo', 'label', 'required'); + $_POST = array('foo' => ''); + $this->form_validation->run(); + $this->assertEquals($error_message, $this->form_validation->error_array()['foo']); + } + + public function test_error_string() + { + $this->form_validation->reset_validation(); + $error_message = 'What a terrible error!'; + $prefix_default = ''; + $suffix_default = ''; + $prefix_test = ''; + $suffix_test = ''; + $this->form_validation->set_error_delimiters($prefix_default, $suffix_default); + $this->form_validation->set_message('required', $error_message); + $this->form_validation->set_rules('foo', 'label', 'required'); + $_POST = array('foo' => ''); + $this->form_validation->run(); + + $this->assertEquals($prefix_default . $error_message . $suffix_default . "\n", $this->form_validation->error_string()); + $this->assertEquals($prefix_test . $error_message . $suffix_default . "\n", $this->form_validation->error_string($prefix_test, '')); + $this->assertEquals($prefix_default . $error_message . $suffix_test . "\n", $this->form_validation->error_string('', $suffix_test)); + $this->assertEquals($prefix_test . $error_message . $suffix_test . "\n", $this->form_validation->error_string($prefix_test, $suffix_test)); + + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('foo', 'label', 'required'); + $_POST = array('foo' => 'bar'); + $this->form_validation->run(); + $this->assertEquals('', $this->form_validation->error_string()); + } + + public function test_run() + { + // form_validation->run() is tested in many of the other unit tests + // This test will only test run(group='') when group is not empty + $config = array( + 'pass' => array( + array( + 'field' => 'username', + 'label' => 'user', + 'rules' => 'alpha_numeric' + ) + ), + 'fail' => array( + array( + 'field' => 'username', + 'label' => 'user', + 'rules' => 'alpha' + ) + ) + ); + $_POST = array('username' => 'foo42'); + $form_validation = new CI_Form_validation($config); + $this->assertTrue($form_validation->run('pass')); + + $form_validation = new CI_Form_validation($config); + $this->assertFalse($form_validation->run('fail')); + } + + public function test_has_rule() + { + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('foo', 'label', 'required'); + + $this->assertTrue($this->form_validation->has_rule('foo')); + $this->assertFalse($this->form_validation->has_rule('bar')); + } + + public function test_set_value() + { + $this->form_validation->reset_validation(); + $default = 'default'; + $this->form_validation->set_rules('foo', 'label', 'required'); + $this->form_validation->set_rules('bar[]', 'label', 'required'); + + // No post data yet: should return the default value provided + $this->assertEquals($default, $this->form_validation->set_value('foo', $default)); + $_POST = array('foo' => 'foo', 'bar' => array('bar1', 'bar2')); + $this->form_validation->run(); + $this->assertEquals('foo', $this->form_validation->set_value('foo', $default)); + $this->assertEquals('bar1', $this->form_validation->set_value('bar[]', $default)); + $this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default)); + } + /** * Run rules * @@ -342,4 +447,5 @@ class Form_validation_test extends CI_TestCase { return $this->form_validation->run(); } + } -- cgit v1.2.3-24-g4f1b From ead327f7fd53946dc61dbd0562d9f7f3d19e802c Mon Sep 17 00:00:00 2001 From: Cyrille TOULET Date: Sun, 29 Mar 2015 14:53:16 +0200 Subject: Fix an "strpos(): Empty needle" warning Signed-off-by: Cyrille TOULET --- system/core/URI.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index 43a0a9caa..9c8e37f0f 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -205,14 +205,17 @@ class CI_URI { $query = isset($uri['query']) ? $uri['query'] : ''; $uri = isset($uri['path']) ? $uri['path'] : ''; - if (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) - { - $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); - } - elseif (!empty($_SERVER['SCRIPT_NAME']) && strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) - { - $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); - } + if (isset($_SERVER['SCRIPT_NAME'][0])) + { + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + { + $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + } + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + { + $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + } + } // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. -- cgit v1.2.3-24-g4f1b From cbc21b9bdbaeb2defd47c0808d47801ab1a14ede Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 13:59:16 -0400 Subject: Increased code coverage Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 929bc2ffd..3c1e19db3 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -38,7 +38,7 @@ class Lang_test extends CI_TestCase { $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); $this->assertEquals('Bytes', $this->lang->language['bytes']); - + // Non-existent file $this->setExpectedException( 'RuntimeException', @@ -46,7 +46,30 @@ class Lang_test extends CI_TestCase { ); $this->lang->load('nonexistent'); } + + // -------------------------------------------------------------------- + + public function test_multiple_file_load() + { + // Multiple files + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $files = Array('profiler', 'nonexistent'); + $this->setExpectedException( + 'RuntimeException', + 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' + ); + $this->assertTrue($this->lang->load($files, 'english')); + } + // -------------------------------------------------------------------- + + public function test_alternative_path_load() + { + // Alternative Path + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/')); + } + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From 4924115bdf8042850e7934d0ab66fe451e7c778b Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 15:10:16 -0400 Subject: removed space Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 3c1e19db3..a4db7a9c2 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -38,7 +38,7 @@ class Lang_test extends CI_TestCase { $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); $this->assertEquals('Bytes', $this->lang->language['bytes']); - + // Non-existent file $this->setExpectedException( 'RuntimeException', -- cgit v1.2.3-24-g4f1b From 7df6771e33c43b86a9e0bb8beb9d55aafec3b978 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 16:27:06 -0400 Subject: Improved unit test code coverage. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 9e2092e05..64632c056 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -22,6 +22,9 @@ class Loader_test extends CI_TestCase { public function test_library() { + // Test getting CI_Loader object + $this->assertInstanceOf('CI_Loader', $this->load->library(NULL)); + // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); @@ -34,6 +37,13 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); + + // Create library in VFS + $lib = Array('unit_test_lib'=>'unit_test_lib'); + + // Test loading as an array (int). + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); + $this->assertTrue(class_exists($class), $class.' does not exist'); // Test a string given to params $this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' ')); @@ -316,6 +326,24 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } + + // -------------------------------------------------------------------- + + public function test_clear_vars() + { + $key1 = 'foo'; + $val1 = 'bar'; + $key2 = 'boo'; + $val2 = 'hoo'; + $this->assertInstanceOf('CI_Loader', $this->load->vars(array($key1 => $val1))); + $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2)); + $this->assertEquals($val1, $this->load->get_var($key1)); + $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); + + $this->assertInstanceOf('CI_Loader', $this->load->clear_vars()); + $this->assertEquals('', $this->load->get_var($key1)); + $this->assertEquals('', $this->load->get_var($key2)); + } // -------------------------------------------------------------------- @@ -443,6 +471,24 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_remove_package_path() + { + $dir = 'third-party'; + $path = APPPATH.$dir.'/'; + $path2 = APPPATH.'another/'; + $paths = $this->load->get_package_paths(TRUE); + + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); + $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); + + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); + $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); + } + + // -------------------------------------------------------------------- + public function test_load_config() { $cfg = 'someconfig'; -- cgit v1.2.3-24-g4f1b From 4b02f1d9545d40fb97c271078e4352693791abaf Mon Sep 17 00:00:00 2001 From: David Woods Date: Sun, 29 Mar 2015 22:46:14 -0700 Subject: Added more unit tests to CI_Form_validation Unit tests for set_select, set_checkbox, and set_radio currently all fail for the same reason. Signed-off-by: David Woods --- .../codeigniter/libraries/Form_validation_test.php | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 19e7beeee..38eb11a34 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -428,6 +428,153 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default)); } + public function test_set_select() + { + // Test 1: No options selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array(); + $this->form_validation->run(); + + $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); + // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar', TRUE)); + + // Test 2: 1 option selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array('select' => 'foo'); + $this->form_validation->run(); + + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo')); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo', TRUE)); + $this->assertEquals('', $this->form_validation->set_select('select', 'bar')); + $this->assertEquals('', $this->form_validation->set_select('select', 'bar', TRUE)); + + // Test 3: Multiple options selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array('select' => array('foo', 'bar')); + $this->form_validation->run(); + + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo')); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo', TRUE)); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar')); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar', TRUE)); + $this->assertEquals('', $this->form_validation->set_select('select', 'foobar')); + $this->assertEquals('', $this->form_validation->set_select('select', 'foobar', TRUE)); + } + + public function test_set_radio() + { + // Test 1: No options selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array(); + $this->form_validation->run(); + + $this->assertEquals('', $this->form_validation->set_radio('select', 'foo')); + // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar', TRUE)); + + // Test 2: 1 option selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array('select' => 'foo'); + $this->form_validation->run(); + + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo', TRUE)); + $this->assertEquals('', $this->form_validation->set_radio('select', 'bar')); + $this->assertEquals('', $this->form_validation->set_radio('select', 'bar', TRUE)); + + // Test 3: Multiple options checked + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array('select' => array('foo', 'bar')); + $this->form_validation->run(); + + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo', TRUE)); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar', TRUE)); + $this->assertEquals('', $this->form_validation->set_radio('select', 'foobar')); + $this->assertEquals('', $this->form_validation->set_radio('select', 'foobar', TRUE)); + } + + public function test_set_checkbox() + { + // Test 1: No options selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array(); + $this->form_validation->run(); + + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); + // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar', TRUE)); + + // Test 2: 1 option selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array('select' => 'foo'); + $this->form_validation->run(); + + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo', TRUE)); + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'bar')); + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'bar', TRUE)); + + // Test 3: Multiple options selected + $this->form_validation->reset_validation(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array('select' => array('foo', 'bar')); + $this->form_validation->run(); + + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo', TRUE)); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar', TRUE)); + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foobar')); + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foobar', TRUE)); + } + + public function test_regex_match() + { + $regex = '/f[a-zA-Z]+/'; + $this->assertTrue($this->form_validation->regex_match('foo', $regex)); + $this->assertFalse($this->form_validation->regex_match('bar', $regex)); + } + + public function test_prep_for_form() + { + $this->form_validation->reset_validation(); + $err_msg_unprepped = ''; + $err_msg_prepped = '<error ='foobar'">'; + $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $err_msg_unprepped)); + $_POST = array('foo' => ''); + $this->form_validation->run(); + $err_arr = $this->form_validation->error_array(); + + $this->assertEquals('', $this->form_validation->prep_for_form('')); + $this->assertEquals(array('foo' => $err_msg_prepped), $this->form_validation->prep_for_form($err_arr)); + } + + public function test_prep_url() + { + $this->assertEquals('', $this->form_validation->prep_url('')); + $this->assertEquals('http://codeigniter.com', $this->form_validation->prep_url('codeigniter.com')); + $this->assertEquals('https://codeigniter.com', $this->form_validation->prep_url('https://codeigniter.com')); + $this->assertEquals('http://codeigniter.com', $this->form_validation->prep_url('http://codeigniter.com')); + $this->assertEquals('http://www.codeigniter.com', $this->form_validation->prep_url('www.codeigniter.com')); + } + + public function test_encode_php_tags() + { + $this->assertEquals("<?php", $this->form_validation->encode_php_tags('assertEquals('?>', $this->form_validation->encode_php_tags('?>')); + } + /** * Run rules * -- cgit v1.2.3-24-g4f1b From cbf3a559583bcc9055fcee5f7564ca847d0b8dff Mon Sep 17 00:00:00 2001 From: Cyrille TOULET Date: Mon, 30 Mar 2015 09:14:46 +0200 Subject: Use tabs instead of spaces Signed-off-by: Cyrille TOULET --- system/core/URI.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/system/core/URI.php b/system/core/URI.php index 9c8e37f0f..2211e3665 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -205,17 +205,17 @@ class CI_URI { $query = isset($uri['query']) ? $uri['query'] : ''; $uri = isset($uri['path']) ? $uri['path'] : ''; - if (isset($_SERVER['SCRIPT_NAME'][0])) - { - if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) - { - $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); - } - elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) - { - $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); - } - } + if (isset($_SERVER['SCRIPT_NAME'][0])) + { + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + { + $uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + } + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + { + $uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + } + } // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct // URI is found, and also fixes the QUERY_STRING server var and $_GET array. -- cgit v1.2.3-24-g4f1b From aa11370ba3d326eef259fedd5a67481b3aa95df6 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:05:47 -0400 Subject: added spaces Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 64632c056..6028521d1 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib'=>'unit_test_lib'); + $lib = Array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From d1f39fdef53fc510a6a5d19ec2991e5bc474bc29 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:11:32 -0400 Subject: updated array style and removed assert true Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index a4db7a9c2..3fccf096d 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -53,12 +53,15 @@ class Lang_test extends CI_TestCase { { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = Array('profiler', 'nonexistent'); + $files = Array( + 0 => 'profiler', + 1 => 'nonexistent' + ); $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' ); - $this->assertTrue($this->lang->load($files, 'english')); + $this->lang->load($files, 'english'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fd3105716f5cdede79b9b471561413c161db250c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Mar 2015 17:19:26 +0300 Subject: Fix #3717 --- system/libraries/Session/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index bb457c659..0549fef66 100644 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -869,7 +869,7 @@ class CI_Session { public function set_tempdata($data, $value = NULL, $ttl = 300) { $this->set_userdata($data, $value); - $this->mark_as_temp($data, $ttl); + $this->mark_as_temp(is_array($data) ? array_keys($data) : $data, $ttl); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From fc67a701a574641b5dfd7afe00d4c5d403111626 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:08:11 -0400 Subject: changed to lowercase array and space. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 3fccf096d..0f6ffd3fa 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -53,9 +53,9 @@ class Lang_test extends CI_TestCase { { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = Array( - 0 => 'profiler', - 1 => 'nonexistent' + $files = array( + 0 => 'profiler', + 1 => 'nonexistent' ); $this->setExpectedException( 'RuntimeException', -- cgit v1.2.3-24-g4f1b From 90e07bdaa034d98e23378c51105a8aea85878d07 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:10:00 -0400 Subject: changed to lowercase array. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 6028521d1..5e64b62b9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib' => 'unit_test_lib'); + $lib = array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From 928134324d75ed4a876237ec00d4374b2213586a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Mar 2015 19:27:06 +0300 Subject: [ci skip] Whitespace cleanup following PRs #3713 #3714 --- tests/codeigniter/core/Lang_test.php | 12 ++++++------ tests/codeigniter/core/Loader_test.php | 19 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 0f6ffd3fa..d2dd7598a 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -46,15 +46,15 @@ class Lang_test extends CI_TestCase { ); $this->lang->load('nonexistent'); } - + // -------------------------------------------------------------------- - + public function test_multiple_file_load() - { + { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); $files = array( - 0 => 'profiler', + 0 => 'profiler', 1 => 'nonexistent' ); $this->setExpectedException( @@ -65,14 +65,14 @@ class Lang_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_alternative_path_load() { // Alternative Path $this->ci_vfs_clone('system/language/english/profiler_lang.php'); $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/')); } - + // -------------------------------------------------------------------- /** diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 5e64b62b9..cfaf6c74b 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -24,7 +24,7 @@ class Loader_test extends CI_TestCase { { // Test getting CI_Loader object $this->assertInstanceOf('CI_Loader', $this->load->library(NULL)); - + // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); @@ -37,10 +37,10 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); - + // Create library in VFS $lib = array('unit_test_lib' => 'unit_test_lib'); - + // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); $this->assertTrue(class_exists($class), $class.' does not exist'); @@ -326,7 +326,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } - + // -------------------------------------------------------------------- public function test_clear_vars() @@ -339,7 +339,7 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2)); $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); - + $this->assertInstanceOf('CI_Loader', $this->load->clear_vars()); $this->assertEquals('', $this->load->get_var($key1)); $this->assertEquals('', $this->load->get_var($key2)); @@ -477,18 +477,18 @@ class Loader_test extends CI_TestCase { $path = APPPATH.$dir.'/'; $path2 = APPPATH.'another/'; $paths = $this->load->get_package_paths(TRUE); - + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); - + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); } // -------------------------------------------------------------------- - + public function test_load_config() { $cfg = 'someconfig'; @@ -557,5 +557,4 @@ class Loader_test extends CI_TestCase { // Verify config calls $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded); } - -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b From 6eb599a2285e2981341b220b72e6f99149f92c3b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Mar 2015 19:53:38 +0300 Subject: [ci skip] Fix a broken link in the changelog --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a1b15105f..45780ddb3 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -565,7 +565,7 @@ Release Date: Not Released - Changed the library constructor to try to create the **log_path** directory if it doesn't exist. - Added support for microseconds ("u" date format character) in ``$config['log_date_format']``. - - Added `compatibility layers ` for: + - Added :doc:`compatibility layers ` for: - `Multibyte String `_ (limited support). - `Hash `_ (``hash_equals()``, ``hash_pbkdf2()``). -- cgit v1.2.3-24-g4f1b From 29704f8890bac6b0173ff60cbf3c3c383448cee2 Mon Sep 17 00:00:00 2001 From: David Woods Date: Mon, 30 Mar 2015 10:37:57 -0700 Subject: Corrected unit tests for set_select, set_radio, and set_checkbox Coverage now at ~75% --- .../codeigniter/libraries/Form_validation_test.php | 59 ++++++++++------------ 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 38eb11a34..9ab16a00f 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -431,13 +431,11 @@ class Form_validation_test extends CI_TestCase { public function test_set_select() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); - // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar', TRUE)); // Test 2: 1 option selected @@ -453,28 +451,27 @@ class Form_validation_test extends CI_TestCase { // Test 3: Multiple options selected $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric'); $_POST = array('select' => array('foo', 'bar')); $this->form_validation->run(); - $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo')); - $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo', TRUE)); - $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar')); - $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar', TRUE)); - $this->assertEquals('', $this->form_validation->set_select('select', 'foobar')); - $this->assertEquals('', $this->form_validation->set_select('select', 'foobar', TRUE)); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'foo')); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'foo', TRUE)); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'bar')); + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'bar', TRUE)); + $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar')); + $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar', TRUE)); } public function test_set_radio() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); $this->assertEquals('', $this->form_validation->set_radio('select', 'foo')); - // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + // Default should only work when no rules are set $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar', TRUE)); // Test 2: 1 option selected @@ -490,28 +487,26 @@ class Form_validation_test extends CI_TestCase { // Test 3: Multiple options checked $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric'); $_POST = array('select' => array('foo', 'bar')); $this->form_validation->run(); - $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo')); - $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo', TRUE)); - $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar')); - $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar', TRUE)); - $this->assertEquals('', $this->form_validation->set_radio('select', 'foobar')); - $this->assertEquals('', $this->form_validation->set_radio('select', 'foobar', TRUE)); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'foo')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'foo', TRUE)); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'bar')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'bar', TRUE)); + $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar')); + $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar', TRUE)); } public function test_set_checkbox() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); - // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar', TRUE)); // Test 2: 1 option selected @@ -527,16 +522,16 @@ class Form_validation_test extends CI_TestCase { // Test 3: Multiple options selected $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric'); $_POST = array('select' => array('foo', 'bar')); $this->form_validation->run(); - $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo')); - $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo', TRUE)); - $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar')); - $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar', TRUE)); - $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foobar')); - $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foobar', TRUE)); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'foo')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'foo', TRUE)); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'bar')); + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'bar', TRUE)); + $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar')); + $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar', TRUE)); } public function test_regex_match() -- cgit v1.2.3-24-g4f1b From 7a46bdeed5c1fb2dfafa18b7bd3a2315bd08255e Mon Sep 17 00:00:00 2001 From: mwhitneysdsu Date: Mon, 30 Mar 2015 12:22:17 -0700 Subject: Fix logged path to match checked path in loader This is to fix a logged path missed in 8f5c1780706113c926bb7801db27dbae97d00fcf --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 254ad0d6d..c0a5cd634 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1118,7 +1118,7 @@ class CI_Loader { } else { - log_message('debug', APPPATH.'libraries/'.$file_path.$subclass.'.php exists, but does not declare '.$subclass); + log_message('debug', $path.' exists, but does not declare '.$subclass); } } } -- cgit v1.2.3-24-g4f1b From 7f6f3e3485c1ba9762a239cf279af49bb9bfc755 Mon Sep 17 00:00:00 2001 From: David Woods Date: Mon, 30 Mar 2015 12:25:27 -0700 Subject: Fix for parsing error in PHP 5.2 and 5.3 --- tests/codeigniter/libraries/Form_validation_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 9ab16a00f..a25dcf747 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -346,7 +346,8 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_rules('foo', 'label', 'required'); $_POST = array('foo' => ''); $this->form_validation->run(); - $this->assertEquals($error_message, $this->form_validation->error_array()['foo']); + $err_arr = $this->form_validation->error_array(); + $this->assertEquals($error_message, $err_arr['foo']); } public function test_error_string() -- cgit v1.2.3-24-g4f1b From e04f4f76199d88ae2a3a62379fac728ceb637895 Mon Sep 17 00:00:00 2001 From: mwhitneysdsu Date: Mon, 30 Mar 2015 12:38:22 -0700 Subject: Fix whitespace in previous commit --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index c0a5cd634..007378ee2 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1118,7 +1118,7 @@ class CI_Loader { } else { - log_message('debug', $path.' exists, but does not declare '.$subclass); + log_message('debug', $path.' exists, but does not declare '.$subclass); } } } -- cgit v1.2.3-24-g4f1b From c0b2ae29b8a4c48c6adde72bc3f66ad3780246ec Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 31 Mar 2015 11:50:46 +0300 Subject: [ci skip] Update version number --- system/core/CodeIgniter.php | 2 +- user_guide_src/source/conf.py | 4 ++-- user_guide_src/source/installation/upgrade_300.rst | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index d830c1829..b38166b60 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -55,7 +55,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @var string * */ - define('CI_VERSION', '3.0-dev'); + define('CI_VERSION', '3.0.0'); /* * ------------------------------------------------------ diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index d65fe0dfd..93d70b2e4 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2014 - 2015, British Columbia Institute of Technology' # built documents. # # The short X.Y version. -version = '3.0' +version = '3.0.0' # The full version, including alpha/beta/rc tags. -release = '3.0-dev' +release = '3.0.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 7e3479740..a3d712482 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -2,8 +2,6 @@ Upgrading from 2.2.x to 3.0.0 ############################# -.. note:: These upgrade notes are for a version that is yet to be released. - Before performing an update you should take your site offline by replacing the index.php file with a static one. ************************************* -- cgit v1.2.3-24-g4f1b From a8c499d0125b2e96f7f3c539f6b46cff7547aa80 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 31 Mar 2015 15:01:36 +0300 Subject: [ci skip] Update security recommendations --- user_guide_src/source/general/security.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/general/security.rst b/user_guide_src/source/general/security.rst index efc821f2b..fcfe4c24b 100644 --- a/user_guide_src/source/general/security.rst +++ b/user_guide_src/source/general/security.rst @@ -143,11 +143,15 @@ with that. Please read below. feature, just randomly generate a new, one-time (this is also important) password and send that instead. -- DO NOT put artificial limits on your users' passwords. +- DO NOT put unnecessary limits on your users' passwords. - There's no point in forcing a rule that a password can only be up to - a number of characters, or that it can't contain a certain set of - special characters. + If you're using a hashing algorithm other than BCrypt (which has a limit + of 72 characters), you should set a relatively high limit on password + lengths in order to mitigate DoS attacks - say, 1024 characters. + + Other than that however, there's no point in forcing a rule that a + password can only be up to a number of characters, or that it can't + contain a certain set of special characters. Not only does this **reduce** security instead of improving it, but there's literally no reason to do it. No technical limitations and -- cgit v1.2.3-24-g4f1b From 0be4c803d10dfb2c697e07751654848829d4476b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 31 Mar 2015 15:03:03 +0300 Subject: [ci skip] Fix a wrong docblock link --- system/core/Hooks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 08479b133..3b4fb2250 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -46,7 +46,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @subpackage Libraries * @category Libraries * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/encryption.html + * @link http://codeigniter.com/user_guide/general/hooks.html */ class CI_Hooks { -- cgit v1.2.3-24-g4f1b From c6ac5592006935eefab2cc88b808497548105953 Mon Sep 17 00:00:00 2001 From: David Woods Date: Tue, 31 Mar 2015 20:19:39 -0700 Subject: Style changes and variable name changes --- .../codeigniter/libraries/Form_validation_test.php | 43 +++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index a25dcf747..b2d401ee5 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -313,7 +313,7 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_data($erroneous_data); $this->form_validation->set_rules($rules); $this->form_validation->run(); - $this->assertEquals('

' . $err_message . '

', $this->form_validation->error('req_field')); + $this->assertEquals('

'.$err_message.'

', $this->form_validation->error('req_field')); $this->form_validation->reset_validation(); $this->form_validation->set_message('required', $err_message); @@ -346,8 +346,8 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_rules('foo', 'label', 'required'); $_POST = array('foo' => ''); $this->form_validation->run(); - $err_arr = $this->form_validation->error_array(); - $this->assertEquals($error_message, $err_arr['foo']); + $error_array = $this->form_validation->error_array(); + $this->assertEquals($error_message, $error_array['foo']); } public function test_error_string() @@ -364,16 +364,16 @@ class Form_validation_test extends CI_TestCase { $_POST = array('foo' => ''); $this->form_validation->run(); - $this->assertEquals($prefix_default . $error_message . $suffix_default . "\n", $this->form_validation->error_string()); - $this->assertEquals($prefix_test . $error_message . $suffix_default . "\n", $this->form_validation->error_string($prefix_test, '')); - $this->assertEquals($prefix_default . $error_message . $suffix_test . "\n", $this->form_validation->error_string('', $suffix_test)); - $this->assertEquals($prefix_test . $error_message . $suffix_test . "\n", $this->form_validation->error_string($prefix_test, $suffix_test)); - + $this->assertEquals($prefix_default.$error_message.$suffix_default."\n", $this->form_validation->error_string()); + $this->assertEquals($prefix_test.$error_message.$suffix_default."\n", $this->form_validation->error_string($prefix_test, '')); + $this->assertEquals($prefix_default.$error_message.$suffix_test."\n", $this->form_validation->error_string('', $suffix_test)); + $this->assertEquals($prefix_test.$error_message.$suffix_test."\n", $this->form_validation->error_string($prefix_test, $suffix_test)); + $this->form_validation->reset_validation(); $this->form_validation->set_rules('foo', 'label', 'required'); $_POST = array('foo' => 'bar'); $this->form_validation->run(); - $this->assertEquals('', $this->form_validation->error_string()); + $this->assertEquals('', $this->form_validation->error_string()); } public function test_run() @@ -399,27 +399,27 @@ class Form_validation_test extends CI_TestCase { $_POST = array('username' => 'foo42'); $form_validation = new CI_Form_validation($config); $this->assertTrue($form_validation->run('pass')); - - $form_validation = new CI_Form_validation($config); + + $form_validation = new CI_Form_validation($config); $this->assertFalse($form_validation->run('fail')); } - + public function test_has_rule() { $this->form_validation->reset_validation(); $this->form_validation->set_rules('foo', 'label', 'required'); - + $this->assertTrue($this->form_validation->has_rule('foo')); $this->assertFalse($this->form_validation->has_rule('bar')); } - + public function test_set_value() { $this->form_validation->reset_validation(); $default = 'default'; $this->form_validation->set_rules('foo', 'label', 'required'); $this->form_validation->set_rules('bar[]', 'label', 'required'); - + // No post data yet: should return the default value provided $this->assertEquals($default, $this->form_validation->set_value('foo', $default)); $_POST = array('foo' => 'foo', 'bar' => array('bar1', 'bar2')); @@ -545,15 +545,15 @@ class Form_validation_test extends CI_TestCase { public function test_prep_for_form() { $this->form_validation->reset_validation(); - $err_msg_unprepped = ''; - $err_msg_prepped = '<error ='foobar'">'; - $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $err_msg_unprepped)); + $error_msg_unprepped = ''; + $error_msg_prepped = '<error ='foobar'">'; + $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $error_msg_unprepped)); $_POST = array('foo' => ''); $this->form_validation->run(); - $err_arr = $this->form_validation->error_array(); - + $error_arr = $this->form_validation->error_array(); + $this->assertEquals('', $this->form_validation->prep_for_form('')); - $this->assertEquals(array('foo' => $err_msg_prepped), $this->form_validation->prep_for_form($err_arr)); + $this->assertEquals(array('foo' => $error_msg_prepped), $this->form_validation->prep_for_form($error_arr)); } public function test_prep_url() @@ -590,5 +590,4 @@ class Form_validation_test extends CI_TestCase { return $this->form_validation->run(); } - } -- cgit v1.2.3-24-g4f1b From da7a2205876791dda5b9b62840c3cf6bd6233543 Mon Sep 17 00:00:00 2001 From: Achraf Almouloudi Date: Wed, 1 Apr 2015 05:27:56 +0100 Subject: Fixed typo --- system/libraries/Encryption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php index e3e68139a..f3e039881 100644 --- a/system/libraries/Encryption.php +++ b/system/libraries/Encryption.php @@ -121,7 +121,7 @@ class CI_Encryption { ); /** - * List of supported HMAC algorightms + * List of supported HMAC algorithms * * name => digest size pairs * -- cgit v1.2.3-24-g4f1b From 2e9ae00efbc8441e7019a7ab68a866798df42800 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 1 Apr 2015 14:45:16 +0300 Subject: [ci skip] Whitespace cleanup following PR #3716 --- .../codeigniter/libraries/Form_validation_test.php | 58 +++++++++++----------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index b2d401ee5..26d82ec93 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -428,34 +428,34 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('bar1', $this->form_validation->set_value('bar[]', $default)); $this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default)); } - + public function test_set_select() { // Test 1: No options selected - $this->form_validation->reset_validation(); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - - $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); + + $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar', TRUE)); - + // Test 2: 1 option selected $this->form_validation->reset_validation(); $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); $_POST = array('select' => 'foo'); $this->form_validation->run(); - + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo')); $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo', TRUE)); $this->assertEquals('', $this->form_validation->set_select('select', 'bar')); $this->assertEquals('', $this->form_validation->set_select('select', 'bar', TRUE)); - + // Test 3: Multiple options selected $this->form_validation->reset_validation(); $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric'); $_POST = array('select' => array('foo', 'bar')); $this->form_validation->run(); - + $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'foo')); $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'foo', TRUE)); $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'bar')); @@ -463,35 +463,35 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar')); $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar', TRUE)); } - + public function test_set_radio() { // Test 1: No options selected - $this->form_validation->reset_validation(); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - + $this->assertEquals('', $this->form_validation->set_radio('select', 'foo')); // Default should only work when no rules are set $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar', TRUE)); - + // Test 2: 1 option selected $this->form_validation->reset_validation(); $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); $_POST = array('select' => 'foo'); $this->form_validation->run(); - + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo')); $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo', TRUE)); $this->assertEquals('', $this->form_validation->set_radio('select', 'bar')); $this->assertEquals('', $this->form_validation->set_radio('select', 'bar', TRUE)); - + // Test 3: Multiple options checked $this->form_validation->reset_validation(); $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric'); $_POST = array('select' => array('foo', 'bar')); $this->form_validation->run(); - + $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'foo')); $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'foo', TRUE)); $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'bar')); @@ -499,34 +499,34 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar')); $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar', TRUE)); } - + public function test_set_checkbox() { // Test 1: No options selected - $this->form_validation->reset_validation(); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - - $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); + + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar', TRUE)); - + // Test 2: 1 option selected $this->form_validation->reset_validation(); $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); $_POST = array('select' => 'foo'); $this->form_validation->run(); - + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo')); $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo', TRUE)); $this->assertEquals('', $this->form_validation->set_checkbox('select', 'bar')); $this->assertEquals('', $this->form_validation->set_checkbox('select', 'bar', TRUE)); - + // Test 3: Multiple options selected $this->form_validation->reset_validation(); $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric'); $_POST = array('select' => array('foo', 'bar')); $this->form_validation->run(); - + $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'foo')); $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'foo', TRUE)); $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'bar')); @@ -534,14 +534,14 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar')); $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar', TRUE)); } - + public function test_regex_match() { $regex = '/f[a-zA-Z]+/'; $this->assertTrue($this->form_validation->regex_match('foo', $regex)); - $this->assertFalse($this->form_validation->regex_match('bar', $regex)); + $this->assertFalse($this->form_validation->regex_match('bar', $regex)); } - + public function test_prep_for_form() { $this->form_validation->reset_validation(); @@ -555,7 +555,7 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('', $this->form_validation->prep_for_form('')); $this->assertEquals(array('foo' => $error_msg_prepped), $this->form_validation->prep_for_form($error_arr)); } - + public function test_prep_url() { $this->assertEquals('', $this->form_validation->prep_url('')); @@ -564,13 +564,13 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('http://codeigniter.com', $this->form_validation->prep_url('http://codeigniter.com')); $this->assertEquals('http://www.codeigniter.com', $this->form_validation->prep_url('www.codeigniter.com')); } - + public function test_encode_php_tags() { $this->assertEquals("<?php", $this->form_validation->encode_php_tags('assertEquals('?>', $this->form_validation->encode_php_tags('?>')); } - + /** * Run rules * -- cgit v1.2.3-24-g4f1b From 68bad62fc4d88b6423bd15ab94a53c54a919f041 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 1 Apr 2015 14:51:25 +0300 Subject: Mitigate potential DoS attacks against hash_pbkdf2() Related: #3720 --- system/core/compat/hash.php | 51 +++++++++++++++++++++++++++++++++++-- user_guide_src/source/changelog.rst | 14 ++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/system/core/compat/hash.php b/system/core/compat/hash.php index 477535dca..15954559c 100644 --- a/system/core/compat/hash.php +++ b/system/core/compat/hash.php @@ -174,9 +174,56 @@ if ( ! function_exists('hash_pbkdf2')) } $hash_length = strlen(hash($algo, NULL, TRUE)); - if (empty($length)) + empty($length) && $length = $hash_length; + + // Pre-hash password inputs longer than the algorithm's block size + // (i.e. prepare HMAC key) to mitigate potential DoS attacks. + static $block_sizes; + empty($block_sizes) && $block_sizes = array( + 'gost' => 32, + 'haval128,3' => 128, + 'haval160,3' => 128, + 'haval192,3' => 128, + 'haval224,3' => 128, + 'haval256,3' => 128, + 'haval128,4' => 128, + 'haval160,4' => 128, + 'haval192,4' => 128, + 'haval224,4' => 128, + 'haval256,4' => 128, + 'haval128,5' => 128, + 'haval160,5' => 128, + 'haval192,5' => 128, + 'haval224,5' => 128, + 'haval256,5' => 128, + 'md2' => 16, + 'md4' => 64, + 'md5' => 64, + 'ripemd128' => 64, + 'ripemd160' => 64, + 'ripemd256' => 64, + 'ripemd320' => 64, + 'salsa10' => 64, + 'salsa20' => 64, + 'sha1' => 64, + 'sha224' => 64, + 'sha256' => 64, + 'sha384' => 128, + 'sha512' => 128, + 'snefru' => 32, + 'snefru256' => 32, + 'tiger128,3' => 64, + 'tiger160,3' => 64, + 'tiger192,3' => 64, + 'tiger128,4' => 64, + 'tiger160,4' => 64, + 'tiger192,4' => 64, + 'whirlpool' => 64 + ); + + if (isset($block_sizes[$algo]) && strlen($password) > $block_sizes[$algo]) { - $length = $hash_length; + $password = hash($algo, $password, TRUE); } $hash = ''; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 45780ddb3..e6e3e9d17 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -2,11 +2,21 @@ Change Log ########## -Version 3.0 (planned) -======================= +Version 3.0.1 +============= Release Date: Not Released +- Core + + - Added DoS mitigation to :php:func:`hash_pbkdf2()` :doc:`compatibility function `. + + +Version 3.0.0 +============= + +Release Date: March 30, 2015 + - License - CodeIgniter has been relicensed with the `MIT License `_, eliminating its old proprietary licensing. -- cgit v1.2.3-24-g4f1b From d75847ecf28bdbad7033af33514d042ee86c13c2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 1 Apr 2015 14:51:47 +0300 Subject: [ci skip] Update version numbers --- system/core/CodeIgniter.php | 2 +- user_guide_src/source/conf.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index b38166b60..ddf322749 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -55,7 +55,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @var string * */ - define('CI_VERSION', '3.0.0'); + define('CI_VERSION', '3.0.1-dev'); /* * ------------------------------------------------------ diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 93d70b2e4..1704654b6 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2014 - 2015, British Columbia Institute of Technology' # built documents. # # The short X.Y version. -version = '3.0.0' +version = '3.0.1' # The full version, including alpha/beta/rc tags. -release = '3.0.0' +release = '3.0.0-dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit v1.2.3-24-g4f1b From 680e52985219a25926a3396677cb8391c8cc9da6 Mon Sep 17 00:00:00 2001 From: Sentabi Date: Thu, 2 Apr 2015 23:52:40 +0700 Subject: fixing typo --- user_guide_src/source/tutorial/static_pages.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst index 0c75d5a34..62b3469ad 100644 --- a/user_guide_src/source/tutorial/static_pages.rst +++ b/user_guide_src/source/tutorial/static_pages.rst @@ -12,14 +12,14 @@ It is the glue of your web application. For example, when a call is made to: - http://example.com/news/latest/10 + http://example.com/news/latest/10 We might imagine that there is a controller named "news". The method being called on news would be "latest". The news method's job could be to grab 10 news items, and render them on the page. Very often in MVC, you'll see URL patterns that match: - http://example.com/[controller-class]/[controller-method]/[arguments] + http://example.com/[controller-class]/[controller-method]/[arguments] As URL schemes become more complex, this may change. But for now, this is all we will need to know. -- cgit v1.2.3-24-g4f1b From b7a8fbb9588ce4603e9c8fa16072a186e70b8bdb Mon Sep 17 00:00:00 2001 From: Kyle Gadd Date: Fri, 3 Apr 2015 17:37:44 -0600 Subject: Matched root_path's slashes with the name being replaced --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index f2f17148b..3e98ac568 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -352,7 +352,7 @@ class CI_Zip { // Set the original directory root for child dir's to use as relative if ($root_path === NULL) { - $root_path = dirname($path).DIRECTORY_SEPARATOR; + $root_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, dirname($path)).DIRECTORY_SEPARATOR; } while (FALSE !== ($file = readdir($fp))) -- cgit v1.2.3-24-g4f1b From 1db6da309a66ff202d43a4bbb5fdbd66d70afe13 Mon Sep 17 00:00:00 2001 From: LouisMilotte Date: Sat, 4 Apr 2015 03:22:12 -0700 Subject: Edit dbforge drop_table line 230 At current the documentation does not distinguish between DROP TABLE IF EXISTS table_name and DROP TABLE table_name. As seen by the DB_forge.php class in system/database; the function accepts a Boolean as the second parameter as to whether or not to apply the IF EXISTS mysql condition. --- user_guide_src/source/database/forge.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/database/forge.rst b/user_guide_src/source/database/forge.rst index 89fac023e..a4edada5c 100644 --- a/user_guide_src/source/database/forge.rst +++ b/user_guide_src/source/database/forge.rst @@ -227,7 +227,7 @@ Execute a DROP TABLE statement and optionally add an IF EXISTS clause. $this->dbforge->drop_table('table_name'); // Produces: DROP TABLE IF EXISTS table_name - $this->dbforge->drop_table('table_name'); + $this->dbforge->drop_table('table_name',TRUE); Renaming a table @@ -405,4 +405,4 @@ Class Reference :returns: TRUE on success, FALSE on failure :rtype: bool - Renames a table. Usage: See `Renaming a table`_. \ No newline at end of file + Renames a table. Usage: See `Renaming a table`_. -- cgit v1.2.3-24-g4f1b From e36d048b068418b76551fb9eaa2c32a7b40f3812 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 4 Apr 2015 21:55:09 +0300 Subject: Fix #3733 Close #3734 --- system/core/Loader.php | 5 +---- user_guide_src/source/changelog.rst | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 007378ee2..9205ad1b6 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1307,10 +1307,7 @@ class CI_Loader { } // Load all other libraries - foreach ($autoload['libraries'] as $item) - { - $this->library($item); - } + $this->library($autoload['libraries']); } // Autoload models diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e6e3e9d17..8fa4d1ef1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -11,6 +11,10 @@ Release Date: Not Released - Added DoS mitigation to :php:func:`hash_pbkdf2()` :doc:`compatibility function `. +Bug fixes for 3.0.1 +------------------- + +- Fixed a bug (#3733) - Autoloading of libraries with aliases didn't work, although it was advertised to. Version 3.0.0 ============= @@ -589,7 +593,7 @@ Release Date: March 30, 2015 Bug fixes for 3.0 ------------------- +----------------- - Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) - a typo in the form validation language file. -- cgit v1.2.3-24-g4f1b From 8f793674fec90d0e3306dce59945fbd6da15936a Mon Sep 17 00:00:00 2001 From: Yahya Erturan Date: Mon, 6 Apr 2015 12:12:53 +0300 Subject: #3727 Lowercase $side variable for $this->db->like() in Query Builder $this->db->like('name',$value,'AFTER') returns LIKE '%$value%'. Safer to lowercase in case of UPPERCASE habits. --- system/database/DB_query_builder.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index e5ffef2bb..a77ed57d0 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -925,6 +925,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver { ? $this->_group_get_type('') : $this->_group_get_type($type); $v = $this->escape_like_str($v); + + // lowercase $side for in case of UPPERCASE string + $side = strtolower($side); if ($side === 'none') { -- cgit v1.2.3-24-g4f1b From 19311361d52413746327b590e3ef51e4d718fd82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Apr 2015 00:02:14 +0300 Subject: Move strtolower() call from PR #3739 out of the loop --- system/database/DB_query_builder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index a77ed57d0..5005d0163 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -918,6 +918,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } is_bool($escape) OR $escape = $this->_protect_identifiers; + // lowercase $side in case somebody writes e.g. 'BEFORE' instead of 'before' (doh) + $side = strtolower($side); foreach ($field as $k => $v) { @@ -925,9 +927,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver { ? $this->_group_get_type('') : $this->_group_get_type($type); $v = $this->escape_like_str($v); - - // lowercase $side for in case of UPPERCASE string - $side = strtolower($side); if ($side === 'none') { -- cgit v1.2.3-24-g4f1b From 475dfac090505832719cb6ff4ff13ab7ac655fbb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Apr 2015 00:07:04 +0300 Subject: Disallow empty FV rules ... for consistency Related: #3736 --- system/libraries/Form_validation.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 05de59628..522eba704 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -198,22 +198,20 @@ class CI_Form_validation { return $this; } - // No fields? Nothing to do... - if ( ! is_string($field) OR $field === '') + // No fields or no rules? Nothing to do... + if ( ! is_string($field) OR $field === '' OR empty($rules)) { return $this; } elseif ( ! is_array($rules)) { // BC: Convert pipe-separated rules string to an array - if (is_string($rules)) - { - $rules = explode('|', $rules); - } - else + if ( ! is_string($rules)) { return $this; } + + $rules = explode('|', $rules); } // If the field label wasn't passed we use the field name -- cgit v1.2.3-24-g4f1b From 5c58e6744c9cf616d93f6f12255e0fc70c751341 Mon Sep 17 00:00:00 2001 From: mult1mate Date: Wed, 8 Apr 2015 16:03:31 +0300 Subject: typo --- system/core/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Common.php b/system/core/Common.php index f28272b5b..a96828e96 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -181,7 +181,7 @@ if ( ! function_exists('load_class')) // Did we find the class? if ($name === FALSE) { - // Note: We use exit() rather then show_error() in order to avoid a + // Note: We use exit() rather than show_error() in order to avoid a // self-referencing loop with the Exceptions class set_status_header(503); echo 'Unable to locate the specified class: '.$class.'.php'; -- cgit v1.2.3-24-g4f1b From 1924eb37cc5488be7560a8a754663bba6a47a5e4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Apr 2015 17:19:24 +0300 Subject: [ci skip] Fix comment typos https://github.com/bcit-ci/CodeIgniter/pull/3748#issuecomment-90925762 --- system/core/Router.php | 2 +- system/database/DB_query_builder.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Router.php b/system/core/Router.php index eb3da2285..f91d3f6ec 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -493,7 +493,7 @@ class CI_Router { * Set directory name * * @param string $dir Directory name - * @param bool $appent Whether we're appending rather then setting the full value + * @param bool $appent Whether we're appending rather than setting the full value * @return void */ public function set_directory($dir, $append = FALSE) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 5005d0163..8251f4558 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2255,7 +2255,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { else { // Cycle through the "select" portion of the query and prep each column name. - // The reason we protect identifiers here rather then in the select() function + // The reason we protect identifiers here rather than in the select() function // is because until the user calls the from() function we don't know if there are aliases foreach ($this->qb_select as $key => $val) { -- cgit v1.2.3-24-g4f1b From abd713f3a6d09f83304e3cf97ff1dfc7b237e094 Mon Sep 17 00:00:00 2001 From: ftwbzhao Date: Thu, 9 Apr 2015 13:11:51 +0800 Subject: use = instead of += --- system/libraries/Cache/drivers/Cache_redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index a35fbf6d2..43e217784 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -270,7 +270,7 @@ class CI_Cache_redis extends CI_Driver if ($CI->config->load('redis', TRUE, TRUE)) { - $config += $CI->config->item('redis'); + $config = $CI->config->item('redis'); } $config = array_merge(self::$_default_config, $config); -- cgit v1.2.3-24-g4f1b From b2119a785cc980cc0b22bc8535729dbad50a0913 Mon Sep 17 00:00:00 2001 From: ftwbzhao Date: Thu, 9 Apr 2015 13:27:01 +0800 Subject: [fix] redis get_metadata --- system/libraries/Cache/drivers/Cache_redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 43e217784..114c32983 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -223,7 +223,7 @@ class CI_Cache_redis extends CI_Driver { $value = $this->get($key); - if ($value) + if ($value !== FALSE) { return array( 'expire' => time() + $this->_redis->ttl($key), -- cgit v1.2.3-24-g4f1b