Archived

This forum has been archived. Please start a new discussion on GitHub.

Undefined variable: IcePHP__t_bool

Good evening, everyone!
  1. I have created an IceBox service: Timer. Both the server side and the client. Both in C#. The server-side runs OK on Debian. The client is under Windows. Also OK.
  2. I have created another client in PHP. Ran it on Debian from command line (php -f timer.php) and it was OK. No errors, very quick. I was happy.
  3. I have incorporated the PHP code into a page executed by apache2. Now comes the problem: Undefined variable: IcePHP__t_bool.
  4. I have checked to see if the incorporation procedure was OK - I have executed the php page with client code agian from command line from the same location the apache2 gets it. Confirm - it runs OK. But, whenever the apache2 tries to execute the client code it fails with the error mentioned above.
APPPATH/classes/controller/Ice/BuiltinSequences.php [ 24 ]
24     $Ice__t_BoolSeq = IcePHP_defineSequence('::Ice::BoolSeq', $IcePHP__t_bool);

I am sure I have something like misconfiguration here, but cannot figure out what that could be.

Could you please ask me some questions so that by answering them I could fix this?

With best regards,
Dmitry

Comments

  • bernard
    bernard Jupiter, FL
    Hi Dmitry,

    On which platform do you run apache2 and your PHP client?

    Which version of Ice / which Ice binaries are you using?

    Cheers,
    Bernard
  • Thanks for your reply, Bernard!
    bernard wrote: »
    On which platform do you run apache2 and your PHP client?
    1. Both the apache2 and the PHP client are run on Debian 6.0.1.
    2. Apache 2.2.16
    3. PHP 5.3.3-7+squeeze1
    bernard wrote: »
    Which version of Ice / which Ice binaries are you using?

    [LIST=2]
    [*]I.C.E. 3.4.1-7 (and actially I found 3.4.1-6)
    [*]IcePHP.so is located in two directories: /usr/lib/php5/20090626 and /usr/lib/php5/20090626+lfs
    [*]I use iceboxnet
    [/LIST]
  • Bernard,
    I did't do any configuration of apache for Ice whatsoever (I'm actually not aware of any...). Just pasted the code that has proved to work from command line into php web page. Should there be any tuning of apache?

    UP: I have also checked rights of ice php files and the Ice directory where they reside. As far as I understand it the apache has no problem accessing them.
  • mes
    mes California
    Hi Dmitry,

    I suspect that your apache server is using an older version of the Ice extension for PHP. If the Ice extension wasn't loaded at all, I would expect you to find an error message like this in apache's error log:

    PHP Fatal error: Call to undefined function IcePHP_defineClass()

    The fact that the error does not mention IcePHP_defineClass but rather IcePHP__t_bool implies that you're not using the correct version of the extension.

    Create a page containing the following script:
    <?php
    phpInfo();
    ?>
    
    Open this page in your browser, scroll down to the "ice" section, and examine the version shown there. If there is no "ice" section, or the version is not 3.4.1, then you've found the problem.

    Regards,
    Mark
  • Hello, Mark!
    Thanks for your hint!

    I have modified the php web page to include only the phpinfo() function, commenting out all the rest strings concerning Ice.

    Following are all the occurencies of Ice in the page produced:
    1. /etc/php5/apache2/conf.d/IcePHP.ini
    2. Ice version 3.4.1

    As far as apache log files are concerned — thre is nothing in there related to Ice. Absolutely clean logs. I have also checked php logs that are also clear.

    I am still curious about both the /usr/lib/php5/20090626 and /usr/lib/php5/20090626+lfs paths containing the IcePHP.so file... Is it normal?

    By the way, despite I am running the Squeeze version of Debian (the stable one) the Ice runtime has been installed from the Sid build which is somewhat unstable as I understand it. Anyway, I have no problems running IceBoxNet on Debian, so, I guess the root of the problem is somewhere else.

    Today, I have reinstalled the Ice (which I always install in binaries as you might have noticed...) with
    apt-get --reinstall install zeroc-ice34
    
    ... Just to be sure I have the latest build.
  • mes
    mes California
    Hi,

    Sorry, I'm not sure why you have the two directories in /usr/lib/php5. We don't use or support Debian here. However, I did build Ice 3.4.1 from source on Ubuntu 10.04, installed the Ice extension, and everything worked as expected.

    Regards,
    Mark
  • mes wrote: »
    Hi,

    Sorry, I'm not sure why you have the two directories in /usr/lib/php5. We don't use or support Debian here. However, I did build Ice 3.4.1 from source on Ubuntu 10.04, installed the Ice extension, and everything worked as expected.

    Regards,
    Mark

    Thanks for your reply, Mark!

    Should I remove the Ice binary and install it from source?

    PS: ...and a question, just to be sure is — after installing from source did you do testing the Ice for PHP via, say, apache?
  • mes
    mes California
    Yes, I verified that a simple Ice script worked with apache.

    If you want to resolve this issue, I recommend removing the Ice packages and building the source distribution. Note that you will also likely need to build and install the third-party packages that Ice requires (Berkeley DB 4.8.30 and MCPP 2.7.2 + patches). The source distributions for these are available on our download page.

    To save time, you really only need to build and install the cpp and php subdirectories, at least at first.

    Regards,
    Mark
  • mes wrote: »
    Yes, I verified that a simple Ice script worked with apache.

    If you want to resolve this issue, I recommend removing the Ice packages and building the source distribution. Note that you will also likely need to build and install the third-party packages that Ice requires (Berkeley DB 4.8.30 and MCPP 2.7.2 + patches). The source distributions for these are available on our download page.

    To save time, you really only need to build and install the cpp and php subdirectories, at least at first.

    Regards,
    Mark


    Finally I did it — I have removed Ice binaries, compiled Ice for cpp and php from sources and installed them. Checked that Ice runtime is loaded by PHP (thanks to this forum's search). Tested my php client from command line - perfect. Tested the same code pasted into a page (which is part of Kohana — a CMS framework on PHP) — alas, the same bug again:
    • ErrorException [ Notice ]: Undefined variable: IcePHP__t_bool
    • APPPATH/classes/controller/Ice/BuiltinSequences.php [ 24 ]
    • 24 $Ice__t_BoolSeq = IcePHP_defineSequence('::Ice::BoolSeq', $IcePHP__t_bool);

    weeeeeeell... what's next? Any ideas?
  • OK, Mark, I guess I have finally have grasp what's wrong. The problem is not with Ice the problem is with me now knowing how to properly use Ice.php and the rest of the related files from the distribution.

    I found out that Ice for PHP is OK under apache as soon as I have created a static php page without any reference to class structure of the CMS.
  • And again — Ice for PHP works OK if it's standalone; but doesn't work under a cms framework like Kohana. What is the reason — I don't know.

    And desperately need help with this.

    The ErrorException [ Notice ]: Undefined variable: IcePHP__t_bool in BuiltinSequences.php is still unsolved.

    Where is the IcePHP__t_bool defined at all? I didn't find the right place of its definition anywhere in the Ice for PHP sources. Am I missing something?
  • And the last test.

    1. I have installed Mediawiki on the same host that runs my copy of Kohana where I tried and failed to use Ice for PHP.
    2. I have created a Mediawiki tag extension which uses PHP client code for my Time Ice service. And it runs OK.

    So, the conclusion is: the problem is not with Ice for PHP as you might have already correctly guessed from the content of this thread. The problem is with the Kohana framework which somehow makes it impossible to use third party PHP code. At least for now. And at least for me.

    Thanks to everyone who participated in this thread. You helped alot. I'm serious.

    PS: Should I succeed with Ice for PHP on Kohana, I will share the explanation here. Or maybe write a short article. Or drop you a message. Whatever :)

    PPS: Anyway, your insights are welcome, of course :)

    With regards,
    Dmitry.
  • mes
    mes California
    Hi,

    The IcePHP__t_XXX symbols are defined by the Ice extension. The problem is that the PHP code doesn't explicitly declare them as global. Everything works fine if you include Ice.php from the global scope, but if you include Ice.php from within the scope of a function then the symbols will not be found.

    Try this. Open Ice.php and add the following lines near the beginning of the file:
    global $IcePHP__t_bool;
    global $IcePHP__t_byte;
    global $IcePHP__t_short;
    global $IcePHP__t_int;
    global $IcePHP__t_long;
    global $IcePHP__t_float;
    global $IcePHP__t_double;
    global $IcePHP__t_string;
    
    Run your test again to see if this fixes the problem.

    Mark
  • mes wrote: »
    Hi,

    The IcePHP__t_XXX symbols are defined by the Ice extension. The problem is that the PHP code doesn't explicitly declare them as global. Everything works fine if you include Ice.php from the global scope, but if you include Ice.php from within the scope of a function then the symbols will not be found.

    Try this. Open Ice.php and add the following lines near the beginning of the file:
    global $IcePHP__t_bool;
    global $IcePHP__t_byte;
    global $IcePHP__t_short;
    global $IcePHP__t_int;
    global $IcePHP__t_long;
    global $IcePHP__t_float;
    global $IcePHP__t_double;
    global $IcePHP__t_string;
    
    Run your test again to see if this fixes the problem.

    Mark

    Mark, MARK!!! You have just saved my stupid LIFE!!! :))))

    Yes, I confirm it! As soon as I have declared these variables in the Ice.php the client php code started to work as expected! I am happy now! :))) Thank you very much, Mark! :)))

    Anyway, after a good sleep I will try to find a place within the Kohana global enough for Ice.php inclusion. I just need it be global, for a number of Controllers will utilize the Ice.

    Thank you once more, Mark! Have a nice day!

    With best regards and wishes,
    Dmitry
    :)
  • mes
    mes California
    I'm glad to hear that solved the problem. We'll include a fix for this in the next release.

    Regards,
    Mark