Ask your Symfony questions! Pay money and get answers fast! (more info)

Why would this code not execute nor throw an error? Symfony

  • SOLVED

Can anyone suggest what is wrong, or how I might get a meaningful error message?

The first log message shows up in the logs, as you would expect. None of the following messages show up in the logs. Nor do any errors appear in the Apache error logs. Nor does the code execute, beyond that first log message.

PaymentOutgoingToTmaPeer is a new class and I assume the problem has something to do with it. But why would there be no error message in the Apache logs?


public function initiate3rdPartyPayment($paypalTransactionId, $theQuestion) {
$isThisACodewiseSite = sfConfig::get('app_is_this_a_codewise_site');
if ($isThisACodewiseSite == 'yes') {
$email = '[email protected]';
} else {
$email = '[email protected]';
}

$this->logMessage("In question/initiate3rdPartyPayment: we were asked to send a payment for paypal transaction id '$paypalTransactionId' and the question id is {$theQuestion->getId()} and the email is $email. We have not yet sent a payment. We will now determine whether or not we have already made a payment on this transaction. ", 'crit');

$c = new Criteria();
$c->add(PaymentOutgoingToTmaPeer::PAYPAL_TRANSACTION_ID_FOR_ORIGINAL_PAYMENT, $paypalTransactionId);
$thisTransaction = PaymentOutgoingToTmaPeer::doSelectOne($c);

if (getClass($thisTransaction) == 'PaymentOutgoingToTma') {
$this->logMessage("In question/initiate3rdPartyPayment: we were asked to send a payment for paypal transaction id '$paypalTransactionId' but a payment for this transaction has already been recorded. If we get here then PayPal is probably pinging us twice for the same question, whose id is: " . $theQuestion->getId(), 'crit');

} else {

$this->logMessage("In question/initiate3rdPartyPayment: we were asked to send a payment for paypal transaction id '$paypalTransactionId' and the question id is {$theQuestion->getId()} and the email is $email. We have determined that this transaction has not happened previously we we will use PaymentOutgoingToTma to make a record of this next mass payment.", 'crit');

$thirdPartyTransactionObject = new PaymentOutgoingToTma();
$thirdPartyTransactionObject->setDate(date('Y-m-d h:i:s'));
$thirdPartyTransactionObject->setPaypalTransactionIdForOriginalPayment($paypalTransactionId);
$thirdPartyTransactionObject->setEmail($email);
$thirdPartyTransactionObject->save();

$isThisACodewiseSite = sfConfig::get('app_is_this_a_codewise_site');
if ($isThisACodewiseSite == 'yes') {
$moneyForL = $theQuestion->getPrizeAmount() * .05;
$this->paypalMassPayTo3rdPartiesIncludingUs($moneyForL, $email);
} else {
$moneyForCodewise = $theQuestion->getPrizeAmount() * .02;
$this->paypalMassPayTo3rdPartiesIncludingUs($moneyForCodewise, $email);
}

$this->logMessage("In question/initiate3rdPartyPayment: we were asked to send a payment for paypal transaction id '$paypalTransactionId' and the question id is {$theQuestion->getId()} and the email is $email. We are now at the end of the function. We have probably sent a payment ", 'crit');
}
}



And yes, I'm aware the code is terribly redundant. I've been tearing it to pieces trying to figure out this bug. If I could just this code to work, then I would clean it up.

Answers (2)

2010-11-30

Christian Schaefer answers:

I think its this line:


if (getClass($thisTransaction) == 'PaymentOutgoingToTma') {

If I'm not mistaken the function getClass() does not exist and you meant to call get_class().
Things like these often crash between the parser and the runtime. It escapes me why there are no errors whatsoever but i experiences the same thing more than once.


Lawrence Krubner comments:

Damn, I hate stuff like that. Was staring at the code for over an hour and just not seeing it. Stupid little typo.

2010-11-30

José Nahuel Cuesta Luengo answers:

As Christian says, get_class() is the correct function. But aside from that, you should check your server's PHP configuration to set it to show errors (if you are in a 'dev' environment).

As a side-tip, consider using transactions in methods like this one where related objects are to be saved to the database.