HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 656 forks source link

Issue 726 - SPOD + "lazy variables" (getters) on PHP - haxe #726

Closed issuesbot closed 11 years ago

issuesbot commented 11 years ago

[Google Issue #726 : https://code.google.com/p/haxe/issues/detail?id=726] by cl3...@gmail.com, at 02/04/2012, 19:01:44 Define a SPOD class with a lazy variable like this:

class SomeObject extends sys.db.Object {
    //...
    @:skip
    public var lazy ( getLazy , null ) : LazyObject;
    private function getLazy(){
        if( lazy == null ){
            lazy = new LazyObject();
            }
        return lazy;
        }
    }

Then the second time you get an object and try to access its lazy field, PHP will throw an exception like:

Undefined property: SomeObject::$lazy (errno: 8) in SomeObject.php at line xx

This is the problematic line in the PHP source :

if($this->links === null) {

This time again, the bug seems related to sys.db.Manager.getFromCache, especially the way it deletes all fields before populating them with updated values.

But it could be related to the PHP target, as IMHO this "undefined property" shouldn't raise an Exception.

Regards,

issuesbot commented 11 years ago

[comment from franco.p...@gmail.com, published at 03/04/2012, 14:28:44]

issuesbot commented 11 years ago

[comment from cl3...@gmail.com, published at 07/04/2012, 10:10:05] Attached is a much simpler test that shows the issue with Reflect, without using SPOD. I get : uncaught exception: Undefined property: Obj::$value (errno: 8) in /home/clemos/public_html/test/out/lib/Test.class.php at line #9Undefined property: Obj::$value

in file: /home/clemos/public_html/test/out/lib/Test.class.php line 9

0 /home/clemos/public_html/test/out/lib/Test.class.php(9): _hx_error_handler(8, 'Undefined prope...', '/home/clemos/pu...', 9, Array)

1 /home/clemos/public_html/test/out/index.php(9): Test::main()

2 {main}%

issuesbot commented 11 years ago

[comment from franco.p...@gmail.com, published at 09/04/2012, 02:49:49] This issue was closed by revision 1836745f4d5c6939ca00e99f3e2cf0a991f05658.

issuesbot commented 11 years ago

[comment from franco.p...@gmail.com, published at 09/04/2012, 02:52:32] I've been able to test the second sample but not the SPOD sample; please let me know if it works.

issuesbot commented 11 years ago

[comment from cl3...@gmail.com, published at 30/04/2012, 17:26:24] Sorry I forgot to confirm: it works, thanks :)