新版本1.4.0.0产品管理加载分类提示错误

bug问题 · shejicq · 于 6年前 发布 · 2444 次阅读

共收到 22 条回复
Fecmall#16年前 0 个赞

发下截图?

Fecmall#26年前 0 个赞

奥,看到了,刚才没加载出来,明天看一下

helloworld#36年前 0 个赞

好像yii框架的错误,所有each返回数据的接口都报错:yii\web\HeadersAlreadySentException: Headers already sent

Fecmall#46年前 0 个赞

@lincome [#3楼](#comment3)

1.我本地没有报错。

2.报错信息和对应文件的内容,粘贴上来。

helloworld#56年前 0 个赞

@Fecshop #4楼 比如:获取产品分类的接口 D:\wwwroot\yii2\app\fecshop\vendor\fancyecommerce\fecshop\app\appadmin\modules\Catalog\block\productinfo\Getproductcategory.php

public function getProductCategory()
    {
        $product_id = CRequest::param('product_id');

        $menuStr = $this->getMenuStr($product_id);
        Yii::info($menuStr,'fecshop_debug');
        echo json_encode([
            'menu'=>$menuStr,
            'return_status'=>'success',
        ]);
    }

echo返回数据后,还会去触发yii框架的 Yii::$app->response 导致的报错!我的是docker-composer安装的

{"status":"success"}<pre>An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /www/web/fecshop/vendor/fancyecommerce/fecshop/app/appfront/modules/Checkout/controllers/CartController.php on line 210. in /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response-&gt;sendHeaders()
#1 /www/web/fecshop/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response-&gt;send()
#2 /www/web/fecshop/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler-&gt;renderException(Object(yii\web\HeadersAlreadySentException))
#3 [internal function]: yii\base\ErrorHandler-&gt;handleException(Object(yii\web\HeadersAlreadySentException))
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /www/web/fecshop/vendor/fancyecommerce/fecshop/app/appfront/modules/Checkout/controllers/CartController.php on line 210. in /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /www/web/fecshop/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response-&gt;sendHeaders()
#1 /www/web/fecshop/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Response-&gt;send()
#2 /www/web/fecshop/appfront/web/index.php(90): yii\base\Application-&gt;run()
#3 {main}</pre>
Fecmall#66年前 0 个赞

对于错误: headers already sent,执行echo等候,不可以继续修改header信息,否则就会报错,

详细资料:http://www.zuimoban.com/php/php/6792.html

你是全新安装fecshop?还是在已有的fecshop进行升级?或者进行了一些改动?

fecshop本地测试没有这个报错,一切正常。

shejicq#76年前 0 个赞

我是docker-composer全新安装的1.4.0.0 获取分类错误

Fecmall#86年前 0 个赞

@shejicq #7楼 你自己尝试排查下看看,能否自己解决。

你是第一个提这个报错的。

你compose 安装其他版本(譬如: 1.3.2.1) 版本,也报错吗?

您自己尝试排查,找找问题点试试,我这里本地没有这个报错,我的环境是centos6 + php7。

docker 里面也是php7,不应该出这个问题。

Fecmall#96年前 0 个赞

通过在代码中 加 exit 的方式,看看在哪里的代码导致的这个报错。

shejicq#106年前 0 个赞

错误: headers already sent 和二楼一样 我自己找下原因吧

helloworld#116年前 1 个赞

docker下全新安装fecshop,,,echo之后,加个exit就可以了。

shejicq#126年前 0 个赞

@lincome #11楼 加exit 结束输出可以

Fecmall#136年前 0 个赞

@lincome #11楼 不需要加的,你们有线上的主机吗?方便的话发我一下,我上去看看

QQ:2358269014

@shejicq #12楼

Fecmall#146年前 0 个赞

你们先尝试解决看看,我之前弄了一个月的阿里云弄的docker,测试过1.3.2,是没有问题的,现在到期了,没法测试了。

你们先测试试试吧,实在解决不了,我重买一个月的阿里云测试看看。

freetiger#156年前 0 个赞

我装的 1.3.2.1也报这个错

Fecmall#166年前 0 个赞

@freetiger [#15楼](#comment15) 2358269014@qq.com

把你的主机的ssh信息,也安装的路径,访问的域名(前台后台)发我一下,我看看。

访问什么页面,报什么错误。

shejicq#176年前 0 个赞

@Fecshop [#16楼](#comment16) 发你邮箱了 这也是个测试环境 自己二开的还在本地

Fecmall#186年前 0 个赞

检测了一下这个问题:

@yii/web/Reponse.php

public function send()
    {
        if ($this->isSent) {
            return;
        }
        $this->trigger(self::EVENT_BEFORE_SEND);
        $this->prepare();
        $this->trigger(self::EVENT_AFTER_PREPARE);
        $this->sendHeaders();
        $this->sendContent();
        $this->trigger(self::EVENT_AFTER_SEND);
        $this->isSent = true;
    }

在 vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productinfo/Getproductcategory.php 的

echo json_encode([
            'menu'=>$menuStr,
            'return_status'=>'success',
        ]);

执行前后各执行了上面的 send()函数,因此,在echo 输出后,继续执行 send()函数内部的 $this->sendHeaders();导致的报错, 具体版本差异不追究了,我处理一下这个问题,处理问题,会有新版本发布, 如果还有类似的问题,在这个帖子就发出来,都处理一下

Fecmall#196年前 1 个赞

这个问题的解决,

1.要么加exit,也就是这样

public function getProductCategory()
    {
        $product_id = CRequest::param('product_id');

        $menuStr = $this->getMenuStr($product_id);
        echo json_encode([
            'menu'=>$menuStr,
            'return_status'=>'success',
        ]);
        exit;
    }

2.要么不使用echo, 而是使用return, 然后在controller的最后也使用return

vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/block/productinfo/Getproductcategory.php

更改为:

public function getProductCategory()
    {
        $product_id = CRequest::param('product_id');

        $menuStr = $this->getMenuStr($product_id);
        return json_encode([
            'menu'=>$menuStr,
            'return_status'=>'success',
        ]);
        
    }

vendor/fancyecommerce/fecshop/app/appadmin/modules/Catalog/controllers/ ProductinfoController.php

// catalog product
    public function actionGetproductcategory()
    {
        $this->getBlock()->getProductCategory();
    }

更改为

// catalog product
    public function actionGetproductcategory()
    {
        return $this->getBlock()->getProductCategory();
    }

OK,2种,后面新版本会修正。你们帮看一下,是否还有其他的问题

另外看一下一下,上传产品图片也有问题,在echo代码后面加个exit解决吧

Fecmall#206年前 0 个赞

https://github.com/fecshop/yii2_fecshop/commit/1d6d13c789c14f9bbee8c2b6956296e941e36b7a

@shejicq [#17楼](#comment17) @freetiger [#15楼](#comment15)

在等几天,看看是否还有其他问题,如果没有其他问题,周末发个新版本。

helloworld#216年前 0 个赞

还有一处,就是appfront购物车增减产品数量的接口

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics