运行 RHEL 7 和 PHP 5.4.16 的服务器.当我尝试在浏览器中打开/phpMyAdmin 时,出现错误:
致命错误:在第 242 行调用/usr/share/phpMyAdmin/libraries/core.lib.php 中未定义的函数 __()
调用栈# 时间记忆功能位置1 0.0008 348000 {main}() ../index.php:02 0.0018 503144 require_once('/usr/share/phpMyAdmin/libraries/common.inc.php') ../index.php:123 0.0252 4224464 PMA_Config->__construct() ../common.inc.php:3044 0.0252 4224712 PMA_Config->load() ../Config.class.php:1005 0.0265 4309888 PMA_Config->checkConfigSource() ../Config.class.php:8496 0.0265 4311088 PMA_fatalError() ../Config.class.php:1169
我相信我已经安装了所有必需的库,并且 apache 对 session.save_path 目录具有适当的权限,这是之前有人问过这个问题的问题.请参阅:调用未定义函数 __() 错误 - phpMyAdmin
有人可以根据那个调用堆栈给我一个提示吗?以下是堆栈跟踪引用的行中的函数,相关行写在左边距中:
core.lib.php
在第 242 行:
/*** 在 phpMyAdmin 错误页面上以外语显示给定的错误信息,* 结束脚本执行并关闭会话** 如果尚未加载,则加载语言文件** @param string $error_message 错误信息或命名错误信息* @param string|array $message_args 应用于 $error_message 的参数* @param boolean $delete_session 是否删除会话cookie** @return 无效*/函数 PMA_fatalError($error_message, $message_args = null, $delete_session = true){/* 如果适用,使用格式字符串 */如果(is_string($message_args)){$error_message = sprintf($error_message, $message_args);} elseif (is_array($message_args)) {$error_message = vsprintf($error_message, $message_args);}如果 ($GLOBALS['is_ajax_request']) {$response = PMA_Response::getInstance();$response->isSuccess(false);$response->addJSON('message', PMA_Message::error($error_message));} 别的 {$error_message = strtr($error_message, array('<br/>' => '[br]'));/* 为致命错误加载 gettext */如果 (!function_exists('__')) {//有可能在包含之前调用了 PMA_fatalError()//vendor_config.php 定义了GETTEXT_INC.参见错误 #4557如果(定义(GETTEXT_INC)){包括_一次GETTEXT_INC;} 别的 {include_once './libraries/php-gettext/gettext.inc';}}//这些变量用于包含的文件 libraries/error.inc.php第242话$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];$dir = $GLOBALS['text_dir'];//对于致命错误,始终删除当前会话不会有什么坏处如果($delete_session&&isset($GLOBALS['session_name'])&&isset($_COOKIE[$GLOBALS['session_name']])){$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);}//显示错误信息包括'./libraries/error.inc.php';}如果(!定义('测试套件')){出口;}}
common.inc.php
在第 304 行:
304 $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);如果(!定义('PMA_MINIMUM_COMMON')){$GLOBALS['PMA_Config']->checkPmaAbsoluteUri();}
Config.class.php
在第 100 行:
/*** 构造函数** @param string $source 读取配置的来源*/函数 __construct($source = null){$this->settings = array();//功能需要刷新,以防配置文件更改进入//PMA_Config::load()100 $this->load($source);//其他设置,独立于配置文件,进来$this->checkSystem();$this->isHttps();$this->base_settings = $this->settings;}
Config.class.php
在第 849 行:
/*** 从 $source 加载配置,通常是配置文件* 应该在对象创建时调用** @param string $source 配置文件** @return 布尔值*/函数加载($source = null){$this->loadDefaults();if (null !== $source) {$this->setSource($source);}/*** 此时我们检查并设置字体大小,使字体大小* 选择器也适用于没有 config.inc.php 的用户*/$this->checkFontsize();如果 (!$this->checkConfigSource()) {第849回}
Config.class.php
在第 1169 行:
/*** 检查配置源** @return boolean 源是否有效*/函数 checkConfigSource(){如果 (!$this->getSource()) {//根本没有设置配置文件返回假;}如果 (!file_exists($this->getSource())) {$this->source_mtime = 0;返回假;}if (!is_readable($this->getSource())) {//手动检查文件是否可读//可能是错误 #3059806 支持从 CIFS/Samba 共享运行$内容=假;$handle = @fopen($this->getSource(), 'r');如果($句柄!==假){$contents = @fread($handle, 1);//读取1个字节足以测试@fclose($handle);}if ($contents === false) {$this->source_mtime = 0;PMA_致命错误(冲刺(function_exists('__')?__('现有配置文件 (%s) 不可读.'): '现有的配置文件 (%s) 不可读.',$this->getSource())第1169章返回假;}}返回真;}
问题是 /etc/phpMyAdmin
目录的权限错误.Web 服务器用户 apache 对 session.save_path
目录具有适当的权限,但 apache 无法读取我的 config.inc.php 文件.将/etc/phpMyAdmin的所有者更改为apache用户,将权限更改为755即可解决问题.
查看 Config.class.php
中的 checkConfigSource()
函数让我相信,如果问题出在访问配置文件上,那么我会收到错误 'Existing configuration file (%s) is not readable.'
而不是 Call to undefined function __()
有谁知道为什么不是这样?>
这是一个非常基本的问题/解决方案,但除非有人提出其他建议,否则我想我会放弃它,因为在 致命错误:调用未定义函数的其他讨论中没有解决这个确切的问题/解决方案__() in/usr/share/phpMyAdmin/libraries/core.lib.php
安装后尝试启动 phpMyAdmin 时出错.
Server running RHEL 7 and PHP 5.4.16. When I try to open /phpMyAdmin in my browser, I'm given the error:
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
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:
/**
* 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:
304 $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);
if (!defined('PMA_MINIMUM_COMMON')) {
$GLOBALS['PMA_Config']->checkPmaAbsoluteUri();
}
Config.class.php
at line 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:
/**
* 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:
/**
* 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;
}
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.
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?
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.
这篇关于phpMyAdmin 致命错误:调用未定义的函数 __()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!