craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
218 stars 170 forks source link

[4.x]: Debug toolbar disappears when enabling Commerce #2742

Closed Nellyaa closed 2 years ago

Nellyaa commented 2 years ago

What happened?

Description

When you enable the Craft Commerce plugin and have the show debug toolbar setting activated, it won't show up anymore on the frontend until you disable the Commerce plugin again. The browser console (tested in FF and Chrome) throws a 404 error.

Steps to reproduce

  1. Enable the 'Show the debug toolbar on the front end' setting in your user profile
  2. Open the frontend
  3. Get "not found" error in browser console, no debug toolbar shows up

Expected behavior

Debug toolbar shows up in the frontend without 404ing after enabling the setting :)

Actual behavior

Console in browser throws:

GET http://localhost:8080/actions/debug/default/toolbar?tag=623a1f7574b8d 404 (Not Found) ajax @ (index):294 (anonymous) @ (index):323 (anonymous) @ (index):686

Screenshot from Firefox console: Unbenannt-2

Craft CMS version

4.0.0-beta.2

Craft Commerce version

4.0.0-beta.1

PHP version

8.1.3

Operating system and version

Linux 5.10.16.3-microsoft-standard-WSL2

Database type and version

MySQL 10.7.3

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

nfourtythree commented 2 years ago

Hi @Nellyaa

Thank you for reporting. Unfortunately, I am unable to replicate this issue on my end.

Is there any data in your phperrors.log file in the Storage > logs directory?

Thanks.

Nellyaa commented 2 years ago

Thanks for looking into it. Unfortunately there are no error logs in phperrors.log that coincidence with this problem.

After looking a bit further into it, we found that there are no files generated in storage/runtime/debug as long as Commerce is enabled. They work fine if it's disabled.

Here's the full error page after trying to access the 404 error directly:


