diff --git a/module/VuFind/src/VuFind/Bootstrap.php b/module/VuFind/src/VuFind/Bootstrap.php
index 0c890f140e6f136843b5afac7e5d5c7536a6a42c..2b5d899111f16dd28324ef75af9860db5dae6c95 100644
--- a/module/VuFind/src/VuFind/Bootstrap.php
+++ b/module/VuFind/src/VuFind/Bootstrap.php
@@ -80,9 +80,10 @@ class Bootstrap
 
         // Attach remaining theme configuration to the dispatch event:
         $config =& $this->config;
-        $events->attach('dispatch', function($event) use ($config) {
+        $callback = function($event) use ($config) {
             $theme = new ThemeInitializer($config, $event);
             $theme->init();
-        });
+        };
+        $events->attach('dispatch', $callback);
     }
 }
\ No newline at end of file