-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[FrameworkBundle] Fixed server:start --router relative path issue #14124 #14129
Conversation
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env)) | ||
; | ||
} else { | ||
if (!file_exists($router)) { |
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.
Please merge both lines into a single elseif
.
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.
By the way, will this work if the user used a relative path?
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.
OK, will merge to elseif
.
Yep, I've tried this with a relative path and it seems to work fine. This was actually the main point of this change, and resembles how file checking is done in ServerRunCommand.php
.
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.
symfony#14129 * Changed `if` nested in `else` to `elseif` * Modified `determineRouterScript` function prototype so that just the `router` argument is passed, rather than the whole `InputInterface`
@@ -177,25 +182,44 @@ private function isOtherServerProcessRunning($address) | |||
} | |||
|
|||
/** | |||
* Determine the absolute file path for the router script based on user input and the environment. |
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 sentence needs to be changed as the user input isn't passed here.
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.
OK, I've updated the comment to be more specific in 4be3757.
…fony#14124 This ensures that a relative path can be used to specify the router script, and that if the router script cannot be found an error is reported and the command fails. The file path for the router script is now determined and checked prior to the child process being forked, which seems cleaner. The same change could be made in ServerRunCommand.php, or possibly in the ServerCommand base class; to keep the scope small, though, this wasn't done as part of this bug fix.
symfony#14129 * Changed `if` nested in `else` to `elseif` * Modified `determineRouterScript` function prototype so that just the `router` argument is passed, rather than the whole `InputInterface`
symfony#14129 * Tweaked `determineRouterScript` function comment to better describe what the function is doing * Removed the usage of `file_exists` and instead made use of the `realpath` result to determine if the specified router file exists
@@ -129,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output) | |||
return 1; | |||
} | |||
|
|||
if (null === $process = $this->createServerProcess($output, $address, $documentRoot, $input->getOption('router'), $env, null)) { | |||
if (null === $process = $this->createServerProcess($output, $address, $documentRoot, $router, null)) { |
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.
you can avoid explicitly set null to the timeout argument as it's the default value.
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.
Agreed, the null there isn't necessary. I was tempted to remove it but didn't want to meddle with the code any more than I needed to. @xabbuh - as the author of this class, would you like me to remove it?
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 don't see anything wrong with you removing this as it is really useless.
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.
// before
$this->createServerProcess($output, $address, $documentRoot, $router, null)
// after
$this->createServerProcess($output, $address, $documentRoot, $router)
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.
Fair enough, I was just wary of changing more than was necessary - I'm pretty new to GitHub so wasn't sure if I would be committing a faux pas!
All done in 139191f.
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.
Thank you. Could also completely remove the $timeout
parameter from the createServerProcess()
method? It's not used anymore.
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.
Could do, though the null
would still need passing to the Process
constructor, otherwise the timeout will be set to 60 seconds:
private function createServerProcess(OutputInterface $output, $address, $documentRoot, $router)
{
...
...
return new Process('exec '.$script, $documentRoot, null, null, null);
}
It doesn't seem to do any harm leaving the option there for future use, but then, you're right, it's currently not being used to doesn't need to be there. Let me know if you'd prefer for it to be removed and, if so, I'll take it out.
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.
Yes please :)
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.
OK, done in a8c29c4.
…ymfony#14129 * Removed unnecessary `null` from `createServerProcess` call
…ony#14129 * Removed unused `timeout` argument from `createServerProcess` function
👍 |
@xabbuh - Is there anything else I need to do in order for this PR to be accepted? |
@abulford Looks good to me. ping @symfony/deciders |
👍 |
1 similar comment
👍 |
Thank you @abulford. |
…h issue #14124 (abulford) This PR was squashed before being merged into the 2.6 branch (closes #14129). Discussion ---------- [FrameworkBundle] Fixed server:start --router relative path issue #14124 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14124 | License | MIT | Doc PR | - This ensures that a relative path can be used to specify the router script, and that if the router script cannot be found an error is reported and the command fails. The file path for the router script is now determined and checked prior to the child process being forked, which seems cleaner. The same change could be made in ServerRunCommand.php, or possibly in the ServerCommand base class; to keep the scope small, though, this wasn't done as part of this bug fix. Commits ------- 0c1b9ba [FrameworkBundle] Fixed server:start --router relative path issue #14124
This ensures that a relative path can be used to specify the router script, and that if the router script cannot be found an error is reported and the command fails.
The file path for the router script is now determined and checked prior to the child process being forked, which seems cleaner. The same change could be made in ServerRunCommand.php, or possibly in the ServerCommand base class; to keep the scope small, though, this wasn't done as part of this bug fix.