From 8cc007ea2a1587cab8f6e84fdcb1bf7bdd4e3f81 Mon Sep 17 00:00:00 2001 From: dryajov Date: Mon, 6 Jun 2016 23:45:24 -0700 Subject: [PATCH 1/2] Load plugin doring init face to prevent race conditions --- Herbert/Framework/Application.php | 98 ++++++++++++++++--------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/Herbert/Framework/Application.php b/Herbert/Framework/Application.php index ee7c3e1..d7e34f0 100644 --- a/Herbert/Framework/Application.php +++ b/Herbert/Framework/Application.php @@ -239,10 +239,10 @@ protected function notifyMismatched() }, $this->mismatched); $message = 'Unfortunately plugin(s) ' - . implode(', ', $mismatched) - . ' can’t work with the following plugin(s) ' - . implode(', ', $matched) - . '. Please disable and try updating all of the above plugins before reactivating.'; + . implode(', ', $mismatched) + . ' can’t work with the following plugin(s) ' + . implode(', ', $matched) + . '. Please disable and try updating all of the above plugins before reactivating.'; Notifier::error($message); } @@ -255,50 +255,52 @@ protected function notifyMismatched() */ public function loadPlugin($config) { - $this->loadPluginRequires( - array_get($config, 'requires', []) - ); - - $this->loadPluginRoutes( - 'router', - array_get($config, 'routes', []) - ); - - $this->loadPluginPanels( - 'panel', - array_get($config, 'panels', []) - ); - - $this->loadPluginX( - 'enqueue', - array_get($config, 'enqueue', []) - ); - - $this->loadPluginX( - 'shortcode', - array_get($config, 'shortcodes', []) - ); - - $this->loadPluginX( - 'widget', - array_get($config, 'widgets', []) - ); - - $this->loadPluginAPIs( - array_get($config, 'apis', []) - ); - - $this->addPluginTwigNamespaces( - array_get($config, 'views', []) - ); - - $this->addPluginViewGlobals( - array_get($config, 'viewGlobals', []) - ); - - $this->addPluginComposers( - array_get($config, 'viewComposers', []) - ); + add_action('init', function () use ($config) { + $this->loadPluginRequires( + array_get($config, 'requires', []) + ); + + $this->loadPluginRoutes( + 'router', + array_get($config, 'routes', []) + ); + + $this->loadPluginPanels( + 'panel', + array_get($config, 'panels', []) + ); + + $this->loadPluginX( + 'enqueue', + array_get($config, 'enqueue', []) + ); + + $this->loadPluginX( + 'shortcode', + array_get($config, 'shortcodes', []) + ); + + $this->loadPluginX( + 'widget', + array_get($config, 'widgets', []) + ); + + $this->loadPluginAPIs( + array_get($config, 'apis', []) + ); + + $this->addPluginTwigNamespaces( + array_get($config, 'views', []) + ); + + $this->addPluginViewGlobals( + array_get($config, 'viewGlobals', []) + ); + + $this->addPluginComposers( + array_get($config, 'viewComposers', []) + ); + }); } /** From c5ae587a655f2f936efae91af6a5d123a0ef6def Mon Sep 17 00:00:00 2001 From: dryajov Date: Sat, 18 Jun 2016 21:08:53 -0700 Subject: [PATCH 2/2] incorrect shortcode callback invocation --- Herbert/Framework/Shortcode.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Herbert/Framework/Shortcode.php b/Herbert/Framework/Shortcode.php index 25b65b4..9ae2b8b 100644 --- a/Herbert/Framework/Shortcode.php +++ b/Herbert/Framework/Shortcode.php @@ -62,10 +62,7 @@ public function add($name, $callable, $arguments = []) $response = $this->app->call( $callable, - array_merge([ - '_attributes' => $attributes, - '_content' => $content - ], $attributes) + $attributes ); if ($response instanceof RedirectResponse)