Welcome Guest, Not a member yet? Register   Sign In
Bug in System->Libraries->Config.php
#1

[eluser]ErwinVanHoof[/eluser]
When using custom Config files I came across the following error:

Using:
Code:
$this->config->load('[config_filename]', TRUE);

I was unable to retrieve the values with the function:
Code:
$this->config->item('[config_filename]','[item]')

The problem is caused by the function item() in Config.php.
In the else statement the function first looks at index and not the item which should be the other way around, the same fault is repeaeted in the function.

The problems is solved by changing:
-system
-libraries
Config.php

starting at line 124:
Code:
function item($item, $index = '')
    {    
        if ($index == '')
        {    
            if ( ! isset($this->config[$item]))
            {
                return FALSE;
            }

            $pref = $this->config[$item];
        }
        else
        {
            if ( ! isset($this->config[$index]))
            {
                return FALSE;
            }

            if ( ! isset($this->config[$index][$item]))
            {
                return FALSE;
            }

            $pref = $this->config[$index][$item];
        }

        return $pref;
    }
to
Code:
function item($item, $index = '')
    {
        if ($index == '')
        {
            if ( ! isset($this->config[$item]))
            {
                return FALSE;
            }

            $pref = $this->config[$item];
        }
        else
        {
            if ( ! isset($this->config[$item]))
            {
                return FALSE;
            }

            if ( ! isset($this->config[$item][$index]))
            {
                return FALSE;
            }

            $pref = $this->config[$item][$index];
        }

        return $pref;
    }
#2

[eluser]xwero[/eluser]
you should switch the parameters for the item method and then it should be fine.

Changing parameters because of grammar causes confusion.
#3

[eluser]ErwinVanHoof[/eluser]
Could you please explain.




Theme © iAndrew 2016 - Forum software by © MyBB