このエラーがあります:
[2012年7月25日水曜日15:48:09][エラー][クライアント50.xxx.xxx.xxx]PHP致命的なエラー:/ var / www / magento / app内の非オブジェクトでメンバー関数getSource()を呼び出す/code/core/Mage/Catalog/Model/Product.php(1389行目)
この関数では:
/**
* Get attribute text by its code
*
* @param $attributeCode Code of the attribute
* @return string
*/
public function getAttributeText($attributeCode)
{
return $this->getResource()
->getAttribute($attributeCode)
->getSource()
->getOptionText($this->getData($attributeCode));
}
そして、エラーが発生するたびに$attributeCode値をログに記録したいと思います。だから私はこれに関数を変更します:
public function getAttributeText($attributeCode)
{
try {
return $this->getResource()
->getAttribute($attributeCode)
->getSource()
->getOptionText($this->getData($attributeCode));
} catch (Exception $e) {
Mage::log($attributeCode);
throw($e);
}
}
…そしてApacheを再起動しますが、server.logには何も表示されません。throw($ e)をコメントアウトしても、例外はスローされます。
./lib/Zend/Rest/Server.phpにはset_exception_handler(array($ this、 "fault"));があります。
ただし、どこかに設定すると、phpはすべての手動例外処理を無視しないことを教えてください。それはおかしいからです。
例外が発生した場合にのみ$attributeCodeをキャプチャする方法はありますか?