phpMyAdmin致命错误:调用未定义的函数__()

时间:2014-12-18 01:06:47

标签: php phpmyadmin

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

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

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

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

第242行

core.lib.php

   /**
   * 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;
   }
   }
第304行

common.inc.php

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

Config.class.php

    /**
    * 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;
   }
第849行

Config.class.php

    /**
    * 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;
       }
第1169行

Config.class.php

     /**
     * 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;
    }

5 个答案:

答案 0 :(得分:11)

问题是/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.'而不是{{1}有谁知道为什么不是这样的?

这是一个非常基本的问题/解决方案,但除非有人建议否则我认为我会将其遗漏,因为在Call to undefined function __()错误的其他讨论中没有解决这个确切的问题/解决方案在安装后尝试启动phpMyAdmin时。

答案 1 :(得分:4)

来自phpMyAdmin的相同错误消息::     在stderr中发送的FastCGI:“PHP消息:PHP致命错误:在第245行的/usr/share/phpMyAdmin/libraries/core.lib.php中调用未定义的函数__(),同时从上游读取响应头,客户端:

使用nginx在我的Fedora 22服务器x86_64上运行的解决方案:     在root文件中更改所有者和组标识符:文件/ var / lib / php / session
上的apache    root:nginx
  使用命令sudo chown -Rfv root:nginx /var/lib/php/session

答案 2 :(得分:0)

如果phpmyadmin工作正常,然后突然停止工作,并且出现奇怪且无用的错误消息,您可以尝试删除您的php会话。

rm -rf /var/lib/php/sessions/*

确切的位置可能非常依赖于操作系统和版本,这将删除所有活动会话,而不仅仅是你的,但它可以解决一些“突然停止工作”问题,当你没有改变任何东西,它之前工作正常

答案 3 :(得分:-1)

对我而言,这是另一个问题。我给了phpMyAdmin forlder 777的权限。当我把它改为755时,它工作正常。

希望这会对某人有所帮助。

答案 4 :(得分:-2)

  

错误“连接已重置”
文件:   /usr/share/phpmyadmin/libraries/common.inc.php

搜索:

$GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);<br>

替换为:

$GLOBALS['PMA_Config'] = new PMA_Config();