php Prestashop 没有错误/空白页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3790220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Prestashop no errors / blank page
提问by Harry M
I'm developing a module in PHP for Prestashop and I'm having a tough time trying to debug code. Whenever something falls over it doesn't display errors, just a blank page - either on the front end where the module is hooked, or on the back end module page.
我正在为 Prestashop 用 PHP 开发一个模块,但我在调试代码时遇到了困难。每当有东西翻倒时,它都不会显示错误,而只是一个空白页面——无论是在模块挂钩的前端,还是在后端模块页面上。
I'm trying to write in another class, or another function but it doesn't like it at all.
我正在尝试编写另一个类或另一个函数,但它根本不喜欢它。
It's on a local dev server, PHP errors are on etc.
它在本地开发服务器上,出现 PHP 错误等。
Can somebody tell me any other way to debug stuff instead of commenting out code? Or some way of getting error codes?
有人可以告诉我任何其他调试内容而不是注释代码的方法吗?或者某种获取错误代码的方法?
Thanks for your help in advance.
提前感谢您的帮助。
回答by David Hancock
Try opening config/config.inc.php
and then change:
尝试打开config/config.inc.php
然后更改:
@ini_set('display_errors', 'off')
@ini_set('display_errors', 'off')
to
到
@ini_set('display_errors', 'on')
.
@ini_set('display_errors', 'on')
.
From PS 1.5+, you need to open config/defines.inc.php
and change:
从PS 1.5+开始,需要打开config/defines.inc.php
更改:
define('_PS_MODE_DEV_', false);
define('_PS_MODE_DEV_', false);
to
到
define('_PS_MODE_DEV_', true);
define('_PS_MODE_DEV_', true);
回答by Pablo S G Pacheco
Go to your backoffice page.
转到您的后台页面。
Advanced Params -> Performance -> Clean Cache (Eraser Icon)
高级参数 -> 性能 -> 清理缓存(橡皮擦图标)
回答by Elia Weiss
I had to do
我必须做
aptitude install php5-mcrypt sudo aptitude install php5-mcrypt sudo service apache2 restart
aptitude 安装 php5-mcrypt sudo aptitude 安装 php5-mcrypt sudo 服务 apache2 重启
The encryption was not installed
未安装加密
回答by Jacopo Pace
In my case (PS 1.7) i had blank screen after massively adding many products. I also noticed it was a blank screen with error 500 (i got it from the browser console).
就我而言(PS 1.7),在大量添加许多产品后,我出现了空白屏幕。我还注意到它是一个带有错误 500 的空白屏幕(我是从浏览器控制台得到的)。
The solution was to simply increase the memory limit of my PHP. It can be done by adding this line to the beginning of index.php file:
解决方案是简单地增加我的 PHP 的内存限制。可以通过将这一行添加到 index.php 文件的开头来完成:
ini_set('memory_limit', '512M');
ini_set('memory_limit', '512M');
I solved with 512M, but you can try more if the problem still persists.
我用512M解决了,但如果问题仍然存在,您可以尝试更多。
This is just a temporary/fast solution, if you want it persistent, you can change directly that value at the source, find your php.ini
and just edit the value on the memory_limit
field.
这只是一个临时/快速解决方案,如果您希望它持久化,您可以直接在源上更改该值,找到您php.ini
的值并在memory_limit
字段上编辑该值。
You can find more info here: https://www.inmotionhosting.com/support/prestashop-16/blank-screen
您可以在此处找到更多信息:https: //www.inmotionhosting.com/support/prestashop-16/blank-screen
回答by user2910491
I just renamed 'class_index.php' in /cache directory to something 'class.index.old.php', then reloaded site - and voila! site was loaded. And in this directory new 'class_index.php' was created.
我只是将 /cache 目录中的“class_index.php”重命名为“class.index.old.php”,然后重新加载站点 - 瞧!网站已加载。在这个目录中创建了新的“class_index.php”。
回答by ganji
check this out for the final solution!
看看这个以获得最终解决方案!
First of all, you need to enable errors reporting on your website.
首先,您需要在您的网站上启用错误报告。
1) Open the file config\config.inc.php and find the following line:
1)打开文件config\config.inc.php,找到如下一行:
@ini_set(‘display_errors', ‘off');
2) Change ‘off' to ‘on', re-upload the file and refresh your page.
2) 将“关闭”更改为“开启”,重新上传文件并刷新页面。
If it doesn't help, go to the next step.
如果没有帮助,请转到下一步。
3)Add this code to the top of your index.php file in the root of PrestaShop installation and re-upload it on your server. Then try to access your website and admin panel.
3) 将此代码添加到 PrestaShop 安装根目录中 index.php 文件的顶部,然后将其重新上传到您的服务器上。然后尝试访问您的网站和管理面板。
<?php error_reporting(0);
$old_error_handler = set_error_handler("userErrorHandler");
function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
{
$time=date("d M Y H:i:s");
// Get the error type from the error number
$errortype = array (1 => "Error",
2 => "Warning",
4 => "Parsing Error",
8 => "Notice",
16 => "Core Error",
32 => "Core Warning",
64 => "Compile Error",
128 => "Compile Warning",
256 => "User Error",
512 => "User Warning",
1024 => "User Notice");
$errlevel=$errortype[$errno];
//Write error to log file (CSV format)
$errfile=fopen("errors.csv","a");
fputs($errfile,"\"$time\",\"$filename:
$linenum\",\"($errlevel) $errmsg\"\r\n");
fclose($errfile);
if($errno!=2 && $errno!=8) {
//Terminate script if fatal error
die("A fatal error has occurred. Script execution has been aborted");
}
}
?>
After this manipulations you will find the file called errors.csv in the folder where your index.php file is located. Download and open the file errors.csv using any text editor, you will find the error log there.
在此操作之后,您将在 index.php 文件所在的文件夹中找到名为 errors.csv 的文件。使用任何文本编辑器下载并打开文件 errors.csv,您将在那里找到错误日志。