php phpMyAdmin 致命错误:调用未定义的函数 __()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27537617/
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
phpMyAdmin Fatal error: Call to undefined function __()
提问by Jim
Server running RHEL 7 and PHP 5.4.16. When I try to open /phpMyAdmin in my browser, I'm given the error:
运行 RHEL 7 和 PHP 5.4.16 的服务器。当我尝试在浏览器中打开 /phpMyAdmin 时,出现错误:
Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php on line 242
Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php on line 242
Call Stack
# Time Memory Function Location
1 0.0008 348000 {main}( ) ../index.php:0
2 0.0018 503144 require_once( '/usr/share/phpMyAdmin/libraries/common.inc.php' ) ../index.php:12
3 0.0252 4224464 PMA_Config->__construct( ) ../common.inc.php:304
4 0.0252 4224712 PMA_Config->load( ) ../Config.class.php:100
5 0.0265 4309888 PMA_Config->checkConfigSource( ) ../Config.class.php:849
6 0.0265 4311088 PMA_fatalError( ) ../Config.class.php:1169
I believe I've installed all required libraries and that apache has the proper permissions for the session.save_path directory, which were the issues previous times that this question had been asked. See: Call to undefined function __() error - phpMyAdmin
我相信我已经安装了所有必需的库,并且 apache 对 session.save_path 目录具有适当的权限,这是之前提出这个问题的问题。请参阅:调用未定义的函数 __() 错误 - phpMyAdmin
Can someone give me a hint based on that call stack? Here are the functions from the lines that the stack trace references, with the relevant line written in the left margin:
有人可以根据该调用堆栈给我一个提示吗?以下是堆栈跟踪引用的行中的函数,相关行写在左边距中:
core.lib.php
at line 242:
core.lib.php
在第 242 行:
/**
* displays the given error message on phpMyAdmin error page in foreign language,
* ends script execution and closes session
*
* loads language file if not loaded already
*
* @param string $error_message the error message or named error message
* @param string|array $message_args arguments applied to $error_message
* @param boolean $delete_session whether to delete session cookie
*
* @return void
*/
function PMA_fatalError(
$error_message, $message_args = null, $delete_session = true
) {
/* Use format string if applicable */
if (is_string($message_args)) {
$error_message = sprintf($error_message, $message_args);
} elseif (is_array($message_args)) {
$error_message = vsprintf($error_message, $message_args);
}
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($error_message));
} else {
$error_message = strtr($error_message, array('<br />' => '[br]'));
/* Load gettext for fatal errors */
if (!function_exists('__')) {
// It is possible that PMA_fatalError() is called before including
// vendor_config.php which defines GETTEXT_INC. See bug #4557
if (defined(GETTEXT_INC)) {
include_once GETTEXT_INC;
} else {
include_once './libraries/php-gettext/gettext.inc';
}
}
// these variables are used in the included file libraries/error.inc.php
242 $error_header = __('Error');
$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
$dir = $GLOBALS['text_dir'];
// on fatal errors it cannot hurt to always delete the current session
if ($delete_session
&& isset($GLOBALS['session_name'])
&& isset($_COOKIE[$GLOBALS['session_name']])
) {
$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
}
// Displays the error message
include './libraries/error.inc.php';
}
if (! defined('TESTSUITE')) {
exit;
}
}
common.inc.php
at line 304:
common.inc.php
在第 304 行:
304 $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);
if (!defined('PMA_MINIMUM_COMMON')) {
$GLOBALS['PMA_Config']->checkPmaAbsoluteUri();
}
Config.class.php
at line 100:
Config.class.php
在第 100 行:
/**
* constructor
*
* @param string $source source to read config from
*/
function __construct($source = null)
{
$this->settings = array();
// functions need to refresh in case of config file changed goes in
// PMA_Config::load()
100 $this->load($source);
// other settings, independent from config file, comes in
$this->checkSystem();
$this->isHttps();
$this->base_settings = $this->settings;
}
Config.class.php
at line 849:
Config.class.php
在第 849 行:
/**
* loads configuration from $source, usually the config file
* should be called on object creation
*
* @param string $source config file
*
* @return bool
*/
function load($source = null)
{
$this->loadDefaults();
if (null !== $source) {
$this->setSource($source);
}
/**
* We check and set the font size at this point, to make the font size
* selector work also for users without a config.inc.php
*/
$this->checkFontsize();
if (! $this->checkConfigSource()) {
849 return false;
}
Config.class.php
at line 1169:
Config.class.php
在第 1169 行:
/**
* check config source
*
* @return boolean whether source is valid or not
*/
function checkConfigSource()
{
if (! $this->getSource()) {
// no configuration file set at all
return false;
}
if (! file_exists($this->getSource())) {
$this->source_mtime = 0;
return false;
}
if (! is_readable($this->getSource())) {
// manually check if file is readable
// might be bug #3059806 Supporting running from CIFS/Samba shares
$contents = false;
$handle = @fopen($this->getSource(), 'r');
if ($handle !== false) {
$contents = @fread($handle, 1); // reading 1 byte is enough to test
@fclose($handle);
}
if ($contents === false) {
$this->source_mtime = 0;
PMA_fatalError(
sprintf(
function_exists('__')
? __('Existing configuration file (%s) is not readable.')
: 'Existing configuration file (%s) is not readable.',
$this->getSource()
)
1169 );
return false;
}
}
return true;
}
回答by Jim
The problem was the wrong permissions for the /etc/phpMyAdmin
directory. The web server user, apache, had proper permissions for the session.save_path
directory, but apache couldn't read from my config.inc.php file. Changing the owner of /etc/phpMyAdmin to the apache user and changing the permissions to 755 solved the problem.
问题是/etc/phpMyAdmin
目录的权限错误。Web 服务器用户 apache 对该session.save_path
目录具有适当的权限,但 apache 无法从我的 config.inc.php 文件中读取。将 /etc/phpMyAdmin 的所有者更改为 apache 用户并将权限更改为 755 解决了问题。
Looking at the checkConfigSource()
function in Config.class.php
led me to believe that if the problem was with accessing the configuration file then I would have received the error 'Existing configuration file (%s) is not readable.'
instead of Call to undefined function __()
Does anyone know why that wasn't the case?
查看中的checkConfigSource()
函数Config.class.php
让我相信,如果问题出在访问配置文件上,那么我会收到错误'Existing configuration file (%s) is not readable.'
而Call to undefined function __()
不是有谁知道为什么不是这样?
This was a pretty basic problem/solution, but unless someone suggests otherwise I think I'll leave it up since this exact problem/solution isn't addressed in other discussions of the Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php
error when trying to start phpMyAdmin after installation.
这是一个非常基本的问题/解决方案,但除非有人另有建议,否则我认为我会保留它,因为Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php
在安装后尝试启动 phpMyAdmin 时,在其他关于错误的讨论中没有解决这个确切的问题/解决方案。
回答by danielmwai
Had the same Error message from phpMyAdmin :: FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php on line 245" while reading response header from upstream, client:
在标准错误中发送来自 phpMyAdmin :: FastCGI的相同错误消息 :“PHP 消息:PHP 致命错误:在第 245 行调用 /usr/share/phpMyAdmin/libraries/core.lib.php 中未定义的函数 __()”,同时阅读来自上游的响应头,客户端:
Solution that worked on my Fedora 22 server x86_64 using nginx :
changing the owner and the group identifier from root:apache on the file /var/lib/php/session
to root:nginx
using the command sudo chown -Rfv root:nginx /var/lib/php/session
.
使用 nginx 在我的 Fedora 22 服务器 x86_64 上运行的解决方案
:
使用命令 将文件 /var/lib/php/session 上的所有者和组标识符从 root:apache 更改为 root:nginx sudo chown -Rfv root:nginx /var/lib/php/session
。
回答by Nick
If phpmyadmin was working fine and then suddenly stops working for no reason with a bizarre and useless error message, you might try deleting your php sessions.
如果 phpmyadmin 工作正常,然后突然无故停止工作并出现奇怪且无用的错误消息,您可以尝试删除您的 php 会话。
rm -rf /var/lib/php/sessions/*
The exact location may very depending on OS and version, and this will delete all active sessions, not just yours, but it can fix some "suddenly stopped working" issues when you haven't changed anything and it was working fine before.
确切位置可能非常取决于操作系统和版本,这将删除所有活动会话,而不仅仅是您的,但它可以解决一些“突然停止工作”的问题,当您没有更改任何内容并且之前工作正常时。
回答by Nilesh
For me it was different issue. I had given 777 permissions to phpMyAdmin forlder. When I changed it to 755, it worked fine.
对我来说,这是不同的问题。我已向 phpMyAdmin 文件夹授予 777 权限。当我将其更改为 755 时,它运行良好。
Hope this will help someone.
希望这会帮助某人。
回答by Raul Arellano
Error "The connection was reset"
File: /usr/share/phpmyadmin/libraries/common.inc.php
错误“连接已重置”
文件:/usr/share/phpmyadmin/libraries/common.inc.php
search:
搜索:
$GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);<br>
replace with:
用。。。来代替:
$GLOBALS['PMA_Config'] = new PMA_Config();