66namespace Icinga \Application \Modules ;
77
88use Exception ;
9+ use Fiber ;
910use Icinga \Application \ApplicationBootstrap ;
1011use Icinga \Application \Config ;
1112use Icinga \Application \Hook ;
@@ -1084,7 +1085,22 @@ public function getSetupWizard()
10841085 */
10851086 public function getUserBackends ()
10861087 {
1087- $ this ->launchConfigScript ();
1088+ // TODO: Remove with v2.15
1089+ if (Fiber::getCurrent () === null ) {
1090+ (new Fiber (function () {
1091+ Logger::debug (
1092+ 'Running config script of module "%s" asynchronously (Process %d; Fiber %d) ' ,
1093+ $ this ->getName (),
1094+ getmypid () ?: 0 ,
1095+ spl_object_id (Fiber::getCurrent ())
1096+ );
1097+
1098+ $ this ->launchConfigScript ();
1099+ }))->start ();
1100+ } else {
1101+ $ this ->launchConfigScript ();
1102+ }
1103+
10881104 return $ this ->userBackends ;
10891105 }
10901106
@@ -1095,7 +1111,22 @@ public function getUserBackends()
10951111 */
10961112 public function getUserGroupBackends ()
10971113 {
1098- $ this ->launchConfigScript ();
1114+ // TODO: Remove with v2.15
1115+ if (Fiber::getCurrent () === null ) {
1116+ (new Fiber (function () {
1117+ Logger::debug (
1118+ 'Running config script of module "%s" asynchronously (Process %d; Fiber %d) ' ,
1119+ $ this ->getName (),
1120+ getmypid () ?: 0 ,
1121+ spl_object_id (Fiber::getCurrent ())
1122+ );
1123+
1124+ $ this ->launchConfigScript ();
1125+ }))->start ();
1126+ } else {
1127+ $ this ->launchConfigScript ();
1128+ }
1129+
10991130 return $ this ->userGroupBackends ;
11001131 }
11011132
@@ -1196,6 +1227,21 @@ protected function provideSetupWizard($className)
11961227 */
11971228 protected function provideUserBackend ($ identifier , $ className )
11981229 {
1230+ if ($ this ->registered ) {
1231+ trigger_error (sprintf (
1232+ 'Module "%s" already registered. Providing user backend "%s" in configuration.php '
1233+ . ' has no effect as of version 2.15. Put it in run.php instead. ' ,
1234+ $ this ->getName (),
1235+ $ identifier
1236+ ), E_USER_DEPRECATED );
1237+ Logger::warning (
1238+ 'Module "%s" already registered. Providing user backend "%s" in configuration.php '
1239+ . ' has no effect as of version 2.15. Put it in run.php instead. ' ,
1240+ $ this ->getName (),
1241+ $ identifier
1242+ );
1243+ }
1244+
11991245 $ this ->userBackends [strtolower ($ identifier )] = $ className ;
12001246 return $ this ;
12011247 }
@@ -1210,6 +1256,21 @@ protected function provideUserBackend($identifier, $className)
12101256 */
12111257 protected function provideUserGroupBackend ($ identifier , $ className )
12121258 {
1259+ if ($ this ->registered ) {
1260+ trigger_error (sprintf (
1261+ 'Module "%s" already registered. Providing user group backend "%s" in configuration.php '
1262+ . ' has no effect as of version 2.15. Put it in run.php instead. ' ,
1263+ $ this ->getName (),
1264+ $ identifier
1265+ ), E_USER_DEPRECATED );
1266+ Logger::warning (
1267+ 'Module "%s" already registered. Providing user group backend "%s" in configuration.php '
1268+ . ' has no effect as of version 2.15. Put it in run.php instead. ' ,
1269+ $ this ->getName (),
1270+ $ identifier
1271+ );
1272+ }
1273+
12131274 $ this ->userGroupBackends [strtolower ($ identifier )] = $ className ;
12141275 return $ this ;
12151276 }
0 commit comments