Which causes an element query to fetch the currently logged-in user.
Problem is, element queries shouldn’t get fired until the application is fully done initializing, so all the plugin-supplied custom fields, event listeners, etc., have had a chance to be registered/initialized. Otherwise you end up getting some weird plugin conflicts, such as https://github.com/craftcms/cms/issues/2860#issuecomment-564956191.
This line in
Patrol::init()
:https://github.com/selvinortiz/craft-plugin-patrol/blob/d443741770fbaca6adbd38236fb0faffab25be7a/src/Patrol.php#L47
Brings us to:
https://github.com/selvinortiz/craft-plugin-patrol/blob/d443741770fbaca6adbd38236fb0faffab25be7a/src/services/PatrolService.php#L66
Then:
https://github.com/selvinortiz/craft-plugin-patrol/blob/d443741770fbaca6adbd38236fb0faffab25be7a/src/services/PatrolService.php#L229
And finally:
https://github.com/selvinortiz/craft-plugin-patrol/blob/d443741770fbaca6adbd38236fb0faffab25be7a/src/services/PatrolService.php#L278
Which causes an element query to fetch the currently logged-in user.
Problem is, element queries shouldn’t get fired until the application is fully done initializing, so all the plugin-supplied custom fields, event listeners, etc., have had a chance to be registered/initialized. Otherwise you end up getting some weird plugin conflicts, such as https://github.com/craftcms/cms/issues/2860#issuecomment-564956191.
You can fix this by holding off until craft\web\Application::EVENT_INIT before calling
$this->defaultService->watch()
.