How to die Magento immediately when getting an exception? - magento

I got a problem when try to get a helper:
Mage::helper('providers')
In fact, the provider helper is not exist.
But it just out an exception and save it into the file: var/log/exception.log and everything is ok, except I could not see the interface which I want.
I need a way to do if I got any exception, Magento will exit immediately and show the messages on the browser.

Turn on developer mode, and make sure PHP is showing errors.
Open up index.php and change this
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
To this
#if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
#}
ini_set('display_errors', 1);
With developer mode on Exceptions will halt execution instead of being logged.
Also, you could skip comment the if block out by adding the apache environmental variable to MAGE_IS_DEVELOPER_MODE to your .htaccess file and setting it to 1.

Try wrapping the call in a try catch block, i.e.
try {
Mage::helper('providers');
}
catch (Exception $e){
echo $e;
}

Related

JMeter - get error when retrieving the Thread Group name

I tried the following statements in the BeanShell PreProcessor
String groupName = ctx.getThreadGroup().getName();
groupName = "${__BeanShell(ctx.getThreadGroup().getName())}"
Both return the ERROR
jmeter.util.BeanShellInterpreter:
Error invoking bsh method: eval Sourced file:
inline evaluation of: ctx.getThreadGroup().getName();
However, they print the Thread Group name correctly.
Your code looks good (at least this line), the problem seems to be somewhere else
Going forward you can use the following options to get to the bottom of your Beanshell script issue:
Put your code inside the try block like:
try {
String groupName = ctx.getThreadGroup().getName();
} catch (Throwable ex) {
log.error("Something went wrong", ex);
throw ex;
}
This way you will be able to see full error details in jmeter.log file
Add debug() command to the beginning of the Beanshell script - it will trigger debugging output to JMeter console window
See How to Debug your Apache JMeter Script article for more information on JMeter test script issues troubleshooting.

Wrong controller function getting called

I'm building a small HR management system for my company, and am facing a weird issue with GoDaddy hosting. As if the pain that comes with figuring out the index.php? part was not enough, now I'm not able to log in as an HR. The error I get is that:
Parse error: syntax error, unexpected '[' in /home/content/37/11019837/html/hrms/application/controllers/hr.php on line 58
Now the line it refers to is part of a file upload function, and goes like this:
$path = $this->upload->data()['full_path'];
. . . which is simply saving the uploaded file path to $path. BUT, this is part of the uploading function and shouldn't even be accessed while logging in. Once I hit "Log in", the URL says http://www.example.com/hrms/index.php?/hr/dashboard which means the following function will be called:
public function dashboard()
{
$data['page_title'] = 'HR Area';
$this->load->view('hr/header.php', $data);
$this->load->view('hr/navigation.php');
$this->load->view('hr/footer.php');
}
A parting note: The app is working without hiccups on the local server, so I'm not sure why it's hopping functions on GoDaddy servers. Can someone throw some light?
Try this:
$path = $this->upload->data();
$path1 = $path['full_path'];

Mangeto how to get session subtotal value?

I am currently using magento 1.9.1 and i'm trying to get the session subtotal value in external file.
So here it is the code that i am working around with:
<?PHP
require('app/Mage.php'); //Path to Magento
Mage::app();
echo Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
?>
The problem is that when i execute this script i receive blank screen. No value is displayed.
This is all the code in this php page.
What i am doing wrong, can you help me ?
Thanks!
Try
<?php echo Mage::helper('checkout/cart')->getQuote()->getSubtotal() ?>
To see whats behind the white screen:
Goto index.php and uncomment the following line:
#ini_set('display_errors', 1);

