Welcome Guest, Not a member yet? Register   Sign In
profiler warning via get_class
#1

[eluser]philipo[/eluser]
The error (twice):
Quote:A PHP Error was encountered
Severity: Warning
Message: get_class() expects parameter 1 to be object, boolean given
Filename: libraries/Profiler.php
Line Number: 113
The code in question:
Code:
// Let's determine which databases are currently connected to
foreach (get_object_vars($this->CI) as $CI_object)
{
    if ( is_subclass_of(get_class($CI_object), 'CI_DB') )
    {
        $dbs[] = $CI_object;
    }
}
A hack of a fix:
Code:
// Let's determine which databases are currently connected to
foreach (get_object_vars($this->CI) as $CI_object)
{
    if ( is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') )
    {
        $dbs[] = $CI_object;
    }
}
The results that are not objects:
Quote: ["_ci_scaffolding"]=>
&bool;(false)
["_ci_scaff_table"]=>
&bool;(false)

PHP Version: PHP 5.3.0RC2-dev (built: Mar 29 2009 02:15:07)
CI Version: 1.7.1
Conclusion: PHP BC bug? Me?
#2

[eluser]Derek Allard[/eluser]
What code can I use to recreate?
#3

[eluser]philipo[/eluser]
A simple call to the profiler, here's the simplest code to reproduce:
Code:
class Main extends Controller {
    function Main() {
        parent::Controller();
        $this->output->enable_profiler(TRUE);
    }
    
    function index() {
        echo "Hello World";
    }
}
It's the default route.
#4

[eluser]philipo[/eluser]
Do you see the _ci_scaffolding and _ci_scaff_table entries as $CI_object? These seem to be the key as they are boolean and resulting in the errors. I long since deleted the debug code since generating them but could create a more detailed test case if needed.
#5

[eluser]wiredesignz[/eluser]
@Derek,

This code is the culprit
Code:
is_subclass_of(get_class($CI_object), 'CI_DB')

//should read like so because the object is required not it's class name
is_subclass_of($CI_object, 'CI_DB')

http://php.net/manual/en/function.is-subclass-of.php

The highlighter helper function also fails to render correctly when displaying the db queries.




Theme © iAndrew 2016 - Forum software by © MyBB