zoukankan      html  css  js  c++  java
  • phpwind9.0升级到php7后出现的问题修复

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

    1、打开文件:src/applications/appcenter/service/srv/PwDebugApplication.php

    定位到214行代码

    修改代码:

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

    修改后

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

    2、打开文件:/src/windid/service/base/WindidUtility.php 

    定位到94行代码

    修改为:

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

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

    4、/wind/web/WindForward.php:96

    修改代码:

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

    修改后:

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

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

    定位代码到:/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处可以不修改

  • 相关阅读:
    分组PARTITION BY及游标CURSOR的用法
    dotnet core 3.1+consul 学习(1)
    常用状态码
    docker 安装consul以及部署consul集群
    泛型
    redis面试题(1)
    asp net core 3.1启动过程源码解读
    .net core 2.x到3.x变化 -> Endpoint Routing
    jwt登录验证逻辑
    .Net Core3.1+Jenkins+Docker+Git实现自动化部署
  • 原文地址:https://www.cnblogs.com/springwind2006/p/7732778.html
Copyright © 2011-2022 走看看