Skip to content

[WebServerBundle] Fix router script option BC #23173

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

Closed
wants to merge 1 commit into from

Conversation

1ed
Copy link
Contributor

@1ed 1ed commented Jun 14, 2017

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23206
License MIT
Doc PR -

Server commands does not work with router script given by a relative path eg.:

bin/console server:run -r router.php 

but, this was working before and was removed (by accident I guess) in https://github.com/symfony/symfony/pull/21039/files#diff-b915f83f99a4166eb34eab581a92501bL187

$this->router = $router ?: __DIR__.'/Resources/router.php';
$this->router = $router ? realpath($router) : __DIR__.'/Resources/router.php';

if (false === $this->router || !file_exists($this->router)) {
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 the file existence validation could be skipped when using the built-in one. We already know it exists:

if (null !== $router) {
    $absoluteRouterPath = realpath($router);

    if (false === $absoluteRouterPath || !file_exists($absoluteRouterPath)) {
        throw new \InvalidArgumentException(sprintf('Router script "%s" does not exists.', $router));
    }

    $this->router = $absoluteRouterPath;
} else {
    $this->router = __DIR__.'/Resources/router.php';
}

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 that realpath returns false when the file dont not exist anyway. That'd means the file_exists check is useless, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Jun 15, 2017
@1ed 1ed force-pushed the fix-router-script-bc branch 3 times, most recently from e63b990 to 8ba667c Compare June 15, 2017 11:36
$absoluteRouterPath = realpath($router);

if (false === $absoluteRouterPath) {
throw new \InvalidArgumentException(sprintf('Router script "%s" does not exists.', $router));
Copy link
Member

Choose a reason for hiding this comment

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

does not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@1ed 1ed force-pushed the fix-router-script-bc branch from 8ba667c to aeab2fe Compare June 16, 2017 13:28
@1ed 1ed force-pushed the fix-router-script-bc branch from aeab2fe to 5840c09 Compare June 16, 2017 13:30
@fabpot
Copy link
Member

fabpot commented Jun 16, 2017

Thank you @1ed.

fabpot added a commit that referenced this pull request Jun 16, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[WebServerBundle] Fix router script option BC

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23206
| License       | MIT
| Doc PR        | -

Server commands does not work with router script given by a relative path eg.:
```
bin/console server:run -r router.php
```
but, this was working before and was removed (by accident I guess) in https://github.com/symfony/symfony/pull/21039/files#diff-b915f83f99a4166eb34eab581a92501bL187

Commits
-------

aeab2fe [WebServerBundle] Fix router script path and check existence
@fabpot fabpot closed this Jun 16, 2017
@fabpot fabpot mentioned this pull request Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants