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
$this->WBSAPI_CurlCall ( "once?action=probe" , &$result) );
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 like
PHP Warning: Call-time pass-by-reference has been deprecated;
So, pass in $result
without 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.
#File: app/code/core/Mage/Core/functions.php
function mageCoreErrorHandler($errno, $errstr, $errfile, $errline)
{
...
if (Mage::getIsDeveloperMode()) {
throw new Exception($errorMessage);
} else {
Mage::log($errorMessage, Zend_Log::ERR);
}
}
Since you're not working in developer mode, Magento tries to log an error using the constant Zend_Log
as its type. The problem is (or appears to be) that if your error happens too soon in the Magento bootstrap/dispatch process, Zend_Log
hasn'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 &$result
from your calling code, but not from the function definitions). If you don't want to do that you could try including lib/Zend/Log.php
earlier 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.
foo(&$bar);
Passing a reference to a function
$bar = &baz;
foo($bar);
Or declaring a paramater in a method's prototype indicating it should be passed by reference
public function applyInApp(&$content)
{
}
is still legal PHP code.
Make sure your method names are not generic. I found out that the problem was the name of one of the methods in my custom class. The method was called getData(). As soon as I renamed it, problem was solved. So, most probably, the problem is in your method naming. Try renaming suspicious function names. Source:
http://www.netismine.com/magento/fatal-error-class-zend_log-not-found
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With