Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue where redirectURLs were not generated correctly.
When the first path segment matches the base path an incorrect URL was generated. Trimming slashes off makes Router normalize the URL correctly as the leading / implies that the base is already prepended. Fixes #3897
- Loading branch information
Showing
2 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ltrim introduces issues when working from a plugin (plugin name is appended again when redirecting). I fixed this by stripping the base path when setting the Auth.redirect in the session:
$this->Session->write('Auth.redirect', $request->here(false));
(line 323)1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be a better solution. I did not do that in the first place as I was worried about creating upgrade issues with data in the session. I will give this a try though as it might be a simpler solution.
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces a bug when the application is not running on
/
.I have just setup a fresh 2.3 application at
/cakephp/2.3
, it tries to redirect tohttp://localhost/cakephp/2.3/cakephp/2.3/users/protected
after login.1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with renansaddam, I reported as ticket #3916
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, twas a bad fix then. I'll take another look at correcting it.
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jinhr, @renansaddam Could you try again with d40c737 I tried with an app in a subdirectory that shared a name with a controller and the original issue stayed fixed. I also tried in a subdir with a different name, and it also worked.
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d40c737 seems to do the trick. The redirect url in the session looks good as well. With 1d18a4f it still had the base in it.
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug introduced by the commit is fixed and all tests are green. Good fix!
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woot 👍
1d18a4f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory I think d40c737 fixed the redirect to '/'. Great job!