[HTTP 404 – Not Found](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404) – [yii\web\NotFoundHttpException](http://www.yiiframework.com/doc-2.0/yii-web-notfoundhttpexception.html)
Unable to find debug data tagged with '623c7dd080caa'.
1. in /var/www/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.phpat line 231
222223224225226227228229230231232233                    }
                }
                $this->summary = $data['summary'];

                return;
            }
            sleep(1);
        }

        throw new NotFoundHttpException("Unable to find debug data tagged with '$tag'.");
    }
}
2. in /var/www/vendor/yiisoft/yii2-debug/src/controllers/DefaultController.php at line 140– [yii\debug\controllers\DefaultController::loadData](http://www.yiiframework.com/doc-2.0/yii-debug-controllers-defaultcontroller.html#loadData()-detail)('623c7dd080caa', 5)
134135136137138139140141142143144145146     * @param string $tag
     * @return string
     * @throws NotFoundHttpException
     */
    public function actionToolbar($tag)
    {
        $this->loadData($tag, 5);

        return $this->renderPartial('toolbar', [
            'tag' => $tag,
            'panels' => $this->module->panels,
            'position' => 'bottom',
            'defaultHeight' => $this->module->defaultHeight,
3. [yii\debug\controllers\DefaultController::actionToolbar](http://www.yiiframework.com/doc-2.0/yii-debug-controllers-defaultcontroller.html#actionToolbar()-detail)('623c7dd080caa')
4. in /var/www/vendor/yiisoft/yii2/base/InlineAction.php at line 57– call_user_func_array([yii\debug\controllers\DefaultController, 'actionToolbar'], ['623c7dd080caa'])
5. in /var/www/vendor/yiisoft/yii2/base/Controller.php at line 178– [yii\base\InlineAction::runWithParams](http://www.yiiframework.com/doc-2.0/yii-base-inlineaction.html#runWithParams()-detail)(['tag' => '623c7dd080caa'])
6. in /var/www/vendor/yiisoft/yii2/base/Module.php at line 552– [yii\base\Controller::runAction](http://www.yiiframework.com/doc-2.0/yii-base-controller.html#runAction()-detail)('toolbar', ['tag' => '623c7dd080caa'])
7. in /var/www/vendor/craftcms/cms/src/web/Application.php at line 300– [yii\base\Module::runAction](http://www.yiiframework.com/doc-2.0/yii-base-module.html#runAction()-detail)('debug/default/toolbar', ['tag' => '623c7dd080caa'])
294295296297298299300301302303304305306     * @param string $route
     * @param array $params
     * @return Response|null The result of the action, normalized into a Response object
     */
    public function runAction($route, $params = []): ?BaseResponse
    {
        $result = parent::runAction($route, $params);

        if ($result === null || $result instanceof Response) {
            return $result;
        }

        $response = $this->getResponse();
8. in /var/www/vendor/craftcms/cms/src/web/Application.php at line 604– craft\web\Application::runAction('debug/default/toolbar', ['tag' => '623c7dd080caa'])
598599600601602603604605606607608609610        if ($request->getIsActionRequest()) {
            $route = implode('/', $request->getActionSegments());

            try {
                Craft::debug("Route requested: '$route'", __METHOD__);
                $this->requestedRoute = $route;
                return $this->runAction($route, $_GET);
            } catch (Throwable $e) {
                $this->_unregisterDebugModule();
                if ($e instanceof InvalidRouteException) {
                    throw new NotFoundHttpException(Craft::t('yii', 'Page not found.'), $e->getCode(), $e);
                }
                throw $e;
9. in /var/www/vendor/craftcms/cms/src/web/Application.php at line 279– craft\web\Application::_processActionRequest(craft\web\Request)
273274275276277278279280281282283284285                    throw new ForbiddenHttpException();
                }
            }
        }

        // If this is an action request, call the controller
        if (($response = $this->_processActionRequest($request)) !== null) {
            return $response;
        }

        // If we're still here, finally let Yii do it's thing.
        try {
            return parent::handleRequest($request);
10. in /var/www/vendor/yiisoft/yii2/base/Application.php at line 384– craft\web\Application::handleRequest(craft\web\Request)
11. in /var/www/web/index.php at line 12– [yii\base\Application::run](http://www.yiiframework.com/doc-2.0/yii-base-application.html#run()-detail)()
6789101112// Load shared bootstrap
require dirname(__DIR__) . '/bootstrap.php';

// Load and run Craft
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php';
$app->run();
$_GET = [
    'tag' => '623c7dd080caa',
];

$_COOKIE = [
    '08b50206495ab19261c35e647aeb027a_username' => '0eb2b1de38f4a73129f8612b2ef4e6b7a1cbcc8435832166c4d9f1e1f0941f52a:2:{i:0;s:41:"08b50206495ab19261c35e647aeb027a_username";i:1;s:7:"nellyaa";}',
    'CraftSessionId' => '49a75e585b9722c26d0a2eb924576d7d',
    '08b50206495ab19261c35e647aeb027a_identity' => '77e956d536e6ca6419d8153b1246a8651ff0a1aa85139de565aad4989a6dc8bca:2:{i:0;s:41:"08b50206495ab19261c35e647aeb027a_identity";i:1;s:159:"[1,"[\\"weATH2BcbVdcIHHIjKoUObULksWdp562FHAk3JCatQ6XD7dJsfq-azJASL3_iXz9tF7D8UpUDHzPRbdOe1PkyShOzqrjkzrDKgQk\\",null,\\"a37de56df4eb013c98c447b3b0967110\\"]",3600]";}',
    'CRAFT_CSRF_TOKEN' => '9c846a7a423f0110d4636985e2da85cff5314cd18d76d0ac9ab8e2c21bb135a2a:2:{i:0;s:16:"CRAFT_CSRF_TOKEN";i:1;s:147:"tj7M-IDvhPwS8ixUYn9JODea3RPp_zszpVNaflCm|240434776b27f8063da8b78a23baa8003e06b117cdd3c5e8784f71b2d3ae808dtj7M-IDvhPwS8ixUYn9JODea3RPp_zszpVNaflCm|1";}',
];

$_SESSION = [
    'a50e111d5f13061b3bc1c20c2a9c215d__flash' => [],
    'a50e111d5f13061b3bc1c20c2a9c215d__auth_access' => [
        'editStructure:4',
        'editStructure:7',
        'editStructure:2',
        'editStructure:8',
        'previewDraft:54',
        'previewElement:180',
        'previewDraft:55',
    ],
    'commerce_cart' => '5cf645dff562cb2093ee1702a4465dd0',
    '08b50206495ab19261c35e647aeb027a__token' => 'weATH2BcbVdcIHHIjKoUObULksWdp562FHAk3JCatQ6XD7dJsfq-azJASL3_iXz9tF7D8UpUDHzPRbdOe1PkyShOzqrjkzrDKgQk',
    '08b50206495ab19261c35e647aeb027a__id' => 1,
    '__authKey' => '["weATH2BcbVdcIHHIjKoUObULksWdp562FHAk3JCatQ6XD7dJsfq-azJASL3_iXz9tF7D8UpUDHzPRbdOe1PkyShOzqrjkzrDKgQk",null,"a37de56df4eb013c98c447b3b0967110"]',
    '08b50206495ab19261c35e647aeb027a__expire' => 1648136905,
    '__duration' => 3600,
];
nfourtythree commented 2 years ago

@Nellyaa thanks for the reply.

A few more questions:

As I am unable to replicate it, just trying to narrow down what might be happening.

Thanks

Nellyaa commented 2 years ago

I'm running PRO, and I tried with all other plugins disabled (currently Icon Picker, Navigation and Redactor) and enabled with the same outcome: the toolbar doesn't show up. Sadly no difference after clearing the cache and deleting the runtime directory. Craft creates the runtime/debug folder but doesn't fill it with any data, as long as Commerce is enabled.

nfourtythree commented 2 years ago

Hi @Nellyaa

Managed to get to the bottom of this. Found the issue in that it is coming from a bug that has since been fixed on the commerce 4 development branch. This is why we were seeing different behaviour.

The fix will be included in the next beta release of Commerce.

To get this early, change your craftcms/commerce requirement in your project's composer.json to:

"require": {
  "craftcms/commerce": "4.0.x-dev as 4.0.0-beta.1",
  "...": "..."
}

Then run composer update.

Hope this helps, thanks!