phpMyAdmin fatal error : Call to undefined function __()

标签 php phpmyadmin

运行 RHEL 7 和 PHP 5.4.16 的服务器。当我尝试在浏览器中打开/phpMyAdmin 时,出现错误:

fatal error :调用/usr/share/phpMyAdmin/libraries/core.lib.php 中的未定义函数 __() 第 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

我相信我已经安装了所有必需的库,并且 apache 对 session.save_path 目录具有适当的权限,这是以前问过这个问题的问题。请参阅:Call to undefined function __() error - phpMyAdmin

有人可以根据那个调用堆栈给我提示吗? 以下是堆栈跟踪引用的行中的函数,相关行写在左边距中:

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 第 304 行:

304  $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);
     if (!defined('PMA_MINIMUM_COMMON')) {
         $GLOBALS['PMA_Config']->checkPmaAbsoluteUri();
     }

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 第 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 第 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;
    }

最佳答案

问题是 /etc/phpMyAdmin 的权限错误目录。 Web 服务器用户 apache 对 session.save_path 具有适当的权限目录,但 apache 无法从我的 config.inc.php 文件中读取。将/etc/phpMyAdmin 的所有者更改为 apache 用户并将权限更改为 755 解决了问题。

查看 checkConfigSource()Config.class.php 中发挥作用让我相信,如果问题出在访问配置文件上,那么我会收到错误 'Existing configuration file (%s) is not readable.'而不是 Call to undefined function __()有谁知道为什么不是这样?

这是一个非常基本的问题/解决方案,但除非有人另有建议,否则我认为我会保留它,因为在 Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php 的其他讨论中没有解决这个确切的问题/解决方案。安装后尝试启动 phpMyAdmin 时出错。

关于phpMyAdmin fatal error : Call to undefined function __(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27537617/

相关文章:

php 按字符串中最后一个单词的字母顺序排列数组

php - fullCalendar ignoreTimezone 似乎不起作用

javascript - 如何在某些文本的每 5,000 个字符后面的第一个 <p> 或 <br> 之后插入 <hr>?

mysql - 如果 JOIN 表中的一行不存在,则 Nothing echo (MySQL)

mysql - SQL如何删除特定列的重复行并保留一个

php - Symfony:如何获取所有服务及其各自的类

php - 将超链接添加到 Wordpress 的 Simplicity-Lite 特色框元素

php - 在 MySQL 中将 TABLE 101 重命名为 table101

mysql - 无法使用 phpmyadmin 向导将 csv 导入 mysql 数据库

mysql - phpmyadmin/创建表/语法错误/枚举