cakephp / debug_kit

Debug Toolbar for CakePHP applications.
http://cakephp.org
Other
852 stars 571 forks source link

Aura\Intl\Exception: Package 'debug_kit' with locale 'en_US' is not registered. #739

Closed geoidesic closed 4 years ago

geoidesic commented 4 years ago

Hi,

I'm getting this error when stepping through the code using Xdebug.

Aura\Intl\Exception: Package 'debug_kit' with locale 'en_US' is not registered.

This is a Standard CakePHP 3.x installation

Is there a fix for this?

markstory commented 4 years ago

How can someone reproduce this problem?

othercorey commented 4 years ago

@geoidesic Can you give us more information?

geoidesic commented 4 years ago

Dunno. I can't replicate it now either. I'll re-open with more info if it recurs.

geoidesic commented 4 years ago

LOL. As I entered that, it happened again :D

geoidesic commented 4 years ago

So here's what I did:

  1. Install cake 3.8: php /usr/local/bin/composer create-project --prefer-dist cakephp/app:^3.8 testCake3
  2. Serve it via a vhost on MAMP Pro
  3. Create a database and config the db settings.
  4. Install the VsCode extension "PHP Debug 1.14.0" by Robert Lu
  5. Added a breakpoint in bootstrap.php
  6. Started the debugger
  7. Browsed to the home page
  8. Clicked to open the Cake Debug footer thingy at the bottom.
  9. Hit play on the debugger

It stops on line 96 of PackageLocator.php with that error.

It is intermittent though. Just tried it a few more times and now I'm not getting it.

garas commented 4 years ago

What is full callstack?

What message does it tries to translate (look for __d() few frames before PackageLocator.php)?

geoidesic commented 4 years ago

It doesn't give me a call stack. The error shows only in the IDE when it hits the error and the step through stops – and there's no call stack given, just the exception message. It's very strange... it also doesn't seem to take me on the same step-through route every request. Looks like it's getting stuck on translations, but only sometimes. Seems to happen something like 1 out of 3 or 4 requests.

geoidesic commented 4 years ago

Something else that's odd is that bootstrap seems to be run twice by the request. I have a breakpoint in there and it gets hit twice by each request.

garas commented 4 years ago

Add breakpoint on line 96 of PackageLocator.php so it stops before throwing exception.

Callstack and message to translate might give a hint why.

It might be cached by Cake cache for short time and it happen or not.

Bootstrap is called twice because one for app request and one to load iframe of DebugKit toolbar. Check URL in $_SERVER in the debugger.

geoidesic commented 4 years ago

Ok found the call stack:

Aura\Intl\PackageLocator->get (/Users/me/testCake3/vendor/aura/intl/src/PackageLocator.php:96)
Cake\I18n\TranslatorRegistry->get (/Users/me/testCake3/vendor/aura/intl/src/TranslatorLocator.php:180)
Cake\I18n\TranslatorRegistry->_getTranslator (/Users/me/testCake3/vendor/cakephp/cakephp/src/I18n/TranslatorRegistry.php:167)
Cake\I18n\TranslatorRegistry->get (/Users/me/testCake3/vendor/cakephp/cakephp/src/I18n/TranslatorRegistry.php:149)
Cake\I18n\I18n::getTranslator (/Users/me/testCake3/vendor/cakephp/cakephp/src/I18n/I18n.php:209)
__d (/Users/me/testCake3/vendor/cakephp/cakephp/src/I18n/functions.php:88)
DebugKit\Panel\TimerPanel->DebugKit\Panel\{closure:/Users/me/testCake3/vendor/cakephp/debug_kit/src/Panel/TimerPanel.php:52-54} (/Users/me/testCake3/vendor/cakephp/debug_kit/src/Panel/TimerPanel.php:53)
Cake\Event\EventManager->_callListener (/Users/me/testCake3/vendor/cakephp/cakephp/src/Event/EventManager.php:352)
Cake\Event\EventManager->dispatch (/Users/me/testCake3/vendor/cakephp/cakephp/src/Event/EventManager.php:329)
App\Controller\PagesController->dispatchEvent (/Users/me/testCake3/vendor/cakephp/cakephp/src/Event/EventDispatcherTrait.php:113)
App\Controller\PagesController->startupProcess (/Users/me/testCake3/vendor/cakephp/cakephp/src/Controller/Controller.php:676)
Cake\Http\ActionDispatcher->_invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php:115)
Cake\Http\ActionDispatcher->dispatch (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php:94)
App\Application->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/BaseApplication.php:234)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
Cake\Http\Middleware\CsrfProtectionMiddleware->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Middleware/CsrfProtectionMiddleware.php:124)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
Cake\Http\Runner->run (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:51)
Cake\Routing\Middleware\RoutingMiddleware->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php:168)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
Cake\Routing\Middleware\AssetMiddleware->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php:88)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php:96)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
DebugKit\Middleware\DebugKitMiddleware->__invoke (/Users/me/testCake3/vendor/cakephp/debug_kit/src/Middleware/DebugKitMiddleware.php:53)
Cake\Http\Runner->__invoke (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:65)
Cake\Http\Runner->run (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Runner.php:51)
Cake\Http\Server->run (/Users/me/testCake3/vendor/cakephp/cakephp/src/Http/Server.php:97)
{main} (/Users/me/testCake3/webroot/index.php:40)
geoidesic commented 4 years ago

The string it's trying to translate is Controller initialization and $domain = debug_kit

ADmad commented 4 years ago

The string it's trying to translate is Controller initialization and $domain = debug_kit

We are getting rid of that translation function usage anyway https://github.com/cakephp/debug_kit/pull/750/files

garas commented 4 years ago

@ADmad PR is for 4.x, not 3.x, so it won't help here.

I'm not sure why exception is not catched here https://github.com/cakephp/cakephp/blob/3.8.11/src/I18n/TranslatorRegistry.php#L166-L169 Or is it thrown again in fallback loader few lines later.

I'm unable to repeat so it is hard to tell why.

But I guess it is something with cache. In debug mode, it is 2 minutes, try shorter duration, it should happen more often.

ADmad commented 4 years ago

@garas We can backport it.

It's highly likely the issue is with a particular environment and not a bug in our code.

othercorey commented 4 years ago

Back-port https://github.com/cakephp/debug_kit/pull/751