phpwind9.0升级到php7后出现的问题修复

最近将一个两年多之前的用phpwind9.0搭建的论坛升级到php7,遇到了页面没法打开,显示为500错误,排查了一成天时间,终于解决!php

 

一、打开文件:src/applications/appcenter/service/srv/PwDebugApplication.phpweb

定位到214行代码正则表达式

修改代码:php7

if (!$toinstall instanceof iPwInstall) continue;
$r = $toinstall->install($install);
if ($r instanceof PwError) return $this->_e($install, $r);
$install->addInstallLog('service', $_tmp);

修改后app

if($toinstall instanceof iPwInstall){
    $r = $toinstall->install($install);
    if ($r instanceof PwError) return $this->_e($install, $r);
    $install->addInstallLog('service', $_tmp);
}

 

二、打开文件:/src/windid/service/base/WindidUtility.php 函数

定位到94行代码this

修改成:spa

if (!isset($exts[$imageInfo[2]])) return false;

 

三、修改preg_replace函数为preg_replace_callback
src/library/ubb/PwUbbCode.php
src/library/ubb/PwSimpleUbbCode.php
说明:preg_replace正则表达式再也不支持/e,须要使用preg_replace_callback来替换code

 

四、/wind/web/WindForward.php:96router

修改代码:

} elseif ($merge && !empty($this->vars[$key])) {

修改后:

} elseif ($merge && isset($this->vars[$key]) && $this->vars[$key]) {

 

五、伪静态开启后出现错误修复

定位代码到:/src/library/route/PwRoute.php:217 

修改代码:

foreach ($this->params as $k => $v) {
            if ($route[$k] === $router->$methods[$k]() && $flag === $flags[$k]) $flag = $consts[$k];
            $_args[$v] = $route[$k];
            unset($args[$k]);
        }

修改后:

foreach ($this->params as $k => $v) {
            $_method=$methods[$k];
            if ($route[$k] === $router->$_method() && $flag === $flags[$k]) $flag = $consts[$k];
            $_args[$v] = $route[$k];
            unset($args[$k],$_method);
        }

 

结论:此行代码中没有在foreach循环以内,所以不能出现关键字continue,而在php7前continue关键字是容许不在foreach中出现的,因而可知php7更加规范了;php7对preg_replace不在支持"/e"修饰符,是一个大坑;empty在php5.5后支持表达式了,第4处能够不修改

相关文章
相关标签/搜索