diff --git a/composer.json b/composer.json index 3f135fa2e7..9135cac5eb 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ "opauth/github": ">=0.1.0@dev,<2.0.0", "opauth/google": ">=0.2.2@dev,<2.0.0", "opauth/twitter": ">=0.3.1@dev,<2.0.0", - "phly/conduit": "~0.10.0", - "phly/http": "~0.8", + "phly/conduit": "~0.11.0", + "phly/http": "~0.8.4", "phly/phly-comic": "~1.0", "phly/mustache": "~1.1", "psr/http-message": "~0.6", diff --git a/composer.lock b/composer.lock index 47d1c7d3e1..c34681b653 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "776b158adecf6b50bf1f2bd333154d1f", + "hash": "092774c43348c47abed70a242e3bc52d", "packages": [ { "name": "aura/session", @@ -254,20 +254,20 @@ }, { "name": "phly/conduit", - "version": "0.10.0", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/phly/conduit.git", - "reference": "d5c57cea8b543a407f401c15887ff9b883a22624" + "reference": "33b3e0c2a0fbced04268ad8806b6320311f9af45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phly/conduit/zipball/d5c57cea8b543a407f401c15887ff9b883a22624", - "reference": "d5c57cea8b543a407f401c15887ff9b883a22624", + "url": "https://api.github.com/repos/phly/conduit/zipball/33b3e0c2a0fbced04268ad8806b6320311f9af45", + "reference": "33b3e0c2a0fbced04268ad8806b6320311f9af45", "shasum": "" }, "require": { - "phly/http": ">=0.8.2,<0.9.0", + "phly/http": ">=0.8.4,<0.9.0", "php": ">=5.4.8", "psr/http-message": "~0.6.0", "zendframework/zend-escaper": "~2.3@stable" @@ -305,20 +305,20 @@ "http", "middleware" ], - "time": "2015-01-20 02:04:50" + "time": "2015-01-26 23:20:05" }, { "name": "phly/http", - "version": "0.8.2", + "version": "0.8.4", "source": { "type": "git", "url": "https://github.com/phly/http.git", - "reference": "1b62ff01a2a3b5a2826c60c870fffd62bb6babaf" + "reference": "8d687785e215625f2a4388c13f44a39dbd026e7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phly/http/zipball/1b62ff01a2a3b5a2826c60c870fffd62bb6babaf", - "reference": "1b62ff01a2a3b5a2826c60c870fffd62bb6babaf", + "url": "https://api.github.com/repos/phly/http/zipball/8d687785e215625f2a4388c13f44a39dbd026e7b", + "reference": "8d687785e215625f2a4388c13f44a39dbd026e7b", "shasum": "" }, "require": { @@ -357,7 +357,7 @@ "keywords": [ "http" ], - "time": "2015-01-19 15:37:23" + "time": "2015-01-26 22:54:22" }, { "name": "phly/mustache", diff --git a/src/Auth/Auth.php b/src/Auth/Auth.php index 126e1b1270..3212891a8f 100644 --- a/src/Auth/Auth.php +++ b/src/Auth/Auth.php @@ -23,7 +23,7 @@ public function __construct(array $authConfig, Session $session) public function __invoke($req, $res, $next) { if ($req->getMethod() !== 'GET') { - return $next('GET', $res->withStatus(405)); + return $next($req, $res->withStatus(405), 'GET'); } if (isset($req->getQueryParams()['redirect'])) { diff --git a/src/Auth/AuthCallback.php b/src/Auth/AuthCallback.php index 5d13b2ca70..9b970c9626 100644 --- a/src/Auth/AuthCallback.php +++ b/src/Auth/AuthCallback.php @@ -34,12 +34,12 @@ public function __invoke($req, $res, $next) $authResponse = unserialize(base64_decode($req->getQueryParams()['opauth'])); break; default: - return $next('Invalid request', $res->withStatus(400)); + return $next($req, $res->withStatus(400), 'Invalid request'); break; } if (array_key_exists('error', $authResponse)) { - return $next('Error authenticating', $res->withStatus(403)); + return $next($req, $res->withStatus(403), 'Error authenticating'); } if (empty($authResponse['auth']) @@ -48,7 +48,7 @@ public function __invoke($req, $res, $next) || empty($authResponse['auth']['provider']) || empty($authResponse['auth']['uid']) ) { - return $next('Invalid authentication response', $res->withStatus(403)); + return $next($req, $res->withStatus(403), 'Invalid authentication response'); } if ($auth->env['callback_transport'] !== 'session' @@ -59,7 +59,7 @@ public function __invoke($req, $res, $next) $reason ) ) { - return $next('Invalid authentication response', $res->withStatus(403)); + return $next($req, $res->withStatus(403), 'Invalid authentication response'); } $auth = $this->session->getSegment('auth'); diff --git a/src/Auth/UserSession.php b/src/Auth/UserSession.php index ba41580a5f..0773030065 100644 --- a/src/Auth/UserSession.php +++ b/src/Auth/UserSession.php @@ -15,6 +15,6 @@ public function __construct(Session $session) public function __invoke($request, $response, $next) { $auth = $this->session->getSegment('auth'); - return $next($request->withAttribute('user', $auth->get('user'))); + return $next($request->withAttribute('user', $auth->get('user')), $response); } } diff --git a/src/Blog/CachingMiddleware.php b/src/Blog/CachingMiddleware.php index 80b6637f23..a10107e796 100644 --- a/src/Blog/CachingMiddleware.php +++ b/src/Blog/CachingMiddleware.php @@ -18,7 +18,7 @@ public function __construct($cachePath, $enabled = true) public function __invoke($req, $res, $next) { if (! $this->enabled) { - return $next(); + return $next($req, $res); } if (! $req->getAttribute('blog', false)) { @@ -39,7 +39,7 @@ public function __invoke($req, $res, $next) return $this->cache($req, $res, $next); } - return $next($req); + return $next($req, $res); } private function fetchFromCache($req, $res, $next) @@ -47,7 +47,7 @@ private function fetchFromCache($req, $res, $next) $path = $req->getUri()->getPath(); if (! preg_match('#^/(?P[^/]+\.html)$#', $path, $matches)) { // Nothing to do; not a blog post - return $next(); + return $next($req, $res); } $cachePath = sprintf('%s/%s', $this->cachePath, $matches['page']); @@ -55,7 +55,7 @@ private function fetchFromCache($req, $res, $next) if (! file_exists($cachePath)) { // Nothing in cache, but should be cached $req->getAttribute('blog')->cacheable = $matches['page']; - return $next(); + return $next($req, $res); } // Cache hit! diff --git a/src/Blog/EngineMiddleware.php b/src/Blog/EngineMiddleware.php index 18d864b1b8..cdc6c2b89b 100644 --- a/src/Blog/EngineMiddleware.php +++ b/src/Blog/EngineMiddleware.php @@ -105,7 +105,7 @@ private function listPosts($req, $res, $next, $tag = null) return $next($req->withAttribute('view', (object) [ 'template' => 'blog.list', 'model' => $view, - ])); + ]), $res); } private function displayPost($id, $req, $res, $next) @@ -113,12 +113,12 @@ private function displayPost($id, $req, $res, $next) $post = $this->mapper->fetch($id); if (! $post) { - return $next('Not found', $res->withStatus(404)); + return $next($req, $res->withStatus(404), 'Not found'); } $post = include $post['path']; if (! $post instanceof EntryEntity) { - return $next('Not found', $res->withStatus(404)); + return $next($req, $res->withStatus(404), 'Not found'); } $original = $req->getOriginalRequest()->getUri()->getPath(); @@ -128,7 +128,7 @@ private function displayPost($id, $req, $res, $next) return $next($req->withAttribute('view', (object) [ 'template' => 'blog.post', 'model' => $post, - ])); + ]), $res); } private function displayFeed($req, $res, $next, $type, $tag = null) @@ -140,7 +140,7 @@ private function displayFeed($req, $res, $next, $type, $tag = null) } if (! file_exists($path)) { - return $next('Not found', $res->withStatus(404)); + return $next($req, $res->withStatus(404), 'Not found'); } return $res diff --git a/src/BodyParams.php b/src/BodyParams.php index f64feaabd6..da7b79f9d6 100644 --- a/src/BodyParams.php +++ b/src/BodyParams.php @@ -12,7 +12,7 @@ class BodyParams public function __invoke($request, $response, $next) { if (in_array($request->getMethod(), $this->nonBodyRequests)) { - return $next(); + return $next($request, $response); } $header = $request->getHeader('Content-Type'); @@ -35,17 +35,19 @@ public function __invoke($request, $response, $next) case 'form': // $_POST is injected by default into the request body parameters; // re-inject them into the attributes. - return $next($request->withAttribute('body', $request->getBodyParams())); + return $next($request->withAttribute('body', $request->getBodyParams()), $response); case 'json': $rawBody = $request->getBody()->getContents(); - return $next($request + return $next( + $request ->withAttribute('rawBody', $rawBody) - ->withAttribute('body', json_decode($rawBody, true)) + ->withAttribute('body', json_decode($rawBody, true)), + $response ); default: break; } - return $next(); + return $next($request, $response); } } diff --git a/src/ComicsPage.php b/src/ComicsPage.php index 9c4a6c02e7..840b134b35 100644 --- a/src/ComicsPage.php +++ b/src/ComicsPage.php @@ -8,7 +8,7 @@ public function __invoke($request, $response, $next) error_log('In ' . get_class($this)); if (! $request->getAttribute('user', false)) { error_log('Returning 401 error'); - return $next(401, $response->withStatus(401)); + return $next($request, $response->withStatus(401), 401); } error_log('Rendering page'); diff --git a/src/Contact/LandingPage.php b/src/Contact/LandingPage.php index b882b83798..84c046a751 100644 --- a/src/Contact/LandingPage.php +++ b/src/Contact/LandingPage.php @@ -22,11 +22,11 @@ public function __invoke($request, $response, $next) { $path = $request->getUri()->getPath(); if ($path !== $this->path) { - return $next(); + return $next($request, $response); } if ($request->getMethod() !== 'GET') { - return $next('GET', $response->withStatus(405)); + return $next($request, $response->withStatus(405), 'GET'); } $basePath = $request->getOriginalRequest()->getUri()->getPath(); @@ -38,6 +38,6 @@ public function __invoke($request, $response, $next) return $next($request->withAttribute('view', (object) [ 'template' => $this->page, 'model' => $view, - ])); + ]), $response); } } diff --git a/src/Contact/Process.php b/src/Contact/Process.php index 047fc6e85b..bde6ca6376 100644 --- a/src/Contact/Process.php +++ b/src/Contact/Process.php @@ -27,7 +27,7 @@ public function __construct( public function __invoke($request, $response, $next) { if ($request->getMethod() !== 'POST') { - return $next('POST', $response->withStatus(405)); + return $next($request, $response->withStatus(405), 'POST'); } $this->session->start(); @@ -44,7 +44,7 @@ public function __invoke($request, $response, $next) $token, $request, $response - )); + ), $response); } $filter = new InputFilter(); @@ -57,7 +57,7 @@ public function __invoke($request, $response, $next) $token, $request, $response - )); + ), $response); } $this->sendEmail($filter->getValues()); diff --git a/src/Contact/ThankYouPage.php b/src/Contact/ThankYouPage.php index 77ed2346e0..80b8fbb8c5 100644 --- a/src/Contact/ThankYouPage.php +++ b/src/Contact/ThankYouPage.php @@ -16,11 +16,11 @@ public function __invoke($request, $response, $next) { $path = $request->getUri()->getPath(); if ($path !== $this->path) { - return $next(); + return $next($request, $response); } if ($request->getMethod() !== 'GET') { - return $next('GET', $response->withStatus(405)); + return $next($request, $response->withStatus(405), 'GET'); } $parentUrl = str_replace('/thank-you', '', $request->originalUrl); @@ -36,6 +36,6 @@ public function __invoke($request, $response, $next) return $next($request->withAttribute('view', (object) [ 'template' => $this->page, 'model' => [], - ])); + ]), $response); } } diff --git a/src/NotAllowed.php b/src/NotAllowed.php index ccbb2f2802..1ee6957288 100644 --- a/src/NotAllowed.php +++ b/src/NotAllowed.php @@ -6,7 +6,7 @@ class NotAllowed public function __invoke($err, $req, $res, $next) { if ($res->getStatusCode() !== 405) { - return $next($err); + return $next($req, $res, $err); } if (is_array($err) || is_string($err)) { diff --git a/src/NotFound.php b/src/NotFound.php index aade6d9495..9cf58080c9 100644 --- a/src/NotFound.php +++ b/src/NotFound.php @@ -5,6 +5,6 @@ class NotFound { public function __invoke($req, $res, $next) { - return $next('Not Found', $res->withStatus(404)); + return $next($req, $res->withStatus(404), 'Not Found'); } } diff --git a/src/Page.php b/src/Page.php index b2ac0ecc92..794e4e6576 100644 --- a/src/Page.php +++ b/src/Page.php @@ -18,15 +18,15 @@ public function __construct($path, $page) public function __invoke($request, $response, $next) { if ($request->getOriginalRequest()->getUri()->getPath() !== $this->path) { - return $next(); + return $next($request, $response); } if ($request->getMethod() !== 'GET') { - return $next('GET', $response->withStatus(405)); + return $next($request, $response->withStatus(405), 'GET'); } $view = $request->getAttribute('view', new stdClass); $view->template = $this->page; - $next($request->withAttribute('view', $view)); + $next($request->withAttribute('view', $view), $response); } } diff --git a/src/Redirects.php b/src/Redirects.php index e4a07cf447..cddfe81276 100644 --- a/src/Redirects.php +++ b/src/Redirects.php @@ -10,7 +10,7 @@ public function __invoke($req, $res, $next) // Ensure php.net is able to retrieve PHP RSS feed without a problem if ('/blog/tag/php.xml' === $path) { - return $next(); + return $next($req, $res); } // PhlyBlog style pagination @@ -83,7 +83,7 @@ public function __invoke($req, $res, $next) return $this->redirect('/blog', $url, $res); } - return $next(); + return $next($req, $res); } private function redirect($path, $url, $res, $query = []) diff --git a/src/Templated.php b/src/Templated.php index 1da8081daa..a7f27d9d9f 100644 --- a/src/Templated.php +++ b/src/Templated.php @@ -42,7 +42,7 @@ public function render(Request $request, Response $response, callable $next) $view = $request->getAttribute('view', false); if (false === $view || ! $view->template) { - return $next(); + return $next($request, $response); } return $response->write($this->renderer->render( diff --git a/src/Unauthorized.php b/src/Unauthorized.php index 0c81351d02..da7d9420a3 100644 --- a/src/Unauthorized.php +++ b/src/Unauthorized.php @@ -19,7 +19,7 @@ public function __invoke($err, $req, $res, $next) error_log('In ' . get_class($this)); if ($res->getStatusCode() !== 401) { error_log('Invalid status code; passing to next handler'); - return $next($err); + return $next($req, $res, $err); } $new = $req->getUri()->withPath('/auth');