Require path is not being accepted [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Warning:
require_once(/var/www/html/test_lms/include/mysql.processing.php):
failed to open stream: No such file or directory in
/var/www/html/test_lms/include/IMEXporter.class.php on line
513
Fatal error: require_once(): Failed opening required
'/var/www/html/test_lms/include/mysql.processing.php'
(include_path='.:/usr/local/lib/php') in
/var/www/html/test_lms/include/IMEXporter.class.php on line
513
PHP from IMEXporter.class.php LINE 513 that is throwing the error
require_once dirname(__FILE__) . "/mysql.processing.php";
The file is there.
The file is chmod 777.
The two files are both owned by the same user and group.
Why is php doing this to me?
The problem could be that mysql.processing.php itself is broken and even though php finds the file it refuses to retrieve it and instead throws a Derp! cant find file. Derp.. Kind of stupid to mislead me like that but its a possibility. I'm checking over my code now.
Nope, I tried erasing the entire script of mysql.processing.php and wrote
echo "Hello you impudent php";
and it still wont find the file. So its not a file broken issue. Also I fixed the file case issue. From uppercase P to lowercase and it still wont go for it. I tried to include a file by the name of test.php and it wont find that one either..
You are having case sensitivity issue. Most likely you moved form windows environment to Linux
If your file is mysql.processing.PHP require_once dirname(__FILE__) . "/mysql.processing.php would work on a windows + apache server but fail on Linux + apace
use the following to get the actual file name
var_dump(scandir(__DIR__));
Please run this simple test
error_reporting(E_ALL);
$name = "mysql.processing.php";
$file = __DIR__ . "/mysql.processing.php";
$dir = scandir(__DIR__);
$func = array("file_exists","is_file","is_readable");
echo "<pre>";
foreach ( $func as $fun ) {
if (! $fun($file)) {
echo $fun, " - Failed ", PHP_EOL;
} else {
echo $fun, " - Failed ", PHP_EOL;
}
}
if (! in_array(basename($file), $dir)) {
echo basename($file), " in_array Error", PHP_EOL;
} else {
echo basename($file), " in_array OK", PHP_EOL;
}
if (! in_array($name, $dir)) {
echo $name, " in_array Failed", PHP_EOL;
} else {
echo $name, " in_array Ok", PHP_EOL;
}
if ($name !== basename($file)) {
echo $name, " basename Failed", PHP_EOL;
} else {
echo $name, " basename OK", PHP_EOL;
}
Well, in the error message the capitalization on the filename is not the same as in the require line you posted... are you sure it's not a typo?
Okay here was the problem. Remember when I mentioned that my mysql.processing.php file could be broken? Well that was half the issue. Apparently php require returns the error failed to open stream: No such file or directory.. etc if it:
1) Cannot find the file.
2) It finds the file, but it cannot open it.
The error message is misleading and leads you to believe it is a path issue. Sometimes it is, but cases like mine, its just a syntax issue with the returned file. Now for the second half. I made the corrections to all my syntax errors on the mysql.processing.php but it still was not working.. So I just did a reboot of my server and now it works.
The second half of the problem is that php has a nasty tendency to cache php files. Often you can start editing a php script, fixing solutions etc etc and not make any progress because php wont immediately take into effect your changes. This can lead you into stumbling around from one solution to the next, constantly changing your script and it can feel like you are in a maze.
There are ways to stop php from caching specific files. But the problem was php itself, with its misleading error report, and two with its caching of problems and excluding solutions.
Maybe the problem is that your php are not in the same folder, you cannot include a .php from a URL or another folder. You can include a php if it is on the same path or in a subfolder that is on your path. Sorry for my english but I think that you're going to understand what I'm saying.

Write permissions with Codeigniter + Simplepie

I am trying to create a simple RSS parser using the two frameworks. However I am getting PHPerrors when trying to write to my cache directory:
set_cache_location(APPPATH.'cache/rss');
I am running windows 7 with XAMPP using the latest version of Simplepie from github
error:
A PHP Error was encountered
Severity: User Warning
Message: C:\xampp\htdocs\geekurls/system/application/cache/rss is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.
Filename: libraries/simplepie.php
Line Number: 1732
Tried like the below comment said and tried making a test file but to no luck
$file = APPPATH."cache/rss/testFile.txt";
$handle = fopen($file, 'w') or die("fail");
fclose($handle);
A simple checks to find out what might be happening,
Try creating a file in this directory using standard php - this could help solve permission problems.
$this->load->helper('file');
$data = 'Some file data';
if ( ! write_file('./path/to/file.php', $data))
{
echo 'Unable to write the file';
}
else
{
echo 'File written!';
}
Also how about using the default cache?
http://simplepie.org/wiki/faq/i_m_getting_cache_error_messages

Resources