summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/core/Config.php11
-rw-r--r--tests/codeigniter/core/Loader_test.php29
-rw-r--r--user_guide_src/source/changelog.rst4
3 files changed, 39 insertions, 5 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index 0264776f9..c507f342c 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -90,7 +90,16 @@ class CI_Config {
{
if (isset($_SERVER['SERVER_ADDR']))
{
- $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['SERVER_ADDR']
+ if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
+ {
+ $server_addr = '['.$_SERVER['SERVER_ADDR'].']';
+ }
+ else
+ {
+ $server_addr = $_SERVER['SERVER_ADDR'];
+ }
+
+ $base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
}
else
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 889ab92e4..db5088d80 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -48,11 +48,9 @@ class Loader_test extends CI_TestCase {
// Test a string given to params
$this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' '));
- // Create library w/o class
- $lib = 'bad_test_lib';
- $this->ci_vfs_create($lib, '', $this->ci_base_root, 'libraries');
+ // test non existent lib
+ $lib = 'non_existent_test_lib';
- // Test non-existent class
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested class: '.ucfirst($lib)
@@ -62,6 +60,19 @@ class Loader_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_bad_library()
+ {
+ $lib = 'bad_test_lib';
+ $this->ci_vfs_create(ucfirst($lib), '', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Non-existent class: '.ucfirst($lib)
+ );
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
+ }
+
+ // --------------------------------------------------------------------
+
public function test_library_extension()
{
// Create library and extension in VFS
@@ -131,6 +142,16 @@ class Loader_test extends CI_TestCase {
// Test is_loaded
$this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib)));
+
+ // Test to load another class with the same object name
+ $lib = 'another_test_lib';
+ $class = ucfirst($lib);
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ "CI Error: Resource '".$obj."' already exists and is not a ".$class." instance."
+ );
+ $this->load->library($lib, NULL, $obj);
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index f28fd8930..77ccd7ce7 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -7,6 +7,10 @@ Version 3.1.0
Release Date: Not Released
+Version 3.0.4
+=============
+
+Release Date: Not Released
Version 3.0.3
=============