Plugin init order issue
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a plugin, which is using another plugin. The issue is that, I am calling some other plugin information in the init function, and I do receive sometimes this error:
2018-11-07 11:44:57 [-][-][k91hcavi6st542afnhsvhdp61u][error][yiibaseErrorException:8] yiibaseErrorException: Trying to get property 'mobileDetectService' of non-object in /home/forge/plugins/releases/20181106223004/src/services/CacheService.php:193
Stack trace:
#0 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yiibaseErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193)
#1 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(193): craftwebErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193, Array)
#2 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(126): trendspublishingcraftpluginservicesCacheService->_generateUri('/hubs/bathroom')
#3 /home/forge/plugins/releases/20181106223004/src/Plugin.php(90): trendspublishingcraftpluginservicesCacheService->uriToFilePath('/hubs/bathroom')
#4 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/BaseObject.php(109): trendspublishingcraftpluginPlugin->init()
#5 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/Module.php(158): yiibaseBaseObject->__construct(Array)
#6 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/base/Plugin.php(113): yiibaseModule->__construct('craftplugin', Object(craftwebApplication), Array)
#7 [internal function]: craftbasePlugin->__construct('craftplugin', Object(craftwebApplication), Array)
This is the error in question:
$mobile_detect = MobileDetect::$plugin->mobileDetectService;
I am not able to replicate it, sometimes a simple database reload is helping sometimes not. So that's why I am only guessing, because I do invoke this call from the plugin init function, that's why the other plugin is not ready yet...
Any thought, best practice on this one?
plugin-development
add a comment |Â
up vote
1
down vote
favorite
I have a plugin, which is using another plugin. The issue is that, I am calling some other plugin information in the init function, and I do receive sometimes this error:
2018-11-07 11:44:57 [-][-][k91hcavi6st542afnhsvhdp61u][error][yiibaseErrorException:8] yiibaseErrorException: Trying to get property 'mobileDetectService' of non-object in /home/forge/plugins/releases/20181106223004/src/services/CacheService.php:193
Stack trace:
#0 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yiibaseErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193)
#1 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(193): craftwebErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193, Array)
#2 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(126): trendspublishingcraftpluginservicesCacheService->_generateUri('/hubs/bathroom')
#3 /home/forge/plugins/releases/20181106223004/src/Plugin.php(90): trendspublishingcraftpluginservicesCacheService->uriToFilePath('/hubs/bathroom')
#4 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/BaseObject.php(109): trendspublishingcraftpluginPlugin->init()
#5 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/Module.php(158): yiibaseBaseObject->__construct(Array)
#6 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/base/Plugin.php(113): yiibaseModule->__construct('craftplugin', Object(craftwebApplication), Array)
#7 [internal function]: craftbasePlugin->__construct('craftplugin', Object(craftwebApplication), Array)
This is the error in question:
$mobile_detect = MobileDetect::$plugin->mobileDetectService;
I am not able to replicate it, sometimes a simple database reload is helping sometimes not. So that's why I am only guessing, because I do invoke this call from the plugin init function, that's why the other plugin is not ready yet...
Any thought, best practice on this one?
plugin-development
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a plugin, which is using another plugin. The issue is that, I am calling some other plugin information in the init function, and I do receive sometimes this error:
2018-11-07 11:44:57 [-][-][k91hcavi6st542afnhsvhdp61u][error][yiibaseErrorException:8] yiibaseErrorException: Trying to get property 'mobileDetectService' of non-object in /home/forge/plugins/releases/20181106223004/src/services/CacheService.php:193
Stack trace:
#0 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yiibaseErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193)
#1 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(193): craftwebErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193, Array)
#2 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(126): trendspublishingcraftpluginservicesCacheService->_generateUri('/hubs/bathroom')
#3 /home/forge/plugins/releases/20181106223004/src/Plugin.php(90): trendspublishingcraftpluginservicesCacheService->uriToFilePath('/hubs/bathroom')
#4 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/BaseObject.php(109): trendspublishingcraftpluginPlugin->init()
#5 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/Module.php(158): yiibaseBaseObject->__construct(Array)
#6 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/base/Plugin.php(113): yiibaseModule->__construct('craftplugin', Object(craftwebApplication), Array)
#7 [internal function]: craftbasePlugin->__construct('craftplugin', Object(craftwebApplication), Array)
This is the error in question:
$mobile_detect = MobileDetect::$plugin->mobileDetectService;
I am not able to replicate it, sometimes a simple database reload is helping sometimes not. So that's why I am only guessing, because I do invoke this call from the plugin init function, that's why the other plugin is not ready yet...
Any thought, best practice on this one?
plugin-development
I have a plugin, which is using another plugin. The issue is that, I am calling some other plugin information in the init function, and I do receive sometimes this error:
2018-11-07 11:44:57 [-][-][k91hcavi6st542afnhsvhdp61u][error][yiibaseErrorException:8] yiibaseErrorException: Trying to get property 'mobileDetectService' of non-object in /home/forge/plugins/releases/20181106223004/src/services/CacheService.php:193
Stack trace:
#0 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yiibaseErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193)
#1 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(193): craftwebErrorHandler->handleError(8, 'Trying to get p...', '/home/forge/plu...', 193, Array)
#2 /home/forge/plugins/releases/20181106223004/src/services/CacheService.php(126): trendspublishingcraftpluginservicesCacheService->_generateUri('/hubs/bathroom')
#3 /home/forge/plugins/releases/20181106223004/src/Plugin.php(90): trendspublishingcraftpluginservicesCacheService->uriToFilePath('/hubs/bathroom')
#4 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/BaseObject.php(109): trendspublishingcraftpluginPlugin->init()
#5 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/yiisoft/yii2/base/Module.php(158): yiibaseBaseObject->__construct(Array)
#6 /home/forge/new.trendsideas.com/releases/20181106223038/vendor/craftcms/cms/src/base/Plugin.php(113): yiibaseModule->__construct('craftplugin', Object(craftwebApplication), Array)
#7 [internal function]: craftbasePlugin->__construct('craftplugin', Object(craftwebApplication), Array)
This is the error in question:
$mobile_detect = MobileDetect::$plugin->mobileDetectService;
I am not able to replicate it, sometimes a simple database reload is helping sometimes not. So that's why I am only guessing, because I do invoke this call from the plugin init function, that's why the other plugin is not ready yet...
Any thought, best practice on this one?
plugin-development
plugin-development
asked 1 hour ago
Visky Máté
11710
11710
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
What I do is I listen for the Plugins::EVENT_AFTER_LOAD_PLUGINS
event, and then do my code that relies on other plugins being loaded:
// Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function ()
// Do stuff only after all other plugins have loaded
);
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
What I do is I listen for the Plugins::EVENT_AFTER_LOAD_PLUGINS
event, and then do my code that relies on other plugins being loaded:
// Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function ()
// Do stuff only after all other plugins have loaded
);
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
add a comment |Â
up vote
3
down vote
What I do is I listen for the Plugins::EVENT_AFTER_LOAD_PLUGINS
event, and then do my code that relies on other plugins being loaded:
// Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function ()
// Do stuff only after all other plugins have loaded
);
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
What I do is I listen for the Plugins::EVENT_AFTER_LOAD_PLUGINS
event, and then do my code that relies on other plugins being loaded:
// Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function ()
// Do stuff only after all other plugins have loaded
);
What I do is I listen for the Plugins::EVENT_AFTER_LOAD_PLUGINS
event, and then do my code that relies on other plugins being loaded:
// Handler: Plugins::EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function ()
// Do stuff only after all other plugins have loaded
);
answered 26 mins ago
andrew.welch
7,4291223
7,4291223
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
add a comment |Â
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
Yes, we have this event, and it is working like charm, but in this case is not good. I have to make a decision in realtime (routing decision for cache). Is there any way to manually instantiate the plugin and store it into the proper place? I am trying to use something like this... but guess this is not the best method:( $mobile_detect = (new superbigmobiledetectservicesMobileDetectService())->getMobileDetect();
â Visky Máté
25 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcraftcms.stackexchange.com%2fquestions%2f28332%2fplugin-init-order-issue%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password