yiisoft / yii2-debug

Debug Extension for Yii 2
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 149 forks source link

Fix response format after scan routes #485

Closed todo369 closed 2 years ago

todo369 commented 2 years ago
Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues

usecase:

$config = [
    'modules' => [
        'user' => [
            'class' => frontend\modules\user\Module::class,
            'shouldBeActivated' => false,
            'enableLoginByPass' => false,
        ],
    ],
<?php

namespace frontend\modules\user;

class Module extends \yii\base\Module
{
    public function init()
    {
        //========I don't know why they reconfigure response like this in current project.
        \Yii::configure(\Yii::$app, [
            'components' => [
                'response' => [
                    'class' => 'yii\web\Response',
                    'format' => \yii\web\Response::FORMAT_JSON,
                    //.....
                ],
                //.....
            ],
        ]);
        //============= if use this,would not tigger the problem
        //\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        parent::init();
    }
}

then after scan the ModuleControllers,the response format changed

vendor/yiisoft/yii2-debug/src/models/router/ActionRoutes.php:125
if (($child = $module->getModule($id)) === null) {

I think it is not a bug,but maybe we could enhance it.

bizley commented 2 years ago

What is the reason for this change? And why only here?

yii-bot commented 2 years ago

Thank you for putting effort in the improvement of the Yii framework. We have reviewed your pull request.

Unfortunately a use case is missing. It is required to get a better understanding of the pull request and helps us to determine the necessity and applicability of the suggested change to the framework.

Could you supply us with a use case please? Please be as detailed as possible and show some code!

Thanks!

This is an automated comment, triggered by adding the label pr:missing usecase.

todo369 commented 2 years ago

What is the reason for this change? And why only here?

usecase updated.

bizley commented 2 years ago

I don't think we should force default format everywhere to make sure it has not been changed globally, it is rather the response of the developer to make sure the app config allows using the tool he would like to use, like debug panel. Otherwise there is too much to check every time on the tool init. Thank you for your proposal but I'm afraid you have to fix it on your end.

todo369 commented 2 years ago

I don't think we should force default format everywhere to make sure it has not been changed globally, it is rather the response of the developer to make sure the app config allows using the tool he would like to use, like debug panel. Otherwise there is too much to check every time on the tool init. Thank you for your proposal but I'm afraid you have to fix it on your end.

ok,I see. but when I visit http://localhost/web/debug/default/view?tag=629854734719f&panel=router,it return json,that confuse me. Maybe I should fix it on my end like you say. Thanks.