IcePHP__t_type globals

petteyg359petteyg359 Member Gordon PetteyOrganization: PersonalProject: CakePHP
Ice 3.4.1, PHP 5.3.4

I am attempting to use Ice to implement a control panel in PHP, using an MVC framework (CakePHP). The nature of the framework prevents Ice's globals (IcePHP__t_bool, IcePHP__t_byte, IcePHP__t_short, IcePHP__t_int, IcePHP__t_long, IcePHP__t_float, IcePHP__t_double, IcePHP__t_string) from working. I could do "global $IcePHP__t_type" for each type in every place I want to use them, but that's far from pretty. Why aren't these enscapulated in the $ICE object created by Ice\initialize()?

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Gordon,

    Welcome to the forum.

    Can you explain a bit more about the situation in which these globals aren't available? It will help us to ensure we get the necessary changes included in a future release.

    Thanks,
    Mark
  • petteyg359petteyg359 Member Gordon PetteyOrganization: PersonalProject: CakePHP
    They are available, if I'm willing to litter a dozen global $IcePHP__t_type;s in every file. What is the rationale for making them global? They're specific to Ice, so they should be part of Ice. Make them members of the object created by Ice\initialize(), and I'll pass it as a parameter of every call to the slice object. Or, the inclusion of a slice could be done by the Ice object ($ICE=Ice\initialize(); $ICE->loadSlice('myslice.php'); or some such), and then the slice object knows that the type objects are members of its parent. Either way is better than having a dozen global statements in each file.
  • petteyg359petteyg359 Member Gordon PetteyOrganization: PersonalProject: CakePHP
    mes wrote: »
    Can you explain a bit more about the situation in which these globals aren't available? It will help us to ensure we get the necessary changes included in a future release.

    A simple example, even outside of a framework, with just two pages:
    <?php // filename: a.php
    require_once 'Ice_ns.php';
    $ICE = Ice\initialize();
    require_once 'b.php';
    murm();
    
    <?php // filename: b.php
    function murm() {
    require_once 'murmur_slice.php';
    }
    

    Output:
    ( ! ) Notice: Undefined variable: IcePHP__t_byte in murmur_slice.php on line 26
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Warning: IcePHP_defineSequence() expects parameter 2 to be object, null given in murmur_slice.php on line 26
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3
    4 0.0030 1360496 IcePHP_defineSequence( ) ../murmur_slice.php:26

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 91
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 92
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_bool in murmur_slice.php on line 93
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_bool in murmur_slice.php on line 94
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_bool in murmur_slice.php on line 95
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_bool in murmur_slice.php on line 96
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_bool in murmur_slice.php on line 97
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 98
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 99
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 100
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 101
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 102
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 103
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 104
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 105
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 106
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 107
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_string in murmur_slice.php on line 108
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_bool in murmur_slice.php on line 110
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Notice: Undefined variable: IcePHP__t_int in murmur_slice.php on line 111
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3

    ( ! ) Fatal error: Uncaught exception 'RuntimeException' with message 'no object found in IcePHP_defineStruct()' in murmur_slice.php on line 111
    ( ! ) RuntimeException: no object found in IcePHP_defineStruct() in murmur_slice.php on line 111
    Call Stack
    # Time Memory Function Location
    1 0.0001 639176 {main}( ) ../a.php:0
    2 0.0027 1248152 murm( ) ../a.php:5
    3 0.0029 1360104 require_once( 'murmur_slice.php' ) ../b.php:3
    4 0.0036 1372984 IcePHP_defineStruct( ) ../murmur_slice.php:111

    The only way to make it work is to explicitly global $IcePHP__t_type; in every function Ice is used in. Hopefully a near-future version will make these part of the object returned by initialize().
  • dmitry.medvedevdmitry.medvedev Member Dmitry N. MedvedevOrganization: PersonalProject: Casual Game Analytics Dashboard ✭✭
    mes wrote: »
    Hi Gordon,

    Welcome to the forum.

    Can you explain a bit more about the situation in which these globals aren't available? It will help us to ensure we get the necessary changes included in a future release.

    Thanks,
    Mark

    Mark, actually we've been talking about exactly the same thing as Gordon does. Please, recall our conversation here.

    ...and, if you have a solution, please, share! I'm very, very, very much like the idea of using Ice from PHP on my site!..
Sign In or Register to comment.