}
/**
+ * Go up the tree of PHPVariables
+ * look whether the PHPValue is a reference to a parent PHPValue
+ *
+ * TODO Check where this recursion can come from.
+ * Whether this back reference is legal or a bug.
+ *
+ * @param var
+ * @return
+ * <ul>
+ * <li> false if the PHPValue is not a child of itself
+ * <li> true if the PHPValue is
+ * </ul>
+ */
+
+ private boolean hasRecursion (PHPVariable var) {
+ PHPVariable parentVar;
+ PHPValue val;
+
+ val = (PHPValue) var.getValue (); // Get the PHPValue from the current PHPVariable
+
+ while (var != null) { // As long as we have PHPVariable
+ parentVar = var.getParent (); // Get the parent PHPVariable
+
+ if (parentVar != null) { // Is there a parent?
+ if (parentVar.getValue ().equals (val)) { // Get the PHPValue for the parent PHPVariable and check
+ // whether it is the same
+ return true; // Return, if we have recursion
+ }
+ }
+
+ var = parentVar;
+ }
+
+ return false; // No recursion found
+ }
+
+ /**
* This method updates the 'static' variables list.
* It does a replication between the 'static' list (the variable list which
* is a member of this DBG interface object) and the DBG variable list
valNew = (PHPValue) varNew.getValue (); // Get the value from DBG
try {
- if (valOld.hasVariables () || // If the 'static' value has child variables
- valNew.hasVariables ()) { // or if the DBG value has child variables
- updateVariableList (valOld.getChildVariables (), // Update the variable list for the child variables
- valNew.getChildVariables ());
+ if (valOld.hasVariables () || // If the 'static' value has child variables
+ valNew.hasVariables ()) { // or if the DBG value has child variables
+ if (!hasRecursion (varOld) &&
+ !hasRecursion (varNew)) { // Both branches should not have a recursion
+ updateVariableList (valOld.getChildVariables (), // Update the variable list for the child variables
+ valNew.getChildVariables ());
+ }
}
else if (!valOld.getValueString ().equals (valNew.getValueString ())) { // Has the value changed?
valOld.setValueString (valNew.getValueString ()); // Yes, set the 'static' value (variable) to the new value
evalStr = new PHPDBGEvalString (stack, serGlobals); // Process serialized variables
updateVariableList (DBGVarList, evalStr.getVariables ()); // Replicate the 'static' variable list and the via DBG received variable list
- return DBGVarList; // Convert the list to an array and return the array
+ return DBGVarList; // Return the variables as list
}
/**