Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full url prefix is better defined before auto loading
- Loading branch information
Showing
1 changed file
with
14 additions
and
11 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
36243b4
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.
Hello @zoghal, can you explain me the rationale behind this change?¿
FULL_BASE_URL
is a Cake construction, and will likely not be defined before bootstrapping, attempting to do it before will not allow the user to modify it insidecore.php
, and that is a major problem when called from the console, whereShellDispatcher::_bootstrap()
will always defineFULL_BASE_URL
unless already defined.Before this change, you could do something like this inside
core.php
and
Cake/bootstrap.php
will handle it nicely.36243b4
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.
@bar This might please you 😄
36243b4
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.
Thanks @ADmad! I saw this in 2.4, but still has the same issue because the test is done before calling
Configure::bootstrap()
which forces the user to copy the code and paste it insideApp/core.php
, so thatShellDispatcher::_bootstrap()
don't define it.Making the test after
Configure::bootstrap()
eased that, allowing the user to setHTTP_HOST
inApp/core.php
if needed and Cake will handle it later in a cleaner way.I think this is more evident when making calls from
php-cli
, and even more when using queues, like Resque, and attempting to create valid links using theRouter
, which was a mid-field goal :p36243b4
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.
I actually had the same problem today as @bar, I think we need to revert this commit
36243b4
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.
👍 as a bugfix in
2.3.x
. It is actually quite difficult to get if not familiarized with the web/cli dispatching workflow.BTW, I'm already loving
App.fullbaseURL
.36243b4
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.
Instead of defining
$_SERVER['HTTP_HOST']
could you not just define the constant?36243b4
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.
Yep @markstory but that basically involves duplicating the code, and because
HTTP_HOST
tends to be more usable, sometimes you need it defined, which can be helpful.Also, setting a PHP var like
HTTP_HOST
when called fromphp-cli
, and relying on Cake to seamlessly do the job later, seems to be cleaner and more transparent IMHO.36243b4
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.
Besides, I don't recall a use case where this can be useful before
Configure::bootstrap()
, whereFULL_BASE_URL
will never be defined, either byphp
here orphp-cli
here, am I right?¿I think it was useful when being after it, so that if not bootsrapped there was still a chance to define it.
36243b4
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.
I'm not really too fussy either way on this one. Both approaches have drawbacks. Bootstrapping before the constant is defined means you cannot use the constant in bootstraping, but can define it as part of the app/Config/bootstrap.php. Bootstrapping after the constant is defined means you can use it in your application bootstrap, but cannot define it in the bootstrap process, and must rely on the automatic value.
36243b4
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 sorry, but I can't imagine a use case where you'd what to use the constant in bootstrapping, that was my question to @zoghal in the first place :p, can you give me a hint on that? I do believe it presents useful when building urls, though.