PHP

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Assistance debugging php 5.x.x

    1 answers - 8365 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    That's just one of the problems, it's about a project with over tens of
    thousands lines of code. As I said before, I don't know whats the exact
    cause. There are so many variables that contribute to this issue and of most
    of them I don't understand why they contribute. However, I'm convinced the
    php compiler screws up "really" bad. Now I have to find out why it screws
    up, to be able to file a complete bug-report or to find a work around.
    As posting code isn't an option I will try to explain the issue more
    thoroughly, tomorrow, I'll discuss the possibility of access to one of our
    development servers with my employer.
    A more thorough explanation:
    As I said before, I have a very complex model of objects. First, I will
    describe the piece of the model thats involved and how it works.
    We have object A, B and C, they are children of each other in this order
    Also we have property objects P1, P2 and PX P1 handles textbased property
    changes, P2 and PX represent other types of properties, which types is not
    interesting, the way they handle input is the same as defined in the parent
    class P, the only difference is how they visually represent theirselfs.
    A has properties:
    (int) status
    (array) properties
    (object) B
    B has properties:
    (string) title
    (array) properties
    (object) C
    C has properties:
    (array) properties
    Each object as a "properties" array. These arrays contain the objects P1, P2
    and/or PX. When object A and B wakeup (in reversed order ofcourse) they both
    call a function, giving themselve ($this) as parameter. This function,
    checks the P-objects in the properties array, for changed values. If a value
    is changed, the function will change the value on the object.
    For example:
    B has a P1 property with the name "title" in it's properties array.
    The P1 object get's on wakeup a new value from $_PST or whatever, puts this
    value in it's "value" property and sets it's "changed" flag.
    Now B wakes up and calls "the function", this functions loops through
    the properties array and sees the P1 object with name "title" has it's
    "changed" flag set. Now, the function copies the value from the P1 object to
    the "title" property of B
    So far so good, no errors there however, I'm doing some strange to the
    model, call me stupid, but it just was de easiest way to fix this as
    C handles to visual representation:
    A has a PX object for it's state
    B has a P1 object for it's title
    C doesn't have any property objects (yet, perhaps future types of C
    will)
    Now B has set its "C" child and want C to have it's parental
    properties so they can be displayed.
    B creates references in the properties array of C to all the
    properties of A and B, this is no problem as C doens't call "the
    function" on wakeup so it won't do anything with the properties values and
    even if it did, I really wouldn't care if C's nonexisting "state" or "title"
    got set.
    This all still works fine.
    Now, B get's a new property of type P2, B doesn't care about
    it's value, but has to initially set it. After it's set you might see P2 as
    a "read-only" property object.
    Still no issue, the P2 object is nicely, visually represented and we don't
    care if it's value would change, B doesn't use a property with the P2
    object name.
    I repeated this trick and added another P2 object. Everything seemed fine
    but then, when the P1 title object from B got it's value changed, an
    error was generated: A noticed it's "state" property object PX
    doens't exist and tries to add a new one to it's properties array. However,
    this is no longer an array (which generated the error in the first place).
    B title get's changed correctly. My prove for php screwing up is the
    following:
    I "never", reset the properties array, I just don't (which is proven by
    ZendPlatform)
    seccond: my error handler, displays backtraces of errors, and the backtrace
    just didn't make sense. I have a "helper function" to add property objects
    to the properties array of objects, the error was generated in this
    function. De backtrace gave me a correct line-number for the error, a
    correct filename for the error, but an incorrect function name, it repeated
    the A function instead of showing the name of "helper function".
    Third: The issue seems only to occur when P1 changes and that magical third
    property is of type P2 (that the 2nd property is also P2 doesn't seem to
    mather also their order don't mather) and the name of this third property
    contains something like "keyword". (original name "ssl_keywords" but
    "keyword" and even "keywoord" caused an error while "key" didn't) (when
    using ZendPlatform, the name of the key doesn't matter anymore, the new
    value of the P1 object "title" seems to leak into another not related array
    and everything else seems to work fine. However, this script, with these
    parameters can't be debugged with ZendPlatform, as httpd will segfault, all
    other scripts, even this, without that "title" parameter debug just fine)
    The fourth reason is even more vague. In the beginning I solved the above
    issue quite fast, by just "trying" something. I got bored and wasn't really
    looking into the issue as I thought it was a stupid mistake by my own
    making. I accidentally fixed the issue by letting "the function" (the one
    that applies properties objects values to an object) work on references in
    the foreach loop that looped through the properties array (
    foreach($object->properties as $object) foreach($object->properties as
    &$object) )
    I did not thrust this fix, as it didn't seem related enough and even more
    when you realize that objects in php5 always are references, zo putting that
    & sign there seems a bogus to me.
    Then again, at that time everything seemed to work not! Something else
    began to screw, A again. In the real-life situation, A may
    contain multiple Bs, during wakeup, it loops through it's Bs for
    maintenance. The array for these B's is an associative one, where the keys
    are the language that the Bs represent. Now the code looks like this:
    $keys=array_keys($this->B);
    foreach($keys as $key) {
    // First statement
    // Seccond statement
    }
    In the real-life situaties, there is just one B with key "Nederlands" which
    is "Dutch" in dutch. In the first statement, A takes Bs title,
    similiar to this:
    $this->title=$this->B[$key]->title;
    Works fine, now the secconds statement is executed, A tries to copy the path
    to the icon of B, similiar to this:
    $this->icon=$this->B[$key]->icon;
    This statement fails telling me the element "Nederlancs" doesn't exists.
    This is not a typo, the key mysterialy changed to "Nederlancs"! The "d"
    became a "c".
    Enough prove for me, however, there is still the problem of finding the
    cause and a solution.
    I'm going to double check if everything I said above is correct and I will
    try to create simple reproduce code in order to pinpoint the cause, however,
    if the problem is subject to specific "keynames" I think there is a lot more
    to the issue than meets the eye. So other parts of my code may be involved.
    If anyone is still interested in helping me, please let me know, tell me
    what you need, what you intend to check, a guess about the cause of the
    issue?
    Thank you!
    Eric van Blokland
    "Jay Blanchard" <jay.blanchard (AT) THERMN (DOT) comwrote in message
    @smtmb.tmc.local
    [snip]
    This is "globally" what happens. If you're insterested in this issue,
    willing to help me and if you think yourself to be cappable of helping me.
    Please contact me by responding to this post or contact me directly:
    [/snip]
    There are several on this list who are willing and capable of helping. Put
    it out here on the list, you'll get a better response. Let's see the code.
  • No.1 | | 908 bytes | |

    Tue, November 22, 2005 2:37 pm, Eric wrote:
    $this->title=$this->B[$key]->title;

    While this is SUPPSED to work in PHP 5, it would be my first suspect
    of under-tested code.

    Try this:
    $temp = $this->B[$key];
    $this->title = $temp->title;

    This is not a typo, the key mysterialy changed to "Nederlancs"! The
    "d"
    became a "c".

    This sounds like you treated a STRING as if it were an ARRAY.

    Keep in mind that PHP is quite happy to treat STRING variables is if
    they were arrays of characters.

    So it's entirely possible that your code is NT altering array
    elements but is altering string characters.

    It sounds like you are storing an object property sometimes as a
    string, and sometimes as an array.

    Don't.

    , if you must, then you had better type-check the data every time
    you use it for anything.

Re: Assistance debugging php 5.x.x


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 8 =
QUESTION ON "PHP"

EMSDN.COM