I've been working with PHP for a while, but fairly new to Smarty.
I'm working with Prestashop and I've noticed Smarty seems to eat up all PHP errors - when there's an error in the PHP code, the .tpl file just outputs a blank page. I've been trying but I can't get Smarty to display whatever the PHP code outputs, even if there's an error.
PHP error reporting is set to show errors.
So, for instance, let's say this is the example.php file:
<?php
//included classes etc go here, irrelevant for this issue
error_reporting(E_ALL ^ E_NOTICE);
echo obvious wrong syntax"
?>
This file is connected to example.tpl which fits the output in a template block.
Obviously, it should throw an error. How do I make Smarty actually display that error?
To activate debug mode, go to config/config.inc.php
Find the following lines and chage off to on for the first one and set to true the second
/* Debug only */
#ini_set('display_errors', 'on');
define('_PS_DEBUG_SQL_', true);
This will display PHP and SQL errors (this would probably be enough for you to resolve "blank page").
There is also a blog post on prestashop site about p() and d() methods and how to track exceptions
To activate templates debug in Prestashop version older than 1.5,go to config/smarty.config.inc.php
Find the following line and set it to true
$smarty->debugging = true;
When you refresh your page, themes/debug.tpl should be rendered.
To activate templates debug in Prestashop 1.5+ you can enable Smarty debugging via Admin panel
Preferences > Performance > Smarty
and set Always open console but console will be opened for everyone ( not good for live site :) )
or set Open console with URL parameter (SMARTY_DEBUG) and add ?SMARTY_DEBUG to the end of your URL to see console
Hope this helps.
I've seen #Sergei Guk's answer and off-course, it's a pretty good answer. However, prestashop has since released version 1.6.
So if you want to show all the errors in prestashop v 1.6.0.6, you just need to go config/defines.inc.php
Replace define('_PS_MODE_DEV_', false); with define('_PS_MODE_DEV_', true);
What it actually does is set a constant and in the next line it checks if "_PS_MODE_DEV_" is true then it will show all kinds of errors in prestashop
if (_PS_MODE_DEV_)
{
#ini_set('display_errors', 'on');
#error_reporting(E_ALL | E_STRICT);
define('_PS_DEBUG_SQL_', true);
}
else
{
#ini_set('display_errors', 'off');
define('_PS_DEBUG_SQL_', false);
}
I have tested it and it works fine.
Set the $error_reporting variable.
See http://www.smarty.net/docsv2/en/variable.error.reporting.tpl
Related
I have a problem with my Wordpress site, more specifically, The7 template. On every page, including the main page at the bottom of page below footer I have 4 Warnings which are the same:
“Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘wp_filter_content_tags’ not found or invalid function name in on line”
I do not know how to solve it/turn it off. Could you tell me which PHP page or what exactly cause this problem to appear? It’s really annoying. Due to the fact that it is in the main body and not in any div/b/p/etc. tag I cannot hide it with CSS just for a while.
Kind regards
Peter
Hiding error reporting on prod
On prod you want to avoid showing errors, due to security and user experience reasons. To achieve this, in PHP you can run
error_reporting(0);
or, even better, in php.ini, you can have this line
error_reporting = off
What the error means
The error tells you that a function is to be called by name, but it does not exist. wp_filter_content_tags does not exist in your context.
Solution to the error
Even though you have hidden error reporting on prod, you still need to show errors on dev and that function might do something very useful. From the doc you can see that it's located in wp-includes/media.php. So, if you do not need to call this function, then search for its calls and remove them. If you need this function, then require or include it into your files. If, for some reason you cannot remove this function (for ex. you do not want to hack a template that might have some versions in the future), but the function/file is not helpful for you, then you can implement a function with the same name.
Thank you very much for answer. I used it to find solution and in my case there is a need to change wp-config.php a little bit. It means to add these specific lines to code:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false)
In my case it worked and no more errors / warnings showed on every / main pages.
Kind Regards
Peter
I try to access my custom components on view and sub controller like
http://www.whizzrd.com/administrator/index.php?option=com_osservicesbooking
I have tried everything, still i didn't know what is the error.
1.added this code on com_yourcomponent/yourcomponent.php
ini_set( 'display_errors', true );
error_reporting( E_ALL );
enable debug in global configuration and set the error_report to development
but I'm still getting blank pages. still not yet find the error
Thank you in advanced
Go to Global Configuration in Admin panel and Server Tab and there do Error Reporting to Maximum.
Doing this setting you will be able to view the error you are getting.
Global Configuration-> Server-> Error Reporting -> Maximum
Try with adding your view name.
http://www.whizzrd.com/administrator/index.php?option=com_osservicesbooking&view=osservicesbookings
Also check filename and component names if it seems differ or capital.
My problem was that I had typed defined('__JEXEC') or die (two underlines before JEXEC) and it is supposed to be defined('_JEXEC') or die and as I had not set a message for die it basically just displayed a blank page with nothing. Took me a couple of hours to figure it out. Best thing I did was to start adding a different message in my die statements and then it will display the die message of the page with errors.
So basically I have tried to setup an error reporting system that logs any PHP, HTML or any other error into a text file called 'errors.txt' located in a specific directory. However, the file is not being created.
Here is the code:
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
ini_set('log_errors',TRUE);
ini_set('error_log','/xampp/xampp-portable-win32-1.8.3-2-VC11/xampp/htdocs/EstateAgent/logs/errors.txt');
ini_set('display_errors',FALSE);
The errors are still be displayed to the user and they error log isn't being created inside of the directory specified.
I have also tried changing the standard values in my 'php.ini' file as suggested on other websites and I have still had no luck.
Any help would be greatly appreciated!
Thanks :)
For anyone who has similar problem - make sure you don't have any other error_reporting and ini_set in other files you use in your project. In those cases it may seem that error reporting is not working properly but in fact it this.
Try to change:
ini_set('log_errors',TRUE);
into
ini_set('log_errors','1');
and
ini_set('display_errors',FALSE);
into
ini_set('display_errors','0');
If it doesn't help, add at the very top beginning of your file:
<?php
error_reporting(0);
ini_set('display_errors','0');
echo $testVariable;
echo "Just testing";
?>
and check if any warning about this variable is displayed before "Just testing".
Now change above code into:
<?php
error_reporting(E_ALL);
ini_set('display_errors','1');
echo $testVariable;
echo "Just testing";
?>
and check if any warning about this variable id displayed before "Just testing".
As above 2 sample codes works as expacted, it's likely that those settings are change in other php files of user or php libraries used by user. You should scan your code and libraries code do track where changes are made and try to solve this issue either removing your code changing your desired reporting or commenting / setting properly (if there is such possibility in constructor or method) reporting in external library
You need to provide a fullpath for the 'error_log' property:
<?php
ini_set('error_log', 'c:/xampp/logs/php_error.log');
?>
You need to make sure that the following folder exists and is "writable": c:/xampp/logs/
If you're using Linux, then the fullpath will look like this: /xampp/logs/php_error.log
Also, use the following:
<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);
ini_set('log_errors', '1');
?>
Trying to figure out why a Wordpress site I moved is doing white screen of death.
Trying to turn on error dumping - but it isn't working. Absolutely nothing is showing up.
Here's sample code:
<?php
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
$con = mysql_connect('localhost', 'groupasa', 'groupasa');
$selected = mysql_select_db("groupasa",$con)
Echo "Test";
?>
for a fatal error you can turn on errors in php code you have to turn them on in apache or htaccess level. You could also go and look in the error log for the errors.
Right click and check the source of your page, sometimes the html doesn't show the error but it's actually in the code.
Not sure if this is the case but hope it helps.
Try putting the Echo statement at the very top of the page and then an exit; if the echo displays then your PHP compiler is working fine and you know that the issue is with the code on the page.
next, add the missing semicolon at the end of mysql_select_db line
you could also check your PHP error logs.
Most times you can solve the 'white screen' by going into the database and using the following query to forcibly 'deactivate' all active plugins.
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
The core of WP is pretty solid, but it's the plugins and garbage that really mucks everything up.
I have a weird problem, I am using print_r($obj) in Joomla YOOtheme ZOO extension and it returns a blank page. it just act as die() !
it should output the object but it does not.
Please note that print_r() is working fine with some other objects and variables.
I am using XAMPP on Windows.
Any help?
Upon executing print_r() and var_dump(), the page is just blank, no error, view source shows:
<html>
<head></head>
<body></body>
</html>
Error reporting is turned on.
It is posible that $obj is too big to load, and grabs a lot of memory after which the script stops to work.
Thanks
Is error reporting turned on?
If not add to your code:
ini_set("display_errors", "1");
If it's outputting nothing, $obj contains nothing. Try var_dump() instead. Also, make sure you're seeing all errors that PHP is producing:
ini_set('display_errors', 1);
error_reporting(-1);