#4 reports <internal:mysql> functions undefined?

open
nobody
None
5
2009-02-09
2009-02-09
whiskey83
No

Hi,

When I run "phpcallgraph -g" on a script with a call to a mysql function it reports "Call to undefined function".

I'm running this on Ubuntu server Linux 8.04, and php

"PHP 5.2.4-2ubuntu5.4 with Suhosin-Patch 0.9.6.2 (cli) (built: Nov 25 2008 22:10:31)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies"

appears to work perfectly in all the scenarios on this box.

Is this a limitation? Is my configuration causing the problem?

"php -re mysql" reports the functions as "<internal:mysql>"

"php -l" reports "No syntax errors detected"

Look forward to getting to the bottom of this.

Mark.

P.S. AWESOME project! (it works on my self-contained scripts)

Discussion

  • Falko
    Falko
    2009-02-09

    Hi Mark,

    Is that function call contained in the body of a function or method? Unfortunately, the current analysis approach doesn't work with code in the global scope (outside of any functions or methods). To analyze such files you have to manually wrap the code in a dummy function called dummyFunctionForFile_filename_php() which will then be recognized by phpCallGraph. Of course this is not very elegant, but currently the only feasible way due to some conceptual restrictions resulting from the utilization of the InstantSVC CodeAnalyzer. I already had an idea on how to make that dirty dummy function workaround unnecessary, but it's like always: So much to code, so little time. ;)

    The mysql function is probably reported as undefined, because the Sandbox in which the analysis takes part uses an own php.ini. But, if the function call is inside a function or method body, it shouldn't be executed at all.

    Let me know if these explanations helped you.

    Greetings from Berlin
    Falko

     
  • Falko
    Falko
    2009-02-09

    • status: open --> pending
     
  • whiskey83
    whiskey83
    2009-02-09

    Hi Falko,

    The mysql call is inside a function, but the global code is also wrapped in dummyFunctionForFile_filename_php.

    I suspected something like a configuration ini i wasn't aware of, so the codeanalyzer sandbox ini sounds like a strong candidate, I'll have to tinker with it, I'll let you know how things go, any tips would be welcome.

    So much code, Yes I know, I feel like a kid in a sweet-shop, so many delicious things and only two hands mwaamwaaamwaaa..... :-)

    Cold, wet, Stansted - London says Hi.
    Mark.

     
  • whiskey83
    whiskey83
    2009-02-09

    • status: pending --> open
     
  • Falko
    Falko
    2009-02-09

    Hi Mark,

    Watch out when playing with the php.ini. It is dynamically modified at runtime, to forbid calls to all internal PHP functions not needed for the analysis. This avoids damage caused by accidentally executing your code. For the analysis it doesn't matter, whether a function is defined or not. A function is only required to be defined, when it is called.

    It would be better to investigate, why the function is called. Could you send me a piece of example code, so that I can reproduce the issue?

    Cheers,
    Falko