News:

Support the VirtueMart project and become a member

Main Menu

"Fatar Error getText()" on the localhost & displays nothing on the livehost

Started by adrianne, May 07, 2010, 09:20:08 AM

Previous topic - Next topic

adrianne

Hi,

I'm new to vm, please let me know why I'm having this error on my localhost:
Fatal error: Call to a member function getText() on a non-object in C:\xampp\htdocs\..\administrator\components\com_virtuemart\classes\shipping\ups.php on line 172

and in the live site I have no error message but it just remain on the checkout page with the "please select a shipping method"..

I'm using VirtueMart 1.1.4 stable [Gentle Samui]

please let me know what's happening!

thanks!

lowmips

I took a peek at the code.  Basically, there is a UPS error, and the code responsible for displaying the error is not very robust.  It assumes that an error message from UPS is available, and when it tries to retrieve the message, it fails.

Unfortunately, it looks like the XML reply code is displayed well below the code that is failing, so we can't simply spit out the XML reply in plaintext to see what the error is.

You could try this...in ups.php, around line 167:
/* Let's check wether the response from UPS is Success or Failure ! */
if( strstr( $xmlResult, "Failure" ) ) {
$error = true;
$error_code = $xmlDoc->getElementsByTagName( "ErrorCode" );
$error_code = $error_code->item(0);
$error_code = $error_code->getText();

$error_desc = $xmlDoc->getElementsByTagName( "ErrorDescription" );
$error_desc = $error_desc->item(0);
$error_desc = $error_desc->getText();

$vmLogger->err( $VM_LANG->_('PHPSHOP_UPS_RESPONSE_ERROR',false).'. '
. $VM_LANG->_('PHPSHOP_ERROR_CODE').": ".$error_code .', '
. $VM_LANG->_('PHPSHOP_ERROR_DESC').": ".$error_desc);
}


Change it to this:
/* Let's check wether the response from UPS is Success or Failure ! */
if( strstr( $xmlResult, "Failure" ) ) {
if (DEBUG){
echo "Cart Contents: ".$order_weight. " ".$weight_measure."<br><br>\n";
echo "XML Post: <br>";
echo "<textarea cols='80'>".$xmlPost."</textarea>";
echo "<br>";
echo "XML Result: <br>";
echo "<textarea cols='80' rows='10'>".$xmlResult."</textarea>";
echo "<br>";
}
$error = true;
$error_code = $xmlDoc->getElementsByTagName( "ErrorCode" );
$error_code = $error_code->item(0);
$error_code = $error_code->getText();

$error_desc = $xmlDoc->getElementsByTagName( "ErrorDescription" );
$error_desc = $error_desc->item(0);
$error_desc = $error_desc->getText();

$vmLogger->err( $VM_LANG->_('PHPSHOP_UPS_RESPONSE_ERROR',false).'. '
. $VM_LANG->_('PHPSHOP_ERROR_CODE').": ".$error_code .', '
. $VM_LANG->_('PHPSHOP_ERROR_DESC').": ".$error_desc);
}

}


This will spit out the XML request and reply, and then attempt to get the error message (and bomb out again). But it may give you more insight into what's going wrong.
Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

adrianne

thanks for your help but the errors are still the same for both the local and live site..
only the line no. in the local site change.. its line 181.. because of the new code you gave..

what could be the cause of this?
what can i do to fix this.. please help me!
thanks!

lowmips

Quote from: adrianne on May 08, 2010, 00:15:04 AM
thanks for your help but the errors are still the same for both the local and live site..
only the line no. in the local site change.. its line 181.. because of the new code you gave..

what could be the cause of this?
what can i do to fix this.. please help me!
thanks!

You ran it in debug mode and didn't get the XML post and reply?
Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

adrianne


adrianne

if you're talking about the Joomla debug mode.. yes, already run it.. but still it doesnt show error on the shipping page.. it still

Fatal error: Call to a member function getText() on a non-object in C:\xampp\htdocs\..\administrator\components\com_virtuemart\classes\shipping\ups.php on line 181

the joomla queries/select statements goes on the page before this.. i didnt see any errors

lowmips

Not Joomla debug mode. VirtueMart debug mode.  Go to the main virtuemart configuration page..scroll almost all the way down..turn on debug mode there.

Then try it again and post your findings here.
Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

RepulsiveCoder

Quote from: lowmips on May 07, 2010, 15:45:19 PM
I took a peek at the code. ....
if (DEBUG){
echo "Cart Contents: ".$order_weight. " ".$weight_measure."<br><br>\n";
echo "XML Post: <br>";
echo "<textarea cols='80'>".$xmlPost."</textarea>";
echo "<br>";
echo "XML Result: <br>";
echo "<textarea cols='80' rows='10'>".$xmlResult."</textarea>";
echo "<br>";
}
...

Thanks for your code. It really helped me to get the problem.

Anyway, the problem still exists and the page still gets the Fetal Error.
I've made the following changes to remove the ERROR!

Line Number 169

$error = true;
$error_code = $xmlDoc->getElementsByTagName( "ErrorCode" );
$error_code = $error_code->item(0);
$error_code = $error_code->getText();

$error_desc = $xmlDoc->getElementsByTagName( "ErrorDescription" );
$error_desc = $error_desc->item(0);
$error_desc = $error_desc->getText();


Change the Above Block with the Following Block

$error = true;
$error_code = $xmlDoc->getElementsByTagName( "ErrorCode" );
$error_code = $error_code->item(0);
// Checking for Empty Object
if (!empty($error_code))
{
$error_code = $error_code->getText();
}

$error_desc = $xmlDoc->getElementsByTagName( "ErrorDescription" );
$error_desc = $error_desc->item(0);
// Checking for Empty Object
if (!empty($error_desc))
{
$error_desc = $error_desc->getText();
}

// Finaly Checks whether the ERROR CODE parsing, if failed use string parse to get the CODE
if (empty($error_code))
{
ereg('<ErrorCode>([^<]*)</', $xmlResult, $parts);
$error_code = $parts[1];
}
// Finaly Checks whether the ERROR DESC parsing, if failed use string parse to get the Description
if (empty($error_desc))
{
ereg('<ErrorDescription>([^<]*)</', $xmlResult, $parts);
$error_desc = $parts[1];
}