我有一个 WordPress 网站,今天突然停止工作了。当我查看日志时,我看到错误:
[错误] [客户端 50.78.108.177] PHP 致命错误:strtotime():时区
数据库已损坏 - 这应该never happen!
在谷歌上阅读后,有人说他们发现了一个权限问题/usr/share/zoneinfo。我尝试将权限更改为 777、775、770,但仍然不断收到相同的错误。我在 Ubuntu 10.04.3 LTS 上运行 php PHP 5.3.2。任何建议或推荐都会有帮助。如果所有其他方法都失败了,我将尝试降级到 php 的早期版本,但在这样做之前我想尝试其他事情。
谢谢,
蒂姆尼特
Update
以防万一有帮助:错误指向strtotime
在下面的函数中
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;
不执行任何操作。但是我仍然没有弄清楚问题的根本原因。
更新#3:
var_dump($dateformatstring)
字符串(5) “d.m.y” 字符串(1) “m” 字符串(5) “d.m.y” 字符串(1) “m”
字符串(5)“d.m.y”字符串(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”
update#4:
还有另一个代码片段正在生成以下错误日志:
PHP 致命错误:date():时区数据库已损坏 - 这应该never发生!在 /srv/www/motionthink.com/public_html/wp-admin/includes/class-wp-filesystem-direct.php
在第346行,推荐人:
wp_root_directory/wp-admin/plugins.php?plugin_status=升级
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
returns
构建日期 => 2011 年 12 月 13 日 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 文件将时区设置为“美国/洛杉矶”并得到此输出
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。我仍然收到错误