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

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

问题描述

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

<块引用>

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

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

谢谢,提姆尼特

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

function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {$m = $mysqlstring;如果(空($m))返回假;if ('G' == $dateformatstring )返回 strtotime( $m . ' +0000' );$i = strtotime( $m );if ('U' == $dateformatstring )返回 $i;如果 ( $translate )返回 date_i18n( $dateformatstring, $i );别的返回日期( $dateformatstring, $i );}

更新#2:
现在我已经解决了这个问题,只需让上面的函数 return false; 不执行任何操作.但是我还没有弄清楚问题的根本原因.

更新#3:

var_dump($dateformatstring)

<块引用>

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)

<块引用>

string(19) "2011-10-20 05:35:01" string(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"

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

<块引用>

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

309 function dirlist($path, $include_hidden = true, $recursive = false) {第 310 章311 $limit_file = basename($path);第312话第313话第314话第315话316第 317 章第318回319第320话第321话第322回323第324话325第 326 章第327话第328话329第 330 章第331话332第 333 章第334话335第 336 章第337话338第 339 章第 340 章第341话342 $struc['owner'] = $this->owner($path.'/'.$entry);343 $struc['group'] = $this->group($path.'/'.$entry);344 $struc['size'] = $this->size($path.'/'.$entry);第 345 章第 346 章第 347 章348 $struc['type'] = $this->is_dir($path.'/'.$entry)'d:'f';349

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

<块引用>

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

日期日期/时间支持 =>启用date.default_latitude =>31.7667 =>31.7667date.default_longitude =>35.2333 =>35.2333date.sunrise_zenith =>90.583333 =>90.583333date.sunset_zenith =>90.583333 =>90.583333日期.时区 =>没有价值 =>没有价值

然后我编辑了 php.ini 文件,将时区设置为美国/洛杉矶"并得到了这个输出

日期/时间支持 =>启用date.default_latitude =>31.7667 =>31.7667date.default_longitude =>35.2333 =>35.2333date.sunrise_zenith =>90.583333 =>90.583333date.sunset_zenith =>90.583333 =>90.583333日期.时区 =>美国/洛杉矶 =>美国/洛杉矶

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

解决方案

问题是文件权限.我给了 apache2 用户阅读 &执行对 usr/share/zoneinfo 和 etc/localtime 的访问.之前,我也没有将本地时间的父级设置为正确的权限.即我只更改了 localtime 和 zoneinfo 的权限,而没有更改其父目录的权限.那么蠢!远离问题并回到它总是有用的.

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

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

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.

thanks, Timnit

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

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.

update#3:

var_dump($dateformatstring)

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)

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"

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

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 

Update#5:
doing a php -i | fgrep -i date returns

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

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

I then restarted apache2. I still get the error

解决方案

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天全站免登陆