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

Controller::curr() should return null instead of throwing an exception #11386

Closed
2 tasks
GuySartorelli opened this issue Sep 17, 2024 · 3 comments
Closed
2 tasks

Comments

@GuySartorelli
Copy link
Member

GuySartorelli commented Sep 17, 2024

Controller::curr() currently throws an exception if there's no current controller. This means you have to use Controller::has_curr() any time you want to call curr() - when a null return value would do just as well.

Related issues

Acceptance Criteria

  • Controller::curr() returns null if there's no current controller (instead of throwing an exception).
  • Make a decision during implementation is Controller::has_curr() should be removed or not

CMS 5 PRs

After merging assign back to Steve to merge-up and rebase

CMS 6 kitchen sink CI

CMS 6 PRs

@GuySartorelli GuySartorelli added this to the Silverstripe CMS 6.0 milestone Sep 17, 2024
@emteknetnz emteknetnz self-assigned this Feb 13, 2025
This was referenced Feb 13, 2025
@emteknetnz emteknetnz removed their assignment Feb 13, 2025
@GuySartorelli
Copy link
Member Author

@emteknetnz NEeds a CMS 6 changelog entry - lots of people will have

if (Controller::has_curr()) {
    $controller = Controller::curr();
    // do something with controller
}

and they'll need to change that now to something like

$controller = Controller::curr();
if ($controller) {
    // do something with controller
}

@emteknetnz
Copy link
Member

Updated

@GuySartorelli
Copy link
Member Author

PRs merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants