Closed andrey-helldar closed 4 years ago
I also tried to transfer the DB::enableQueryLog()
method from register
to boot
- it does not help. The same error.
Registering event service provider before AppServiceProvider resolves the issue:
$app->register(App\Providers\EventServiceProvider::class);
$app->register(App\Providers\AppServiceProvider::class);
\DB facade call asks to resolve the database manager instance. There is:
if ($this->app->bound('events')) {
$connection->setEventDispatcher($this->app['events']);
}
and app['events'] is not ready yet. So, maybe move 'events' initiation to own service provider, which will be booted before any user code?
I think this will solve my problem. I can check in the morning.
So. I have checked and cannot change the order of the service providers as it breaks the application.
BUT I created another service provider and placed it last in the init list.
Moved the call to the DB::enableLogQuery()
method into it.
I think this is not a bug, it's a feature. So I close the issue :)
6.3.5
,8.1.0
Description:
Calling the static method for enabling logging does not trigger the event call.
Steps To Reproduce:
namespace App\Listeners;
use Illuminate\Database\Events\TransactionCommitted;
final class FooListener { public function handle(TransactionCommitted $event) { dd('check'); } }
namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Support\Facades\DB;
final class Foo extends Command { protected $signature = 'foo';
}
See:
The
commit()
method: https://github.com/laravel/framework/blob/6.x/src/Illuminate/Database/Concerns/ManagesTransactions.php#L186The
Connection
classs:$this->events
is null https://github.com/laravel/framework/blob/6.x/src/Illuminate/Database/Connection.php#L810I checked the same behavior in the Laravel Framework - everything works there.