|
Posted by tigerincanada on 12/27/05 19:42
My host recently upgraded to PHP 4.4.1 and I started getting notes from
clients about "call to member function on a non-object" errors. After
investigating, I found the the object was getting overwritten, when
previously the code had worked as intended on PHP 4.3.10.
This is happening deep within a huge application, so I'm having trouble
coming up with a simple reproduce script, and would appreciate any help
or tips from others who've seen a similar problem.
Here's the guilty code segment:
$tax =& $client->getTax();
$order->setTax($tax);
....
Class Order
{
....
function setTax(&$tax) {
if (is_a($tax,'SalesTax')) {
$this->setTaxId($tax->getId());
$this->_tax =& $tax;
} else {
PEAR::raiseError('Expected Sales Tax',ERROR_OBJECT_EXPECTED);
}
}
function setTaxId($tid) {
if (($this->status == ORDER_QUOTE) or ($this->status ==
ORDER_SUSPENDED)) {
if ($this->tax_id != $tid) {
$this->tax_id = $tid;
$this->_tax = NULL;
$this->quotetime = NULL;
}
} else {
PEAR::raiseError('Can not change sales tax for order in
progress',ERROR_PROPERTY_LOCKED);
}
}
....
}
Expected Result:
$order is still an object
Actual Result:
$order is set to the value of $order->quotetime
I've checked, and $order is an object before the method call, but not
afterwards... very strange indeed
[Back to original message]
|