After having written a few helper classes in magento, now i have this problem, i’m getting this error
Fatal error: Class ‘Zend_Log’ not found in app\code\local\Uhma\Program\Helper\Data.php on line 33
in line 33 i have this
function WBSAPI_OnceProbe ()
{
return ( $this->WBSAPI_CurlCall ( "once?action=probe" , &$result) );//LINE 33
}
the function i’m calling with the return is this
function WBSAPI_CurlCall ( $service , &$result=null )
{
try {
$s = curl_init();
curl_setopt($s,CURLOPT_URL,MYWBSAPIURL.$service);
curl_setopt($s,CURLOPT_POST,false);
curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($s);
curl_close($s);
$result = json_decode ( $output , TRUE );
if (!is_array($result)) return (false);
if (!key_exists('status',$result)) return (false);
if ($result['status'] != 0) return (false);
return ( true );
} catch ( Exception $e ) {
return ( false );
}
}
i’ve been in google for a while, some say that it is a function in my helper that is overwriting a function from magento’s, i put WBSAPI_ to all my functions at the begining, so, it can’t be the cause, i keep getting the same error and i dont know what else to try, need some help here
if it can help, i have some other definitioNs in my file, somthing like this
define ('MYWBSAPIURL','wbsapi.withings.net/');
define ('MYAPIURL','scalews.withings.net/cgi-bin/');
define ('pound',0.453592);
define ('inch', 0.0254);
class Uhma_Program_Helper_Data extends Mage_Core_Helper_Abstract{
//CLASS CONTENT
}
thanks
The reason you’re getting that error is
The code in question is
You’re passing a variable by reference at call time (
&$result). That’s been depreciated in modern versions of PHP. Without custom error handling, you’ll get an warning something likeSo, pass in
$resultwithout the&. Given than your method has the paramater declared in its prototype as a pass-by-reference, doing so won’t functionally change your code. That should take care of your immediate problem.The larger reason Magento’s giving you this error is its custom error handler.
Since you’re not working in developer mode, Magento tries to log an error using the constant
Zend_Logas its type. The problem is (or appears to be) that if your error happens too soon in the Magento bootstrap/dispatch process,Zend_Loghasn’t been loaded yet and the autoloader doesn’t take care of it. That’s why you’re getting your error.You should fix your code not to use call-time pass by reference (remove
&$resultfrom your calling code, but not from the function definitions). If you don’t want to do that you could try includinglib/Zend/Log.phpearlier yourself. I think that’s a bad idea so I’ll leave the hows as an exercise for the reader.Also, for those not familiar with the term “call time pass by reference”, it means indicating a variable should be passed by reference when you call a method.
Passing a reference to a function
Or declaring a paramater in a method’s prototype indicating it should be passed by reference
is still legal PHP code.