Prestashop 没有错误/空白页

发布于 2024-09-25 00:04:10 字数 236 浏览 4 评论 0原文

我正在为 Prestashop 开发一个 PHP 模块,但在尝试调试代码时遇到了困难。每当有东西摔倒时,它不会显示错误,只是显示一个空白页面 - 无论是在挂接模块的前端,还是在后端模块页面。

我试图在另一个类或另一个函数中编写,但它根本不喜欢它。

它位于本地开发服务器上,PHP 错误等。

有人可以告诉我任何其他方法来调试东西而不是注释掉代码吗?或者某种获取错误代码的方法?

提前感谢您的帮助。

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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

南汐寒笙箫 2024-10-02 00:04:10

尝试打开 config/config.inc.php,然后将

@ini_set('display_errors', 'off')

更改为

@ini_set('display_errors', '上')


从 PS 1.5+ 开始,您需要打开 config/defines.inc.php 并将:

define('_PS_MODE_DEV_', false);

更改为

define('_PS_MODE_DEV_ ', true);

Try opening config/config.inc.php and then change:

@ini_set('display_errors', 'off')

to

@ini_set('display_errors', 'on').


From PS 1.5+, you need to open config/defines.inc.php and change:

define('_PS_MODE_DEV_', false);

to

define('_PS_MODE_DEV_', true);

苍风燃霜 2024-10-02 00:04:10

转到您的后台页面。

高级参数 ->性能->清理缓存(橡皮擦图标)

Go to your backoffice page.

Advanced Params -> Performance -> Clean Cache (Eraser Icon)

如梦亦如幻 2024-10-02 00:04:10

我必须做

aptitude 安装 php5-mcrypt
sudo aptitude 安装 php5-mcrypt
sudo 服务 apache2 重新启动

未安装加密

I had to do

aptitude install php5-mcrypt
sudo aptitude install php5-mcrypt
sudo service apache2 restart

The encryption was not installed

铁憨憨 2024-10-02 00:04:10

看看这个最终的解决方案!

首先,您需要在网站上启用错误报告。

1) 打开文件 config\config.inc.php 并找到以下行:

@ini_set(‘display_errors’, ‘off’);    

2) 将“off”更改为“on”,重新上传文件并刷新页面。

如果没有帮助,请转到下一步。

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");
  } 
   }
?>

完成此操作后,您将在index.php 文件所在的文件夹中找到名为errors.csv 的文件。使用任何文本编辑器下载并打开文件errors.csv,您将在那里找到错误日志。

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:

@ini_set(‘display_errors’, ‘off’);    

2) Change ‘off’ to ‘on’, re-upload the file and refresh your page.

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.

    <?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.

愁以何悠 2024-10-02 00:04:10

就我而言(PS 1.7),在大量添加许多产品后,我出现了空白屏幕。
我还注意到它是一个空白屏幕,错误为 500(我从浏览器控制台得到它)。

解决方案是简单地增加 PHP 的内存限制。
可以通过将此行添加到 index.php 文件的开头来完成:

ini_set('memory_limit', '512M');

我用 512M 解决了,但如果问题仍然存在,您可以尝试更多。

这只是一个临时/快速的解决方案,如果您希望它持久存在,您可以直接在源代码中更改该值,找到您的 php.ini 并只需编辑 memory_limit 上的值代码 > 字段。

您可以在这里找到更多信息:
https://www.inmotionhosting.com/support/prestashop-16/blank-屏幕

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).

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:

ini_set('memory_limit', '512M');

I solved with 512M, but you can try more if the problem still persists.

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.

You can find more info here:
https://www.inmotionhosting.com/support/prestashop-16/blank-screen

灯下孤影 2024-10-02 00:04:10

我刚刚将 /cache 目录中的“class_index.php”重命名为“class.index.old.php”,然后重新加载网站 - 瞧!网站已加载。并在此目录中创建了新的“class_index.php”。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文