Caching Issue with Standard mode?

Discussion about the open-source Phalanger [?] project.

Caching Issue with Standard mode?

Postby cr33p » February 21st, 2013, 12:07 am

:?: Hey folks - I'm testing using Phalanger in a C# application as a scripting language. The short of it is that I want to call standard PHP code from within C# and retrieve the value. Simple enough.

Here's the issue: I created a simple Windows Forms application and added all the relevant references. I created a simple PHP class file as follows:

Code: Select all
    <?php

    class Standard
    {
        function __construct()
        {
        }
   
        function wows()
        {
            return "Test1";
        }
    }

    ?>



And in my Forms application, I create the context and call the PHP code:

Code: Select all
    private void button1_Click(object sender, EventArgs e)
    {
        ScriptContext context = ScriptContext.CurrentContext;
        context.Include("standard.php", true);

        var c = (PhpObject)context.NewObject("Standard", PhpArray.Keyed());

        var bar2 = new PhpCallback(c, "wows");
        var ret3 = bar2.Invoke(null, new object[] {});
        MessageBox.Show((string)ret3);
    }



Compile and run in debug and it works just fine. I get the message box and it return "Test1" as expected.

Now for grins, I change the return statement to: return "something else";

Compile and run again and it still returns "Test1". Step through it in debug mode and I can see the PHP code is indeed updated. This is unexpected. As a test, I changed the function name in the PHP code to something else and the C# code doesn't error and still return "Test1". Obviously Phalanger is caching the PHP code somewhere, but I've been unable to find it.

I've run the "Clean and Rebuild" option on the entire solution as well as the individual project. I've manually deleted all the bin\debug files. I created a new project and follow the same steps... all yields the same results.

This is the most recent version (as of yesterday) of Phalanger running on VS2010 Professional (also up to date with SP's, etc), Windows 7 x64 (also up to date).

Is anyone aware of any additional caching Phalanger is doing when calling PHP code in "standard" mode? If so, any idea how I can clear that cache to get the expected results?
cr33p
 
Posts: 3
Joined: February 21st, 2013, 12:04 am

Re: Caching Issue with Standard mode?

Postby Jakub Misek » February 21st, 2013, 8:36 am

Hi,

Phalanger does not cache compiled source code. Only when running web app (into C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files) and when running eval() command (cache into memory, so the code is recompiled after app restarts).

I would suggest to ensure, your app references latest version of the compiled PHP code. Possibly restart VS, and check when the files were created.

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Caching Issue with Standard mode?

Postby cr33p » February 22nd, 2013, 2:02 am

Thanks Jakub,

I tried restarting VS and that didn't help. Another interesting tidbit, if I run the the exe directly from the debug folder without VS I see the same results. To see if it's a caching issue I removed the .php file from the folder and re-ran the application and it throws the expected error that the script cannot be included, so it doesn't appear to be a caching issue.

Yet another test: edit the PHP code, create a variable $blah = "something", change the return value to $blah, save, close, rerun the executable and it now sees the new return value. Edit the php code, change $blah to "something else", rerun and it still returns the original $blah value.

I can't see for the life of me why or how it is still pulling the old value. It doesn't seem to be a VS issue since it also happens outside VS.

Any ideas on how I can track this down?
cr33p
 
Posts: 3
Joined: February 21st, 2013, 12:04 am

Re: Caching Issue with Standard mode?

Postby Jakub Misek » February 22nd, 2013, 9:34 am

Not sure what can cause this.

Try to 'discover' location of that PHP DLL. In C# once you have instance of PHP class, it would be something like
Code: Select all
c.GetType().Assembly.Location


Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Caching Issue with Standard mode?

Postby cr33p » February 22nd, 2013, 11:44 pm

Recall that this is standard mode, so the file in question is a pure php file being included from a c# winforms app, not a php dll. When I do the same in pure mode it works fine... its only standard mode that causes the issue.
cr33p
 
Posts: 3
Joined: February 21st, 2013, 12:04 am

Re: Caching Issue with Standard mode?

Postby Jakub Misek » February 23rd, 2013, 12:38 am

And what is the location of DLL (compiled in standard mode) ? Isn't there a lost copy of old DLL being used in runtime?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 21 guests

User Control Panel

Login

Who is online

In total there are 21 users online :: 0 registered, 0 hidden and 21 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 21 guests