Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: $routes->setDefaultMethod() does not work #5682

Merged
merged 5 commits into from
Feb 15, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Feb 12, 2022

Description

  • $routes->setDefaultMethod() does not work when you go to /

See https://forum.codeigniter.com/thread-81269.html

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 12, 2022
@iRedds
Copy link
Collaborator

iRedds commented Feb 12, 2022

Wrong approach.
The constructor of the Router class already defines a controller and a default method.
And the Router::setDefaultController() method doesn't make sense.

@kenjis
Copy link
Member Author

kenjis commented Feb 12, 2022

Removed Router::setDefaultController().
If all the tests pass, is this okay?

The default method may be not `index`, and it is set in the constructor.
The constructor of the Router class already defines the default controller.
@kenjis
Copy link
Member Author

kenjis commented Feb 12, 2022

Removing a protected method is a breaking change.

I reverted Router::setDefaultController() and make it deprecated.

@@ -646,8 +640,6 @@ protected function setRequest(array $segments = [])
{
// If we don't have any segments - try the default controller;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. "try" is strange.
Updated.

if (empty($segments)) {
$this->setDefaultController();
}
// If we don't have any segments left - use the default controller;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment should also be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is true. I don't think to be removed.

user_guide_src/source/changelogs/v4.2.0.rst Outdated Show resolved Hide resolved
kenjis and others added 2 commits February 15, 2022 15:41
Co-authored-by: John Paul E. Balandan, CPA <51850998+paulbalandan@users.noreply.github.com>
@kenjis kenjis merged commit 909e78c into codeigniter4:develop Feb 15, 2022
@kenjis kenjis deleted the fix-router-default-method branch February 15, 2022 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants