Log message #4141414

# At Username Text
# May 16th 2018, 14:30 neon1024 Your docblock says 304, but your code is 301 :P
# May 16th 2018, 14:29 neon1024 Thanks! I’ll take a look
# May 16th 2018, 14:29 admad use that instead of core `ErrorHandlerMiddlware`
# May 16th 2018, 14:29 neon1024 No harm in teaching me something.
# May 16th 2018, 14:28 admad @neon1024 i am in a spoon feeding mood :slightly_smiling_face: https://gist.github.com/ADmad/606beddce65495d37d5e0bce1e2a7c04
# May 16th 2018, 14:23 neon1024 It’s all a bit new as we tend to do this in Nginx, but some of the redirects are complicated.
# May 16th 2018, 14:19 neon1024 Cool, well I will try and capture a 404 first, and that will give me an idea of where to start
# May 16th 2018, 14:19 saeideng you have a lot of ways to do it :,)
# May 16th 2018, 14:18 neon1024 Well yeah, that’s what I thought, but couldn’t I overload the `ErrorHandlerMiddleware::handleException` ? I should go and look at Crud and see how it captures those 404s I suppose
# May 16th 2018, 14:17 slackebot ->add($this->redirect()) ; return $middlewareQueue; } public function redirect() { return function($request, $response, $next){ $response = $next($request, $response); if ($response->getStatusCode()==404) { $response = $response->withHeader(' ....redirect ....'); } return $response; }; } ```
# May 16th 2018, 14:17 saeideng ``` public function middleware($middlewareQueue) { $middlewareQueue // Catch any exceptions in the lower layers, // and make an error page/response ->add(ErrorHandlerMiddleware::class) // Handle plugin/theme assets like CakePHP normally does. ->add(AssetMiddleware::class) // Add routing middleware. ->add(new RoutingMiddleware($this))
# May 16th 2018, 14:17 saeideng @neon1024 did not test but
# May 16th 2018, 14:12 neon1024 Sorry, I misunderstood what you meant. I’ll go do some reading! Thanks for the tips
# May 16th 2018, 14:11 admad i already told you to use custom error handler middleware instead :slightly_smiling_face:
# May 16th 2018, 14:10 saeideng you should use response
# May 16th 2018, 14:10 admad having it as first would be unnecessary overhead for every request which does not need rediecting
# May 16th 2018, 14:10 Diego_ the associated save() has worked fine with the creation form
# May 16th 2018, 14:09 neon1024 @admad Oh? I was thinking of having it as the first middleware in the stack, which interrogated the incoming request, changed the url and sent it off down the middleware queue, right?
# May 16th 2018, 14:08 admad @neon1024 new response not request :slightly_smiling_face:
# May 16th 2018, 14:08 Diego_ hello, i'm trying to figure out why save() associated is not working, using cake 3.6 version. When i save the entity only the main one is saved, the entity debug shows the correct data for the main and the associated entity with de data marked as dirty and the modified values but the associated one is not saved: https://pastebin.com/VvpCTVLM
# May 16th 2018, 14:08 neon1024 Well, I’ll get it setup and try!
# May 16th 2018, 14:07 neon1024 @admad I just return a new Request with the new url?
# May 16th 2018, 14:07 neon1024 Good idea @admad I think I migrate my redirects into a proper middleware, then I can unit test it too, which is probably a good idea.
# May 16th 2018, 14:03 admad maintain a map of old => new urls and if found return a new `RedirectResponse` instance from `handleException()`
# May 16th 2018, 14:02 neon1024 Even with scope and some clever regex that could get fiddly
# May 16th 2018, 14:02 neon1024 Well I’d rather not slow down my routing by having it parse all the redirects first
# May 16th 2018, 14:02 saeideng `Router::redirect()`
# May 16th 2018, 14:01 neon1024 Beats having to send a pull request to our Ansible config repo!
# May 16th 2018, 14:01 admad to handle redirects for old urls
# May 16th 2018, 14:01 admad i have done same
# May 16th 2018, 14:01 admad ah, use a custom error handler middlware and override handleException () :slightly_smiling_face:
# May 16th 2018, 14:00 neon1024 I’d just like to manage some of the tougher cases in PHP to avoid false positives, such as missing news slugs, redirecting back to the index
# May 16th 2018, 14:00 neon1024 @admad Yeah, that’s what I’ve been told to do by our SEO guy. I think I will make some behind the scenes changes to return some different codes. I am using a 301 for some of the more general ones, as we’ve deployed a new site so there are some legitimate redirects. However some stuff which is missing will probably benefit from a 405 or 410
# May 16th 2018, 13:58 admad @neon1024 i don't think redirect for 404 are good for SEO. Of course not a concern if its an "internal" app
# May 16th 2018, 13:33 neon1024 Is it viable to manage 404 redirects in my own application? Do I need to implement my own Exception Handler?
# May 16th 2018, 13:04 neon1024 unclezoot, Sorry I missed you. I went to lunch and get some tyres fitted to the car. I store the front-end timezone separately in a Configure setting
# May 16th 2018, 13:00 Diego_ yes its auth acl error
# May 16th 2018, 12:53 Guest95046 AclNode::node() - Couldn't find Aro node identified by "Array\n(\n [Aro0.model] => User\n [Aro0.foreign_key] => \n)\n
# May 16th 2018, 12:53 Guest95046 @Diego: SO the error which I am getting is related to authentication?
# May 16th 2018, 12:46 Guest95046 the cake php version is 2.10 so will it work for version 2.10
# May 16th 2018, 12:45 Diego_ you need send and verify the token for every request