Skip to content

[Routing] allow HEAD method to be defined first #23618

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

Merged
merged 1 commit into from
Jul 22, 2017
Merged

[Routing] allow HEAD method to be defined first #23618

merged 1 commit into from
Jul 22, 2017

Conversation

DavidBadura
Copy link
Contributor

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

Since 3.3 it's no longer possible to set the allowed methods to HEAD followed by GET. If you try this you get an Notice: Undefined offset: 0 error.

index:
  path: '/'
  defaults:
    _controller: AppBundle:Default:index
  methods: [HEAD, GET]

It works perfectly if you change the ordering of the allowed methods:

index:
  path: '/'
  defaults:
    _controller: AppBundle:Default:index
  methods: [GET, HEAD]

The problem has been added in this commit: dd647ff#diff-3b72491a9ba1cff58442b845ae837eb3R297

After an array_filter the keys will not be reset. So the key 0 does not exist anymore and this check if ('$methods[0]' !== \$$methodVariable) { fails. A simple array_values ​​fix this issue.

@DavidBadura DavidBadura changed the title Router: allow HEAD method to be defined first [Routing] allow HEAD method to be defined first Jul 21, 2017
@symfony symfony deleted a comment from JasonCoal Jul 22, 2017
@fabpot
Copy link
Member

fabpot commented Jul 22, 2017

Thank you @DavidBadura.

@fabpot fabpot merged commit 52e2821 into symfony:3.3 Jul 22, 2017
fabpot added a commit that referenced this pull request Jul 22, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[Routing] allow HEAD method to be defined first

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

Since 3.3 it's no longer possible to set the allowed methods to HEAD followed by GET. If you try this you get an `Notice: Undefined offset: 0` error.

```
index:
  path: '/'
  defaults:
    _controller: AppBundle:Default:index
  methods: [HEAD, GET]
```

It works perfectly if you change the ordering of the allowed methods:

```
index:
  path: '/'
  defaults:
    _controller: AppBundle:Default:index
  methods: [GET, HEAD]
```

The problem has been added in this commit: dd647ff#diff-3b72491a9ba1cff58442b845ae837eb3R297

After an `array_filter` the keys will not be reset. So the key `0` does not exist anymore and this check `if ('$methods[0]' !== \$$methodVariable) {` fails. A simple `array_values` ​​fix this issue.

Commits
-------

52e2821 Router: allow HEAD method to be defined first
@DavidBadura DavidBadura deleted the patch-php-matcher-dumper branch July 22, 2017 09:49
@fabpot fabpot mentioned this pull request Aug 1, 2017
@JasonCoal
Copy link

JasonCoal commented Aug 24, 2017 via email

@sstok
Copy link
Contributor

sstok commented Aug 27, 2017

Go home GitHub your drunk... 🍺

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.

6 participants