From 3feb93c0746a002d1d9d717cc1cf1a60c8a9a8ba Mon Sep 17 00:00:00 2001 From: James Brooks Date: Thu, 5 May 2016 16:46:37 +0100 Subject: [PATCH 1/2] Remove dump and die call --- app/Http/Controllers/Dashboard/IncidentController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 9a6097ed..80b5bd50 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -120,8 +120,6 @@ class IncidentController extends Controller null )); } catch (ValidationException $e) { - dd($e->getMessageBag()); - return Redirect::route('dashboard.incidents.add') ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure'))) From bfd0ccd652d6f5a8869991e2d4d54ae26dfb6ab8 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Thu, 5 May 2016 16:47:41 +0100 Subject: [PATCH 2/2] Commands now use db transactions. Fixes #1745 --- .../Middleware/UseDatabaseTransactions.php | 38 +++++++++++++++++++ .../Providers/AppServiceProvider.php | 10 +++++ 2 files changed, 48 insertions(+) create mode 100644 app/Bus/Middleware/UseDatabaseTransactions.php diff --git a/app/Bus/Middleware/UseDatabaseTransactions.php b/app/Bus/Middleware/UseDatabaseTransactions.php new file mode 100644 index 00000000..b0d48d74 --- /dev/null +++ b/app/Bus/Middleware/UseDatabaseTransactions.php @@ -0,0 +1,38 @@ + + */ +class UseDatabaseTransactions +{ + /** + * Handle the current command in the pipeline. + * + * @param mixed $command + * @param \Closure $next + * + * @return bool + */ + public function handle($command, Closure $next) + { + return DB::transaction(function () use ($command, $next) { + return $next($command); + }); + } +} diff --git a/app/Foundation/Providers/AppServiceProvider.php b/app/Foundation/Providers/AppServiceProvider.php index 9db59ec6..387ec0c9 100644 --- a/app/Foundation/Providers/AppServiceProvider.php +++ b/app/Foundation/Providers/AppServiceProvider.php @@ -12,10 +12,18 @@ namespace CachetHQ\Cachet\Foundation\Providers; use AltThree\Bus\Dispatcher; +use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions; use CachetHQ\Cachet\Dates\DateFactory; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; +/** + * This is the app service provider. + * + * @author James Brooks + * @author Joe Cohen + * @author Graham Campbell + */ class AppServiceProvider extends ServiceProvider { /** @@ -29,6 +37,8 @@ class AppServiceProvider extends ServiceProvider return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet\Bus', 'CachetHQ\Cachet\Bus\Handlers'); }); + $dispatcher->pipeThrough([UseDatabaseTransactions::class]); + Str::macro('canonicalize', function ($url) { return preg_replace('/([^\/])$/', '$1/', $url); });