2012年9月13日

最近,网站升级到了PHP 5.3。结果,wordpress报出来一大堆错误信息,经过修改,一一解决如下:

1. Deprecated: Function eregi() is deprecated in XXX

eregi() 为 preg_match() 。特别要注意,preg_match()中的正则表达式开头和结尾要加\。

即wp-include/gettext.php的288行:将if (eregi(“plural-forms: ([^\n]*)\n”, $header, $regs)) 要改为 if (preg_match(“/plural-forms: ([^\n]*)\n/”, $header, $regs))

2. Warning: mktime() : It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.

在php.ini开头增加date_default_timezone_set(‘PRC’);

3. Deprecated: Assigning the return value of new by reference is deprecated in XXX

将=&改为=

即:

wp-include的cache.php的36行,将$GLOBALS[‘wp_object_cache’] =& new WP_Object_Cache(); 改为$GLOBALS[‘wp_object_cache’] = new WP_Object_Cache();

wp-include的query.php的21行,将 $GLOBALS[‘wp_query’] =& new WP_Query();改为$GLOBALS[‘wp_query’] = new WP_Query();

wp-include的theme.php的507行,将 $GLOBALS[‘custom_image_header’] =& new Custom_Image_Header($admin_header_callback); 改为$GLOBALS[‘custom_image_header’] = new Custom_Image_Header($admin_header_callback);

原文永久链接:https://jijian91.com/blog20120913/php53deprecated.html