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: site_url() does not use alt Config #7211

Closed
wants to merge 2 commits into from

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Feb 2, 2023

Description
From https://forum.codeigniter.com/showthread.php?tid=86549

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 2, 2023
@kenjis kenjis marked this pull request as draft February 2, 2023 02:06
@kenjis kenjis marked this pull request as ready for review February 2, 2023 02:43
@kenjis kenjis added the 4.3 label Feb 2, 2023
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

I'm not a big fan of adding another parameter to these functions.

? rtrim($config->baseURL, '/ ') . '/'
: $request->getUri()->getBaseURL();
if ($useConfig) {
$url = rtrim($config->baseURL, '/ ') . '/';
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for not using

$url = rtrim($config->baseURL, '/ ') . '/';

every time - no matter what request type we are dealing with?

Copy link
Member Author

Choose a reason for hiding this comment

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

*
* @throws HTTPException For invalid paths.
* @throws InvalidArgumentException For invalid config.
*/
function _get_uri(string $relativePath = '', ?App $config = null): URI
function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfig = false): URI
{
$config ??= config('App');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$config ??= config('App');
if ($config === null) {
$appConfig = config('App');
}

Maybe we can do something like this? This way, we could still distinguish the custom config type from the default one. And no additional parameters for the functions would be required.

Copy link
Member Author

Choose a reason for hiding this comment

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

I sent a new PR #7215

@kenjis kenjis closed this Feb 3, 2023
@kenjis kenjis deleted the fix-site_url-altConfig branch February 7, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 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.

None yet

3 participants