[英]Attempted to call function “wp” from the global namespace Symfony2 + Ekino Wordpress
I got this error on prod : 我在prod上收到此错误:
Attempted to call function "wp" from the global namespace
I'm using 我正在使用
Symfony 2.8 with ekino/wordpress-bundle dev-master 使用ekino / wordpress-bundle dev-master的Symfony 2.8
The code is working fine on localhost both on prod and dev environement. 该代码在prod和dev环境上都可以在localhost上正常运行。
Here is the wp-blog-header.php file (standard wordpress file) 这是wp-blog-header.php文件(标准的wordpress文件)
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
If I comment wp()
and require_once( ABSPATH . WPINC . '/template-loader.php' );
如果我评论
wp()
和require_once( ABSPATH . WPINC . '/template-loader.php' );
I don't have the error and I can reach the home page (but I probably gonna have some issues later). 我没有错误,可以进入主页(但以后可能会出现一些问题)。
The cache is cleared. 缓存被清除。 Capisfony run composer install just before, so the autoload file should be ok.
Capisfony在刚刚安装composer之前运行,因此自动加载文件应该没问题。
The exact error : 确切的错误:
[2016-07-05 12:51:37] request.CRITICAL: Uncaught PHP Exception Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException: "Attempted to call function "wp" from the global namespace."
[2016-07-05 12:51:37] request.Critical:未捕获的PHP异常Symfony \\ Component \\ Debug \\ Exception \\ UndefinedFunctionException:“试图从全局名称空间调用函数“ wp”。 at /var/www/blabla/releases/20160705104736/web/blog/wp-blog-header.php line 16 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException(code: 0): Attempted to call function \\"wp\\" from the global namespace. at /var/www/blabla/releases/20160705104736/web/blog/wp-blog-header.php:16)"} []
在/var/www/blabla/releases/20160705104736/web/blog/wp-blog-header.php第16行{“ exception”:“ [object](Symfony \\ Component \\ Debug \\ Exception \\ UndefinedFunctionException(code:0):尝试从全局名称空间中调用函数\\“ wp \\”。位于/var/www/blabla/releases/20160705104736/web/blog/wp-blog-header.php:16)“] []
Any idea ? 任何想法 ? This is driving me crazy ...
这真让我抓狂 ...
In case you have this error check you wp-config.php file. 如果出现此错误,请检查wp-config.php文件。
In my case it was corrupted during the initial deployment process. 就我而言,它在初始部署过程中已损坏。 I regenerated it on the server and set the file as shared so capisfony won't overide it.
我在服务器上重新生成了文件,并将文件设置为共享文件,因此capisfony不会覆盖它。
I hope this can help someone. 我希望这可以帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.