[eluser]predi[/eluser]
php 5.3.3
ci 2.1.3
server dedicated, cpu usage 5%, 7 gb ram free, mid traffic.
Server keeps throwing this error from time to time, when i
randomly refresh the page.
I.e. i refresh the page - all works. Keep refreshing and randomly get this error:
Code:
Fatal error: Call to a member function item() on a non-object in /var/www/system/core/Router.php on line 110
I've investigated the Router.php 110 line, this part fails
Code:
if ($this->config->item('enable_query_strings')
Fails because $this->config is randomly NULL, so the config class just doesn't load-up randomly.
Why? How?!
I've modified the Router class, added force class load code:
Code:
if($this->config === NULL)
{
// force load and instantiate
require_once(BASEPATH.'core/Config.php');
$this->config = new CI_Config();
if($this->config === NULL)
die('How can that be?');
}
Still get the error and "How can that be?" message randomly.
Anyone knows seems to be the problem?
UPDATE
I've modified the Router's constructor to the following:
Code:
/**
* Constructor
*
* Runs the route mapping function.
*/
function __construct()
{
$this->config =& load_class('Config', 'core');
$this->uri =& load_class('URI', 'core');
log_message('debug', "Router Class Initialized");
if(ENVIRONMENT == 'development' && $this->config === NULL)
{
print_r($this->config);
die('router->construct :: fail');
}
}
Now i randomly get the die message "router->construct :: fail". So, why question is the same - why and how to fix?