PHP时区数据库损坏错误 [英] PHP Timezone database is corrupt error

查看:126
本文介绍了PHP时区数据库损坏错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wordpress网站,今天突然停止工作.当我查看日志时会看到错误:

I have a wordpress website which suddenly stopped working today. When I look at the logs I see and error:

[错误] [客户端50.78.108.177] PHP致命错误:strtotime():时区 数据库已损坏-这应该永远不会发生!

[error] [client 50.78.108.177] PHP Fatal error: strtotime(): Timezone database is corrupt - this should never happen!

在Google上阅读后,一个人说他们在/usr/share/zoneinfo 中发现了权限问题.我尝试将权限更改为777、775、770,但仍然继续遇到相同的错误.我在Ubuntu 10.04.3 LTS上运行php PHP 5.3.2.任何建议或建议都将是有帮助的.如果其他所有方法都失败,我将尝试降级到php的早期版本,但在此之前我想尝试其他方法.

After reading up on google one person said that they discovered a permissions problem in /usr/share/zoneinfo. I tried changing the permissions to 777, 775, 770 and I still keep on getting the same error. I am running php PHP 5.3.2 on Ubuntu 10.04.3 LTS. Any suggestions or recommendations would be helpful.If all else fails I'm going to try downgrading to an earlier version of php but I wanted to try other things before doing that.

谢谢, 蒂姆尼特(Timnit)

thanks, Timnit

更新
以防万一:指向下面函数中的strtotime

Update
just in case it helps: the error points to strtotime in the function below

function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
    $m = $mysqlstring;
    if ( empty( $m ) )
            return false;

    if ( 'G' == $dateformatstring )
            return strtotime( $m . ' +0000' );

    $i = strtotime( $m );

    if ( 'U' == $dateformatstring )
            return $i;

    if ( $translate )
            return date_i18n( $dateformatstring, $i );
    else
            return date( $dateformatstring, $i );
}

更新#2:
现在,我已经通过简单地使return false;以上的函数不执行任何操作来解决了该问题.但是我仍然没有找出问题的根本原因.

Update#2:
for now I have fixed the problem by simply having the function above return false; without performing anything. However I still haven't figured out the root cause of the problem.

更新#3:

var_dump($dateformatstring)

字符串(5)"d.m.y"字符串(1)"m"字符串(5)"d.m.y"字符串(1)"m" 字符串(5)"d.m.y"字符串(1)"m"

string(5) "d.m.y" string(1) "m" string(5) "d.m.y" string(1) "m" string(5) "d.m.y" string(1) "m"

var_dump($mysqlstring)

字符串(19)"2011-10-20 05:35:01"字符串(19)"2011-10-20 05:35:01" 字符串(19)"2011-10-20 05:25:22"字符串(19)"2011-10-20 05:25:22" 字符串(19)"2011-10-19 05:10:06"字符串(19)"2011-10-19 05:10:06"

string(19) "2011-10-20 05:35:01" string(19) "2011-10-20 05:35:01" string(19) "2011-10-20 05:25:22" string(19) "2011-10-20 05:25:22" string(19) "2011-10-19 05:10:06" string(19) "2011-10-19 05:10:06"

更新#4 :
还有另一个代码段正在生成下面的错误日志:

update#4:
there is another code snippet that is generating the error log below:

PHP致命错误:date():时区数据库已损坏-这应该 从不发生!在/srv/www/motionthink.com/public_html/wp-admin/includes/class-wp-filesystem-direct.php中 在第346行上,引荐网址: wp_root_directory/wp-admin/plugins.php?plugin_status = upgrade

PHP Fatal error: date(): Timezone database is corrupt - this should never happen! in /srv/www/motionthink.com/public_html/wp-admin/includes/class-wp-filesystem-direct.php on line 346, referer: wp_root_directory/wp-admin/plugins.php?plugin_status=upgrade

309         function dirlist($path, $include_hidden = true, $recursive = false) {
  310                 if ( $this->is_file($path) ) {
  311                         $limit_file = basename($path);
  312                         $path = dirname($path);
  313                 } else {
  314                         $limit_file = false;
  315                 }
  316 
  317                 if ( ! $this->is_dir($path) )
  318                         return false;
  319 
  320                 $dir = @dir($path);
  321                 if ( ! $dir )
  322                         return false;
  323 
  324                 $ret = array();
  325 
  326                 while (false !== ($entry = $dir->read()) ) {
  327                         $struc = array();
  328                         $struc['name'] = $entry;
  329 
  330                         if ( '.' == $struc['name'] || '..' == $struc['name'] )
  331                                 continue;
  332 
  333                         if ( ! $include_hidden && '.' == $struc['name'][0] )
  334                                 continue;
  335 
  336                         if ( $limit_file && $struc['name'] != $limit_file)
  337                                 continue;
  338 
  339                         $struc['perms']         = $this->gethchmod($path.'/'.$entry);
  340                         $struc['permsn']  = $this->getnumchmodfromh($struc['perms']);
  341                         $struc['number']        = false;
  342                         $struc['owner']         = $this->owner($path.'/'.$entry);
  343                         $struc['group']         = $this->group($path.'/'.$entry);
  344                         $struc['size']          = $this->size($path.'/'.$entry);
  345                         $struc['lastmodunix']= $this->mtime($path.'/'.$entry);
  346                         $struc['lastmod']   = date('M j',$struc['lastmodunix']);
  347                         $struc['time']          = date('h:i:s',$struc['lastmodunix']);
  348                  $struc['type']          = $this->is_dir($path.'/'.$entry) ?   'd:'f';
  349 

更新#5:
php -i | fgrep -i date返回

构建日期=> 2011年12月13日18:43:02

Build Date => Dec 13 2011 18:43:02

date
date/time support => enabled
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => no value => no value

然后我编辑了php.ini文件,将时区设置为"America/Los Angeles",并获得了此输出

then I edited the php.ini file to set the timezone to "America/Los Angeles" and got this output

date/time support => enabled
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => America/Los_Angeles => America/Los_Angeles

然后我重新启动了apache2.我仍然收到错误消息

I then restarted apache2. I still get the error

推荐答案

问题出在文件权限上.我给apache2用户阅读了&执行对usr/share/zoneinfo和etc/localtime的访问.以前,我也没有将本地时间的父母设置为正确的权限.即我只更改了本地时间和区域信息的权限,而没有更改其父目录的权限.这么笨!摆脱问题并重新解决问题总是很有用的.

The problem was file permissions. I gave the apache2 user read & execute access to usr/share/zoneinfo and etc/localtime. Before, I hadn't set the parents of local time to the right permissions as well. i.e. I only changed the permissions of localtime and zoneinfo without changing the permissions of their parent directories. So stupid! Stepping away from a problem and getting back to it is always useful.

这篇关于PHP时区数据库损坏错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