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