微擎-php7.2下调试模式报warning: Use of undefined MODULE_ROOT 或 FRAME

谭文林
2023-12-01

出现的问题, 找了几圈某度, 说的都不知道什么鬼. 所以还得自己试着搞(因为不太想跟这源码写的代码)
可处理方法:

  • 直接把调试模式关掉, 不鸟他
  • 对于强迫症的人来说(譬如我) 不能容忍在开启调试模式时,还有一堆的warning提示, 解决方法如下:
Warning: Use of undefined constant MODULE_ROOT - assumed 'MODULE_ROOT' (this will throw an Error in a future version of PHP) in xxxxx

Warning: Use of undefined constant FRAME - assumed 'FRAME' (this will throw an Error in a future version of PHP) in xxxxx

当前环境配置为: we7 1.7.0 + x版 + php7.2+mysql(这个不用管)

  1. MODULE_ROOT 的问题, 一般是由cloudapi.class.php 文件里没定义MODULE_ROOT常量引起的. 所以, 定位到问题出处:
    \framework\class\cloudapi.class.php 53行 修改为:
private function cer_filepath($file) {
        if (defined('MODULE_ROOT')) {
            return MODULE_ROOT.'/'.$file;
        }
		return $file;
}
  1. FRAME 的问题, 是由于头部没定义常量FRAME就直接用,所以在 \web\themes\default\common\header-base.html 的头部加个defined的判断就可以了.
    web/themes/default/common/header.html 去掉:
{php $frames = buildframes(FRAME);_calc_current_frames($frames);}

web/themes/default/common/header-base.html 4行 添加

{if !defined('FRAME')}{php define('FRAME', '')}{/if}
{php $frames = buildframes(FRAME);_calc_current_frames($frames);}
 类似资料: