本文實例講述了DEDECMS在PHP5.4不能正常運行的解決方法。分享給大家供大家參考。具體分析如下:
PHP5.4是公開發(fā)行的PHP程式最新版本,其執(zhí)行速度和內(nèi)存占用等相比PHP5.3而言有10%~30%的性能提升,所以筆者也一直想在實際環(huán)境中試運行PHP5.4(PHP5.4目前最新的版本為5.4.9)。
棘手的是與PHP5.2升級到PHP5.3有所不同的是,從5.3到5.4之間似乎變化不少,這也造成了筆者在將DEDECMS系統(tǒng)遷移到PHP5.4.x平臺的時候出現(xiàn)了前臺500錯誤后臺直接空白的情況,當(dāng)時也沒有深究便換回PHP5.3了。
最近仔細查了下相關(guān)資料,發(fā)現(xiàn)主要是因為目前DEDECMS代碼中使用了PHP5.4中棄用的一些函數(shù),主要如下:
allow_call_time_pass_reference、define_syslog_variables、highlight.bg、register_globals、register_long_arrays、magic_quotes、safe_mode、zend.ze1_compatibility_mode、session.bug_compat42、session.bug_compat_warn、session_register以及 y2k_compliance
其中造成DEDECMS5.7無法正常運行的函數(shù)便是session_register。
網(wǎng)上實測有效的方法有如下兩種:
第一種方法申明將此函數(shù)廢棄,在include/userlogin.class.php中加入如下代碼:
復(fù)制代碼代碼如下:function session_register()
{
return true;
}
第二種方法是該該頁中的函數(shù)代碼替換,被替換代碼大致在287到308行之間,代碼如下:
復(fù)制代碼代碼如下:@session_register($this->keepUserIDTag);
$_SESSION[$this->keepUserIDTag] = $this->userID;
@session_register($this->keepUserTypeTag);
$_SESSION[$this->keepUserTypeTag] = $this->userType;
@session_register($this->keepUserChannelTag);
$_SESSION[$this->keepUserChannelTag] = $this->userChannel;
@session_register($this->keepUserNameTag);
$_SESSION[$this->keepUserNameTag] = $this->userName;
@session_register($this->keepUserPurviewTag);
$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
@session_register($this->keepAdminStyleTag);
$_SESSION[$this->keepAdminStyleTag] = $adminstyle;
PutCookie('DedeUserID', $this->userID, 3600 * 24, '/');
PutCookie('DedeLoginTime', time(), 3600 * 24, '/');
替換為如下代碼:
復(fù)制代碼代碼如下:global $admincachefile,$adminstyle;
if(emptyempty($adminstyle)) $adminstyle = 'dedecms';
$_SESSION[$this->keepUserIDTag] = $this->keepUserIDTag;
$_SESSION[$this->keepUserIDTag] = $this->userID;
$_SESSION[$this->keepUserTypeTag] = $this->keepUserTypeTag;
$_SESSION[$this->keepUserTypeTag] = $this->userType;
$_SESSION[$this->keepUserChannelTag] = $this->keepUserChannelTag;
$_SESSION[$this->keepUserChannelTag] = $this->userChannel;
$_SESSION[$this->keepUserNameTag] = $this->keepUserNameTag;
$_SESSION[$this->keepUserNameTag] = $this->userName;
$_SESSION[$this->keepUserPurviewTag] = $this->keepUserPurviewTag;
$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
$_SESSION[$this->keepAdminStyleTag] = $this->keepAdminStyleTag;
$_SESSION[$this->keepAdminStyleTag] = $adminstyle;
PutCookie('DedeUserID', $this->userID, 3600 * 24, '/');
PutCookie('DedeLoginTime', time(), 3600 * 24, '/');
希望本文所述對大家的dedecms建站有所幫助。
更多信息請查看IT技術(shù)專欄